Debian Codegraph @

texmf-dist/source/latex/linguistix/linguistix-malayalam.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: linguistix-malayalam.dtx
4 %
5 % ----------------------------------------------------------
6 % The LaTeX bundle LinguisTiX v1.0
7 % Copyright ยฉ 2026 เคจเคฟเคฐเค‚เคœเคจ
8 %
9 % This program is free software: you can redistribute it
10 % and/or modify it under the terms of the GNU General Public
11 % License as published by the Free Software Foundation,
12 % either version 3 of the License, or (at your option) any
13 % later version.
14 %
15 % This program is distributed in the hope that it will be
16 % useful, but WITHOUT ANY WARRANTY; without even the implied
17 % warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 % PURPOSE. See the GNU General Public License for more
19 % details.
20 %
21 % You should have received a copy of the GNU General Public
22 % License along with this program. If not, see
23 % <https://www.gnu.org/licenses/>.
24 % ----------------------------------------------------------
25 %
26 % \fi
27 % \iffalse
28 %<*driver>
29 \documentclass{l3doc}
30 \usepackage{linguistix}
31 \usepackage{xcolor}
32 \usepackage{fontawesome5}
33 \usepackage[verbose=silent]{microtype}
34 \usepackage{cleveref}
35 \usepackage{hyperxmp}
36
37 \makeatletter
38 \def\@xobeysp{\hphantom{X}}%
39 \makeatother
40
41 \linguistix{old style one}
42 \loadlanguages{british,malayalam,marathi}
43
44 \setquotestyle{british}
45
46 \colorlet{lngxredcolor}{red!50!black}
47 \colorlet{lngxgreencolor}{green!50!black}
48 \colorlet{lngxbluecolor}{blue!50!black}
49
50 \urlstyle{tt}
51
52 \hypersetup{%
53 unicode,%
54 colorlinks,%
55 linkcolor = {lngxredcolor},
56 citecolor = {lngxgreencolor},
57 urlcolor = {lngxbluecolor},
58 pdftitle = {linguistix-malayalam},%
59 pdfauthor = {เคจเคฟเคฐเค‚เคœเคจ},%
60 pdfsubject = {%
61 เดฎเดฒเดฏเดพเดณเด‚ (Malayalam) with LinguisTiX.%
62 },%
63 pdfcreator = {เคจเคฟเคฐเค‚เคœเคจ},%
64 pdfkeywords = {Linguistics, LaTeX},%
65 pdfcopyright = {%
66 The LaTeX bundle linguistix\textLF
67 Copyright ยฉ 2026 เคจเคฟเคฐเค‚เคœเคจ\textLF
68 This program is free software: you can redistribute it
69 and/or modify it under the terms of the GNU General
70 Public License as published by the Free Software
71 Foundation, either version 3 of the License, or (at your
72 option) any later version.%
73 },%
74 pdflicenseurl = {gnu.org/licenses/gpl-3.0.txt}%
75 }%
76
77 \colorlet{lngxpurplecolor}{blue!50!red}
78
79 \def\lngxtval{%
80 \begingroup
81 \color{lngxredcolor}
82 true%
83 \endgroup
84 \,|\,false%
85 }
86
87 \def\lngxfval{%
88 true%
89 \begingroup
90 \color{lngxredcolor}
91 \,|\,false%
92 \endgroup
93 }
94
95 \ExplSyntaxOn
96 \msg_redirect_name:nnn { l3doc }
97 { foreign-internal }
98 { none }
99 \ExplSyntaxOff
100
101 \makeatletter
102 \NewDocumentCommand \supportfootnote { +m } {%
103 \begingroup
104 \def\thefootnote{}%
105 \let\@makefntext\relax
106 \def\Hy@Warning##1{}%
107 \footnotetext{%
108 \hspace*{-\parindent}%
109 #1%
110 }%
111 \endgroup
112 }
113 \makeatother
114
115 \begin{document}
116 \DocInput{\jobname.dtx}
117 \end{document}
118 %</driver>
119 % \fi
120 % \title{เดฎเดฒเดฏเดพเดณเด‚\,--\,\lngxmalayalamlogo}
121 % \author{เคจเคฟเคฐเค‚เคœเคจ}
122 % \date{^^A
123 % \today\ (v1.0)\\[1ex]^^A
124 % {^^A
125 % \small\faIcon{home}\quad
126 % \url{^^A
127 % https://ctan.org/pkg/linguistix^^A
128 % }\\[0.5ex]^^A
129 % \small\faIcon{git-alt}\quad
130 % \url{^^A
131 % https://puszcza.gnu.org.ua/projects/linguistix^^A
132 % }\\[0.5ex]^^A
133 % \small\faIcon[regular]{comments}\quad
134 % \url{^^A
135 % https://matrix.to/\#/\#linguistix:matrix.org^^A
136 % }^^A
137 % }^^A
138 % }
139 %
140 % \maketitle
141 %
142 % \supportfootnote{^^A
143 % The \lngxpkg\ bundle
144 %
145 % \noindent
146 % Copyright ยฉ 2025, 2026 เคจเคฟเคฐเค‚เคœเคจ
147 %
148 % This program is free software: you can redistribute it
149 % and/or modify it under the terms of the \textsc{gnu}
150 % General Public License as published by the Free Software
151 % Foundation, either version 3 of the License, or (at your
152 % option) any later version.
153 %
154 % This program is distributed in the hope that it will be
155 % useful, but \emph{\textbf{without any warranty}};
156 % without even the implied warranty of
157 % \emph{\textbf{merchantability}} or \emph{\textbf{fitness
158 % for a particular purpose}}. See the \textsc{gnu} General
159 % Public License for more details.
160 %
161 % You should have received a copy of the \textsc{gnu}
162 % General Public License along with this program. If not,
163 % see \url{https://www.gnu.org/licenses/}.^^A
164 % }
165 %
166 % This file is translated by เด…เดญเดฟเดฒเดพเดทเต. The original
167 % author of the document is เดจเดฟเดฐเดžเตเดœเตป who also
168 % maintains the package. We initialise the package with
169 % basic information.
170 % \begin{implementation}
171 % \begin{macrocode}
172 %<*malayalam>
173 \ProvidesExplPackage{linguistix-malayalam}
174 {2026-05-15}
175 {v1.0}
176 {เดฎเดฒเดฏเดพเดณเด‚ (Malayalam)}
177 % \end{macrocode}
178 % Average height of Malayalam conjuncts could be more than
179 % that of Latin letters with descenders. This requires minor
180 % adjustments in the baseline stretch. To do it uniformly
181 % for footnotes also, we use the \pkg{setspace} package (if
182 % not loaded already).
183 % \begin{macrocode}
184
185 \IfPackageLoadedF { setspace } {
186 \RequirePackage { setspace }
187 }
188 % \end{macrocode}
189 % We need to set the spacing between lines for which we use
190 % an internal floating point number. It is declared here.
191 % \begin{macrocode}
192
193 \fp_gzero_new:N \g_เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚_fp
194 % \end{macrocode}
195 % This macro grabs an argument, (g-)sets it as the value of
196 % \cs{g_เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚_fp} and resets
197 % the baseline stretch with \cs{setstretch} command. If the
198 % current class is \cls{memoir}, then there is a method to
199 % do that without any package. I use that.
200 % \begin{macrocode}
201
202 \cs_new_protected:Npn \เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚:n #1 {
203 \fp_gset:Nn \g_เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚_fp { #1 }
204 \IfClassLoadedTF { memoir } {
205 \setSingleSpace {
206 \fp_use:N \g_เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚_fp
207 }
208 \SingleSpacing
209 } {
210 \setstretch {
211 \fp_use:N \g_เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚_fp
212 }
213 }
214 }
215
216 \cs_gset_eq:NN \เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†เด…เด•เดฒเด‚
217 \เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚:n
218 % \end{macrocode}
219 % Here, we define two keys for adjusting the space between
220 % lines.
221 % \begin{macrocode}
222
223 \keys_define:nn { เดฎเดฒเดฏเดพเดณเด‚ } {
224 เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†~ เด…เด•เดฒเด‚
225 .code:n = {
226 \เดฎเดฒเดฏเดพเดณเด‚_เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†_เด…เด•เดฒเด‚:n { #1 }
227 },
228 เดตเดฐเดฟเด•เตพเด•เตเด•เดฟเดŸเดฏเดฟเดฒเต†~ เด…เด•เดฒเด‚
229 .initial:n = { 1.2 }
230 }
231 % \end{macrocode}
232 % The \pkg{babel} package defines |\extrasxxxx| commands for
233 % languages where the additional code that should go with a
234 % particular language (|xxxx| in this case) is set. The
235 % |\addto| command is used for appending to the same. We
236 % start with defining additional macros for Malayalam.
237 % \begin{macrocode}
238
239 \addto { \extrasmalayalam } {
240 % \end{macrocode}
241 % We have added the command for using the socket for native
242 % numbering. It will pickup its value from the current
243 % assignment of the plugs and produce the results
244 % accordingly.
245 % \begin{macrocode}
246 \socket_use:n { lngx / native-numbering }
247 % \end{macrocode}
248 % By default, \LaTeX\ prints roman numeral (in capital) as
249 % part numbers. They are not suitable for Malayalam. Thus we
250 % change them to arabic instead.
251 % \begin{macrocode}
252 \cs_set:Npn \thepart { \lngx_counter:n { part } }
253 % \end{macrocode}
254 % The default \LaTeX\ produces Latin numerals, roman (small
255 % and capital both) alphabets and a-z alphabets with
256 % enumerate at different levels of nesting. In Malayalam,
257 % both of these are irrelevant. Thus we renew all of the
258 % concerned commands and change them to print numbers
259 % instead. Since Malayalam doesnโ€™t have much variety
260 % available for counters, we have chosen a simpler style,
261 % i.e. 1, 1.1, 1.1.1 and 1.1.1.1.
262 % \begin{macrocode}
263 \cs_set:Npn \theenumi { \lngx_counter:n { enumi } }
264 \cs_set:Npn \theenumii {
265 \lngx_counter:n { enumi } .
266 \lngx_counter:n { enumii }
267 }
268 % \end{macrocode}
269 % A period is added after each โ€˜labelโ€™ in enumerate. In
270 % default \LaTeX, the label for second level enumeration is
271 % printed inside brackets. We donโ€™t need it in Malayalam. So
272 % we change the \cs{labelenumii} command and add a period.
273 % It is not added for the first level because thatโ€™s
274 % \LaTeX-default too. Similarly, this is extended to all the
275 % other levels.
276 % \begin{macrocode}
277 \cs_set:Npn \labelenumii { \theenumii . }
278 \cs_set:Npn \theenumiii {
279 \lngx_counter:n { enumi } .
280 \lngx_counter:n { enumii } .
281 \lngx_counter:n { enumiii }
282 }
283 \cs_set:Npn \labelenumiii { \theenumiii . }
284 \cs_set:Npn \theenumiv {
285 \lngx_counter:n { enumi } .
286 \lngx_counter:n { enumii } .
287 \lngx_counter:n { enumiii } .
288 \lngx_counter:n { enumiv }
289 }
290 \cs_set:Npn \labelenumiv { \theenumiv . }
291 % \end{macrocode}
292 % The \pkg{expex} package has an independent mechanism of
293 % defining and using counters. We define a set called
294 % |เดฎเดฒเดฏเดพเดณเด‚| here and make it the default when Malayalam is
295 % used. Note that this change will disappear with the
296 % \cs{lngx_misc_reset:} command. Refer to |linguistix.pdf|
297 % for more information on this.
298 % \begin{macrocode}
299 \IfPackageLoadedT { expex } {
300 \definelabeltype { เดฎเดฒเดฏเดพเดณเด‚ } {
301 labelgen = { list },
302 labellist = {
303 เด•, เด–, เด—, เด˜, เด™,
304 เดš, เด›, เดœ, เด, เดž,
305 เดŸ, เด , เดก, เดข, เดฃ,
306 เดค, เดฅ, เดฆ, เดง, เดจ,
307 เดช, เดซ, เดฌ, เดญ, เดฎ,
308 เดฏ, เดฐ, เดฑ, เดฒ, เดณ, เดด, เดต, เดถ, เดท, เดธ, เดน
309 },
310 labelformat = {A.},
311 fullrefformat = {XA},
312 labelalign = {left},
313 labelwidth = {1.5em}
314 }
315 \lingset {
316 labeltype = { เดฎเดฒเดฏเดพเดณเด‚ }
317 }
318 }
319 % \end{macrocode}
320 % Malayalam doesnโ€™t distinguish between Italic and Upright.
321 % So I redefine \cs{emph} to produce the argument in bold
322 % instead. This also goes when \cs{lngx_misc_reset:} is
323 % used.
324 % \begin{macrocode}
325 \cs_gset_eq:NN \emph \textbf
326 }
327 % \end{macrocode}
328 % Now we make some changes that are necessary when the main
329 % language of the document is Malayalam.
330 % \begin{macrocode}
331
332 \tl_if_eq:NnTF \g_lngx_main_language_tl { malayalam } {
333 % \end{macrocode}
334 % The |\arraystretch| command needs to be reset to a larger
335 % value so that it can incorporate Malayalamโ€™s vertical
336 % conjuncts.
337 % \begin{macrocode}
338 \cs_set:Npn \arraystretch { 1.2 }
339 % \end{macrocode}
340 % The Rachana Institute of Typography has created a variety
341 % of fonts that have full glyph set of Malayalam. Rachana
342 % and MeeraNew have the most robust feature-set and hence
343 % they are set in main and sans families respectively. In
344 % the context of mono, despite being a little less
345 % feature-rich, tnjoy looks like a better fit. So I have
346 % used it.
347 % \begin{macrocode}
348 \lngx_set_keys:n {
349 text~ main~ font = { RIT-Rachana-Regular.ttf },
350 text~ sans~ font = { RIT-MeeraNew.ttf },
351 text~ mono~ font = { RIT-tnjoy-regular.ttf }
352 }
353 % \end{macrocode}
354 % RITโ€™s fonts have Italic shapes, but since Indian scripts
355 % do not have the tradition of Italic shapes, their regular
356 % versions are used where Italic would be expected. MeeraNew
357 % doesnโ€™t provide a bold font, so a slight amount of
358 % boldness is faked.
359 % \begin{macrocode}
360 \clist_map_inline:nn {
361 upright,
362 italic,
363 slanted,
364 swash,
365 small~ caps
366 } {
367 \lngx_set_keys:n {
368 text~ #1 = { RIT-Rachana-Regular.ttf },
369 text~ bold~ #1 = { RIT-Rachana-Bold.ttf },
370 text~ sans~ #1 = { RIT-MeeraNew.ttf },
371 text~ sans~ bold~ #1 = { RIT-MeeraNew.ttf },
372 text~ sans~ bold~ #1~
373 features = {
374 FakeBold = { 1.2 }
375 },
376 text~ mono~ #1 = { RIT-tnjoy-regular.ttf },
377 text~ mono~ bold~ #1 = { RIT-tnjoy-bold.ttf }
378 }
379 }
380 % \end{macrocode}
381 % Using the |text extra features| key, I declare
382 % \textsc{nfss} families called |เดฎเดฒเดฏเดพเดณเด‚_main|,
383 % |เดฎเดฒเดฏเดพเดณเด‚_sans|, |เดฎเดฒเดฏเดพเดณเด‚_mono| that will be used
384 % later. Malayalam looks too small when combined with Latin
385 % script as the base characters are set at the x-height in
386 % RITโ€™s fonts. In order to present both the scripts with
387 % equal importance, I scale Malayalam fonts and bring them
388 % to the cap-height.
389 % \begin{macrocode}
390 \lngx_set_keys:n {
391 text~ main~ extra~
392 features = {
393 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_main },
394 Scale = { 1.3 }
395 },
396 text~ sans~ extra~
397 features = {
398 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_sans },
399 Scale = { 1.3 }
400 },
401 text~ mono~ extra~
402 features = {
403 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_mono },
404 Scale = { 1.3 }
405 }
406 }
407 } {
408 % \end{macrocode}
409 % In the false branch (i.e., if Malayalam is not the main
410 % language), I use the macros that set the โ€˜otherโ€™
411 % (non-main) fonts for Malayalam. The fonts are the same,
412 % but the key-value interface is not available, so the code
413 % is slightly verbose. Before that we load the |onchar|
414 % option with |ids| and |fonts| options.
415 % \begin{macrocode}
416 \babelprovide [
417 onchar = { ids~ fonts }
418 ] { malayalam }
419 \lngx_other_main_font:nnn { malayalam } {
420 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_main },
421 Scale = { 1.3 },
422 UprightFont = { RIT-Rachana-Regular.ttf },
423 ItalicFont = { RIT-Rachana-Regular.ttf },
424 BoldFont = { RIT-Rachana-Bold.ttf },
425 BoldItalicFont = { RIT-Rachana-Bold.ttf },
426 SlantedFont = { RIT-Rachana-Regular.ttf },
427 BoldSlantedFont = { RIT-Rachana-Bold.ttf },
428 SwashFont = { RIT-Rachana-Regular.ttf },
429 BoldSwashFont = { RIT-Rachana-Bold.ttf },
430 SmallCapsFont = { RIT-Rachana-Regular.ttf }
431 } { RIT-Rachana-Regular.ttf }
432 \lngx_other_sans_font:nnn { malayalam } {
433 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_sans },
434 Scale = { 1.3 },
435 UprightFont = { RIT-MeeraNew.ttf },
436 ItalicFont = { RIT-MeeraNew.ttf },
437 BoldFont = { RIT-MeeraNew.ttf },
438 BoldFeatures = { FakeBold = { 1.2 } },
439 BoldItalicFont = { RIT-MeeraNew.ttf },
440 BoldItalicFeatures = { FakeBold = { 1.2 } },
441 SlantedFont = { RIT-MeeraNew.ttf },
442 BoldSlantedFeatures = { FakeBold = { 1.2 } },
443 BoldSlantedFont = { RIT-MeeraNew.ttf },
444 SwashFont = { RIT-MeeraNew.ttf },
445 BoldSwashFont = { RIT-MeeraNew.ttf },
446 BoldSwashFeatures = { FakeBold = { 1.2 } },
447 SmallCapsFont = { RIT-MeeraNew.ttf }
448 } { RIT-Rachana-Regular.ttf }
449 \lngx_other_mono_font:nnn { malayalam } {
450 NFSSFamily = { เดฎเดฒเดฏเดพเดณเด‚_mono },
451 Scale = { 1.3 },
452 UprightFont = { RIT-tnjoy-regular.ttf },
453 ItalicFont = { RIT-tnjoy-regular.ttf },
454 BoldFont = { RIT-tnjoy-bold.ttf },
455 BoldItalicFont = { RIT-tnjoy-bold.ttf },
456 SlantedFont = { RIT-tnjoy-regular.ttf },
457 BoldSlantedFont = { RIT-tnjoy-bold.ttf },
458 SwashFont = { RIT-tnjoy-regular.ttf },
459 BoldSwashFont = { RIT-tnjoy-bold.ttf },
460 SmallCapsFont = { RIT-tnjoy-regular.ttf }
461 } { RIT-Rachana-Regular.ttf }
462 }
463 % \end{macrocode}
464 % In order to allow Malayalam in math mode, I use the
465 % following code. Since this setting has to be done after
466 % the initialisation, I use a hook for lazy loading.
467 % \begin{macrocode}
468
469 \IfPackageLoadedT { lua-unicode-math } {
470 \DeclareSymbolFont { เดฎเดฒเดฏเดพเดณเด‚ }
471 { TU }
472 { เดฎเดฒเดฏเดพเดณเด‚_main }
473 { m }
474 { n }
475 }
476
477 \hook_gput_code:nnn { begindocument / end } { . } {
478 \IfPackageLoadedF { lua-unicode-math } {
479 \DeclareSymbolFont { เดฎเดฒเดฏเดพเดณเด‚ }
480 { TU }
481 { เดฎเดฒเดฏเดพเดณเด‚_main }
482 { m }
483 { n }
484 }
485 \int_step_inline:nnn { "0D00 } { "0D7F } {
486 \Umathcode #1 = "0 ~ \use:c { symเดฎเดฒเดฏเดพเดณเด‚ } ~ #1
487 }
488 }
489 %</malayalam>
490 % \end{macrocode}
491 % \end{implementation}
492 % \Finale