Debian Codegraph @

texmf-dist/source/latex/fontspec/fontspec-code-feat-opentype.dtx

raw
1 %%^^A%% fontspec-code-feat-opentype.dtx -- part of FONTSPEC <latex3.github.io/fontspec>
2
3 % \section{OpenType feature definitions}
4 %
5 % \iffalse
6 % \begin{macrocode}
7 %<*fontspec>
8 % \end{macrocode}
9 % \fi
10 %
11 %
12 % \begin{macrocode}
13 \@@_feat_prop_add:nn {salt} { Alternate\,=\,$N$ }
14 \@@_feat_prop_add:nn {nalt} { Annotation\,=\,$N$ }
15 \@@_feat_prop_add:nn {ornm} { Ornament\,=\,$N$ }
16 \@@_feat_prop_add:nn {cvNN} { CharacterVariant\,=\,$N$:$M$ }
17 \@@_feat_prop_add:nn {ssNN} { StylisticSet\,=\,$N$ }
18 % \end{macrocode}
19 %
20 % \section{Regular key=val / tag definitions}
21 %
22 % \subsection{Ligatures}
23 % \begin{macrocode}
24 \@@_define_opentype_feature_group:n {Ligatures}
25 \@@_define_opentype_feature:nnnnn {Ligatures} {ResetAll} {} {}
26 {
27 +dlig,-dlig,+rlig,-rlig,+liga,-liga,+dlig,-dlig,+clig,-clig,+hlig,-hlig,
28 %<XE> mapping = tex-text
29 %<LU> +tlig,-tlig
30 }
31 % \end{macrocode}
32 %
33 % \begin{macrocode}
34 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Required} {rlig} {rlig} {}
35 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Common} {liga} {liga} {}
36 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Rare} {dlig} {dlig} {}
37 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Discretionary} {dlig} {dlig} {}
38 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Contextual} {clig} {clig} {}
39 \@@_define_opentype_onoffreset:nnnnn {Ligatures} {Historic} {hlig} {hlig} {}
40 % \end{macrocode}
41 % Emulate CM extra ligatures.
42 % \begin{macrocode}
43 %<*XE>
44 \keys_define:nn {fontspec-opentype}
45 {
46 Ligatures / TeX .code:n = { \tl_set:Nn \l_@@_mapping_tl {tex-text} },
47 Ligatures / TeXOff .code:n = { \tl_clear:N \l_@@_mapping_tl },
48 Ligatures / TeXReset .code:n = { \tl_clear:N \l_@@_mapping_tl },
49 }
50 %</XE>
51 %<LU>\@@_define_opentype_onoffreset:nnnnn {Ligatures} {TeX} {} {tlig} {}
52 % \end{macrocode}
53 %
54 % \subsection{Letters}
55 % \begin{macrocode}
56 \@@_define_opentype_feature_group:n {Letters}
57 \@@_define_opentype_feature:nnnnn {Letters} {ResetAll} {} {}
58 {
59 %<LU> +lower,-lower,+upper,-upper,+case,+cpsp,
60 +smcp,+pcap,+c2sc,+c2pc,+unic,+rand,
61 -smcp,-pcap,-c2sc,-c2pc,-unic,-rand
62 }
63 % \end{macrocode}
64 %
65 % \begin{macrocode}
66 %<*LU>
67 \keys_define:nn {fontspec-opentype}
68 {
69 Letters / Uppercase .code:n = {
70 \@@_make_OT_feature:nnn {} {+upper} {+lower}
71 \@@_make_OT_feature:nnn {} {+case} {}
72 \@@_make_OT_feature:nnn {} {+cpsp} {}
73 },
74 }
75 \@@_define_opentype_feature:nnnnn {Letters} {UppercaseOff} {} {-upper} {+case,+cpsp}
76 \@@_define_opentype_feature:nnnnn {Letters} {UppercaseReset} {} {} {+upper,-upper}
77 \@@_define_opentype_onoffreset:nnnnn {Letters} {Lowercase} {} {lower} {+upper,+case,+cpsp}
78 %</LU>
79 \@@_define_opentype_onoffreset:nnnnn {Letters} {SmallCaps} {smcp} {smcp} {+pcap,+unic}
80 \@@_define_opentype_onoffreset:nnnnn {Letters} {PetiteCaps} {pcap} {pcap} {+smcp,+unic}
81 \@@_define_opentype_onoffreset:nnnnn {Letters} {UppercaseSmallCaps} {c2sc} {c2sc} {+c2pc,+unic}
82 \@@_define_opentype_onoffreset:nnnnn {Letters} {UppercasePetiteCaps} {c2pc} {c2pc} {+c2sc,+unic}
83 \@@_define_opentype_onoffreset:nnnnn {Letters} {Unicase} {unic} {unic} {}
84 \@@_define_opentype_onoffreset:nnnnn {Letters} {Random} {rand} {rand} {}
85 % \end{macrocode}
86 %
87 % \subsection{Numbers}
88 % \begin{macrocode}
89 \@@_define_opentype_feature_group:n {Numbers}
90 \@@_define_opentype_feature:nnnnn {Numbers} {ResetAll} {} {}
91 {
92 +tnum,-tnum,
93 +pnum,-pnum,
94 +onum,-onum,
95 +lnum,-lnum,
96 +zero,-zero,
97 +anum,-anum,
98 }
99 % \end{macrocode}
100 %
101 % \begin{macrocode}
102 \@@_define_opentype_onoffreset:nnnnn {Numbers} {Monospaced} {tnum} {tnum} {+pnum,-pnum}
103 \@@_define_opentype_onoffreset:nnnnn {Numbers} {Proportional} {pnum} {pnum} {+tnum,-tnum}
104 \@@_define_opentype_onoffreset:nnnnn {Numbers} {Lowercase} {onum} {onum} {+lnum,-lnum}
105 \@@_define_opentype_onoffreset:nnnnn {Numbers} {Uppercase} {lnum} {lnum} {+onum,-onum}
106 \@@_define_opentype_onoffreset:nnnnn {Numbers} {SlashedZero} {zero} {zero} {}
107 % \end{macrocode}
108 %
109 % \begin{macrocode}
110 \aliasfontfeatureoption {Numbers} {Monospaced} {Tabular}
111 \aliasfontfeatureoption {Numbers} {Lowercase} {OldStyle}
112 \aliasfontfeatureoption {Numbers} {Uppercase} {Lining}
113 % \end{macrocode}
114 %
115 % |luaotload| provides a custom |anum| feature for replacing Latin
116 % (AKA Arabic) numbers with Arabic (AKA Indic-Arabic). The same feature
117 % maps to Farsi (Persian) numbers if font language is Farsi.
118 % \begin{macrocode}
119 %<LU> \@@_define_opentype_onoffreset:nnnnn {Numbers} {Arabic} {anum} {anum} {}
120 % \end{macrocode}
121 %
122 % \subsection{Vertical position}
123 % \begin{macrocode}
124 \@@_define_opentype_feature_group:n {VerticalPosition}
125 \@@_define_opentype_feature:nnnnn {VerticalPosition} {ResetAll} {} {}
126 {
127 +sups,-sups,
128 +subs,-subs,
129 +ordn,-ordn,
130 +numr,-numr,
131 +dnom,-dnom,
132 +sinf,-sinf,
133 }
134 % \end{macrocode}
135 %
136 % \begin{macrocode}
137 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Superior} {sups} {sups} {+subs,+ordn,+numr,+dnom,+sinf}
138 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Inferior} {subs} {subs} {+sups,+ordn,+numr,+dnom,+sinf}
139 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Ordinal} {ordn} {ordn} {+sups,+subs,+numr,+dnom,+sinf}
140 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Numerator} {numr} {numr} {+sups,+subs,+ordn,+dnom,+sinf}
141 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {Denominator} {dnom} {dnom} {+sups,+subs,+ordn,+numr,+sinf}
142 \@@_define_opentype_onoffreset:nnnnn {VerticalPosition} {ScientificInferior} {sinf} {sinf} {+sups,+subs,+ordn,+numr,+dnom}
143 % \end{macrocode}
144 %
145 % \subsection{Contextuals}
146 % \begin{macrocode}
147 \@@_define_opentype_feature_group:n {Contextuals}
148 \@@_define_opentype_feature:nnnnn {Contextuals} {ResetAll} {} {}
149 {
150 +cswh,-cswh,
151 +calt,-calt,
152 +init,-init,
153 +fina,-fina,
154 +falt,-falt,
155 +medi,-medi,
156 }
157 % \end{macrocode}
158 %
159 % \begin{macrocode}
160 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {Swash} {cswh} {cswh} {}
161 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {Alternate} {calt} {calt} {}
162 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {WordInitial} {init} {init} {}
163 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {WordFinal} {fina} {fina} {}
164 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {LineFinal} {falt} {falt} {}
165 \@@_define_opentype_onoffreset:nnnnn {Contextuals} {Inner} {medi} {medi} {}
166 % \end{macrocode}
167 %
168 % \subsection{Diacritics}
169 % \begin{macrocode}
170 \@@_define_opentype_feature_group:n {Diacritics}
171 \@@_define_opentype_feature:nnnnn {Diacritics} {ResetAll} {} {}
172 {
173 +mark,-mark,
174 +mkmk,-mkmk,
175 +abvm,-abvm,
176 +blwm,-blwm,
177 }
178 % \end{macrocode}
179 %
180 % \begin{macrocode}
181 \@@_define_opentype_onoffreset:nnnnn {Diacritics} {MarkToBase} {mark} {mark} {}
182 \@@_define_opentype_onoffreset:nnnnn {Diacritics} {MarkToMark} {mkmk} {mkmk} {}
183 \@@_define_opentype_onoffreset:nnnnn {Diacritics} {AboveBase} {abvm} {abvm} {}
184 \@@_define_opentype_onoffreset:nnnnn {Diacritics} {BelowBase} {blwm} {blwm} {}
185 % \end{macrocode}
186 %
187 % \subsection{Kerning}
188 % \begin{macrocode}
189 \@@_define_opentype_feature_group:n {Kerning}
190 \@@_define_opentype_feature:nnnnn {Kerning} {ResetAll} {} {}
191 {
192 +cpsp,-cpsp,
193 +kern,-kern,
194 }
195 \@@_define_opentype_onoffreset:nnnnn {Kerning} {Uppercase} {cpsp} {cpsp} {}
196 \@@_define_opentype_feature:nnnnn {Kerning} {On} {kern} {+kern} {-kern}
197 \@@_define_opentype_feature:nnnnn {Kerning} {Off} {kern} {-kern} {+kern}
198 \@@_define_opentype_feature:nnnnn {Kerning} {Reset} {} {} {+kern,-kern}
199 % \end{macrocode}
200 %
201 % \subsection{Fractions}
202 % \begin{macrocode}
203 \@@_define_opentype_feature_group:n {Fractions}
204 \@@_define_opentype_feature:nnnnn {Fractions} {ResetAll} {} {}
205 {
206 +frac,-frac,
207 +afrc,-afrc,
208 }
209 % \end{macrocode}
210 %
211 % \begin{macrocode}
212 \@@_define_opentype_feature:nnnnn {Fractions} {On} {frac} {+frac} {}
213 \@@_define_opentype_feature:nnnnn {Fractions} {Off} {frac} {-frac} {}
214 \@@_define_opentype_feature:nnnnn {Fractions} {Reset} {} {} {+frac,-frac}
215 \@@_define_opentype_onoffreset:nnnnn {Fractions} {Alternate} {afrc} {afrc} {-frac}
216 % \end{macrocode}
217 %
218 % \begin{macrocode}
219 \@@_define_opentype_feature_group:n {LocalForms}
220 \@@_define_opentype_feature:nnnnn {LocalForms} {On} {locl} {+locl} {}
221 \@@_define_opentype_feature:nnnnn {LocalForms} {Off} {locl} {-locl} {}
222 \@@_define_opentype_feature:nnnnn {LocalForms} {Reset} {} {} {+locl,-locl}
223 % \end{macrocode}
224 %
225
226 % \subsection{Style}
227 % \begin{macrocode}
228 \@@_define_opentype_feature_group:n {Style}
229 \@@_define_opentype_feature:nnnnn {Style} {ResetAll} {} {}
230 {
231 +salt,-salt,
232 +ital,-ital,
233 +ruby,-ruby,
234 +swsh,-swsh,
235 +hist,-hist,
236 +titl,-titl,
237 +hkna,-hkna,
238 +vkna,-vkna,
239 +ssty=0,-ssty=0,
240 +ssty=1,-ssty=1,
241 }
242 % \end{macrocode}
243 %
244 % \begin{macrocode}
245 \@@_define_opentype_onoffreset:nnnnn {Style} {Alternate} {salt} {salt} {}
246 \@@_define_opentype_onoffreset:nnnnn {Style} {Italic} {ital} {ital} {}
247 \@@_define_opentype_onoffreset:nnnnn {Style} {Ruby} {ruby} {ruby} {}
248 \@@_define_opentype_onoffreset:nnnnn {Style} {Swash} {swsh} {swsh} {}
249 \@@_define_opentype_onoffreset:nnnnn {Style} {Cursive} {swsh} {curs} {}
250 \@@_define_opentype_onoffreset:nnnnn {Style} {Historic} {hist} {hist} {}
251 \@@_define_opentype_onoffreset:nnnnn {Style} {Titling} {titl} {titl} {}
252 \@@_define_opentype_onoffreset:nnnnn {Style} {TitlingCaps} {titl} {titl} {} % backwards compat
253 \@@_define_opentype_onoffreset:nnnnn {Style} {HorizontalKana} {hkna} {hkna} {+vkna,+pkna}
254 \@@_define_opentype_onoffreset:nnnnn {Style} {VerticalKana} {vkna} {vkna} {+hkna,+pkna}
255 \@@_define_opentype_onoffreset:nnnnn {Style} {ProportionalKana} {pkna} {pkna} {+vkna,+hkna}
256 \@@_define_opentype_feature:nnnnn {Style} {MathScript} {ssty} {+ssty=0} {+ssty=1}
257 \@@_define_opentype_feature:nnnnn {Style} {MathScriptScript} {ssty} {+ssty=1} {+ssty=0}
258 \@@_define_opentype_onoffreset:nnnnn {Style} {Uppercase} {case} {case} {}
259 % \end{macrocode}
260 %
261 % \subsection{CJK shape}
262 % \begin{macrocode}
263 \@@_define_opentype_feature_group:n {CJKShape}
264 \@@_define_opentype_feature:nnnnn {CJKShape} {ResetAll} {} {}
265 {
266 +trad,-trad,
267 +smpl,-smpl,
268 +jp78,-jp78,
269 +jp83,-jp83,
270 +jp90,-jp90,
271 +jp04,-jp04,
272 +expt,-expt,
273 +nlck,-nlck,
274 }
275 % \end{macrocode}
276 %
277 % \begin{macrocode}
278 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {Traditional} {trad} {trad} {+smpl,+jp78,+jp83,+jp90,+jp04,+expt,+nlck}
279 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {Simplified} {smpl} {smpl} {+trad,+jp78,+jp83,+jp90,+jp04,+expt,+nlck}
280 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1978} {jp78} {jp78} {+trad,+smpl,+jp83,+jp90,+jp04,+expt,+nlck}
281 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1983} {jp83} {jp83} {+trad,+smpl,+jp78,+jp90,+jp04,+expt,+nlck}
282 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS1990} {jp90} {jp90} {+trad,+smpl,+jp78,+jp83,+jp04,+expt,+nlck}
283 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {JIS2004} {jp04} {jp04} {+trad,+smpl,+jp78,+jp83,+jp90,+expt,+nlck}
284 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {Expert} {expt} {expt} {+trad,+smpl,+jp78,+jp83,+jp90,+jp04,+nlck}
285 \@@_define_opentype_onoffreset:nnnnn {CJKShape} {NLC} {nlck} {nlck} {+trad,+smpl,+jp78,+jp83,+jp90,+jp04,+expt}
286 % \end{macrocode}
287 %
288 % \subsection{Character width}
289 % \begin{macrocode}
290 \@@_define_opentype_feature_group:n {CharacterWidth}
291 \@@_define_opentype_feature:nnnnn {CharacterWidth} {ResetAll} {} {}
292 {
293 +pwid,-pwid,
294 +fwid,-fwid,
295 +hwid,-hwid,
296 +twid,-twid,
297 +qwid,-qwid,
298 +palt,-palt,
299 +halt,-halt,
300 }
301 % \end{macrocode}
302 %
303 % \begin{macrocode}
304 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Proportional} {pwid} {pwid} {+fwid,+hwid,+twid,+qwid,+palt,+halt}
305 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Full} {fwid} {fwid} {+pwid,+hwid,+twid,+qwid,+palt,+halt}
306 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Half} {hwid} {hwid} {+pwid,+fwid,+twid,+qwid,+palt,+halt}
307 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Third} {twid} {twid} {+pwid,+fwid,+hwid,+qwid,+palt,+halt}
308 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {Quarter} {qwid} {qwid} {+pwid,+fwid,+hwid,+twid,+palt,+halt}
309 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {AlternateProportional} {palt} {palt} {+pwid,+fwid,+hwid,+twid,+qwid,+halt}
310 \@@_define_opentype_onoffreset:nnnnn {CharacterWidth} {AlternateHalf} {halt} {halt} {+pwid,+fwid,+hwid,+twid,+qwid,+palt}
311 % \end{macrocode}
312 %
313 % \subsection{Vertical}
314 % According to spec |vkrn| must also activate |vpal| if available but for simplicity we don't do that here (yet?).
315 % \begin{macrocode}
316 \@@_define_opentype_feature_group:n {Vertical}
317 \@@_define_opentype_onoffreset:nnnnn {Vertical} {RotatedGlyphs} {vrt2} {vrt2} {+vrtr,+vert}
318 \@@_define_opentype_onoffreset:nnnnn {Vertical} {AlternatesForRotation} {vrtr} {vrtr} {+vrt2}
319 \@@_define_opentype_onoffreset:nnnnn {Vertical} {Alternates} {vert} {vert} {+vrt2}
320 \@@_define_opentype_onoffreset:nnnnn {Vertical} {KanaAlternates} {vkna} {vkna} {+hkna}
321 \@@_define_opentype_onoffreset:nnnnn {Vertical} {Kerning} {vkrn} {vkrn} {}
322 \@@_define_opentype_onoffreset:nnnnn {Vertical} {AlternateMetrics} {valt} {valt} {+vhal,+vpal,+kern}
323 \@@_define_opentype_onoffreset:nnnnn {Vertical} {HalfMetrics} {vhal} {vhal} {+valt,+vpal,+kern}
324 \@@_define_opentype_onoffreset:nnnnn {Vertical} {ProportionalMetrics} {vpal} {vpal} {+valt,+vhal}
325 % \end{macrocode}
326 %
327 %
328 %
329 %
330 % \section{OpenType features that need numbering}
331 %
332 % \subsection{Alternate}
333 %
334 % \begin{macrocode}
335 \@@_define_opentype_feature_group:n {Alternate}
336 \keys_define:nn {fontspec-opentype}
337 {
338 Alternate .default:n = {0} ,
339 Alternate .groups:n = {opentype},
340 Alternate / unknown .code:n =
341 {
342 \clist_map_inline:nn {#1}
343 { \@@_make_OT_feature:nnn {salt}{ +salt = ##1 }{} }
344 }
345 }
346 % \end{macrocode}
347 %
348 % \begin{macrocode}
349 %<*LU>
350 \keys_define:nn {fontspec-opentype}
351 {
352 Alternate / Random .code:n =
353 { \@@_make_OT_feature:nnn {salt}{ +salt = random }{} } ,
354 }
355 %</LU>
356 % \end{macrocode}
357 %
358 % \begin{macrocode}
359 \aliasfontfeature{Alternate}{StylisticAlternates}
360 % \end{macrocode}
361 %
362 %
363 % \subsection{Variant / StylisticSet}
364 %
365 % \begin{macrocode}
366 \@@_define_opentype_feature_group:n {Variant}
367 \keys_define:nn {fontspec-opentype}
368 {
369 Variant .default:n = {0} ,
370 Variant .groups:n = {opentype} ,
371 Variant / unknown .code:n =
372 {
373 \clist_map_inline:nn {#1}
374 {
375 \@@_make_OT_feature:xxx { ss \two@digits {##1} } { +ss \two@digits {##1} } {}
376 }
377 }
378 }
379 % \end{macrocode}
380 %
381 % \begin{macrocode}
382 \aliasfontfeature{Variant}{StylisticSet}
383 % \end{macrocode}
384 %
385 % \subsection{CharacterVariant}
386 % \begin{macrocode}
387 \@@_define_opentype_feature_group:n {CharacterVariant}
388 \use:x
389 {
390 \cs_new:Npn \exp_not:N \fontspec_parse_cv:w
391 ##1 \c_colon_str ##2 \c_colon_str ##3 \exp_not:N \q_nil
392 {
393 \@@_make_OT_feature:xxx
394 { cv \exp_not:N \two@digits {##1} }
395 { +cv \exp_not:N \two@digits {##1} = ##2 } {}
396 }
397 \keys_define:nn {fontspec-opentype}
398 {
399 CharacterVariant / unknown .code:n =
400 {
401 \clist_map_inline:nn {##1}
402 {
403 \exp_not:N \fontspec_parse_cv:w
404 ####1 \c_colon_str 0 \c_colon_str \exp_not:N \q_nil
405 }
406 }
407 }
408 }
409 % \end{macrocode}
410 % Possibilities: \verb|a:0:\q_nil| or \verb|a:b:0:\q_nil|.
411 %
412 %
413 % \subsection{Annotation}
414 % \begin{macrocode}
415 \@@_define_opentype_feature_group:n {Annotation}
416 \keys_define:nn {fontspec-opentype}
417 {
418 Annotation .default:n = {0} ,
419 Annotation .groups:n = {opentype},
420 Annotation / unknown .code:n =
421 {
422 \@@_make_OT_feature:nnn {nalt} {+nalt=#1} {}
423 }
424 }
425 % \end{macrocode}
426 %
427 % \subsection{Ornament}
428 %
429 % \begin{macrocode}
430 \@@_define_opentype_feature_group:n {Ornament}
431 \keys_define:nn {fontspec-opentype}
432 {
433 Ornament .default:n = {0} ,
434 Ornament .groups:n = {opentype},
435 Ornament / unknown .code:n =
436 {
437 \@@_make_OT_feature:nnn {ornm} { +ornm=#1 } {}
438 }
439 }
440 % \end{macrocode}
441 %
442 %
443 % \section{Script and Language}
444 %
445 %
446 % \subsection{Script}
447 %
448 % \begin{macrocode}
449 \keys_define:nn {fontspec-opentype}
450 {
451 Script .choice: ,
452 Script .groups:n = {opentype} ,
453 }
454 \cs_new:Nn \fontspec_new_script:nn
455 {
456 \keys_define:nn {fontspec-opentype} { Script / #1 .code:n =
457 {
458 %<debug>\typeout{Trying~[Script=#1]}
459 \bool_set_false:N \l_@@_scriptlang_exist_bool
460 \clist_map_inline:nn {#2}
461 {
462 \exp_args:No \@@_check_script:NnT \l_@@_fontface_cs_tl {####1}
463 {
464 %<debug>\typeout{Script~tag~found:~####1}
465 \tl_set:Nn \l_@@_script_name_tl {#1}
466 \tl_set:Nn \l_@@_script_tl {####1}
467 \int_set:Nn \l_@@_script_int {\l_@@_strnum_int}
468 \bool_set_true:N \l_@@_scriptlang_exist_bool
469 \tl_gset:Nx \g_@@_single_feat_tl { script=####1 }
470 \clist_map_break:
471 }
472 }
473 % \end{macrocode}
474 % If not found give a warning but load it anyway:
475 % \begin{macrocode}
476 \bool_if:NF \l_@@_scriptlang_exist_bool
477 {
478 %<debug>\typeout{Script~not~found!}
479 \@@_info:nxx {script-not-exist} {\l_fontspec_fontname_tl} {#1}
480 \clist_set:Nn \l_tmpa_clist {#2}
481 \clist_get:NN \l_tmpa_clist \l_@@_script_tl
482 \exp_args:Noo \@@_check_script:NnF \l_@@_fontface_cs_tl \l_@@_script_tl
483 {
484 \tl_set:Nn \l_@@_script_name_tl {#1}
485 \int_set:Nn \l_@@_script_int {\l_@@_strnum_int}
486 \tl_gset:Nx \g_@@_single_feat_tl { script=\l_@@_script_tl }
487 }
488 }
489 }
490 }
491 }
492 % \end{macrocode}
493 % When script is not explicitly requested, use this list:
494 % \begin{macrocode}
495 \clist_new:N \g_@@_default_scripts_clist
496 \cs_new:Nn \fontspec_default_script:n
497 {
498 \clist_gset:Nn \g_@@_default_scripts_clist {#1}
499 }
500 \fontspec_default_script:n {latn,DFLT}
501 % \end{macrocode}
502 %
503 % \begin{macrocode}
504 \keys_define:nn {fontspec-opentype} { Script / CustomDefault .code:n =
505 {
506 %<debug>\typeout{Trying~CustomDefault~Script}
507 \bool_set_false:N \l_@@_scriptlang_exist_bool
508 \clist_map_inline:Nn \g_@@_default_scripts_clist
509 {
510 \exp_args:No \@@_check_script:NnT \l_@@_fontface_cs_tl {##1}
511 {
512 %<debug>\typeout{Script~tag~found:~##1}
513 \tl_set:Nn \l_@@_script_name_tl {Default (##1)}
514 \tl_set:Nn \l_@@_script_tl {##1}
515 \int_set:Nn \l_@@_script_int {\l_@@_strnum_int}
516 \bool_set_true:N \l_@@_scriptlang_exist_bool
517 \tl_gset:Nx \g_@@_single_feat_tl { script=##1 }
518 \clist_map_break:
519 }
520 }
521 \bool_if:NF \l_@@_scriptlang_exist_bool
522 {
523 %<debug>\typeout{Script~not~found!}
524 \tl_clear:N \l_@@_script_name_tl
525 }
526 }
527 }
528 % \end{macrocode}
529 %
530 %
531 % \subsection{Language}
532 %
533 % \begin{macrocode}
534 \keys_define:nn {fontspec-opentype}
535 {
536 Language .choice: ,
537 Language .groups:n = {opentype} ,
538 }
539 \cs_new:Nn \fontspec_new_lang:nn
540 {
541 \keys_define:nn {fontspec-opentype} { Language / #1 .code:n =
542 {
543 \bool_set_false:N \l_@@_scriptlang_exist_bool
544 \clist_map_inline:nn {#2}
545 {
546 \exp_args:No \@@_check_lang:NnTF \l_@@_fontface_cs_tl {####1}
547 {
548 \tl_set:Nn \l_@@_lang_tl {####1}
549 \int_set:Nn \l_@@_language_int {\l_@@_strnum_int}
550 \tl_gset:Nx \g_@@_single_feat_tl { language=####1 }
551 \bool_set_true:N \l_@@_scriptlang_exist_bool
552 \clist_map_break:
553 }
554 }
555 % \end{macrocode}
556 % If not found give a warning but load it anyway:
557 % \begin{macrocode}
558 \bool_if:NF \l_@@_scriptlang_exist_bool
559 {
560 %<debug>\typeout{Lang~not~found!}
561 \@@_info:nx {language-not-exist} {#1}
562 \clist_set:Nn \l_tmpa_clist {#2}
563 \clist_get:NN \l_tmpa_clist \l_@@_lang_tl
564 \exp_args:Noo \@@_check_lang:NnF \l_@@_fontface_cs_tl \l_@@_lang_tl
565 {
566 \tl_set:Nn \l_@@_lang_name_tl {#1}
567 \int_set:Nn \l_@@_language_int {\l_@@_strnum_int}
568 \tl_gset:Nx \g_@@_single_feat_tl { language=\l_@@_lang_tl }
569 }
570 }
571 }
572 }
573 }
574 % \end{macrocode}
575 %
576 % \paragraph{Language=Default}
577 % These are special-cased to avoid the additional logic above.
578 % From memory, the OpenType default
579 % language is hardcoded to have a zero value,
580 % although this might be some \XeTeX-specific thing.
581 % \begin{macrocode}
582 \clist_new:N \g_@@_default_langs_clist
583 \cs_new:Nn \fontspec_default_lang:n
584 {
585 \clist_gset:Nn \g_@@_default_langs_clist {#1}
586 }
587 \fontspec_default_lang:n {dflt}
588 \@@_keys_define_code:nnn {fontspec-opentype} { Language / Default }
589 {
590 \tl_set:Nn \l_@@_lang_tl {dflt}
591 \int_zero:N \l_@@_language_int
592 \tl_gset:Nn \g_@@_single_feat_tl { language=dflt }
593 }
594 % \end{macrocode}
595 %
596 %
597 % \section{Backwards compatibility}
598 %
599 % \begin{macrocode}
600 \cs_new:Nn \@@_ot_compat:nn
601 {
602 \aliasfontfeatureoption {#1} {#2Off} {No#2}
603 }
604 \@@_ot_compat:nn {Ligatures} {Rare}
605 \@@_ot_compat:nn {Ligatures} {Required}
606 \@@_ot_compat:nn {Ligatures} {Common}
607 \@@_ot_compat:nn {Ligatures} {Discretionary}
608 \@@_ot_compat:nn {Ligatures} {Contextual}
609 \@@_ot_compat:nn {Ligatures} {Historic}
610 \@@_ot_compat:nn {Numbers} {SlashedZero}
611 \@@_ot_compat:nn {Contextuals} {Swash}
612 \@@_ot_compat:nn {Contextuals} {Alternate}
613 \@@_ot_compat:nn {Contextuals} {WordInitial}
614 \@@_ot_compat:nn {Contextuals} {WordFinal}
615 \@@_ot_compat:nn {Contextuals} {LineFinal}
616 \@@_ot_compat:nn {Contextuals} {Inner}
617 \@@_ot_compat:nn {Diacritics} {MarkToBase}
618 \@@_ot_compat:nn {Diacritics} {MarkToMark}
619 \@@_ot_compat:nn {Diacritics} {AboveBase}
620 \@@_ot_compat:nn {Diacritics} {BelowBase}
621 % \end{macrocode}
622 %
623 % \iffalse
624 % \begin{macrocode}
625 %</fontspec>
626 % \end{macrocode}
627 % \fi
628
629
630 \endinput
631
632 % /©
633 % ------------------------------------------------
634 % The FONTSPEC package <latex3.github.io/fontspec>
635 % ------------------------------------------------
636 % Copyright 2022-2025 The LaTeX project, LPPL "maintainer"
637 % Copyright 2004-2022 Will Robertson
638 % Copyright 2009-2015 Khaled Hosny
639 % Copyright 2013 Philipp Gesang
640 % Copyright 2013-2016 Joseph Wright
641 % ------------------------------------------------
642 % This package is free software and may be redistributed and/or modified under
643 % the conditions of the LaTeX Project Public License, version 1.3c or higher
644 % (your choice): <http://www.latex-project.org/lppl/>.
645 % ------------------------------------------------
646 % ©/