summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/unicode-math/um-code-opening.dtx
blob: 0f681f52dee5ef0209a2464492c0534ef0dd2cdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
%%^^A%% um-code-opening.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>

% \section{Start of the package code}
%
% The prefix for \pkg{unicode-math} is \texttt{um}:
%    \begin{macrocode}
%<@@=um>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*LU>
\RequirePackage{lualatex-math}
%</LU>
%    \end{macrocode}
%
%    \begin{macrocode}
\ExplSyntaxOn
%    \end{macrocode}
%
% \subsection{\pkg{expl3} variants}
%
% Variants needed from \pkg{expl3}:
%    \begin{macrocode}
\cs_set_protected_nopar:Npn \exp_last_unbraced:NNx { \::N \::x_unbraced \::: }
%    \end{macrocode}
%
% For \pkg{fontspec}:
%    \begin{macrocode}
\cs_generate_variant:Nn \fontspec_set_family:Nnn {Nx}
\cs_generate_variant:Nn \fontspec_set_fontface:NNnn {NNx}
%    \end{macrocode}
%
%
% \subsection{Primitive font commands}
%
% What might end up being provided by the kernel.
%
% \begin{macro}{\@@_glyph_if_exist:NnTF}
%    \begin{macrocode}
\prg_new_conditional:Nnn \@@_glyph_if_exist:Nn {p,TF,T,F}
  {
    \etex_iffontchar:D #1 #2 \scan_stop:
      \prg_return_true:
    \else:
      \prg_return_false:
    \fi:
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Mathcode and friends}
%
% \begin{macro}{\@@_set_mathcode:nnnn}
% \begin{macro}{\@@_set_mathcode:nnn}
% These are all wrappers for the primitive commands that take numerical
% input only.
%    \begin{macrocode}
\cs_set:Npn \@@_set_mathcode:nnnn #1#2#3#4
  {
    \Umathcode \int_eval:n {#1} =
      \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
  }
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_set:Npn \@@_set_mathcode:nnn #1#2#3
  {
    \Umathcode \int_eval:n {#1} =
      \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#1} \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@_set_mathchar:NNnn}
% \begin{macro}{\@@_set_mathchar:cNnn}
%    \begin{macrocode}
\cs_set:Npn \@@_set_mathchar:NNnn #1#2#3#4
  {
    \Umathchardef #1 =
      \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
\cs_generate_variant:Nn \@@_set_mathchar:NNnn {c}
%    \end{macrocode}
%
% \begin{macro}{\@@_set_delcode:nnn}
%    \begin{macrocode}
\cs_new:Nn \@@_set_delcode:nnn
  {
    \Udelcode#2 = \csname sym#1\endcsname #3 \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_radical:nn}
%    \begin{macrocode}
\cs_new:Nn \@@_radical:nn
  {
    \Uradical \csname sym#1\endcsname #2 \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_delimiter:Nnn}
%    \begin{macrocode}
\cs_new:Nn \@@_delimiter:Nnn
  {
    \Udelimiter \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_accent:nnn}
%    \begin{macrocode}
\cs_new:Nn \@@_accent:nnn
  {
    \Umathaccent #1~ \mathchar@type\mathaccent \use:c { sym #2 } #3 \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_char_gmake_mathactive:N}
% \begin{macro}{\@@_char_gmake_mathactive:n}
%    \begin{macrocode}
\cs_new:Nn \@@_char_gmake_mathactive:N
  {
    \global\mathcode `#1 = "8000 \scan_stop:
  }
\cs_new:Nn \@@_char_gmake_mathactive:n
  {
    \global\mathcode #1 = "8000 \scan_stop:
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Font parameters}
%
% \begin{macro}{\@@_copy_fontparam:nnn}
%    \begin{macrocode}
\cs_new:Nn \@@_copy_fontparam:nnn
  {
    \fontdimen #1 \font = \@@_get_fontparam:nn {#2} {#3}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_zero_fontparam:n}
%    \begin{macrocode}
\cs_new:Nn \@@_zero_fontparam:n
  {
    \fontdimen #1 \font = 0pt\relax
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_get_fontparam:nn}
%    \begin{macrocode}
\cs_new:Nn \@@_get_fontparam:nn
  {
%<XE>    \the\fontdimen#1\l_@@_font\relax
%<LU>    \directlua{fontspec.mathfontdimen("l_@@_font","#2")}
  }
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Alphabet Unicode positions (USVs)}
%
% Before we begin, let's define the positions of the various Unicode
% alphabets so that our code is a little more readable.\footnote{`\textsc{u.s.v.}' stands
% for `Unicode scalar value'.}
%
% \begin{macro}{\usv_set:nnn,\@@_to_usv:nn}
% Rather than `readable', in the end, this makes the code more extensible.
%    \begin{macrocode}
\cs_new:Nn \usv_set:nnn  { \tl_const:cn { c_@@_#1_#2_usv } {#3} }
\cs_new:Nn \@@_to_usv:nn {       \use:c { c_@@_#1_#2_usv } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\@@_usv_if_exist:nn}
%    \begin{macrocode}
\prg_new_conditional:Nnn \@@_usv_if_exist:nn {T,F,TF}
  {
    \cs_if_exist:cTF { c_@@_#1_#2_usv }
      \prg_return_true: \prg_return_false:
  }
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Overcoming \texorpdfstring{\cmd\@onlypreamble}{\textbackslash @onlypreamble}}
%
% The requirement of only setting up the maths fonts in the preamble is lifted.
% (Perhaps unwisely.)
%    \begin{macrocode}
\tl_map_inline:nn
  {
    \new@mathgroup\cdp@list\cdp@elt\DeclareMathSizes
    \@DeclareMathSizes\newmathalphabet\newmathalphabet@@\newmathalphabet@@@
    \DeclareMathVersion\define@mathalphabet\define@mathgroup\addtoversion
    \version@list\version@elt\alpha@list\alpha@elt
    \restore@mathversion\init@restore@version\dorestore@version\process@table
    \new@mathversion\DeclareSymbolFont\group@list\group@elt
    \new@symbolfont\SetSymbolFont\SetSymbolFont@\get@cdp
    \DeclareMathAlphabet\new@mathalphabet\SetMathAlphabet\SetMathAlphabet@
    \DeclareMathAccent\set@mathaccent\DeclareMathSymbol\set@mathchar
    \set@mathsymbol\DeclareMathDelimiter\@xxDeclareMathDelimiter
    \@DeclareMathDelimiter\@xDeclareMathDelimiter\set@mathdelimiter
    \set@@mathdelimiter\DeclareMathRadical\mathchar@type
    \DeclareSymbolFontAlphabet\DeclareSymbolFontAlphabet@
  }
  {
    \tl_remove_once:Nn \@preamblecmds {\do#1}
  }
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}

\endinput

% /©
%
% ------------------------------------------------
% The UNICODE-MATH package  <wspr.io/unicode-math>
% ------------------------------------------------
% This package is free software and may be redistributed and/or modified under
% the conditions of the LaTeX Project Public License, version 1.3c or higher
% (your choice): <http://www.latex-project.org/lppl/>.
% ------------------------------------------------
% Copyright 2006-2017  Will Robertson, LPPL "maintainer"
% Copyright 2010-2017  Philipp Stephani
% Copyright 2011-2017  Joseph Wright
% Copyright 2012-2015  Khaled Hosny
% ------------------------------------------------
%
% ©/