Debian Codegraph @

texmf-dist/source/latex/fontspec/fontspec-code-opening.dtx

raw
1 %%^^A%% fontspec-code-opening.dtx -- part of FONTSPEC <latex3.github.io/fontspec>
2 %
3 % \section{Opening code}
4 %
5 % \begin{function}{\FontspecSetCheckBoolTrue,\FontspecSetCheckBoolFalse}
6 % Allows easy return of boolean results (\verb|\l_@@_check_bool|) without requiring specific catcode regimes.
7 % Used within Lua functions.
8 % \end{function}
9 %
10 % \begin{function}{\@@_keys_set_known:nnN,\@@_keys_set_known:nxN}
11 % Wrapper around standard \verb|\keys_set_known:nnN| which permits debugging.
12 % \end{function}
13 %
14 % \begin{function}{\@@_int_mult_truncate:Nn}
15 % \begin{syntax}
16 % |\@@_int_mult_truncate:nn| \meta{int} \Arg{scale}
17 % \end{syntax}
18 % Scales \meta{integer variable} by \meta{scale}, discarding any fractional components.
19 % E.g.,
20 % \begin{Verbatim}
21 % \int_new:N \foo
22 % \int_set:Nn \foo {3}
23 % \__fontspec_int_mult_truncate:Nn \foo {3.3}
24 % \int_show:N \foo % \foo = 9
25 %
26 % \int_set:Nn \foo {3}
27 % \__fontspec_int_mult_truncate:Nn \foo {3.4}
28 % \int_show:N \foo % \foo = 10
29 % \end{Verbatim}
30 % \end{function}
31 %
32 % \begin{function}{\@@_lua_function:ne,\@@_lua_function:nee,\@@_lua_function:neee,\@@_lua_function:neeee}
33 % \begin{syntax}
34 % |\@@_lua_function:ne| \Arg{method} \Arg{arg.~1}
35 % \end{syntax}
36 % Wrapper around \verb|\lua_now:e|, hard-coded to refer to a method of the \verb|fontspec| module.
37 % \verb|\@@_lua_function:ne {foo} {bar}| executes \verb|fontspec.foo("bar")| in the Lua engine.
38 % Variants for up to four arguments are provided.
39 % \end{function}
40 %
41 % \section{Implementation}
42 %
43 % \iffalse
44 % \begin{macrocode}
45 %<*options>
46 % \end{macrocode}
47 % \fi
48 %
49 % \subsection{Package options}
50 %
51 % \begin{macrocode}
52 \DeclareKeys
53 {
54 % \end{macrocode}
55 % \begin{macrocode}
56 ,math .bool_gset:N = \g_@@_math_bool
57 ,math .usage:n = preamble
58 ,math / unknown .code:n = { } % \msg_warning:nnn {fontspec} {math-opt-unknown} {#1}
59 ,no-math .bool_gset_inverse:N = \g_@@_math_bool
60 ,no-math .usage:n = preamble
61 % \end{macrocode}
62 % \begin{macrocode}
63 ,config .bool_gset:N = \g_@@_cfg_bool
64 ,config .usage:n = load
65 ,no-config .bool_gset_inverse:N = \g_@@_cfg_bool
66 ,no-config .usage:n = load
67 % \end{macrocode}
68 % \begin{macrocode}
69 ,cm-default .code:n = { \msg_warning:nn {fontspec} {cm-default-obsolete} }
70 ,euenc .code:n = { \msg_warning:nnn {fontspec} {enc-obsolete}{euenc} }
71 ,tuenc .code:n = { \msg_warning:nnn {fontspec} {enc-obsolete}{tuenc} }
72 % \end{macrocode}
73 % \begin{macrocode}
74 ,quiet .code:n =
75 {
76 \msg_redirect_module:nnn { fontspec } { warning } { info }
77 \msg_redirect_module:nnn { fontspec } { info } { none }
78 }
79 ,silent .code:n =
80 {
81 \msg_redirect_module:nnn { fontspec } { warning } { none }
82 \msg_redirect_module:nnn { fontspec } { info } { none }
83 }
84 ,verbose .code:n =
85 {
86 \msg_redirect_module:nnn { fontspec } { warning } { warning }
87 \msg_redirect_module:nnn { fontspec } { info } { info }
88 }
89 }
90 % \end{macrocode}
91 %
92 % \begin{macrocode}
93 \SetKeys{config,math}
94 \ProcessKeyOptions
95 % \end{macrocode}
96 %
97 % \iffalse
98 % \begin{macrocode}
99 %</options>
100 %<*fontspec>
101 % \end{macrocode}
102 % \fi
103 %
104 %
105 % \subsection{Encodings}
106 %
107 % Now the default, with a just-in-case check:
108 % \begin{macrocode}
109 \cs_if_exist:cF {T@TU}
110 {
111 \@@_warning:n {tu-clash}
112 \DeclareFontEncoding{TU}{}{}
113 \DeclareFontSubstitution{TU}{lmr}{m}{n}
114 }
115 \tl_gset:Nn \g_fontspec_encoding_tl { TU }
116 % \end{macrocode}
117 %
118 % \begin{macrocode}
119 \tl_set:Nn \rmdefault {lmr}
120 \tl_set:Nn \sfdefault {lmss}
121 \tl_set:Nn \ttdefault {lmtt}
122 \RequirePackage[\g_fontspec_encoding_tl]{fontenc}
123 \tl_set_eq:NN \UTFencname \g_fontspec_encoding_tl % for xunicode if needed
124 % \end{macrocode}
125 % To overcome the encoding changing the current font size, but only if a class has been loaded first:
126 % \begin{macrocode}
127 \tl_if_in:NnT \@filelist {.cls} { \normalsize }
128 % \end{macrocode}
129 % Dealing with a couple of the problems introduced by \pkg{babel}:
130 % \begin{macrocode}
131 \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl
132 \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl
133 \AtBeginDocument
134 {
135 \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl
136 \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl
137 }
138 % \end{macrocode}
139 % That latin encoding definition is repeated to suppress font warnings.
140 % Something to do with \cmd\select@language\ ending up in the \texttt{.aux}
141 % file which is read at the beginning of the document.
142 %
143 %
144 % \subsection{Generic functions}
145 %
146 % \begin{macro}{\FontspecSetCheckBoolTrue}
147 % \begin{macro}{\FontspecSetCheckBoolFalse}
148 % These strange set functions are to simplify returning code from LuaTeX:
149 % \begin{macrocode}
150 \cs_new:Npn \FontspecSetCheckBoolTrue { \bool_set_true:N \l_@@_check_bool }
151 \cs_new:Npn \FontspecSetCheckBoolFalse { \bool_set_false:N \l_@@_check_bool }
152 % \end{macrocode}
153 % \end{macro}
154 % \end{macro}
155 %
156 % \begin{macro}{\@@_keys_set_known:nnN}
157 % \begin{macrocode}
158 \cs_new:Nn \@@_keys_set_known:nnN
159 {
160 %<debug> \typeout{:::: Keys~set:~{#1}~{#2} }
161 \keys_set_known:nnN {#1} {#2} #3
162 %<debug> \typeout{:::: Leftover:~{#3} }
163 }
164 \cs_generate_variant:Nn \@@_keys_set_known:nnN {nx}
165 % \end{macrocode}
166 % \end{macro}
167 %
168 % \begin{macro}{\@@_int_mult_truncate:Nn}
169 % Missing in expl3, IMO.
170 % \begin{macrocode}
171 \cs_new:Nn \@@_int_mult_truncate:Nn
172 {
173 \int_set:Nn #1 { \__dim_eval:w #2 #1 \__dim_eval_end: }
174 }
175 % \end{macrocode}
176 % \end{macro}
177 %
178 % \begin{macro}{\@@_lua_function:ne}
179 % \begin{macro}{\@@_lua_function:nee}
180 % \begin{macro}{\@@_lua_function:neee}
181 % \begin{macro}{\@@_lua_function:neeee}
182 % \begin{macrocode}
183 %<*LU>
184 \cs_set:Npn \@@_lua_function:ne #1#2 { \lua_now:e { fontspec.#1 ("#2") } }
185 \cs_set:Npn \@@_lua_function:nee #1#2#3 { \lua_now:e { fontspec.#1 ("#2","#3") } }
186 \cs_set:Npn \@@_lua_function:neee #1#2#3#4 { \lua_now:e { fontspec.#1 ("#2","#3","#4") } }
187 \cs_set:Npn \@@_lua_function:neeee #1#2#3#4#5 { \lua_now:e { fontspec.#1 ("#2","#3","#4","#5") } }
188 %</LU>
189 % \end{macrocode}
190 % \end{macro}
191 % \end{macro}
192 % \end{macro}
193 % \end{macro}
194 %
195 %
196 %
197 % \subsection{\pkg{expl3} variants}
198 %
199 % \begin{macrocode}
200 \cs_generate_variant:Nn \int_set:Nn {Nv}
201 \cs_generate_variant:Nn \prop_gput_if_not_in:Nnn {NeV}
202 \cs_generate_variant:Nn \prop_gput:Nnn {Nxn} % needed by unicode-math
203 \cs_generate_variant:Nn \tl_if_empty:nF {f}
204 \cs_generate_variant:Nn \tl_if_eq:nnT {oe}
205 % \end{macrocode}
206 %
207 % \begin{macrocode}
208 \cs_generate_variant:Nn \msg_new:nnn {nnx}
209 \cs_generate_variant:Nn \msg_new:nnnn {nnxx}
210 % \end{macrocode}
211 %
212 %
213 %
214 % \iffalse
215 % \begin{macrocode}
216 %</fontspec>
217 % \end{macrocode}
218 % \fi
219
220
221 \endinput
222
223 % /©
224 % ------------------------------------------------
225 % The FONTSPEC package <latex3.github.io/fontspec>
226 % ------------------------------------------------
227 % Copyright 2022-2025 The LaTeX project, LPPL "maintainer"
228 % Copyright 2004-2022 Will Robertson
229 % Copyright 2009-2015 Khaled Hosny
230 % Copyright 2013 Philipp Gesang
231 % Copyright 2013-2016 Joseph Wright
232 % ------------------------------------------------
233 % This package is free software and may be redistributed and/or modified under
234 % the conditions of the LaTeX Project Public License, version 1.3c or higher
235 % (your choice): <http://www.latex-project.org/lppl/>.
236 % ------------------------------------------------
237 % ©/