Debian Codegraph @

texmf-dist/source/latex/mathfont/mathfont-code.dtx

raw
1 % \iffalse ---!!! FIRST META-COMMENT !!!---
2 %
3 %
4 % This file is mathfont-code.dtx from version 3.0a of the
5 % free and open-source LaTeX package "mathfont," released
6 % February 2026, to be used with the XeTeX or LuaTeX engines.
7 %
8 % Running Plain TeX on mathfont-code.dtx will produce the
9 % following files:
10 %
11 % (1) the package file mathfont.sty;
12 %
13 % (2) the derived files mathfont-symbol-list.tex,
14 % mathfont-user-guide.tex, and four files called
15 % mathfont-example-<fontname>.tex, which can be
16 % used to typeset further documentation for
17 % mathfont;
18 %
19 % (3) the stand-alone derived files mathfont-doc-patch.tex,
20 % mathfont-equations.tex, and mathfont-heading.tex,
21 % which are used to produce documentation;
22 %
23 % and
24 %
25 % (4) a number of other derived files.
26 %
27 % Running LaTeX on mathfont-code.dtx will produce the files
28 % listed above as well as the following:
29 %
30 % (5) the pdf documentation file mathfont-code.pdf;
31 %
32 % and
33 %
34 % (6) a number of other derived files.
35 %
36 % To install mathfont on your computer, run this file through
37 % Plain TeX or LaTeX and move mathfont.sty into a directory
38 % searchable by TeX. See the associated README.txt file for
39 % installation information.
40 %
41 %
42 % \fi
43 % \iffalse ---!!! SECOND META-COMMENT !!!---
44 %
45 %
46 % This file is from version 3.0a of the free and open-source
47 % LaTeX package "mathfont," released February 2026, to be used
48 % with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
49 % is recommended.)
50 %
51 % Copyright 2018, 2019, 2021-2023, 2025, 2026 Conrad Kosowsky
52 %
53 % This Work may be used, distributed, and modified under the
54 % terms of the LaTeX Public Project License, version 1.3c or
55 % any later version. The most recent version of this license
56 % is available online at
57 %
58 % https://www.latex-project.org/lppl/.
59 %
60 % This Work has the LPPL status "maintained," and the current
61 % maintainer is the package author, Conrad Kosowsky. He can
62 % be reached at [email protected]. The Work consists
63 % of the following items:
64 %
65 % (1) the base file:
66 % mathfont-code.dtx
67 %
68 % (2) the package file:
69 % mathfont.sty
70 %
71 % (3) the derived files:
72 % mathfont-doc-patch.tex
73 % mathfont-equations.tex
74 % mathfont-example-cormorant.tex
75 % mathfont-example-kelvinch.tex
76 % mathfont-example-roboto.tex
77 % mathfont-example-typey.tex
78 % mathfont-heading.tex
79 % mathfont-symbol-list.tex
80 % mathfont-user-guide.tex
81 %
82 % (4) the pdf documentation files:
83 % mathfont-code.pdf,
84 % mathfont-example-cormorant.pdf
85 % mathfont-example-kelvinch.pdf
86 % mathfont-example-roboto.pdf
87 % mathfont-example-typey.pdf
88 % mathfont-symbol-list.pdf
89 % mathfont-user-guide.pdf
90 %
91 % (5) all other files created through the configuration
92 % process
93 %
94 % and
95 %
96 % (6) the associated README.txt file
97 %
98 % The Work does not include any fonts, and the installation
99 % does not contain any font files. The fonts Bona Nova,
100 % Cormorant, Crimson, Kelvinch, Overpass, STIXGeneral, and
101 % Typey McTypeface have been released under the SIL Open
102 % Font License and are used pursuant to that license. The
103 % font Roboto has been released under the Apache License
104 % and is used pursuant to that license.
105 %
106 % PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
107 % ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
108 % THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
109 %
110 % THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
111 % STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
112 % `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
113 % OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
114 % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
115 % PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
116 % OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
117 % YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
118 % CORRECTION.
119 %
120 % IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
121 % TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
122 % NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
123 % WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
124 % ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
125 % SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
126 % OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
127 % (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
128 % RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
129 % RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
130 % OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
131 % AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
132 % POSSIBILITY OF SUCH DAMAGES.
133 %
134 % For more information, see the Latex Project Public License.
135 % Derivative works based on this package may come with their
136 % own license or terms of use, and the package author is not
137 % responsible for any third-party software.
138 %
139 % Happy TeXing!
140 %
141 %
142 % \fi
143 % \iffalse
144 %
145 % The installation and driver files are incorporated into
146 % mathfont-code.dtx, so we do not need to generate them
147 % separately. The <batchfile> and <driver> tags are for
148 % reference.
149 %
150 %<*batchfile>
151 \begingroup
152 \input docstrip.tex
153 \keepsilent
154 \askforoverwritefalse
155 \preamble
156
157 This file is from version 3.0a of the free and open-source
158 LaTeX package "mathfont," released February 2026, to be used
159 with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
160 is recommended.)
161
162 Copyright 2018, 2019, 2021-2023, 2025, 2026 Conrad Kosowsky
163
164 This Work may be used, distributed, and modified under the
165 terms of the LaTeX Public Project License, version 1.3c or
166 any later version. The most recent version of this license
167 is available online at
168
169 https://www.latex-project.org/lppl/.
170
171 This Work has the LPPL status "maintained," and the current
172 maintainer is the package author, Conrad Kosowsky. He can
173 be reached at [email protected].
174
175 PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
176 ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
177 THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
178
179 THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
180 STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
181 `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
182 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
183 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
184 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
185 OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
186 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
187 CORRECTION.
188
189 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
190 TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
191 NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
192 WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
193 ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
194 SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
195 OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
196 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
197 RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
198 RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
199 OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
200 AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
201 POSSIBILITY OF SUCH DAMAGES.
202
203 For more information, see the LaTeX Project Public License.
204 Derivative works based on this package may come with their
205 own license or terms of use, and the package author is not
206 responsible for any third-party software.
207
208 For more information, see mathfont-code.dtx. Happy TeXing!
209
210 \endpreamble
211 \generate{
212 \file{mathfont.sty}{\from{mathfont-code.dtx}{package}}
213 \file{mathfont-symbol-list.tex}{\from{mathfont-code.dtx}{chars}}
214 \file{mathfont-user-guide.tex}{\from{mathfont-code.dtx}{user}}
215 \file{mathfont-heading.tex}{\from{mathfont-code.dtx}{heading}}
216 \file{mathfont-doc-patch.tex}{\from{mathfont-code.dtx}{doc}}
217 \file{mathfont-equations.tex}{\from{mathfont-code.dtx}{equations}}
218 \file{mathfont-example-cormorant.tex}{\from{mathfont-code.dtx}{cormorant}}
219 \file{mathfont-example-kelvinch.tex}{\from{mathfont-code.dtx}{kelvinch}}
220 \file{mathfont-example-roboto.tex}{\from{mathfont-code.dtx}{roboto}}
221 \file{mathfont-example-typey.tex}{\from{mathfont-code.dtx}{typey}}}
222 \catcode`\ =12\relax
223 \immediate\write0{^^J%
224 ***************************************************^^J%
225 * Step 1 of the mathfont installation complete! *^^J%
226 ***************************************************^^J^^J%
227 ***************************************************^^J%
228 * To finish the installation, move mathfont.sty *^^J%
229 * to a directory searchable by TeX once *^^J%
230 * mathfont-code.dtx is done typesetting *^^J%
231 ***************************************************^^J^^J}
232 \endgroup
233 \ifx\LaTeX\undefined
234 \immediate\write0{Plain TeX format used; quitting now.}
235 \immediate\write0{To create mathfont-code.pdf, run^^J%
236 mathfont-code.dtx through LaTeX.^^J^^J}
237 \expandafter\end
238 \fi
239 %</batchfile>
240 %<*driver>
241 \documentclass[12pt,doc2,letterpaper,oneside]{ltxdoc}
242 \makeatletter
243 \flushbottom
244 \usepackage[margin=1.5in]{geometry}
245 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
246 \usepackage{graphicx}
247 \usepackage{tabularx}
248 \usepackage{booktabs}
249 \usepackage{multirow}
250 \usepackage{enumitem}
251 \usepackage{soul}
252 \usepackage{amsmath}
253 \setlist{itemsep=\smallskipamount,topsep=\smallskipamount,
254 parsep=\z@,partopsep=\z@}
255 \hyphenation{OpenType}
256 \hyphenation{mathfont}
257 \c@IndexColumns=2
258 \c@topnumber\@ne
259 \columnsep=20pt
260 \MacroIndent=1.5em
261 \AtBeginDocument{%
262 \baselineskip=\the\baselineskip plus 0.3pt minus 0.3pt\relax}
263 \let\index@prologue\relax
264 \EnableCrossrefs\CodelineIndex
265 \begin{document}
266 \def\documentname{Implementation}
267 \def\showabstract{1}
268 \input mathfont-doc-patch.tex
269 \input mathfont-heading.tex
270 \DocInput{mathfont-code.dtx}
271 \vfil\eject
272 \immediate\closeout\@indexfile
273 \ifx\directlua\@undefined
274 \immediate\write18{makeindex -s gind.ist mathfont-code.idx}
275 \else
276 \directlua{os.execute("makeindex -s gind.ist mathfont-code.idx")}
277 \fi
278
279 \section*{Index}
280
281 Entries refer to lines in the code. Bold means a
282 definition.
283
284 \hfuzz=20pt
285
286 %\medskip
287 \input mathfont-code.ind
288
289 \end{document}
290 %</driver>
291 %<*package>
292 %
293 % \fi
294 %
295 %
296 % \CheckSum{7307}
297 % \init@checksum
298 %
299 %
300 % \makeatother\CharacterTable
301 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
302 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
303 % Digits \0\1\2\3\4\5\6\7\8\9
304 % Exclamation \! Double quote \" Hash (number) \#
305 % Dollar \$ Percent \% Ampersand \&
306 % Acute accent \' Left paren \( Right paren \)
307 % Asterisk \* Plus \+ Comma \,
308 % Minus \- Point \. Solidus \/
309 % Colon \: Semicolon \; Less than \<
310 % Equals \= Greater than \> Question mark \?
311 % Commercial at \@ Left bracket \[ Backslash \\
312 % Right bracket \] Circumflex \^ Underscore \_
313 % Grave accent \` Left brace \{ Vertical bar \|
314 % Right brace \} Tilde \~}
315 % \makeatletter
316 %
317 %
318 % \DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\DeclareOption,
319 % \ProcessOptions,\def,\edef,\global,\let,\csname,\endcsname,
320 % \expandafter,\relax,\advance,\newcount,\newif,\z@,\@ne,\m@ne,
321 % \ifx,\ifcat,\ifnum,\ifeof,\ifmmode,\else,\fi,\PackageInfo,
322 % \PackageWarning,\PackageError,\message,\@undefined,
323 % \space,\MessageBreak,\string,\M@count,\count@,\noexpand,
324 % \@empty,\@tempa,\@tempb,\@tempc,\@temp@opt,\@temp@sub,\@i,
325 % \@j,\@k,\count,\tw@,\do,\the,\mathalpha,\mathord,\multiply,
326 % \mathop,\mathbin,\mathrel,\mathopen,\mathclose,\mathpunct,
327 % \mathinner,\DeclareRobustCommand,\joinrel,\smash,\newtoks,
328 % \if,\\,\@nil,\leavevmode,\begingroup,\endgroup,\+,\active,
329 % \@gobbletwo,\GenericError,\catcode,\wlog,\typeout,
330 % \E@sterEggUpd@te,\show,\@temperror,\xdef,\@for,\@tfor,
331 % \@ifundefined,\@ifpackageloaded,\@nnil,\@onlypreamble,
332 % \AtBeginDocument,\AtEndOfPackage,\AtVeryVeryEnd,\bgroup,
333 % \CurrentOption,\egroup,\escapechar,\ifM@upper,\ifM@lower,
334 % \ifM@diacritics,\ifM@greekupper,\ifM@greeklower,
335 % \ifM@agreekupper,\ifM@agreeklower,\ifM@cyrillicupper,
336 % \ifM@cyrilliclower,\ifM@hebrew,\ifM@digits,\ifM@operator,
337 % \ifM@symbols,\ifM@extsymbols,\ifM@delimiters,\ifM@arrows,
338 % \ifM@bigops,\ifM@extbigops,\ifM@bb,\ifM@cal,\ifM@frak,
339 % \ifM@bcal,\M@font@loadedtrue,\ifM@bfrak,\if@optionpresent,
340 % \if@suboptionpresent,\mathgroup,\nolimits,\on@line,
341 % \PackageWarningNoLine,\RequirePackage,\thr@@,
342 % \inputlineno,\mathchar@type,\DeclareMathAccent,
343 % \ifM@EasterEgg@declare,\M@EasterEgg@declaretrue,
344 % \M@EasterEgg@declarefalse,\IfFileExists,\E@sterEggHook,
345 % \@gobblefour,\@gobble@brackets,\protected,\@eha,\@cclv,
346 % \new@mathgroup,\new@symbolfont,\@latex@error,\ifcase,\or,
347 % \thr@@,\gdef,\rmdefault,\openin,\closein,\immediate,\itdefault,
348 % \shapedefault,\mddefault,\bfdefault,\E@sterEggDecl@redtrue,
349 % \detokenize,\scdefault,\@next,\@suboptionpresenttrue,
350 % \@suboptionpresentfalse,\@break@tfor,\M@adjust@fonttrue,
351 % \M@adjust@fontfalse,\next,\@tempcntb,\ifdim,
352 % \M@arg@goodtrue,\M@arg@goodfalse,\M@Noluaotfloadtrue,
353 % \M@Noluaotfloadfalse,\M@XeTeXLuaTeXtrue,\ifcsname,\ifdefined,
354 % \TU,\",\@@DeclareSymbolFont,\@@set@mathaccent,\@@set@mathchar,
355 % \@@set@mathsymbol,\@expandedtwoargs,\@spaces,\@tempswatrue,
356 % \@tempswafalse,\@iftempswa,\copy,\e@mathgroup@top,\endlinechar,
357 % \everyeof,\globaldefs,\m@th,\newbox,\newread,\newmuskip,\number,
358 % \zap@space,\setbox,\clap,\hss,\ht,\wd,\dp,
359 % \raise,\M@arrows@id,\M@delimiters@id,\M@extbigops@id,
360 % \M@extsymbols@id,\M@symbols@id,\M@greekupper@id,
361 % \M@greeklower@id,\M@agreekupper@id,\M@agreeklower@id,
362 % \M@bigops@id,\M@upper@id,\M@lower@id,\M@radical@id,
363 % \M@diacritics@id,\M@cyrillicupper@id,\M@digits@id,
364 % \M@cyrilliclower@id,\M@hebrew@id,\Umathcode,\EasterEggUpdate,
365 % \@firstofone,\if@arg@good,\M@f@ntn@me,\M@f@ntn@meb@se,
366 % \dimen@,\math@E@sterEggUpd@te,\@DMA,\M@sym@,\@tempwarning,
367 % \@mathfontinfo,\everymath,\Udelcode,\Udelimiter,\@@set@mathchar,
368 % \@@set@mathsymbol,\@@set@mathaccent,\set@mathchar,\set@mathsymbol,
369 % \set@mathaccent,\Umathcode,\Umathchardef,\Umathaccent,
370 % \@easter@egg@,\@expandtwoargs,\afterassignment,\aftergroup,
371 % \AtEndDocument,\DeclareSymbolFont@m@dropped,\directlua,\ifodd,
372 % \edef@nospace,\hb@xt@,\hbox,\hfil,\if@operator@s,
373 % \ifE@sterEggDecl@red,\ifin@,in@,\llap,\mathpalette,\mathsm@sh,
374 % \meaning,\numexpr,\scantokens,\scantextokens,\strip@prefix,
375 % \vphantom,\XeTeXrevision,\symMupright,\ProcessE@sterEgg,
376 % \@ifnextchar,\@testopt,\endinput,\Umathcharnumdef,\Umathcodes,
377 % \Umathcodenum,\seriesdefault,\@@DeclareSymbolFont@m@dropped,
378 % \ifM@radical,\@backslashchar,\@tempbase,\@tempboxa,
379 % \@tempfeatures,\@secondoftwo,\unexpanded,\long,
380 % \@tempseries,\@tempshape,\displaystyle,\textstyle,\scriptstyle,
381 % \scriptscriptstyle,\f@family,\getanddefine@fonts,\if@tempswa,
382 % \@tempswatrue,\@tempswafalse,\M@acc@,\M@addtab@count@tempa,
383 % \M@addto@localfonts,\M@addto@symbolfonts,
384 % \M@delimiters@num,\M@localfonts,\M@symbolfonts,
385 % \M@robust@def,\M@base@false,\M@base@true,\toks@,\Uchar,
386 % \@nomath,\@whilenum,\@notprerr,\@optionpresenttrue,
387 % \@optionpresentfalse,\@@mathchar@type,\luafunction,
388 % \newluafunction,\remove@to@nnil,\showtokens}
389 %
390 %
391 % \DoNotIndex{\cyrA,\cyrBe,\cyrVe,\cyrGhe,\cyrDe,%
392 % \cyrIe,\cyrZhe,\cyrZe,\cyrI,\cyrKa,\cyrEl,%
393 % \cyrEm,\cyrEn,\cyrO,\cyrPe,\cyrEr,\cyrEs,%
394 % \cyrTe,\cyrU,\cyrEf,\cyrHa,\cyrTse,\cyrChe,%
395 % \cyrSha,\cyrShcha,\cyrHard,\cyrYeru,\cyrSoft,%
396 % \cyrE,\cyrYu,\cyrYa,\cyrvarI,\cyra,\cyrbe,%
397 % \cyrve,\cyrghe,\cyrde,\cyrie,\cyrzhe,\cyrze,%
398 % \cyri,\cyrka,\cyrel,\cyrem,\cyren,\cyro,%
399 % \cyrpe,\cyrer,\cyres,\cyrte,\cyru,\cyref,%
400 % \cyrha,\cyrtse,\cyrche,\cyrsha,\cyrshcha,%
401 % \cyrhard,\cyryeru,\cyrsoft,\cyre,\cyryu,%
402 % \cyrya,\cyrvari}
403 %
404 %
405 % \DoNotIndexMain{\colon,\mathellipsis,\angle,\sqsubset,\sqsupset,
406 % \bowtie,\doteq,\neq,\ng,\clubsuit,\spadesuit,\diamondsuit,%
407 % \heartsuit,\cong,\uparrow,\Uparrow,\downarrow,\Downarrow,%
408 % \updownarrow,\Updownarrow,\longrightarrow,\longleftarrow,$
409 % \longleftrightarrow,\hookrightarrow,\hookleftarrow,%
410 % \Longrightarrow,\Longleftarrow,\Longleftrightarrow,%
411 % \rightleftharpoons,\to,\mapsto,\mapsto,\longmapsto,%
412 % \from,\mapsfrom,\longmapsfrom,\lightningboltarrow,\sum,%
413 % \prod,\coprod,\bigvee,\bigwedge,\bigcup,\bigcap,%
414 % \bigoplus,\bigotimes,\bigodot,\bigsqcup,\iint,\iiint,%
415 % \oint,\oiint,\oiiint,\lbrace,\rbrace,\lguil,\rguil,%
416 % \backslash,\mathbackslash,\textng,\simeq,\vert,\llguil,%
417 % \rrguil,\fakelangle,\fakerangle,\fakellangle,\fakerrangle,%
418 % \bigtimes,\@@relbar,\@@Relbar,\hbar,\mathsterling}
419 %
420 % \noindent This file documents the code for the \textsf{mathfont} package. It is not a user guide! If you are looking for instructions on how to use \textsf{mathfont} in your document, see |mathfont-user-guide.pdf|, which is included with the \textsf{mathfont} installation and is available on \textsc{ctan}. See also the other |pdf| documentation files for \textsf{mathfont}. Section~1 of this document begins with the implementation basics, including package declaration and package options. Section~2 provides package default settings, and section~3 deals with errors and messaging. Section~4 contains the fontloader, and section~5 contains the optional-argument parser for |\mathfont|. Section 6 documents the code for the |\mathfont| command itself. Section~7 contains the code for local font changes. Section~8 contains miscellaneous material. Sections~9--11 contain the Lua code to modify font objects at loading, and section~12 lists the Unicode hex values used in symbol declaration. Version history and code index appear at the end of the document.
421 %
422 % At high level, the package works as follows: the font-loader |\M@newfont| is a wrapper around \textsc{nfss} macros to declare fonts---namely |\DeclareFontFamily| and |\DeclareFontShape|---or, if the user requested to use \textsf{fontspec} as a backend, the macro |\fontspec_set_family:Nnn|. All font-setting macros in the package will call |\M@newfont|. The primary font-setting command |\mathfont| is a wrapper around |\DeclareSymbolFont| and calls various |\M@|\meta{keyword}|@set| commands. Each |\M@|\meta{keyword}|@set| macro is a wrapper around a number of |\Umathcode| declarations that do the actual work of setting default font(s). The local font-change commands are wrappers around |\DeclareMathAlphabet|, and the Lua font adjustments alter the font table through the |luaotfload.patch_font| callback when \TeX\ loads the font. Specifically, we change the top-level flag |nomath| to false, alter character-level entries in the table to make the font more suitable for math typesetting, and add a MathConstants table based on font dimensions.
423 %
424 %
425 %
426 % \section{Setup}
427 %
428 %
429 % First, the package should declare itself. The first 61 lines of |mathfont.sty| are comments. \c@CodelineNo=61\relax
430 % \begin{macrocode}
431 \NeedsTeXFormat{LaTeX2e}
432 \ProvidesPackage{mathfont}[2026/02/07 v. 3.0a]
433 % \end{macrocode}
434 % Informational message.
435 % \begin{macrocode}
436 \def\@mathfontinfo#1{\wlog{Package mathfont Info: #1}}
437 % \end{macrocode}
438 % We specify conditionals and one count variable that we use later in handling options and setup.
439 % \begin{macrocode}
440 \newif\ifM@XeTeXLuaTeX % is engine one of xetex or luatex?
441 \newif\ifM@Noluaotfload % cannot find luaotfload.sty?
442 \newif\ifM@adjust@font % should adjust fonts with lua script?
443 \newif\ifM@font@loaded % load mathfont with font specified?
444 \newif\ifE@sterEggDecl@red % already did easter egg?
445 \newcount\M@loader % specifies which font-loader to use
446 % \end{macrocode}
447 % We disable the twenty user-level commands. If \textsf{mathfont} runs normally, it will overwrite these ``bad'' definitions later, but if it throws one of its two fatal errors, it will |\endinput| while the user-level commands are error messages. That way the commands don't do anything in the user's document, and the user gets information on why not. The bad definitions gobble their original arguments to avoid a ``missing |\begin{document}|'' error. To streamline the process, we metacode most of the error messages, namely the macros that |\@gobble| their argument and the macros that |\@gobbletwo| their argument.
448 % \begin{macrocode}
449 \long\def\@gobble@brackets[#1]{}
450 \def\M@NoMathfontError#1{\PackageError{mathfont}
451 {\MessageBreak Invalid command\MessageBreak
452 \string#1 on line \the\inputlineno}
453 {Your command was ignored. I couldn't\MessageBreak
454 load mathfont, so I never defined this\MessageBreak
455 control sequence.}}
456 % \end{macrocode}
457 % The macro |\M@robust@def| is an engine-dependent command to define robust control sequences. We want this part of the package to work regardless of the engine, so we need an approach that doesn't depend on $\epsilon$-\TeX\ support. However, I don't want to use |\DeclareRobustCommand| with \XeTeX\ or Lua\TeX\ because that will leave useless macros like \verb*.\mathfont . defined when we fill in the proper definitions of the user-level commands later.
458 % \begin{macrocode}
459 \ifx\protected\@undefined
460 \let\M@robust@def\DeclareRobustCommand
461 \else
462 \def\M@robust@def{\protected\def}
463 \fi
464 % \end{macrocode}
465 % First the commands that normally accept a single argument---the ``bad'' versions |\@gobble| the argument. To keep the syntax straightforward, we expand the definition using |\edef|. (We can't use |\expanded| because that's \XeTeX/Lua\TeX\ only.) We need to do this because the macro name is stored in |\@i|, and otherwise, we would end up with a mess of |\expandafter|s to expand all instances of |\@i|.
466 % \begin{macrocode}
467 \@tfor\@i:=\setfont
468 \RuleThicknessFactor
469 \IntegralItalicFactor
470 \SurdVerticalFactor
471 \SurdHorizontalFactor
472 \charmline
473 \charmfile
474 \CharmLine
475 \CharmFile
476 \CharmInfo
477 \CharmType\do{%
478 \edef\@tempa{\noexpand\M@robust@def\expandafter\noexpand\@i{%
479 \noexpand\M@NoMathfontError\expandafter\noexpand\@i
480 \noexpand\@gobble}}
481 \@tempa}
482 % \end{macrocode}
483 % Now for the macros that |\@gobbletwo| their argument. The code is essentially the same.
484 % \begin{macrocode}
485 \@tfor\@i:=\newmathrm
486 \newmathit
487 \newmathbf
488 \newmathbfit
489 \newmathsc
490 \newmathscit
491 \newmathbfsc
492 \newmathbfscit\do{%
493 \edef\@tempa{\noexpand\M@robust@def\expandafter\noexpand\@i{%
494 \noexpand\M@NoMathfontError\expandafter\noexpand\@i
495 \noexpand\@gobbletwo}}
496 \@tempa}
497 % \end{macrocode}
498 % The two commands with weird ``arguments'': |\charminfo| and |\charmtype| scan and remove the next integer, so we assign a count value instead of gobbling stuff.
499 % \begin{macrocode}
500 \M@robust@def\charminfo{\M@NoMathfontError\charminfo
501 \begingroup
502 \afterassignment\endgroup
503 \count@}
504 \M@robust@def\charmtype{\M@NoMathfontError\charmtype
505 \begingroup
506 \afterassignment\endgroup
507 \count@}
508 % \end{macrocode}
509 % For the optional argument, we check if the following character is a |[|. If yes, we gobble first the brackets and then the mandatory argument. If not, we gobble the single mandatory argument.
510 % \begin{macrocode}
511 \@tfor\@i:=\documentfont
512 \mathfont
513 \mainfont
514 \mathfontshapes
515 \mathconstantsfont\do{%
516 \edef\@tempa{\noexpand\M@robust@def\expandafter\noexpand\@i{%
517 \noexpand\M@NoMathfontError\expandafter\noexpand\@i
518 \noexpand\@ifnextchar[%
519 {\noexpand\expandafter\noexpand\@gobble
520 \noexpand\@gobble@brackets}
521 {\noexpand\@gobble}}}
522 \@tempa}
523 % \end{macrocode}
524 % We code |\newmathfontcommand| by hand because it is the only command with four arguments.
525 % \begin{macrocode}
526 \M@robust@def\newmathfontcommand{%
527 \M@NoMathfontError\newmathfontcommand\@gobblefour}
528 % \end{macrocode}
529 % Check that the engine is \XeTeX\ or Lua\TeX. If yes, set |\ifM@XeTeXLuaTeX| to true. (Otherwise the conditional will be false by default.)
530 % \begin{macrocode}
531 \ifx\directlua\@undefined
532 \else
533 \M@XeTeXLuaTeXtrue
534 \fi
535 \ifx\XeTeXrevision\@undefined
536 \else
537 \M@XeTeXLuaTeXtrue
538 \fi
539 % \end{macrocode}
540 % The package can raise two fatal errors: one if the engine is not \XeTeX\ or Lua\TeX\ (and cannot load OpenType fonts) and one if \TeX\ cannot find the \textsf{luaotfload} package. In both cases, the package will stop loading, so we want a particularly conspicuous error message. For each message, we check the appropriate conditional to determine if we need to raise the error. If yes, we change space to catcode 12 inside a group. We define a |\GenericError| inside a macro and then call the macro for a cleaner error context line. The |\@gobbletwo| eats the extra period and return that \LaTeX\ adds to the error message. Notice that we expand the error before the |\endgroup|\textemdash this is because we need to switch |\M@XeTeXLuaTeXError| with its replacement text while it is still defined before we leave the group. At the same time, we want |\AtBeginDocument| and |\endinput| outside the group. The second |\expandafter| means that we expand the final |\fi| before |\endinput|, which balances the original conditional.
541 % \begin{macrocode}
542 \ifM@XeTeXLuaTeX\else
543 \begingroup
544 \catcode`\ =12\relax
545 \def\M@XeTeXLuaTeXError{\GenericError{}%
546 {\MessageBreak\MessageBreak
547 Package mathfont error:%
548 \MessageBreak\MessageBreak
549 *************************\MessageBreak
550 * *\MessageBreak
551 * UNABLE TO *\MessageBreak
552 * LOAD MATHFONT *\MessageBreak
553 * *\MessageBreak
554 * Missing XeTeX *\MessageBreak
555 * or LuaTeX *\MessageBreak
556 * *\MessageBreak
557 *************************\MessageBreak\@gobbletwo}%
558 {See the mathfont package documentation for explanation.}%
559 {I need XeTeX or LuaTeX to use mathfont. It\MessageBreak
560 looks like the current engine is something\MessageBreak
561 else, so I'm going to stop reading in the\MessageBreak
562 package file now. (You won't be able to use\MessageBreak
563 commands from mathfont in your document.) To\MessageBreak
564 load mathfont correctly, please retypeset your\MessageBreak
565 document with one of those two engines.^^J}}%
566 \expandafter\endgroup
567 \M@XeTeXLuaTeXError
568 \AtEndOfPackage{%
569 \typeout{:: mathfont :: Failed to load\on@line.}}
570 \expandafter\endinput % we \endinput with a balanced conditional
571 \fi
572 % \end{macrocode}
573 % Now do the same thing in checking for \textsf{luaotfload}. If the engine is Lua\TeX, we tell \textsf{mathfont} to implement Lua-based font adjustments by default. The conditional |\ifM@Noluaotfload| will keep track of whether \TeX\ could find |luaotfload.sty|. If the engine is \XeTeX, issue a warning.
574 % \begin{macrocode}
575 \ifdefined\directlua
576 \M@adjust@fonttrue % if engine is LuaTeX, adjust font by default
577 \IfFileExists{luaotfload.sty}
578 {\M@Noluaotfloadfalse\RequirePackage{luaotfload}}
579 {\M@Noluaotfloadtrue}
580 \else
581 \AtEndOfPackage{\PackageWarningNoLine{mathfont}{%
582 The current engine is XeTeX, but as\MessageBreak
583 of mathfont version 2.0, LuaTeX is\MessageBreak
584 recommended. Consider compiling with\MessageBreak
585 LuaLaTeX. Certain features will not\MessageBreak
586 work with XeTeX}}
587 \fi
588 % \end{macrocode}
589 % If the engine is Lua\TeX, we must have \textsf{luaotfload} because Lua\TeX\ needs this package to load OpenType fonts. Before anything else, \TeX\ should check whether it can find |luaotfload.sty| and stop reading in \textsf{mathfont} if it cannot. Same command structure as before. Newer \LaTeX\ versions load \textsf{luaotfload} as part of the format, but it never hurts to double check.
590 % \begin{macrocode}
591 \ifM@Noluaotfload % true if LuaTeX AND no luaotfload.sty
592 \begingroup
593 \catcode`\ =12\relax
594 \def\M@NoluaotfloadError{\GenericError{}%
595 {\MessageBreak\MessageBreak
596 Package mathfont error:%
597 \MessageBreak\MessageBreak
598 *************************\MessageBreak
599 * *\MessageBreak
600 * UNABLE TO *\MessageBreak
601 * LOAD MATHFONT *\MessageBreak
602 * *\MessageBreak
603 * Cannot find the *\MessageBreak
604 * file luaotfload.sty *\MessageBreak
605 * *\MessageBreak
606 *************************\MessageBreak\@gobbletwo}%
607 {You are likely seeing this message because you haven't^^J%
608 installed luaotfload. Check your TeX distribution for a^^J%
609 list of the packages on your system.^^J^^J%
610 See the mathfont documentation for further explanation.}%
611 {You're in trouble here. It looks like the current\MessageBreak
612 engine is LuaTeX, so I need the luaotfload package\MessageBreak
613 to make mathfont work correctly. However, I can't\MessageBreak
614 find luaotfload, which likely means something is\MessageBreak
615 wrong with your TeX installation. I'm going to stop\MessageBreak
616 reading in the mathfont package file. (You won't be\MessageBreak
617 able to use commands from mathfont in your document.)\MessageBreak
618 To load mathfont properly, make sure you installed\MessageBreak
619 luaotfload.sty in a directory searchable by TeX or\MessageBreak
620 compile with XeLaTeX.^^J}}%
621 \expandafter\endgroup
622 \M@NoluaotfloadError
623 \AtEndOfPackage{%
624 \typeout{:: mathfont :: Failed to load\on@line.}}
625 \expandafter\endinput % we \endinput with a balanced conditional
626 \fi
627 % \end{macrocode}
628 % Easter egg!!
629 % \begin{macrocode}
630 \DeclareOption{easter-egg}{%
631 \ifE@sterEggDecl@red\else
632 \E@sterEggDecl@redtrue
633 \newcount\@easter@egg@
634 \protected\def\EasterEggUpdate{%
635 \ProcessE@sterEgg\showtokens\expandafter{\E@sterEggUpd@te}}
636 \let\ProcessE@sterEgg\relax
637 % \end{macrocode}
638 % Two status updates during package loading.
639 % \begin{macrocode}
640 \edef\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
641 Okay, opening your Easter egg.^^J%
642 Type \string\EasterEggUpdate\space in your^^J%
643 document to see the status.^^J^^J}
644 \EasterEggUpdate
645 \def\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
646 Uh oh. It looks like your Easter^^J%
647 egg flew out the window. I don't^^J%
648 I don't suppose you know the best^^J%
649 kind of bait to lure an egg?^^J^^J}
650 \EasterEggUpdate
651 % \end{macrocode}
652 % Possible updates if the user types |\EasterEggUpdate|. We define the status update with |\ProcessE@sterEgg|, which stores the current message in |\E@sterEggUpd@te| and changes the message as the user calls |\EasterEggUpdate|. The count |\@easter@egg@| keeps track of how many times the user has requested a status update.
653 % \begin{macrocode}
654 \def\ProcessE@sterEgg{%
655 \edef\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
656 \ifodd\@easter@egg@
657 \ifcase\numexpr(\@easter@egg@ - 1) / 2\relax
658 An Easter bunny must be related to a^^J%
659 platypus, no? Some sort of monotreme...%
660 \or
661 Don't count your chickens before they hatch^^J%
662 out of Easter eggs! But we don't have any^^J%
663 chickens right now because there are no eggs,^^J%
664 and the supply chain is sad.%
665 \or
666 Sorry, I'm late to a meeting. Can't talk right now.%
667 \or
668 Sunday, Monday, Tuesday, Wednesday, also^^J%
669 known as hump day, as in camel humps, which^^J%
670 I must say look distinctly egg-like if you^^J%
671 squint.%
672 \or
673 I'm calling Eggs Anonymous!%
674 \or
675 Sorry, I'm on the phone. Can't talk right now.%
676 \or
677 Still haven't found your Easter egg. I know^^J%
678 it's floating around here somewhere. Like an^^J%
679 asteroid in space, hopefully without the^^J%
680 massive extinction event.%
681 \or
682 Did you know eggs are used to make certain^^J%
683 types of vaccines? PSA: get your flu shot^^J%
684 and your covid shot!%
685 \or
686 Three large eggs.^^J%
687 Three large eggs.^^J%
688 See how they crack.^^J%
689 See how they crack.^^J%
690 Their broken shells are so pearly white.^^J%
691 In simmering water they catch the light.^^J%
692 Did you ever see such a sight in your life^^J%
693 As three poached eggs?%
694 \or
695 Do gnus eat eggs? Surely they must.%
696 \or
697 Okay, I have a fishing rod, some twine, and^^J%
698 a hook, but I still haven't caught your Easter^^J%
699 egg. Apparently it's harder to catch an egg^^J%
700 than a fish.%
701 \or
702 Sorry, I'm out fishing. Can't talk right now.%
703 \or
704 Is ghoti really an acceptable phonetic^^J%
705 spelling of fish? I am skeptical.%
706 \or
707 Perhaps an Easter bunny is actually a species^^J%
708 of fish. A rabbit fish.%
709 \else
710 Sorry, I'm all out of witty things to say.^^J%
711 Check back later.%
712 \fi
713 \else
714 Still wrangling. Check back later.%
715 \fi^^J^^J}%
716 \global\advance\@easter@egg@\@ne}
717 % \end{macrocode}
718 % One status update |\AtBeginDocument|.
719 % \begin{macrocode}
720 \AtBeginDocument{\bgroup
721 \let\ProcessE@sterEgg\relax
722 \def\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
723 If we have zero eggs^^J%
724 and zero bunnies, how^^J%
725 many gnats does it take^^J%
726 to change a lightbulb??^^J^^J}
727 \EasterEggUpdate
728 \egroup}
729 % \end{macrocode}
730 % One update at the first instance of math mode, assuming another package doesn't overwrite the contents of |\everymath| first.
731 % \begin{macrocode}
732 \def\math@E@sterEggUpd@te{\begingroup
733 \let\ProcessE@sterEgg\relax
734 \def\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
735 Scrambled, poached, or sunny side up?^^J^^J}%
736 \EasterEggUpdate
737 \endgroup
738 \global\let\math@E@sterEggUpd@te\relax}
739 \everymath\expandafter{\the\everymath\math@E@sterEggUpd@te}
740 % \end{macrocode}
741 % Two status updates |\AtEndDocument|, including the egg itself. First, we disable |\ProcessE@sterEgg| since we don't need it anymore. Then inside a group, we make the control symbols |\*|, |\/|, and |\=| expand to their own names and do some extreme catcode sports. We convert |+| to active and make it expand to a space. Because everything has already been tokenized inside |\DeclareOption|, we have to retokenize the definition of |+| inside |\scantokens|, and we set |\everyeof| to |\noexpand| to avoid an end-of-file error.
742 % \begin{macrocode}
743 \AtEndDocument{\let\ProcessE@sterEgg\relax
744 \begingroup
745 \edef\*{\@backslashchar*}
746 \edef\/{\@backslashchar/}
747 \edef\={\@backslashchar=}
748 \catcode`\+=\active
749 \everyeof{\noexpand}
750 \scantokens{\def+{ }}
751 % \end{macrocode}
752 % At this point we are ready to make the egg message Again, we have to retokenize everything with |\scantokens| because it was previously tokenized. However, if we write |^^J| directly inside |\scantokens|, that primitive will convert the newline to a blank space, so instead we store |^^J| in |\@tempb|. After the |\edef| expands |\scantokens|, it also expands each |\@tempb|, so |\@tempa| has the line breaks we want.
753 % \begin{macrocode}
754 \def\@tempb{^^J}
755 \edef\@tempa{\scantokens{Easter Egg Status:\@tempb\@tempb
756 The egg has been retrieved. What\@tempb
757 pinnacle of pulchritude!\@tempb\@tempb
758 +++++++++++++******\@tempb
759 ++++++++++************\@tempb
760 +++++++******************\@tempb
761 +++++----------------------\@tempb
762 +++**************************\@tempb
763 ++****/\****/\****/\****/\****\@tempb
764 +*****\/****\/****\/****\/*****\@tempb
765 +******************************\@tempb
766 ********************************\@tempb
767 ***/\****/\****/\****/\****/\***\@tempb
768 ***\/****\/****\/****\/****\/***\@tempb
769 ********************************\@tempb
770 ********************************\@tempb
771 ******/\****/\****/\****/\******\@tempb
772 +*****\/****\/****\/****\/*****\@tempb
773 ++****************************\@tempb
774 +++--------------------------\@tempb
775 +++++**********************\@tempb
776 +++++++******************\@tempb
777 +++++++++\============/\@tempb
778 +++++++++++\========/\@tempb
779 ++++++++++++\======/\@tempb
780 +++++++++++++|====|\@tempb
781 ++++++++++++/======\@backslashchar\@tempb
782 +++++++++++(________)\@tempb}}
783 % \end{macrocode}
784 % Then end the group and store the message in |\E@sterEggUpd@te|.
785 % \begin{macrocode}
786 \expandafter\endgroup\expandafter
787 \def\expandafter\E@sterEggUpd@te\expandafter{\@tempa}
788 \EasterEggUpdate
789 \def\E@sterEggUpd@te{Easter Egg Status:^^J^^J%
790 Happy, happy day! Happy,^^J%
791 happy day! Clap your hands,^^J%
792 and be glad your hovercraft^^J%
793 isn't full of eels!^^J^^J}
794 \EasterEggUpdate
795 \let\E@sterEggUpd@te\relax
796 \let\EasterEggUpdate\relax}
797 \fi}% my easter egg :)
798 % \end{macrocode}
799 % The five real package options. The |default-loader| and |fontspec-loader| tell \textsf{mathfont} what to use as a backend for loading fonts.
800 % \begin{macrocode}
801 \DeclareOption{default-loader}{\M@loader\z@}
802 \DeclareOption{fontspec-loader}{\M@loader\@ne}
803 % \end{macrocode}
804 % The options |adjust| and |no-adjust| determine whether \textsf{mathfont} applies Lua-based font adjustments to fonts loaded in the future.
805 % \begin{macrocode}
806 \DeclareOption{adjust}{\M@adjust@fonttrue}
807 \DeclareOption{no-adjust}{\M@adjust@fontfalse}
808 % \end{macrocode}
809 % Interpret an unknown option as a font name and save it for loading. In this case, the package sets |\ifM@font@loaded| to true and stores the font name in |\M@font@load|.
810 % \begin{macrocode}
811 \DeclareOption*{\M@font@loadedtrue
812 \edef\M@font@load{\CurrentOption}}
813 \ProcessOptions*
814 % \end{macrocode}
815 % For the font-loader, we have a bit of processing to do. First print an informational message in the |log| file. The default loader is easy, but if the user requests \textsf{fontspec}, we have to make sure to load everything properly.
816 % \begin{macrocode}
817 \ifcase\M@loader
818 \@mathfontinfo{Default font-loader was
819 requested for font loading.}
820 \or
821 \@mathfontinfo{Package fontspec was
822 requested for font loading.}
823 % \end{macrocode}
824 % If \textsf{fontspec} was already loaded, check whether |\g__fontspec_math_bool| is true or not. If it is, change it to false.
825 % \begin{macrocode}
826 \@ifpackageloaded{fontspec}
827 {\@mathfontinfo{Package fontspec detected.}
828 \csname bool_if:NTF\expandafter\endcsname
829 \csname g__fontspec_math_bool\endcsname
830 {\@mathfontinfo{Setting
831 \string\g__fontspec_math_bool to false.}
832 \csname bool_set_false:N\expandafter\endcsname
833 \csname g__fontspec_math_bool\endcsname}{\relax}}
834 % \end{macrocode}
835 % If \textsf{fontspec} was not loaded, check that the package file exists.
836 % \begin{macrocode}
837 {\@mathfontinfo{Package fontspec not detected.}
838 \IfFileExists{fontspec.sty}
839 {\@mathfontinfo{File fontspec.sty was found.}
840 \@mathfontinfo{Loading fontspec.}
841 \RequirePackage[no-math]{fontspec}}
842 {\PackageError{mathfont}
843 {Missing package fontspec;^^J%
844 using default font-loader instead}
845 {You requested fontspec as the font-loader\MessageBreak
846 for mathfont. However, I can't find the\MessageBreak
847 package file for fontspec, so I'm going to\MessageBreak
848 use mathfont's built-in font-loader. (This\MessageBreak
849 likely means that something is wrong with\MessageBreak
850 your TeX installation.) Check your TeX\MessageBreak
851 distribution for a list of the packages\MessageBreak
852 installed on your system. To resolve this\MessageBreak
853 error, make sure fontspec is installed in\MessageBreak
854 a directory searchable by TeX or load\MessageBreak
855 mathfont with the default-loader option.^^J}
856 \M@loader\z@}}
857 \fi
858 % \end{macrocode}
859 % We print an informational message specifying the font-loader in use. We store default OpenType features in |\M@otf@features|. The contents depend on the font-loader because we use \XeTeX/\textsf{luaotfload} syntax versus \textsf{fontspec} syntax. By default, \textsf{mathfont} loads fonts with Latin script, default language, \TeX\ and common ligatures, and lining numbers.
860 % \begin{macrocode}
861 \ifcase\M@loader
862 \@mathfontinfo{Using default font-loader.}
863 \AtEndOfPackage{%
864 \typeout{:: mathfont :: Using default font-loader.}}
865 \def\M@otf@features{script=latn;language=dflt;+tlig;+liga;+lnum}
866 \or
867 \@mathfontinfo{Using fontspec as font-loader.}
868 \AtEndOfPackage{%
869 \typeout{:: mathfont :: Using fontspec as font-loader.}}
870 \def\M@otf@features{Script=Latin,%
871 Language=Default,%
872 Ligatures={TeX,Common},%
873 Numbers=Lining}
874 \fi
875 % \end{macrocode}
876 % We print an informational message depending on whether the user enabled Lua-based font adjustments. If |\directlua| is defined, that means we are using Lua\TeX, so we print a message depending on |\ifM@adjust@font|.
877 % \begin{macrocode}
878 \ifdefined\directlua
879 \ifM@adjust@font
880 \@mathfontinfo{Enabling Lua-based font adjustments.}
881 \AtEndOfPackage{%
882 \typeout{:: mathfont :: Lua-based font adjustments
883 enabled.}}
884 \else
885 \@mathfontinfo{Disabling Lua-based font adjustments.}
886 \AtEndOfPackage{%
887 \typeout{:: mathfont :: Lua-based font adjustments
888 disabled.}}
889 \fi
890 \else
891 % \end{macrocode}
892 % If |\directlua| is undefined, we make sure Lua-based font adjustments are disabled, and we issue an error if the user tried to manually enable them.
893 % \begin{macrocode}
894 \ifM@adjust@font
895 \PackageError{mathfont}{Option^^J"adjust" ignored with XeTeX}
896 {Your package option "adjust" was ignored.\MessageBreak
897 This option works only with LuaTeX, and it\MessageBreak
898 looks like the current engine is XeTeX. To\MessageBreak
899 enable Lua-based font adjustments, typeset\MessageBreak
900 with LuaLaTeX.^^J}
901 \M@adjust@fontfalse
902 \fi
903 \@mathfontinfo{Disabling Lua-based font adjustments.}
904 \AtEndOfPackage{%
905 \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
906 \fi
907 % \end{macrocode}
908 %
909 %
910 %
911 % \section{Default Settings}
912 %
913 % We save four macros from the \LaTeX\ kernel for safe-keeping, and then we change their definitions. As of version 3.0 of \textsf{mathfont}, the new definitions for |\set@mathchar|, etc.\ are not necessary for implementing \textsf{mathfont}, but we keep them in the package to make |\DeclareMathSymbol| and friends compatible with Unicode. For these three control sequences, we convert the hexadecimal digits in |\count0| and |\count2| back to decimal and change the |\math| primitive to |\Umath|.
914 % \begin{macrocode}
915 \let\@@set@mathchar\set@mathchar
916 \let\@@set@mathsymbol\set@mathsymbol
917 \let\@@set@mathaccent\set@mathaccent
918 \let\@@DeclareSymbolFont\DeclareSymbolFont
919 \let\@@DeclareSymbolFont@m@dropped\DeclareSymbolFont@m@dropped
920 \@onlypreamble\@@set@mathchar
921 \@onlypreamble\@@set@mathsymbol
922 \@onlypreamble\@@set@mathaccent
923 \@onlypreamble\@@DeclareSymbolFont
924 \@onlypreamble\@@DeclareSymbolFont@m@dropped
925 \@mathfontinfo{Adapting \noexpand\set@mathchar for Unicode.}
926 \@mathfontinfo{Adapting \noexpand\set@mathsymbol for Unicode.}
927 \@mathfontinfo{Adapting \noexpand\set@mathaccent for Unicode.}
928 \@mathfontinfo{Increasing upper bound on
929 \noexpand\DeclareSymbolFont to 256.}
930 % \end{macrocode}
931 % Kernel command to set math characters from keystrokes.
932 % \begin{macrocode}
933 \def\set@mathchar#1#2#3#4{%
934 \multiply\count\z@ by 16\relax
935 \advance\count\z@\count\tw@
936 \global\Umathcode`#2=\mathchar@type#3+#1+\count\z@\relax}
937 % \end{macrocode}
938 % Kernel command to set math characters from control sequences.
939 % \begin{macrocode}
940 \def\set@mathsymbol#1#2#3#4{%
941 \multiply\count\z@ by 16\relax
942 \advance\count\z@\count\tw@
943 \global\Umathchardef#2=\mathchar@type#3+#1+\count\z@\relax}
944 % \end{macrocode}
945 % Kernel command to set accents.
946 % \begin{macrocode}
947 \def\set@mathaccent#1#2#3#4{%
948 \multiply\count\z@ by 16\relax
949 \advance\count\z@\count\tw@
950 \protected\xdef#2{%
951 \Umathaccent\mathchar@type#3+\number#1+\the\count\z@\relax}}
952 % \end{macrocode}
953 % We increase the upper bound on the number of symbol fonts to be 256. Lua\TeX\ and \XeTeX\ allow up to 256 math families, but the \LaTeX\ kernel keeps the old upper bound of 16 symbol fonts under these two engines. We patch |\DeclareSymbolFont| to change the |\count18<15| to |\count18|\penalty0|<\e@mathgroup@top|, where |\e@mathgroup@top| is the number of math families, which is 256 in \XeTeX\ and Lua\TeX. We get a sanitized definition with |\meaning| and |\strip@prefix|, implement the patch by expanding |\M@p@tch@decl@re|, and retokenize the whole thing. A simpler approach, such as calling |\M@p@tch@decl@re| directly on the expansion of |\DeclareSymbolFont|, won't work because of how \TeX\ stores and expands parameter symbols inside macros.
954 %
955 % As of November 2022, the \LaTeX\ team renamed |\DeclareSymbolFont| to |\DeclareSymbolFont@m@dropped|, and now |\DeclareSymbolFont| is a wrapper around the old version of itself. This was done for error checking purposes to remove extra |m|'s from certain \textsc{nfss} family names. This means that if |\DeclareSymbolFont@m@dropped| is defined, we should patch that macro, and otherwise, we should patch |\DeclareSymbolFont|.
956 % \begin{macrocode}
957 \ifx\DeclareSymbolFont@m@dropped\@undefined
958 \edef\@tempa{\expandafter
959 \strip@prefix\meaning\DeclareSymbolFont}
960 \def\@tempb{\def\DeclareSymbolFont##1##2##3##4##5}
961 \else
962 \edef\@tempa{\expandafter
963 \strip@prefix\meaning\DeclareSymbolFont@m@dropped}
964 \def\@tempb{\def\DeclareSymbolFont@m@dropped##1##2##3##4##5}
965 \fi
966 \def\M@p@tch@decl@re#1<15#2\@nil{#1<\e@mathgroup@top#2}
967 \edef\M@DecSymDef{\expandafter\M@p@tch@decl@re\@tempa\@nil}
968 % \end{macrocode}
969 % Now |\M@DecSymDef| contains the patched text of our new |\DeclareSymbolFont|, all with catcode 12. In order to make it useable, we have to retokenize it. If this package was Lua\TeX\ only, we could use |\scantextokens|, which is nicely behaved and does what we expect. However, to make it compatible with \XeTeX, we use |\scantokens|. Unfortunately, while |\scantextokens| is straightforward, |\scantokens| is a menace. The problem is that when it expands, the primitive inserts an end-of-file token (because |\scantokens| mimics writing to a file and |\input|ing what it just wrote) after the retokenized code, and as a result, |\scantokens| can produce an end-of-file error. The trick (realized after much trial and error) is that if we scan the entire definition statement including |\def| and the macro definition, the end-of-file token doesn't end up in the macro definition, and we avoid the ``file ended'' error message.
970 % \begin{macrocode}
971 \scantokens\expandafter{%
972 \expandafter\@tempb\expandafter{\M@DecSymDef}}
973 % \end{macrocode}
974 % We need to keep track of the number of times we have loaded fonts, and |\M@count| fulfills this role. The |\toks| will record a message that displays in the |log| file when the user calls |\mathfont|. The |\newread| is for Lua-based font adjustments.
975 % \begin{macrocode}
976 \newbox\surdbox
977 \newcount\M@count
978 \newcount\M@num@localfonts
979 \newcount\rulethicknessfactor
980 \newcount\hsurdfactor
981 \newcount\vsurdfactor
982 \newmuskip\radicandoffset
983 \newread\M@Charm
984 \M@count\z@
985 \rulethicknessfactor\@m
986 \hsurdfactor\@m
987 \vsurdfactor\@m
988 \radicandoffset=1mu\relax
989 % \end{macrocode}
990 % Necessary booleans and default math font shapes.
991 % \begin{macrocode}
992 \newif\ifM@upper
993 \newif\ifM@lower
994 \newif\ifM@diacritics
995 \newif\ifM@greekupper
996 \newif\ifM@greeklower
997 \newif\ifM@agreekupper
998 \newif\ifM@agreeklower
999 \newif\ifM@cyrillicupper
1000 \newif\ifM@cyrilliclower
1001 \newif\ifM@hebrew
1002 \newif\ifM@digits
1003 \newif\ifM@operator
1004 \newif\ifM@symbols
1005 \newif\ifM@extsymbols
1006 \newif\ifM@delimiters
1007 \newif\ifM@radical
1008 \newif\ifM@arrows
1009 \newif\ifM@bigops
1010 \newif\ifM@extbigops
1011 \newif\ifM@bb
1012 \newif\ifM@cal
1013 \newif\ifM@frak
1014 \newif\ifM@bcal
1015 \newif\ifM@bfrak
1016 \newif\if@optionpresent
1017 \newif\if@suboptionpresent
1018 \newif\ifM@arg@good
1019 \newif\ifM@mode@
1020 % \end{macrocode}
1021 % Default shapes.
1022 % ^^A temporarily disable writing
1023 % ^^A macros in the margin
1024 % ^^A otherwise it looks weird
1025 % \let\@@marginmacro\marginmacro
1026 % \def\marginmacro#1\@nil{}
1027 % \begin{macrocode}
1028 \def\upperdefault{italic} % latin upper
1029 \def\lowerdefault{italic} % latin lower
1030 \def\diacriticsdefault{upright} % diacritics
1031 \def\greekupperdefault{upright} % greek upper
1032 \def\greeklowerdefault{italic} % greek lower
1033 \def\agreekupperdefault{upright} % ancient greek upper
1034 \def\agreeklowerdefault{italic} % ancient greek lower
1035 \def\cyrillicupperdefault{upright} % cyrillic upper
1036 \def\cyrilliclowerdefault{italic} % cyrillic lower
1037 \def\hebrewdefault{upright} % hebrew
1038 \def\digitsdefault{upright} % numerals
1039 \def\operatordefault{upright*} % operator font
1040 \def\delimitersdefault{upright} % delimiters
1041 \def\radicaldefault{upright} % surd
1042 \def\bigopsdefault{upright} % big operators
1043 \def\extbigopsdefault{upright} % extended big operators
1044 \def\symbolsdefault{upright} % basic symbols
1045 \def\extsymbolsdefault{upright} % extended symbols
1046 \def\arrowsdefault{upright} % arrows
1047 \def\bbdefault{upright} % blackboard bold
1048 \def\caldefault{upright} % caligraphic
1049 \def\frakdefault{upright} % fraktur
1050 \def\bcaldefault{upright} % bold caligraphic
1051 \def\bfrakdefault{upright} % bold fraktur
1052 % \end{macrocode}
1053 % \let\marginmacro\@@marginmacro
1054 % The |\M@keys| list stores all the possible keyword options, and |\M@defaultkeys| stores the character classes that |\mathfont| acts on by default.
1055 % \begin{macrocode}
1056 \def\M@keys{upper,lower,diacritics,greekupper,%
1057 greeklower,agreekupper,agreeklower,cyrillicupper,%
1058 cyrilliclower,hebrew,digits,operator,delimiters,%
1059 radical,bigops,extbigops,symbols,extsymbols,arrows,%
1060 bb,cal,frak,bcal,bfrak}
1061 \def\M@defaultkeys{upper,lower,diacritics,greekupper,%
1062 greeklower,digits,operator,symbols}
1063 % \end{macrocode}
1064 % If the user enabled Lua-based font adjustments, the |\M@defaultkeys| list also includes delimiters, surd, and big operator symbols.
1065 % \begin{macrocode}
1066 \ifM@adjust@font
1067 \edef\M@defaultkeys{\M@defaultkeys,delimiters,radical,bigops}
1068 \fi
1069 % \end{macrocode}
1070 % A few macros that we use for assembling lists of font information and printing messages |\AtBeginDocument|.
1071 % \begin{macrocode}
1072 \let\M@localfonts\@empty
1073 \let\M@symbolfonts\@empty
1074 \let\M@families\@empty
1075 % \end{macrocode}
1076 % And now the macros to add to those three control sequences. First is a helper macro that accepts two arguments and stores information about declaration of local font changes. The macro successively adds comma-separated pairs of control sequence and font name information to |\M@localfonts|. It also keeps track of the number of distinct font names in |\M@localfonts| with the count variable |\M@num@localfonts|. The |#1| argument is a control sequence (with all characters having catcode 12 from |\string|), and the |#2| argument is a font name. We have two different approaches depending on whether |\M@localfonts| is empty, i.e.\ if it's the first time calling |\M@addto@localfonts|. If |\M@localfonts| is |\@empty|, that means we haven't added any fonts to the list yet, so we increase |\M@num@localfonts|. Otherwise we loop through |\M@localfonts|, and we increase |\M@num@localfonts| only if none of the entries in |\M@localfonts| use the |#2| font. After incrementing (or not) the count, we append |#1| and |#2| to |\M@localfonts|.
1077 % \begin{macrocode}
1078 \def\M@addto@localfonts#1#2#3#4{%
1079 \begingroup
1080 \@tempswatrue % increase by default
1081 \def\@tempa##1##2##3##4{##2}%
1082 \@for\@j:=\M@localfonts\do{%
1083 \edef\@tempb{\expandafter\@tempa\@j}%
1084 \ifx\@tempbase\@tempb
1085 \@tempswafalse % if \@tempbase is in list, don't add
1086 \fi}%
1087 \expandafter
1088 \endgroup
1089 \if@tempswa
1090 \advance\M@num@localfonts\@ne
1091 \fi
1092 \ifx\M@localfonts\@empty
1093 \else
1094 \edef\M@localfonts{\M@localfonts,}%
1095 \fi
1096 \edef\M@localfonts{\M@localfonts{#1}{#2}{#3}{#4}}}
1097 % \end{macrocode}
1098 % Same thing for symbol fonts.
1099 % \begin{macrocode}
1100 \def\M@addto@symbolfonts#1#2#3#4{%
1101 \ifx\M@symbolfonts\@empty
1102 \else
1103 \edef\M@symbolfonts{\M@symbolfonts,}%
1104 \fi
1105 \edef\M@symbolfonts{\M@symbolfonts{#1}{#2}{#3}{#4}}}
1106 % \end{macrocode}
1107 % And font families.
1108 % \begin{macrocode}
1109 \def\M@addto@families#1{%
1110 \ifx\M@families\@empty
1111 \else
1112 \edef\M@families{\M@families,}%
1113 \fi
1114 \xdef\M@families{\M@families#1}}
1115 % \end{macrocode}
1116 %
1117 %
1118 % \section{Messages and Errors}
1119 % \suppressfloats[t]
1120 %
1121 %
1122 %
1123 % \begin{figure}[t]
1124 % \def\vrb#1{\texttt{\string#1}}
1125 % \centerline{\bfseries Table 1: Package Messages and Errors and Their Uses\strut}
1126 % \begin{tabularx}\textwidth{lX<{\raggedright\arraybackslash}}
1127 % \toprule
1128 % Command & Use\\\midrule
1129 % \vrb\@mathfontinfo & General informational macro\\
1130 % \vrb\M@FontChangeInfo & When using a new symbol font\\
1131 % \vrb\M@FontFamilyInfo & Declaring new font shape in the \textsc{nfss}\\
1132 % \vrb\M@NewFontCommandInfo & New local font-change command\\
1133 % \vrb\M@SymbolFontInfo & Declare new symbol font\\\midrule
1134 % \vrb\M@FamilyTypeError & Error if bad argument for \vrb\mainfont\\
1135 % \vrb\M@NFSSShapesWarning & Warning if font is missing shapes\\
1136 % \vrb\M@NoBaseModeError & Error if no base-mode version of a font\\\midrule
1137 % \vrb\M@InvalidOptionError & Bad keyword for font-change command\\
1138 % \vrb\M@InvalidSupoptionError & Bad suboption for font-change command\\
1139 % \vrb\M@MissingOptionError & Missing keyword for font-change command\\
1140 % \vrb\M@MissingSuboptionError & Missing suboption for font-change command\\\midrule
1141 % \vrb\M@FontShapesError & Tried to add font shapes after preamble\\
1142 % \vrb\M@LuaTeXOnlyWarning & User called Lua\TeX-only macro in \XeTeX\\\midrule
1143 % \vrb\M@HModeError & Font-change command used outside math\\
1144 % \vrb\M@MissingCSError & No macro for font-change command\\\midrule
1145 % \vrb\M@BadIntegerError & Non-integer value for font adjustment\\
1146 % \vrb\M@NoCharmFileError & Bad file name for \vrb\charmfile\\
1147 % \vrb\M@NoFontAdjustError & Macro used without Lua font adjustments\\
1148 % \bottomrule
1149 % \end{tabularx}
1150 % \end{figure}
1151 %
1152 %
1153 %
1154 % Some error and informational messages. Table~1 lists all macros defined in this section along with a brief description of their use. We begin with general informational messages.
1155 % \begin{macrocode}
1156 \def\M@FontChangeInfo#1#2{\@mathfontinfo{Setting #1 chars to #2!}}
1157 \def\M@FontFamilyInfo#1{\@mathfontinfo{Adding #1 to the nfss.}}
1158 \def\M@SymbolFontInfo#1#2#3{%
1159 \@mathfontinfo{New symbol font uses TU/#1/#2/#3.}}
1160 \def\M@NewFontCommandInfo#1#2#3#4{%
1161 \@mathfontinfo{New \string#1 uses TU/#2/#3/#4.}}
1162 % \end{macrocode}
1163 % Warnings and errors related to font declaration.
1164 % \begin{macrocode}
1165 \def\M@NFSSShapesWarning#1#2{%
1166 \PackageWarningNoLine{mathfont}
1167 {The nfss family "#1"\MessageBreak
1168 from line \the\inputlineno\space is missing shapes.\MessageBreak
1169 You may see some substitutions\MessageBreak
1170 or errors. See the log file for\MessageBreak
1171 details}
1172 \@mathfontinfo{Shapes missing: #2.}}
1173 \def\M@NoBaseModeError#1{%
1174 \PackageError{mathfont}
1175 {Missing base-mode^^J%
1176 version of font family "#1"}
1177 {With LuaTeX, when you tell mathfont to\MessageBreak
1178 use a font family from the nfss, I try to\MessageBreak
1179 find aversion of that font in the nfss\MessageBreak
1180 that uses base mode. I couldn't do that\MessageBreak
1181 here, so you may see some problems with\MessageBreak
1182 your math. To resolve this error, either\MessageBreak
1183 use XeTeX, or make sure the nfss contains\MessageBreak
1184 a version of your font in base mode, and\MessageBreak
1185 define \string\<font family>-base to be the nfss\MessageBreak
1186 name for your base-mode family.^^J}}
1187 \def\M@FamilyTypeError#1{%
1188 \PackageError{mathfont}
1189 {Invalid family type/^^J%
1190 optional argument "#1" for \string\mainfont}
1191 {The optional argument of
1192 \string\mainfont\space should\MessageBreak
1193 be one of rm, sf, or tt. You used something\MessageBreak
1194 else, so I'm changing it to rm.^^J}}
1195 % \end{macrocode}
1196 % Error and warning messages for keywords and shape identifiers.
1197 % \begin{macrocode}
1198 \def\M@InvalidOptionError#1{%
1199 \PackageError{mathfont}
1200 {Invalid^^Jkeyword "#1" on line \the\inputlineno}
1201 {You used a character keyword that I'm\MessageBreak
1202 not familiar with. Check that you spelled\MessageBreak
1203 everything correctly. To resolve this\MessageBreak
1204 error, make sure you use keywords that\MessageBreak
1205 are listed in the documentation.^^J\@gobble}}
1206 \def\M@InvalidSuboptionError#1{%
1207 \PackageError{mathfont}
1208 {Invalid^^Jshape identifer "#1" on line \the\inputlineno}
1209 {You used a suboption/shape identifier\MessageBreak
1210 that I'm not familiar with. Check that\MessageBreak
1211 you spelled everything correctly. To\MessageBreak
1212 resolve this error, make sure you use\MessageBreak
1213 shape identifiers that are listed in\MessageBreak
1214 the documentation.^^J}}
1215 \def\M@MissingOptionError{%
1216 \PackageError{mathfont}
1217 {Missing keyword on line \the\inputlineno}
1218 {I didn't see a character keyword\MessageBreak
1219 where I was expecting to. This can\MessageBreak
1220 happen if you type ,, or ,= by\MessageBreak
1221 mistake. To resolve this error,\MessageBreak
1222 make sure you provided a comma-\MessageBreak
1223 separated list of keywords.^^J}}
1224 \def\M@MissingSuboptionError{%
1225 \PackageError{mathfont}
1226 {Missing suboption/^^Jshape identifier on line \the\inputlineno}
1227 {I didn't see a suboption/shape identifier\MessageBreak
1228 where I was expecting to. This can happen\MessageBreak
1229 if you type ,, or =, or == by mistake. To\MessageBreak
1230 resolve this error, make sure that every\MessageBreak
1231 = sign comes before a suboption or that you\MessageBreak
1232 provided a comma-separated list of shape\MessageBreak
1233 identifiers, depending on the context.^^J}}
1234 % \end{macrocode}
1235 % Error messages regarding arguments previously fed to |\mathfont| and friends.
1236 % \begin{macrocode}
1237 \def\M@FontShapesError{%
1238 \PackageError{mathfont}
1239 {^^JCan't declare new font shapes after
1240 \string\begin{document}}
1241 {This error means that you (1) requested\MessageBreak
1242 to use a family/series/shape combination\MessageBreak
1243 for a font-change command in this package\MessageBreak
1244 (2) after your document preamble (3) that\MessageBreak
1245 does not match any font you used for this\MessageBreak
1246 package in the preamble. To resolve this\MessageBreak
1247 error, try declaring more font shapes in\MessageBreak
1248 your preamble with \string\mathfontshapes.^^J}}
1249 \def\M@LuaTeXOnlyWarning#1{%
1250 \PackageWarningNoLine{mathfont}
1251 {Your \string#1\space on line
1252 \the\inputlineno\MessageBreak
1253 is mainly for use in LuaTeX with font\MessageBreak
1254 adjustments enabled. In the current\MessageBreak
1255 situation, it is probably not doing\MessageBreak
1256 anything}}
1257 % \end{macrocode}
1258 % Error messages for the |\newmathrm|, etc.\ commands.
1259 % \begin{macrocode}
1260 \def\M@MissingCSError#1#2{%
1261 \PackageError{mathfont}
1262 {Missing control sequence^^J%
1263 for\string#1\space on line \the\inputlineno}
1264 {Your command was ignored. Instead of\MessageBreak
1265 "#2,"\MessageBreak
1266 I was expecting a single control\MessageBreak
1267 sequence. To resolve this error,\MessageBreak
1268 please use one control sequence instead.^^J}}
1269 \def\M@HModeError#1{%
1270 \PackageError{mathfont}
1271 {Missing \string$ inserted^^J%
1272 on line \the\inputlineno}
1273 {I raised an error because you used\MessageBreak
1274 \string#1\space outside of math mode,\MessageBreak
1275 which isn't allowed. I inserted a \string$\MessageBreak
1276 before your control sequence, so we\MessageBreak
1277 should be all good now.^^J}}
1278 % \end{macrocode}
1279 % We need error messages related to Lua-based font adjustments.
1280 % \begin{macrocode}
1281 \def\M@NoFontAdjustError#1{%
1282 \PackageError{mathfont}
1283 {\string#1^^J%
1284 is invalid without Lua-based font adjustments}
1285 {Your control sequence won't do anything\MessageBreak
1286 without Lua-based font adjustments, but\MessageBreak
1287 you didn't enable them. To resolve this\MessageBreak
1288 error, load mathfont with LuaTeX and the\MessageBreak
1289 package option "adjust" or remove your\MessageBreak
1290 control sequence.^^J}}
1291 \def\M@BadIntegerError#1#2{%
1292 \PackageError{mathfont}
1293 {Bad argument^^J%
1294 "#2" for \string#1 on line \the\inputlineno}
1295 {Your command was ignored. Please make sure\MessageBreak
1296 that your argument for \string#1\MessageBreak
1297 is a nonnegative integer.^^J}}
1298 \def\M@NoCharmFileError#1{%
1299 \PackageError{mathfont}{Missing Charm File}
1300 {You requested to read the file\MessageBreak
1301 "#1"\MessageBreak
1302 with \string\charmfile. I can't find that file,\MessageBreak
1303 so I'm ignoring your command. To resolve\MessageBreak
1304 this error, make sure the filename is\MessageBreak
1305 correct, and double check that the file\MessageBreak
1306 is in a directory searchable by TeX.^^J}}
1307 % \end{macrocode}
1308 %
1309 %
1310 %
1311 % \section{Font Declaration}
1312 %
1313 % We come to the fontloader. The main font declaration macro is |\M@newfont|, and it accepts one argument that is a combination of font name and optional OpenType feature information separated by a colon. The macro accomplishes four tasks: (1) it separates the font name and features and stores them in |\@tempbase| and |\@tempfeatures|; (2) it checks whether tbe argument is present as a font name in the \textsc{nfss}; (3) if not, it declares the font in the \textsc{nfss}, either with the built-in font loader or using \textsf{fontspec}; and (4) it stores the \textsc{nfss} family name(s) in |\M@f@ntn@me| and |\M@f@ntn@meb@se|. If |\M@newfont| reaches step~3 after |\begin{document}|, it raises a ``can't declare new font shapes'' error.
1314 %
1315 % Checking the \textsc{nfss} happens in two steps. First, |\M@newfont| removes the spaces from its argument and checks whether the result matches a previous call to |\M@newfont|, and if yes, |\M@newfont| uses the family name from the previous call. If no, the macro checks whether the argument with spaces removed appears in the \textsc{nfss}. (Properly declared \textsc{nfss} font families shouldn't have spaces in their names because \LaTeX\ ignores spaces when scanning a font family declaration.) If |\M@newfont| finds an \textsc{nfss} family, it looks at the font shapes associated with that family using the helper macro |\M@check@nfss@shapes|. This command prints a warning if the \textsc{nfss} is missing any standard series/shape combinations (|m|/|n|, |m|/|it|, |b|/|n|, and |b|/|it|) for the font family. The package does not add any font shapes to the \textsc{nfss} at this point in the font-loading process.
1316 %
1317 % If both checks of the \textsc{nfss} fail, \textsf{mathfont} assumes the \textsc{nfss} does not contain the user's desired font and proceeds to declare it in the \textsc{nfss}. For the built-in font loader, font declaration uses the helper macros |\M@fill@nfss@shapes| and |\M@declare@shape|. The first of these two macros loops through series/shape pairs and feeds them to the second macro, which acts as a wrapper around |\DeclareFontShape|. If the user requested to use \textsf{fontspec} for the font loader, |\M@newfont| feeds the font name and requested features to |\fontspec_set_family:Nnn|, which modifies the \textsc{nfss} accordingly. Advanced users should keep in mind the difference between font declaration and font loading in \LaTeX. Font declaration, the subject of this section, means adding font information to the \textsc{nfss} through |\DeclareFontFamily| and |\DeclareFontShape|, and font loading is when \TeX\ reads a font file into memory via the |\font| primitive. \LaTeX\ handles font loading automatically at a |\selectfont| command or upon entering math mode, so a call to |\M@newfont| will not actually load any fonts into memory, just prepare \LaTeX\ to do so at a later time.
1318 %
1319 % In Lua\TeX, users can load fonts in one of three modes, namely |node| (the default), |base|, or |harf|. Node mode works well for text, but it has more limited capabilities for math. Harf mode uses the HarfBuzz renderer and is appropriate for more complicated scripts. Accordingly, when the engine is Lua\TeX, \textsf{mathfont} loads fonts once in base mode for math and once in unspecified (so likely node) mode for text. If the user specifies a font family already in the \textsc{nfss}, |\M@newfont| tries to find a base-mode version of the font family and raises an error if it cannot. When |\M@newfont| declares the font, it does so twice, once in unspecified mode and once in base mode. This is why we have two control sequences for font family names: |\M@f@ntn@me| is the font family, and |\M@f@nt@n@me@base| contains the \textsc{nfss} family name of the base-mode version of the font. In \XeTeX, these control sequences will be identical because \textsf{mathfont} does not load a font multiple times in that case.
1320 %
1321 % During font declaration, \textsf{mathfont} links several pieces of information as follows:
1322 % \begin{itemize}
1323 % \item Given an \meta{argument} with spaces removed, |\M@newfont| stores the corresponding \textsc{nfss} family name in |\M@fontfamily@|\meta{argument}
1324 % \item The \textsc{nfss} family name for the base-mode version of the font goes in |\M@fontfamily@base@|\meta{argument}
1325 % \item Given a \meta{family name}, |\M@newfont| stores the corresponding base-mode font family name in the control sequence |\|\meta{family name}|-base|. Users who want to declare their own fonts in the \textsc{nfss} prior to using them with \textsf{mathfont} should manually define this control sequence so that \textsf{mathfont} knows where your base-mode font lives.
1326 % \item Each \textsc{nfss} font family is assigned a unique value of |\M@count| that is stored in |\M@fontid@|\meta{family}.
1327 % \end{itemize}
1328 % These macro assignments are global. The difference relative to |\M@f@ntn@me| and |\M@f@ntn@meb@se| is that |\M@f@ntn@me| and |\M@f@ntn@meb@se| are temporary and always hold the font family from the most recent call to |\M@newfont|.
1329 %
1330 % The |\M@check@nfss@shapes| macro checks if a font family has shapes declared in upright, italic, bold, and bold italic. If any of those shapes are missing, we issue a warning. We store the missing series/shape pairs in |\@tempb| to print them as part of the warning message.
1331 % \begin{macrocode}
1332 \def\M@check@nfss@shapes#1{%
1333 \let\@tempb\@empty
1334 \let\@tempwarning\@gobble
1335 \@for\@i:=\mddefault/\shapedefault,%
1336 \mddefault/\itdefault,%
1337 \bfdefault/\shapedefault,%
1338 \bfdefault/\itdefault\do{%
1339 \expandafter\ifx\csname TU/#1/\@i\endcsname\relax
1340 \def\@tempwarning{\M@NFSSShapesWarning{#1}}%
1341 \edef\@tempb{\@tempb, \@i}%
1342 \fi}%
1343 % \end{macrocode}
1344 % We use a small hack to get everything to print correctly. If all shapes are present, then |\@tempwarning| is |\@gobble|, and the argument disappears. Otherwise, the argument becomes part of the warning message. The |\@gobble| eats the (unnecessary) first comma inside |\@tempb|.
1345 % \begin{macrocode}
1346 \@tempwarning{\expandafter\@gobble\@tempb}}
1347 % \end{macrocode}
1348 % Next we have commands to add series and shape information to the \textsc{nfss} for a given font family. The |\M@declare@shape| macro takes several arguments. It checks whether the series/shape pair exists in the \textsc{nfss}, and if not, it adds it using |\DeclareFontShape|. The argument structure is
1349 % \begin{itemize}
1350 % \item |#1|---\textsc{nfss} font family name
1351 % \item |#2|---optional |/B| or |/I| (or |/BI|) suffix on the font name
1352 % \item |#3|---a list of (default) OpenType feature tags
1353 % \item |#4|---a list of (the user's) OpenType feature tags
1354 % \item |#5|---\textsc{nfss} series identifier
1355 % \item |#6|---\textsc{nfss} shape identifier
1356 % \end{itemize}
1357 % We assume that the font file reference has already been stored in |\@tempbase|.
1358 % \begin{macrocode}
1359 \def\M@declare@shape#1#2#3#4#5#6{%
1360 \ifcsname TU/#1/#5/#6\endcsname
1361 \else
1362 \DeclareFontShape{TU}{#1}{#5}{#6}{<->"\@tempbase#2:#3;#4"}{}%
1363 \fi}
1364 % \end{macrocode}
1365 % The |\M@fill@nfss@shapes| command does the work of populating the \textsc{nfss} with the correct shape information. The argument structure is:
1366 % \begin{itemize}
1367 % \item |#1|---\textsc{nfss} font family name
1368 % \item |#2|---a list of (default) OpenType feature tags
1369 % \item |#3|---a list of (the user's) OpenType feature tags
1370 % \end{itemize}
1371 % We call |\M@declare@shape| for each combination of medium/bold series and upright/italic shape, and the result is an entry in the \textsc{nfss} for each combination. We have separate declarations for regular and small caps because they have different shape identifiers in the \textsc{nfss}. We manually set |smcp| to be |true| or |false| accordingly.
1372 % \begin{macrocode}
1373 \def\M@fill@nfss@shapes#1#2#3{%
1374 \@for\@i:={#1}{}{#2;-smcp}{#3}{\mddefault}{\shapedefault},%
1375 {#1}{/I}{#2;-smcp}{#3}{\mddefault}{\itdefault},%
1376 {#1}{/B}{#2;-smcp}{#3}{\bfdefault}{\shapedefault},%
1377 {#1}{/BI}{#2;-smcp}{#3}{\bfdefault}{\itdefault},%
1378 % \end{macrocode}
1379 % And do small caps. If a small caps font face is separate from the main font file, \TeX\ won't be able to find it automatically. In that case, you will have to write your own |fd| file or |\DeclareFontShape| commands.
1380 % \begin{macrocode}
1381 {#1}{}{#2;+smcp}{#3}{\mddefault}{\scdefault},%
1382 {#1}{/I}{#2;+smcp}{#3}{\mddefault}{\scdefault\itdefault},%
1383 {#1}{/B}{#2;+smcp}{#3}{\bfdefault}{\scdefault},%
1384 {#1}{/BI}{#2;+smcp}{#3}{\bfdefault}{\scdefault\itdefault}%
1385 \do{\expandafter\M@declare@shape\@i}}
1386 % \end{macrocode}
1387 % We use |\M@split@colon| and |\M@strip@colon| for parsing the argument of |\mathfont|. If the user calls |\mathfont{|\meta{name}|:|\meta{features}|}|, we store the name in |\@tempbase| and the features in |\@tempfeatures|. If the user specifies a name only, then |\@tempfeatures| will be empty. Syntactically, we use |\M@strip@colon| to remove a final |:| the same way we remove a final |=| when we parse the optional argument in the next section.
1388 % \begin{macrocode}
1389 \def\M@split@colon#1:#2\@nil{%
1390 \def\@tempbase{#1}%
1391 \def\@tempfeatures{#2}}
1392 \def\M@strip@colon#1:{#1}
1393 % \end{macrocode}
1394 % The main font-loading macro. It takes a single argument, which should look like either \meta{\textup{\textsc{nfss}} family} or \meta{font name}|:|\meta{optional features}. The first thing |\M@newfont| does is split the font name and OpenType features and store each portion in |\@tempbase| and |\@tempfeatures|. If |\@tempfeatures| is not empty, it has an extra colon at the end, so we remove it.
1395 % \begin{macrocode}
1396 \def\M@newfont#1{%
1397 \expandafter\M@split@colon\expanded{#1}:\@nil
1398 \ifx\@tempfeatures\@empty\else
1399 \edef\@tempfeatures{\expandafter\M@strip@colon\@tempfeatures}%
1400 \fi
1401 % \end{macrocode}
1402 % Then we find the font family name. We remove spaces from the argument, store it in |\@tempa|, and check whether the result matches a previous call to |\M@newfont|. If yes, we retrieve the font family and base-mode family names and store them in the appropriate control sequences.
1403 % \begin{macrocode}
1404 \edef@nospace\@tempa{#1}%
1405 \ifcsname M@fontfamily@\@tempa\endcsname
1406 \edef\M@f@ntn@me
1407 {\csname M@fontfamily@\@tempa\endcsname}%
1408 \edef\M@f@ntn@meb@se
1409 {\csname M@fontfamily@base@\@tempa\endcsname}%
1410 \else
1411 % \end{macrocode}
1412 % Next check whether |\@tempa| appears as a font family in the \textsc{nfss}.
1413 % \begin{macrocode}
1414 \ifcsname TU+\@tempa\endcsname% is #1 font family in the nfss?
1415 \let\M@f@ntn@me\@tempa
1416 % \end{macrocode}
1417 % Check that the \textsc{nfss} contains some font shapes. If any are missing, we issue a warning but do not fill them.
1418 % \begin{macrocode}
1419 \M@check@nfss@shapes\M@f@ntn@me
1420 % \end{macrocode}
1421 % With Lua\TeX, we want a proper base-mode version of the font. In this situation, \textsf{mathfont} expects to find a second font family whose \textsc{nfss} identifier is stored in |\|\meta{font family}|-base|, and we assume this second font was loaded with |mode=base|. If that information exists, we use it for the base-mode version.
1422 % \begin{macrocode}
1423 \ifdefined\directlua % if LuaTeX?
1424 \ifcsname\M@f@ntn@me-base\endcsname % if base-mode version
1425 \edef\M@f@ntn@meb@se
1426 {\csname\M@f@ntn@me-base\endcsname}%
1427 % \end{macrocode}
1428 % If the package found a base-mode font, again check that it contains some font shapes, and issue a warning if not.
1429 % \begin{macrocode}
1430 \M@check@nfss@shapes\M@f@ntn@meb@se
1431 \else
1432 % \end{macrocode}
1433 % Raise an error if we can't find a base-mode font family, and use the regular font instead.
1434 % \begin{macrocode}
1435 \M@NoBaseModeError\M@f@ntn@me
1436 \expandafter\xdef
1437 \csname\M@f@ntn@me-base\endcsname{\M@f@ntn@me}%
1438 \let\M@f@ntn@meb@se\M@f@ntn@me
1439 \fi
1440 % \end{macrocode}
1441 % Base mode is a Lua\TeX-only feature version of a font, so we link the base-mode identifier to the same font.
1442 % \begin{macrocode}
1443 \else % if XeTeX?
1444 \expandafter\xdef
1445 \csname\M@f@ntn@me-base\endcsname{\M@f@ntn@me}%
1446 \let\M@f@ntn@meb@se\M@f@ntn@me
1447 \fi
1448 % \end{macrocode}
1449 % Now save the font families for reference later.
1450 % \begin{macrocode}
1451 \expandafter\xdef
1452 \csname M@fontfamily@\@tempa\endcsname
1453 {\M@f@ntn@me}%
1454 \expandafter\xdef
1455 \csname M@fontfamily@base@\@tempa\endcsname
1456 {\M@f@ntn@meb@se}%
1457 \else % if #1 is not in nfss
1458 % \end{macrocode}
1459 % If the argument does not match a known font family, we have to load it ourselves. First, we check that we are still in the document preamble, and if not, we issue an error.
1460 % \begin{macrocode}
1461 \ifx\@onlypreamble\@notprerr % if after \begin{document}
1462 \M@FontShapesError
1463 \else % if in preamble
1464 % \end{macrocode}
1465 % If we are in the document preamble, we can still add information to the \textsc{nfss}. We store the font family name in |\M@f@ntn@me| and print messages in the |log| file. Then we declare the font family and call |\M@fill@nfss@shapes| to declare all the shapes.
1466 % \begin{macrocode}
1467 \ifcase\M@loader % are we using default font-loader?
1468 \let\M@f@ntn@me\@tempa
1469 \M@FontFamilyInfo\M@f@ntn@me
1470 \DeclareFontFamily{TU}{\M@f@ntn@me}{}%
1471 \M@fill@nfss@shapes{\M@f@ntn@me}{\M@otf@features}
1472 {\@tempfeatures}%
1473 % \end{macrocode}
1474 % If the engine is Lua\TeX, we load a separate version of the font with |mode=base| and |script=math|. We need to set the |script| because \textsf{luaotfload} processes math information only for fonts with the script set to |math|, and we definitely want that information loaded if present. Then we link the base-mode and regular versions.
1475 % \begin{macrocode}
1476 \ifdefined\directlua
1477 \edef\M@f@ntn@meb@se{\M@f@ntn@me-base}%
1478 \M@FontFamilyInfo\M@f@ntn@meb@se
1479 \DeclareFontFamily{TU}{\M@f@ntn@meb@se}{}%
1480 \M@fill@nfss@shapes{\M@f@ntn@meb@se}{\M@otf@features}
1481 {\@tempfeatures;-nomathparam;mode=base}%
1482 \else
1483 \let\M@f@ntn@meb@se\M@f@ntn@me
1484 \fi
1485 \or % are we using fontspec as font-loader?
1486 % \end{macrocode}
1487 % If the user requested \textsf{fontspec} as the font-loader, we pass the font name and features to |\fontspec_set_family:Nnn| for loading and store the \textsc{nfss} family name in |\M@f@ntn@me|. In Lua\TeX, we request a separate base-mode version by specifying |Renderer=Base| and |Script=Math|.
1488 % \begin{macrocode}
1489 \@mathfontinfo{Passing \@tempbase\space
1490 to fontspec for handling!}%
1491 \csname fontspec_set_family:Nnn\endcsname\M@f@ntn@me
1492 {\M@otf@features,\@tempfeatures}{\@tempbase}%
1493 \ifdefined\directlua
1494 \@mathfontinfo{Passing \@tempbase\space
1495 with Renderer=Base to fontspec for handling!}%
1496 \csname fontspec_set_family:Nnn\endcsname
1497 \M@f@ntn@meb@se
1498 {\M@otf@features,\@tempfeatures,%
1499 RawFeature=-nomathparam,Renderer=Base}
1500 {\@tempbase}%
1501 \else
1502 \edef\M@f@ntn@meb@se{\M@f@ntn@me}%
1503 \fi
1504 \fi
1505 % \end{macrocode}
1506 % Now link the base-mode family name and store the family names for future reference.
1507 % \begin{macrocode}
1508 \expandafter\xdef\csname\M@f@ntn@me-base\endcsname
1509 {\M@f@ntn@meb@se}%
1510 \expandafter\xdef\csname M@fontfamily@\@tempa\endcsname
1511 {\M@f@ntn@me}%
1512 \expandafter\xdef
1513 \csname M@fontfamily@base@\@tempa\endcsname
1514 {\M@f@ntn@meb@se}%
1515 \fi
1516 \fi
1517 \fi
1518 % \end{macrocode}
1519 % Finally, assign |\M@count| values to the font family(ies) if needed and save their names in |\M@families|.
1520 % \begin{macrocode}
1521 \ifcsname M@fontid@\M@f@ntn@me\endcsname % need new \M@count?
1522 \else
1523 \expandafter\xdef
1524 \csname M@fontid@\M@f@ntn@me\endcsname{\the\M@count}%
1525 \global\advance\M@count\@ne
1526 \M@addto@families{\M@f@ntn@me}%
1527 \fi
1528 % \end{macrocode}
1529 % Same thing with the base-mode version of the font.
1530 % \begin{macrocode}
1531 \ifcsname M@fontid@\M@f@ntn@meb@se\endcsname
1532 \else
1533 \expandafter\xdef
1534 \csname M@fontid@\M@f@ntn@meb@se\endcsname{\the\M@count}%
1535 \global\advance\M@count\@ne
1536 \M@addto@families{\M@f@ntn@meb@se}%
1537 \fi}
1538 % \end{macrocode}
1539 % The font-loading commands should appear only in the preamble.
1540 % \begin{macrocode}
1541 \@onlypreamble\M@declare@shape
1542 \@onlypreamble\M@fill@nfss@shapes
1543 % \end{macrocode}
1544 %
1545 %
1546 % \section{Parse Input}
1547 %
1548 % This section provides the macros to parse the optional argument of |\mathfont|. We have two parts to this section: error checking and parsing. For parsing, we extract option and suboption information, and for error checking, we make sure that both are valid. The command |\M@check@opt| accepts a macro containing (what is hopefully) the text of a keyword-option. The macro defines |\@temperror| to be an invalid option error and loops through all possible options. If the argument matches one of the correct possibilities, \textsf{mathfont} changes |\@temperror| to |\relax|. The macro ends by calling |\@temperror| and issuing an error if and only if the argument is invalid. If |\M@check@opt| finds a valid keyword-option, it changes |\if@optionpresent| to true.
1549 % \begin{macrocode}
1550 \def\M@check@opt#1{%
1551 \@optionpresentfalse % set switch to false by default
1552 \ifx#1\@empty
1553 \M@MissingOptionError
1554 \else
1555 \let\@temperror\M@InvalidOptionError % error by default
1556 \@for\@j:=\M@keys\do{%
1557 \ifx\@j#1%
1558 \let\@temperror\@gobble % eliminate error
1559 \@optionpresenttrue % set switch to true
1560 \fi}%
1561 \@temperror{#1}%
1562 \fi}
1563 % \end{macrocode}
1564 % Now we have to parse the optional argument of |\mathfont|. The macro |\M@parse@option| carries out the following tasks:
1565 % \begin{enumerate}
1566 % \item Store the keyword in |\@temp@opt| and the suboption (if present) in |\@temp@sub|. Set the boolean corresponding to the presence of a suboption.
1567 % \item Check that |\@temp@opt| is actually a keyword and set the corresponding boolean.
1568 % \item Convert |\@temp@sub| into \textsc{nfss} series and shape keywords.
1569 % \end{enumerate}
1570 % We want to allow the user to specify options using an \textsf{xkeyval}-type syntax. However, we do not need the full package; a slim few lines of code will suffice. When |\mathfont| reads one segment of \textit{text} from its optional argument, it calls |\M@parse@option|\meta{text}|=\@nil|. The |\M@parse@option| macro splits the option and suboption by looking for the first |=|.
1571 % \begin{macrocode}
1572 \def\M@strip@equals#1={#1}
1573 \def\M@parse@option#1=#2\@nil{%
1574 \def\@temp@opt{#1}% % store option
1575 \def\@temp@sub{#2}% % store suboption
1576 % \end{macrocode}
1577 % After storing the option and suboption, check for errors. If the user specified a suboption, |\@temp@sub| contains \meta{suboption}|=|, and we use |\M@strip@equals| to get rid of the extra |=|. If the user does not specify a suboption, |\@temp@sub| will be empty. After |\M@parse@sub|, the \textsc{nfss} series and shape codes for the suboption (if provided) will be stored in |\@tempseries| and |\@tempshape|.
1578 % \begin{macrocode}
1579 \M@check@opt\@temp@opt
1580 % \end{macrocode}
1581 % At this point, we have three possibilities for |\@temp@sub|:
1582 % \begin{enumerate}
1583 % \item |\@temp@sub| is |=|, which means the user wrote something like |,|\meta{keyword}|=,| and indicates a missing suboption.
1584 % \item |\@temp@sub| is empty, which indicates the user didn't provide a suboption, and we should use the default setting.
1585 % \item Otherwise, we try to extract series and shape information from |\@temp@sub|.
1586 % \end{enumerate}
1587 % We process |\@temp@sub| in that order. In case 3, we expect |\@temp@sub| to look like \meta{shape identifier}|=|, so we have to strip the final |=| before processing.
1588 % \begin{macrocode}
1589 \begingroup
1590 \def\@tempa{=}%
1591 \expandafter
1592 \endgroup
1593 \@suboptionpresentfalse % set switch to false by default
1594 \ifx\@temp@sub\@tempa % if missing suboption
1595 \M@MissingSuboptionError
1596 \else
1597 \ifx\@temp@sub\@empty % if no suboption provided
1598 \else % if suboption provided, parse it
1599 \@suboptionpresenttrue % set switch to true
1600 \edef\@temp@sub{\expandafter\M@strip@equals\@temp@sub}%
1601 \M@parse@sub\@temp@sub
1602 \fi
1603 \fi}
1604 % \end{macrocode}
1605 % Now a macro to convert a shape identifier into \textsc{nfss} series and shape codes. Here the |#1| argument is a control sequence such as |\@temp@sub|. The first thing we do is check whether |#1| ends in an asterisk and set |\M@base@| accordingly. This boolean is true if we use base mode (if no asterisk) and false otherwise (if asterisk). Note that |\M@parse@sub| should always be called when |\@suboptionpresent| is set to true. If we encounter a bad shape identifier in |#1|, we change |\@suboptionpresent| to false. (So it may be more accurate to name the conditional something like |\@suboptioncheck|, but I'm keeping the name as is to match |\@optionpresent|.)
1606 % \begin{macrocode}
1607 \def\M@parse@sub#1{%
1608 \expanded{\noexpand\in@*{#1}}%
1609 % \end{macrocode}
1610 % If |#1| contains an asterisk, we check that it is the final character in |#1| and strip it.
1611 % \begin{macrocode}
1612 \ifin@
1613 \begingroup
1614 \expandafter\M@split@star#1\@nil
1615 \ifx\@tempb\@empty
1616 \expanded{\endgroup % first branch \endgroup
1617 \def\noexpand#1{\@tempa}}%
1618 \M@mode@true
1619 % \end{macrocode}
1620 % If the asterisk is not the final character, that probably means something went wrong. (But we'll catch the problem later.)
1621 % \begin{macrocode}
1622 \else
1623 \endgroup % second branch \endgroup
1624 \M@mode@false
1625 \fi
1626 \else
1627 \M@mode@false
1628 \fi
1629 % \end{macrocode}
1630 % If the shape identifier contains a |/|, we interpret it as \textsc{nfss} identifiers and do not check further, and otherwise, we check that the argument is one of |upright|, |italic|, |bold|, or |bolditalic|. We also accept |roman| for backwards compatibility. We store \textsc{nfss} information in |\@tempseries| and |\@tempshape|.
1631 % \begin{macrocode}
1632 \expanded{\noexpand\in@/{#1}}%
1633 \ifin@
1634 \expandafter\M@split@slash#1\@nil
1635 \else
1636 % \end{macrocode}
1637 % If the user wrote out a shape identifier, we have a bit more checking to do: we have to check whether |#1| is one of |roman|, |upright|, |italic|, |bold|, or |bolditalic|. We let |\@tempa| be equal to different strings inside a group, and for each possibility, if |#1| is that string, we set |\@tempseries| and |\@tempshape| to the correct definitions. We have multiple |\endgroup|s for the same |\begingroup| because they occur on different branches of the compound conditional.
1638 % \begin{macrocode}
1639 \begingroup
1640 \def\@tempa{roman}%
1641 \ifx#1\@tempa
1642 \endgroup % first branch \endgroup
1643 % \end{macrocode}
1644 % If |\@temp@sub| is |roman|, we change it to |upright|.
1645 % \begin{macrocode}
1646 \def#1{upright}%
1647 \let\@tempseries\mddefault
1648 \let\@tempshape\shapedefault
1649 \else
1650 \def\@tempa{upright}%
1651 \ifx#1\@tempa
1652 \endgroup % second branch \endgroup
1653 \let\@tempseries\mddefault
1654 \let\@tempshape\shapedefault
1655 \else
1656 \def\@tempa{italic}%
1657 \ifx#1\@tempa
1658 \endgroup % third branch \endgroup
1659 \let\@tempseries\mddefault
1660 \let\@tempshape\itdefault
1661 \else
1662 \def\@tempa{bold}%
1663 \ifx#1\@tempa
1664 \endgroup % fourth branch \endgroup
1665 \let\@tempseries\bfdefault
1666 \let\@tempshape\shapedefault
1667 \else
1668 \def\@tempa{bolditalic}%
1669 \ifx#1\@tempa
1670 \endgroup % fifth branch \endgroup
1671 \let\@tempseries\bfdefault
1672 \let\@tempshape\itdefault
1673 \else
1674 % \end{macrocode}
1675 % Otherwise, the user specified a bad suboption.
1676 % \begin{macrocode}
1677 \endgroup % sixth branch \endgroup
1678 \@suboptionpresentfalse
1679 \M@InvalidSuboptionError{#1}%
1680 \fi
1681 \fi
1682 \fi
1683 \fi
1684 \fi
1685 % no \fi at this level of indentation
1686 \fi}
1687 % \end{macrocode}
1688 % Helper macro to parse the shape identifier if it contains a |/| character.
1689 % \begin{macrocode}
1690 \def\M@split@slash#1/#2\@nil{%
1691 \def\@tempseries{#1}%
1692 \def\@tempshape{#2}}
1693 % \end{macrocode}
1694 % Helper macros for processing asterisks in the shape identifier. The first macro here should be called inside a group since it uses |\@tempa| and |\@tempb| and therefore will mess with temporary assignments otherwise.
1695 % \begin{macrocode}
1696 \def\M@split@star#1*#2\@nil{%
1697 \def\@tempa{#1}%
1698 \def\@tempb{#2}}
1699 \def\M@strip@star#1*{#1}
1700 % \end{macrocode}
1701 % We code a general-purpose definition macro that defines its first argument to be the second argument fully expanded and with spaces removed.
1702 % \begin{macrocode}
1703 \long\def\edef@nospace#1#2{%
1704 \edef#1{\expandafter\zap@space\expanded{#2} \@empty}}
1705 % \end{macrocode}
1706 % Perhaps something that sets spaces to |\catcode9| and then retokenizes |#2| would be better, but I don't think it matters very much.
1707 %
1708 %
1709 % \section{Default Font Changes}
1710 %
1711 % This section documents default font changes. We have three main user-level commands in this section: |\mathfont|, which makes changes for math mode; |\mainfont|, which makes changes for horizontal mode; and |\documentfont|, which calls both |\mathfont| and |\mainfont|. The |\mainfont| command is straightforward: set |\rmdefault| to be the font family corresponding to the user's argument and, when necessary, call |\selectfont| to change the font family in use. (So unlike |\mathfont|, |\mainfont| can result in font loading rather than just font declaration.)
1712 %
1713 % The |\mathfont| command serves as the primary font-changing command for this package and is more complicated than |\mainfont|. This command is a wrapper around |\@mathfont|, the internal command that does the actual font changing, and when a user calls |\mathfont|, the |\@mathfont| macro carries out the following tasks:
1714 % \begin{enumerate}
1715 % \item Call |\M@newfont| on the mandatory argument of |\mathfont|, and store |\M@count| values.
1716 % \item Loop through the optional argument of |\mathfont| and determine \textsc{nfss} series and shape codes from any suboptions using macros from the previous section.
1717 % \item On each iteration, check whether \textsf{mathfont} added a symbol font to the \textsc{nfss} that uses the series and shape corresponding to the current suboption (or the default series and shape if there is no suboption). If not, call |\DeclareSymbolFont| to add the symbol font or raise a ``Can't declare new font shapes after |\begin{document}|'' error.
1718 % \item Call |\M@|\meta{keyword}|@set| to actually change the font.
1719 % \end{enumerate}
1720 % Each |\M@|\meta{keyword}|@set| macro is a wrapper around |\Umathcode| declarations and is defined in the last section of this document.
1721 %
1722 % For a given \meta{keyword}, |\M@fontinfo@|\meta{keyword} stores the human-readable name of the new default font for \meta{keyword} as well as the \textsc{nfss} series and shape identifiers. (This is the name in |\@tempbase|, not |\M@f@ntn@me|.) We use this information for writing messages to the user. Additionally, |\M@|\meta{keyword}|shape| holds the series and shape pair for \meta{keyword}. If the user specified a suboption, the contents of this macro come from the suboption via |\M@parse@sub|, and if the user did not specify a suboption, the information comes from |\|\meta{keyword}|default|.
1723 %
1724 % For a combination of \meta{font family}, \meta{series}, and \meta{shape} identifiers, \textsf{mathfont} calls the associated symbol font |M|\meta{count}|-|\meta{series}|/|\meta{shape}, where \meta{count} is the |\M@count| value associated to the \meta{font family}, i.e.\ the contents of |\M@fontid@|\meta{font family}. The \meta{series} and \meta{shape} values should be entries in the \textsc{nfss}. For example, calls to |\mathfont| will often result symbol font names like |M0-m/n|. Including a count value in the symbol font name serves two purposes. First, it enables consistent formatting of symbol font names regardless of underlying \textsc{nfss} family names. In particular, using the built-in fontloader vs.\ \textsf{fontspec} will result in different family names for the same font face with the same OpenType features, but the symbol font names will still match. Second, it simplifies the symbol font names and makes them human readable regardless of the underlying \textsc{nfss} family names, which may be complicated.
1725 %
1726 % The last two user-level commands in this section are |\mathconstantsfont| and |\mathfontshapes|. The first of these two commands only works in Lua\TeX\ and makes \TeX\ use the math parameters from a given font when formatting equations. Traditional \TeX\ expects to see extra parameters in the font(s) in |\|\meta{math style}|font2| and |\|\meta{math style}|font3|, and it uses those parameters to format equations. Lua\TeX\ can pull these extra parameters from the fonts in any math family, and |\mathconstantsfont| tells Lua\TeX\ to do so for a given font family. The command |\mathfontshapes| declares extra font shapes for the \textsc{nfss} as well as extra symbol fonts. The purpose of this command is to allow the user to declare symbol fonts in the document preamble for use after |\begin{document}|.
1727 %
1728 % We begin by coding |\mainfont|. This command is a wrapper around |\@mainfont|.
1729 % \begin{macrocode}
1730 \protected\def\mainfont{\@testopt{\@mainfont}{rm}}
1731 % \end{macrocode}
1732 % Now the internal |\@mainfont| command. This command doesn't do anything in math mode, so we include |\@nomath|. We check whether |#1| is one of |rm|, |sf|, |tt|, or empty. If not, we issue an error and change |\@tempa| to |rm|. We use |\@tempswa| to check whether we are storing the font family name in |\|\meta{type}|default| macros.
1733 % \begin{macrocode}
1734 \def\@mainfont[#1]#2{%
1735 \@nomath\mainfont
1736 \M@newfont{#2}%
1737 \edef@nospace\@tempa{#1}%
1738 \@tempswatrue
1739 \def\@tempb{rm}%
1740 \ifx\@tempa\@tempb
1741 \else
1742 \def\@tempb{sf}%
1743 \ifx\@tempa\@tempb
1744 \else
1745 \def\@tempb{tt}%
1746 \ifx\@tempa\@tempb
1747 \else
1748 \ifx\@tempa\@empty
1749 \@tempswafalse
1750 \else
1751 \M@FamilyTypeError\@tempa
1752 \def\@tempa{rm}%
1753 \fi
1754 \fi
1755 \fi
1756 \fi
1757 % \end{macrocode}
1758 % Now close the group and save the font family in |\|\meta{\upshape\ttfamily\string#1}|default| and change the default family to |#1|.
1759 % \begin{macrocode}
1760 \if@tempswa
1761 \expandafter\let\csname\@tempa default\endcsname\M@f@ntn@me
1762 \edef\familydefault{\expandafter\noexpand
1763 \csname\@tempa default\endcsname}%
1764 \fi
1765 % \end{macrocode}
1766 % If the current font is not |\nullfont| or |\M@f@ntn@me|, select |\M@f@ntn@me| as the font family.
1767 % \begin{macrocode}
1768 \expandafter\ifx\the\font\nullfont
1769 \else
1770 \ifx\f@family\M@f@ntn@me
1771 \else
1772 \fontfamily\M@f@ntn@me\selectfont
1773 \fi
1774 \fi}
1775 % \end{macrocode}
1776 % Now we come to |\mathfont|. This macro is a wrapper around |\@mathfont| that we use to check for an optional argument. The default argument is |\M@defaultkeys|.
1777 % \begin{macrocode}
1778 \protected\def\mathfont{\@testopt{\@mathfont}{\M@defaultkeys}}
1779 % \end{macrocode}
1780 % The internal font-changing command. We call |\M@newfont| on the mandatory argument of |\mathfont|, which stores the \textsc{nfss} family name(s) in |\M@f@ntn@me| and |\M@f@ntn@meb@se|. We check whether each family name corresponds to a value of |\M@newcount|, and if not, we define it. Throughout the definition of |\mathfont|, |\@tempa| stores the value of |\M@count| that corresponds to the |#1| font, and |\@tempb| stores the value of |\M@count| that corresponds to the |#1| font in base mode.
1781 % \begin{macrocode}
1782 \def\@mathfont[#1]#2{%
1783 \wlog{}%
1784 \M@newfont{#2}%
1785 % \end{macrocode}
1786 % Temporarily store values of |\M@count|.
1787 % \begin{macrocode}
1788 \edef\@tempa{\csname M@fontid@\M@f@ntn@me\endcsname}%
1789 \edef\@tempb{\csname M@fontid@\M@f@ntn@meb@se\endcsname}%
1790 % \end{macrocode}
1791 % Expand, zap spaces from, and store the optional argument in |\@tempc|, and then perform the loop. (At that point, we do not need |\@tempc| anymore.) We store the current keyword-suboption pair in |\@i| and feed it to |\M@parse@option|.
1792 % \begin{macrocode}
1793 \edef@nospace\@tempc{#1}%
1794 \@for\@i:=\@tempc\do{%
1795 \expandafter\M@parse@option\@i=\@nil
1796 \if@optionpresent
1797 % \end{macrocode}
1798 % If the user did not specify a suboption, parse the default option, and use that instead. We set |\@suboptionpresent| to true before calling |\M@parse@sub| so that we can check whether the default shape identifier is valid. If |\@suboptionpresent| is false after |\M@parse@sub|, we use |m/n| as the series/shape pair.
1799 % \begin{macrocode}
1800 \if@suboptionpresent
1801 \else
1802 \@suboptionpresenttrue
1803 \expandafter\M@parse@sub
1804 \csname\@temp@opt default\endcsname
1805 \if@suboptionpresent
1806 \else
1807 \let\@tempseries\mddefault
1808 \let\@tempshape\shapedefault
1809 \fi
1810 \fi
1811 % \end{macrocode}
1812 % Now store the series and shape in |\M@|\meta{option}|shape|.
1813 % \begin{macrocode}
1814 \expandafter\edef\csname M@\@temp@opt shape\endcsname{%
1815 \@tempseries/\@tempshape}%
1816 % \end{macrocode}
1817 % At this point we have the information we need to declare the symbol font, namely the \textsc{nfss} family (|\M@f@ntn@me| or |\M@f@ntn@meb@se|), series (|\@tempseries|), and shape (|\@tempshape|). We check if the symbol font we want to use is defined, and if not, we define it. We have two cases to consider: if |\M@base@| is true, we use the base-mode version of the font (corresponding to information in |\@tempb| and |\M@f@ntn@meb@se|), and if |\M@base@| is false, we use the default-mode version of the font (corresponding to information in |\@tempa| and |\M@f@ntn@me|). We let |\@tempc| be the count value in use for the current iteration of the loop.
1818 % \begin{macrocode}
1819 \ifM@mode@ % if default/node mode
1820 \let\@tempc\@tempa
1821 \ifcsname symM\@tempa-\@tempseries/\@tempshape\endcsname
1822 % \end{macrocode}
1823 % If the symbol font has not been declared, check that we are still in the preamble. If no, issue an error message.
1824 % \begin{macrocode}
1825 \else
1826 \ifx\@onlypreamble\@notprerr
1827 \M@FontShapesError
1828 % \end{macrocode}
1829 % Otherwise, we declare the symbol font.
1830 % \begin{macrocode}
1831 \else
1832 \M@SymbolFontInfo{\M@f@ntn@me}
1833 {\@tempseries}{\@tempshape}%
1834 \M@addto@symbolfonts
1835 {M\@tempa-\@tempseries/\@tempshape}
1836 {\@tempbase}{\@tempseries}{\@tempshape}%
1837 \DeclareSymbolFont
1838 {M\@tempa-\@tempseries/\@tempshape}{TU}
1839 {\M@f@ntn@me}{\@tempseries}{\@tempshape}%
1840 \fi
1841 \fi
1842 % \end{macrocode}
1843 % Now do the same thing for default (node) mode.
1844 % \begin{macrocode}
1845 \else % if default/node mode
1846 \let\@tempc\@tempb
1847 \ifcsname
1848 symM\@tempb-\@tempseries/\@tempshape\endcsname
1849 \else
1850 \ifx\@onlypreamble\@notprerr
1851 \M@FontShapesError
1852 % \end{macrocode}
1853 % The only difference is we use different font family and symbol font names.
1854 % \begin{macrocode}
1855 \else
1856 \M@SymbolFontInfo{\M@f@ntn@meb@se}
1857 {\@tempseries}{\@tempshape}%
1858 \M@addto@symbolfonts
1859 {M\@tempb-\@tempseries/\@tempshape}
1860 {\@tempbase(base)}{\@tempseries}
1861 {\@tempshape}%
1862 \DeclareSymbolFont
1863 {M\@tempb-\@tempseries/\@tempshape}{TU}
1864 {\M@f@ntn@meb@se}{\@tempseries}{\@tempshape}%
1865 \fi
1866 \fi
1867 \fi
1868 % \end{macrocode}
1869 % We store the new font information so we can write it to the |log| file |\AtBeginDocument| and send an informational message to the user.
1870 % \begin{macrocode}
1871 \expandafter\edef
1872 \csname M@fontinfo@\@temp@opt\endcsname{%
1873 {\@tempbase}{\@tempseries}{\@tempshape}}%
1874 \M@FontChangeInfo{\@temp@opt}{\@tempbase}%
1875 % \end{macrocode}
1876 % We have extra information to keep track of when |\@temp@opt| is |bb|, |cal|, |frak|, |bcal|, or |bfrak| because then \textsf{mathfont} effectively creates a new local font-change command. We make sure that information gets added to |\M@localfonts| (a macro that tracks the font names used for local font changes).
1877 % \begin{macrocode}
1878 \@tfor\@j:={bb}{cal}{frak}{bcal}{bfrak}\do{%
1879 \ifx\@temp@opt\@j
1880 \M@addto@localfonts{\expandafter\string
1881 \csname math\@temp@opt\endcsname}
1882 {\@tempbase}{\@tempseries}{\@tempshape}%
1883 \@break@tfor
1884 \fi}%
1885 % \end{macrocode}
1886 % And now the magic happens!
1887 % \bgroup
1888 % \advance\c@CodelineNo\@ne
1889 % \SpecialIndex{\M@upper@set}
1890 % \SpecialIndex{\M@lower@set}
1891 % \SpecialIndex{\M@diacritics@set}
1892 % \SpecialIndex{\M@greekupper@set}
1893 % \SpecialIndex{\M@greeklower@set}
1894 % \SpecialIndex{\M@agreekupper@set}
1895 % \SpecialIndex{\M@agreeklower@set}
1896 % \SpecialIndex{\M@cyrillicupper@set}
1897 % \SpecialIndex{\M@cyrilliclower@set}
1898 % \SpecialIndex{\M@hebrew@set}
1899 % \SpecialIndex{\M@digits@set}
1900 % \SpecialIndex{\M@operator@set}
1901 % \SpecialIndex{\M@delimiters@set}
1902 % \SpecialIndex{\M@radical@set}
1903 % \SpecialIndex{\M@bigops@set}
1904 % \SpecialIndex{\M@extbigops@set}
1905 % \SpecialIndex{\M@symbols@set}
1906 % \SpecialIndex{\M@extsymbols@set}
1907 % \SpecialIndex{\M@arrows@set}
1908 % \SpecialIndex{\M@bb@set}
1909 % \SpecialIndex{\M@cal@set}
1910 % \SpecialIndex{\M@frak@set}
1911 % \SpecialIndex{\M@bcal@set}
1912 % \SpecialIndex{\M@bfrak@set}
1913 % \egroup
1914 % \begin{macrocode}
1915 \csname M@\@temp@opt @set\endcsname % set default font
1916 \csname M@\@temp@opt true\endcsname % set switch to true
1917 \fi}%
1918 % \end{macrocode}
1919 % Display concluding messages for the user.
1920 % \begin{macrocode}
1921 \ifx\@tempa\@empty
1922 \wlog{The \string\mathfont\space command on line
1923 \the\inputlineno\space did not change the font
1924 for any characters!}%
1925 \else
1926 \typeout{:: mathfont :: Using font \@tempbase\space
1927 on line \the\inputlineno.}%
1928 \fi
1929 \wlog{}}
1930 % \end{macrocode}
1931 % Using |\documentfont| calls |\mainfont|, |\mathfont|, and |\mathconstantsfont|. It also calls |\mathfontcommands| if the user is still in the preamble. The optional argument gets fed directly to |\@mainfont|.
1932 % \begin{macrocode}
1933 \protected\def\documentfont{\@testopt{\@documentfont}{rm}}
1934 % \end{macrocode}
1935 % The internal command.
1936 % \begin{macrocode}
1937 \def\@documentfont[#1]#2{%
1938 \@mainfont[#1]{#2}%
1939 \mathfont{#2}%
1940 \ifdefined\directlua
1941 \mathconstantsfont{#2}%
1942 \fi
1943 \ifx\@onlypreamble\@notprerr
1944 \else
1945 \mathfontcommands{#2}%
1946 \fi}
1947 % \end{macrocode}
1948 % For backwards compatibility, we make |\setfont| expand to |\documentfont| (plus a warning message).
1949 % \begin{macrocode}
1950 \protected\def\setfont{%
1951 \PackageWarningNoLine{mathfont}
1952 {Using \string\setfont\space is deprecated; I\MessageBreak
1953 replaced it with \string\documentfont}%
1954 \documentfont}
1955 % \end{macrocode}
1956 % The macro |\mathconstantsfont| chooses a font for setting math parameters. It is intended for Lua\TeX\ when \textsf{mathfont} can adjust text fonts and add a MathConstants table. It issues a warning if called without font adjustments enabled. First, we check for an optional argument, which should be a shape identifier.
1957 % \begin{macrocode}
1958 \let\M@SetMathConstants\relax
1959 \protected\def\mathconstantsfont{%
1960 \@testopt{\@mathconstantsfont}{upright}}
1961 % \end{macrocode}
1962 % The internal command that does the processing. We begin by feeding the |#2| argument to |\M@newfont| and parsing the |#1| argument.
1963 % \begin{macrocode}
1964 \def\@mathconstantsfont[#1]#2{%
1965 \M@newfont{#2}%
1966 \edef@nospace\@tempa{#1}%
1967 \M@parse@sub\@tempa
1968 % \end{macrocode}
1969 % Store the family, series, and shape information. Because it doesn't make sense to use a font that is loaded with node mode, we force use of the base-mode version of the font regardless of the value of |\ifM@mode@|.
1970 % \begin{macrocode}
1971 \let\m@th@const@nts@f@mily\M@f@ntn@meb@se
1972 \let\m@th@const@nts@series\@tempseries
1973 \let\m@th@const@nts@sh@pe\@tempshape
1974 % \end{macrocode}
1975 % Temporarily store the value of |\M@count|.
1976 % \begin{macrocode}
1977 \edef\@tempa{\csname M@fontid@\m@th@const@nts@f@mily\endcsname}%
1978 % \end{macrocode}
1979 % Now check whether the desired symbol font has been declared. If no, we declare it or issue an error.
1980 % \begin{macrocode}
1981 \ifcsname symM\@tempa-\@tempseries/\@tempshape\endcsname
1982 \else
1983 \ifx\@onlypreamble\@notprerr
1984 \M@FontShapesError
1985 \else
1986 % \end{macrocode}
1987 % Declare the symbol font.
1988 % \begin{macrocode}
1989 \M@SymbolFontInfo{\m@th@const@nts@f@mily}
1990 {\@tempseries}{\@tempshape}%
1991 \M@addto@symbolfonts
1992 {M\@tempb-\@tempseries/\@tempshape}
1993 {\@tempbase(base)}{\@tempseries}{\@tempshape}%
1994 \DeclareSymbolFont
1995 {M\@tempa-\@tempseries/\@tempshape}{TU}
1996 {\m@th@const@nts@f@mily}{\@tempseries}{\@tempshape}%
1997 \fi
1998 \fi
1999 % \end{macrocode}
2000 % We come to the tricky problem of making sure to use the correct MathConstants table. Lua\TeX\ automatically initializes all math parameters based on the most recent |\textfont|, etc.\ assignment, so we want to tell \LaTeX\ to reassign whatever font we're using to the correct math family right after we finish assigning other math fonts. This is possible, but the implementation is super hacky. When \LaTeX\ enters math mode, it checks whether it needs to redo any math family assignments, typically because of a change in font size, and if so, it calls |\getanddefine@fonts| repeatedly to append |\textfont|, etc.\ assignments onto the macro |\math@fonts|. Usually |\math@fonts| is empty because this process always happens inside a group, so we can hook into the code by defining |\math@font| to be |\aftergroup|\meta{extra code}. In this case, the \textit{extra code} will be another call to |\getanddefine@fonts|.
2001 %
2002 % We initialize |\M@SetMathConstants| to be |\relax|, and we define it the first time the user calls |\mathconstantsfont|. When that happens, \textsf{mathfont} begins by calling |\getanddefine@fonts| inside a group and uses as arguments the upright face of the font corresponding to |#1|. That puts the |\textfont|, |\scriptfont|, and |\scriptscriptfont| assignments corresponding to |#1| inside |\math@fonts|. Then we call |\math@fonts|, and to avoid an infinite loop, we gobble the |\aftergroup||\M@SetMathConstants| macros that \textsf{mathfont} has inserted at the start of |\math@fonts|. Setting |\globaldefs| to 1 makes the |\textfont|, etc.\ assignments from |\getanddefine@fonts| global when we call |\math@fonts|.
2003 % \begin{macrocode}
2004 \ifx\M@SetMathConstants\relax
2005 \protected\def\M@SetMathConstants{%
2006 \begingroup
2007 \escapechar\m@ne
2008 \expandafter\getanddefine@fonts
2009 \csname symM%
2010 \csname M@fontid@\m@th@const@nts@f@mily\endcsname
2011 -\m@th@const@nts@series/\m@th@const@nts@sh@pe
2012 \expandafter
2013 \endcsname % expands to e.g. \symM0-m/n
2014 \csname TU/\m@th@const@nts@f@mily
2015 /\m@th@const@nts@series
2016 /\m@th@const@nts@sh@pe
2017 \endcsname % expands to \TU/<family>/<series>/<shape>
2018 \globaldefs\@ne
2019 \expandafter\@gobbletwo\math@fonts % avoid infinite loop
2020 \endgroup}%
2021 \fi
2022 \ifM@adjust@font
2023 \else
2024 \M@LuaTeXOnlyWarning\mathconstantsfont
2025 \fi}
2026 \def\math@fonts{\aftergroup\M@SetMathConstants}
2027 % \end{macrocode}
2028 % Now |\mathfontshapes|. This macro adds extra font shapes to the \textsc{nfss} and defines symbol fonts. Its purpose is to allow the user to easily declare symbol fonts in the preamble without using them right away. The user-level command is a wrapper around |\@mathfontshapes|.
2029 % \begin{macrocode}
2030 \protected\def\mathfontshapes{\@testopt{\@mathfontshapes}
2031 {upright,upright*,italic,bold}}
2032 % \end{macrocode}
2033 % For the internal command, we feed the font name to |\M@newfont| and then loop through the optional argument. For each shape identifier in the optional argument, we parse it and then use it to declare a symbol font. This macro is very similar to parts of |\@mathfont|.
2034 % \begin{macrocode}
2035 \protected\def\@mathfontshapes[#1]#2{%
2036 \wlog{}%
2037 \M@newfont{#2}%
2038 % \end{macrocode}
2039 % As in |\@mathfont|, we temporarily store values of |\M@count|.
2040 % \begin{macrocode}
2041 \edef\@tempa{\csname M@fontid@\M@f@ntn@me\endcsname}%
2042 \edef\@tempb{\csname M@fontid@\M@f@ntn@meb@se\endcsname}%
2043 % \end{macrocode}
2044 % Expand, zap spaces, and loop through the optional argument.
2045 % \begin{macrocode}
2046 \edef@nospace\@tempc{#1}%
2047 \@for\@i:=\@tempc\do{%
2048 \@suboptionpresenttrue
2049 \M@parse@sub\@i
2050 % \end{macrocode}
2051 % Then check whether the symbol font exists and if not, declare it. We start with default/node mode. We print a message in the log file, add the information to |\M@symbolfonts|, and call |\DeclareSymbolFont|.
2052 % \begin{macrocode}
2053 \if@suboptionpresent
2054 \ifM@mode@ % if default/node mode
2055 \ifcsname symM\@tempa-\@tempseries/\@tempshape\endcsname
2056 \else
2057 \M@SymbolFontInfo{\M@f@ntn@me}
2058 {\@tempseries}{\@tempshape}%
2059 \M@addto@symbolfonts
2060 {M\@tempa-\@tempseries/\@tempshape}
2061 {\@tempbase}{\@tempseries}{\@tempshape}%
2062 \DeclareSymbolFont
2063 {M\@tempa-\@tempseries/\@tempshape}{TU}
2064 {\M@f@ntn@me}{\@tempseries}{\@tempshape}%
2065 \fi
2066 % \end{macrocode}
2067 % And do the same thing for base mode.
2068 % \begin{macrocode}
2069 \else % if base mode
2070 \ifcsname symM\@tempb-\@tempseries/\@tempshape\endcsname
2071 \else
2072 \M@SymbolFontInfo{\M@f@ntn@meb@se}
2073 {\@tempseries}{\@tempshape}%
2074 \M@addto@symbolfonts
2075 {M\@tempb-\@tempseries/\@tempshape}
2076 {\@tempbase(base)}{\@tempseries}{\@tempshape}%
2077 \DeclareSymbolFont
2078 {M\@tempb-\@tempseries/\@tempshape}{TU}
2079 {\M@f@ntn@meb@se}{\@tempseries}{\@tempshape}%
2080 \fi
2081 \fi
2082 \fi}}
2083 \@onlypreamble\mathfontshapes
2084 \@onlypreamble\@mathfontshapes
2085 % \end{macrocode}
2086 %
2087 %
2088 %
2089 % \section{Local Font Changes}
2090 %
2091 % This section deals with local font changes. The main user-level macro in this section is |\newmathfontcommand|, which creates macros that change the font for math alphabet characters and is basically a wrapper around |\DeclareMathAlphabet|. Other user-level commands are a special case of this one.
2092 %
2093 % We begin with two helper macros. First is |\M@check@csarg|, which accepts two arguments and handles some error checking. The |#1| argument is a user-level command that we use in error messaging, and |#2| should be a single control sequence. The way |\M@check@csarg| scans the following tokens is a bit tricky: (1) check the length of the argument (number of tokens) by seeing if |\@gobble| eats it completely; and (2) check that the argument is a control sequence. If the user specifies an argument of the form |{..}|, i.e.\ extra text inside braces, the |\ifcat| will catch it and issue an error. If |\M@check@csarg| likes the input, it sets |\ifM@arg@good| to true, and otherwise, it sets |\ifM@arg@good| to false.
2094 % \begin{macrocode}
2095 \def\M@check@csarg#1#2{%
2096 \expandafter\ifx\expandafter\@nnil\@gobble#2\@nnil % good
2097 \ifcat\relax\noexpand#2 % good
2098 \M@arg@goodtrue
2099 \else % if #2 not a control sequence
2100 \M@MissingCSError#1{\detokenize{#2}}
2101 \M@arg@goodfalse
2102 \fi
2103 \else % if #2 is multiple tokens
2104 \M@MissingCSError#1{\detokenize{#2}}
2105 \M@arg@goodfalse
2106 \fi}
2107 % \end{macrocode}
2108 % The macro |\M@checkspecials| accepts a control sequence as its |#1| argument and a font name as its |#2| argument, and it checks whether |#1| is |\mathbb| or a related command. If yes, we assume that the user is using some variant of |\newmathrm| instead of, for example, |\mathfont[bb]|, so we do some processing analogous to what happens inside |\@mathfont|.
2109 % \begin{macrocode}
2110 \def\M@checkspecials#1#2{%
2111 \in@#1{\mathbb\mathcal\mathfrak\mathbcal\mathbfrak}
2112 \ifin@
2113 % \end{macrocode}
2114 % We set |\escapechar| to $-1$ and use |\@gobblefour| to remove the |\math| from the start of |#1|. The string of |\expandafter|s hits the |\string| inside |\@tempa|, and then the |\edef| expands the |\@gobblefour|. We are left with just the keyword inside |\@tempa|.
2115 % \begin{macrocode}
2116 \begingroup
2117 \escapechar\m@ne
2118 \expandafter
2119 \endgroup
2120 \expandafter\edef\expandafter\@tempa\expandafter{%
2121 \expandafter\@gobblefour\string#1}%
2122 % \end{macrocode}
2123 % Then write a message to the |log| file and set the corresponding boolean to true.
2124 % \begin{macrocode}
2125 \@mathfontinfo{Interpreting your new macro \string#1\space
2126 as \@tempa\space chars.}%
2127 \@mathfontinfo{Setting \expandafter\string
2128 \csname ifM@\@tempa\endcsname\space to true.}%
2129 \csname M@\@tempa true\endcsname
2130 % \end{macrocode}
2131 % And store the information to write to the |log| file |\AtBeginDocument|.
2132 % \begin{macrocode}
2133 \expandafter\edef\csname M@fontinfo@\@tempa\endcsname{%
2134 {\@tempbase}{\@tempseries}{\@tempshape}}%
2135 \expandafter\edef\csname M@\@tempa shape\endcsname
2136 {\@tempseries/\@tempshape}%
2137 \fi}
2138 % \end{macrocode}
2139 % Now declare the math alphabet. This macro first checks that its |#1| argument is a control sequence using |\M@check@csarg|. If yes, load the |#2| argument with |\M@newfont|, call |\DeclareMathAlphabet|, and check whether |#1| is |\mathbb| or a related command. Finally, add |#1| and |#2| to the list of local font-change commands.
2140 % \begin{macrocode}
2141 \protected\def\newmathfontcommand#1#2#3#4{%
2142 \M@check@csarg\newmathfontcommand{#1}%
2143 \ifM@arg@good
2144 \M@newfont{#2}
2145 \M@NewFontCommandInfo{#1}{\M@f@ntn@meb@se}{#3}{#4}
2146 \DeclareMathAlphabet{#1}{TU}{\M@f@ntn@meb@se}{#3}{#4}
2147 \M@checkspecials{#1}{\@tempbase}
2148 \M@addto@localfonts{\string#1}{\@tempbase}{#3}{#4}
2149 \fi}
2150 \@onlypreamble\newmathfontcommand
2151 % \end{macrocode}
2152 % Then define macros that create local font-changing commands with default series and shape information. Because they're all similar, we metacode them. We define the commands themselves with |\define@newmath@cmd|. The argument structure is:
2153 % \begin{itemize}
2154 % \item |#1|---|\newmath|\meta{key} macro name
2155 % \item |#2|---font series
2156 % \item |#3|---font shape
2157 % \item |##1|---the user's control sequence
2158 % \item |##2|---the user's font information (family name)
2159 % \end{itemize}
2160 % We feed |##1|, |##2|, |#2|, and |#3| to |\newmathfontcommand|, and we load |##2| with |\M@newfont|. Each |\newmath|\meta{key} macro will check its first argument using |\M@check@csarg| and then call |\newmathfontcommand| on both of its two arguments. We store the list of |\newmath|\meta{key} commands that we want to define with their series and shape information in |\M@default@newmath@cmds|, and we loop through it with |\@for|.
2161 % \begin{macrocode}
2162 \def\M@define@newmath@cmd#1#2#3{%
2163 \protected\def#1##1##2{%
2164 \M@check@csarg{#1}{##1}
2165 \newmathfontcommand{##1}{##2}{#2}{#3}}}
2166 \def\M@default@newmath@cmds{%
2167 \newmathrm{\mddefault}{\shapedefault},%
2168 \newmathit{\mddefault}{\itdefault},%
2169 \newmathbf{\bfdefault}{\shapedefault},%
2170 \newmathbfit{\bfdefault}{\itdefault},%
2171 \newmathsc{\mddefault}{\scdefault},%
2172 \newmathscit{\mddefault}{\scdefault\itdefault},%
2173 \newmathbfsc{\bfdefault}{\scdefault},%
2174 \newmathbfscit{\bfdefault}{\scdefault\itdefault}}
2175 \@for\@i:=\M@default@newmath@cmds\do{%
2176 \expandafter\M@define@newmath@cmd\@i}
2177 \@onlypreamble\newmathrm
2178 \@onlypreamble\newmathit
2179 \@onlypreamble\newmathbf
2180 \@onlypreamble\newmathbfit
2181 \@onlypreamble\newmathsc
2182 \@onlypreamble\newmathscit
2183 \@onlypreamble\newmathbfsc
2184 \@onlypreamble\newmathbfscit
2185 \@onlypreamble\M@define@newmath@cmd
2186 \let\M@default@newmath@cmds\@undefined
2187 % \end{macrocode}
2188 % The command |\mathfontcommands| sets all the default local font-change commands at once.
2189 % \begin{macrocode}
2190 \protected\def\mathfontcommands#1{%
2191 \newmathrm\mathrm{#1}
2192 \newmathit\mathit{#1}
2193 \newmathbf\mathbf{#1}
2194 \newmathbfit\mathbfit{#1}
2195 \newmathsc\mathsc{#1}
2196 \newmathscit\mathscit{#1}
2197 \newmathbfsc\mathbfsc{#1}
2198 \newmathbfscit\mathbfscit{#1}}
2199 \@onlypreamble\mathfontcommands
2200 % \end{macrocode}
2201 %
2202 %
2203 % \section{Miscellaneous}
2204 %
2205 %
2206 % We begin this section with the user-level macros that provide information for Lua-based font adjustments. We define a macro |\M@check@int| to determine if |#1| is a nonnegative integer and set the switch |\M@arg@good| accordingly. Checking happens in three stages inside a group. Immediately after the group, we will check whether |\@tempb| is |\@empty|, so to force the switch to be false, we sometimes set |\@tempb| to |\@nnil| inside the group. The first stage is a check whether |#1| is empty.
2207 % \begin{macrocode}
2208 \ifM@adjust@font
2209 \def\M@check@int#1{%
2210 \begingroup
2211 \def\@tempa{#1}%
2212 \ifx\@tempa\@empty
2213 \let\@tempb\@nnil
2214 % \end{macrocode}
2215 % If |#1| is not empty, we check whether it is a nonnegative integer. If |#1| is a nonnegative integer, the entirety of |0#1| becomes the value of |\count@|, and |\@tempb| will end up empty. Otherwise, |\@tempb| will be nonempty. The use of |\afterassignment| here is inspired by |\@defaultunits| from the kernel.
2216 % \begin{macrocode}
2217 \else
2218 \def\@tempa##1\relax\@nil{\def\@tempb{##1}}%
2219 \afterassignment\@tempa
2220 \count@=0#1\relax\@nil
2221 % \end{macrocode}
2222 % If |\@tempb| is nonempty, we handle the case where |#1| is an octal or hexadecimal integer. We use |\if| to check whether the first character of |#1| is |'| or |"|, and if yes, we replace it with |'0| or |"0| and repeat the same check with |\@tempb|. The |\relax| prevents |\if| from scanning past |#1| if |#1| expands to something empty. The |\remove@to@nnil| gobbles everything in |#1| (except the |'| or |"|, which is eaten by |\if|) when the test is successful, and it gobbles the |\@nnil| after the |\else| when the test is unsuccessful.
2223 % \begin{macrocode}
2224 \ifx\@tempb\@empty
2225 \else
2226 \expandafter\remove@to@nnil\if'#1\relax
2227 \@nnil
2228 \afterassignment\@tempa
2229 \count@'0\expandafter\@gobble
2230 \expanded{#1}\relax\@nil
2231 \else
2232 \@nnil
2233 \expandafter\remove@to@nnil\if"#1\relax
2234 \@nnil
2235 \afterassignment\@tempa
2236 \count@"0\expandafter\@gobble
2237 \expanded{#1}\relax\@nil
2238 % \end{macrocode}
2239 % If |#1| is neither octal nor hexadecimal, we check whether it starts with |\numexpr|. This case is good, so we set |\@tempb| to |\@empty|.
2240 % \begin{macrocode}
2241 \else
2242 \@nnil
2243 \expandafter\remove@to@nnil\ifx\numexpr#1\@nnil
2244 \let\@tempb\@empty
2245 % \end{macrocode}
2246 % The last possibility is if |#1| has the form |`|\meta{character}. To allow for the possibility of, for example, |`\%|, we check whether |#1| begins with |`| and contains two tokens. This is not foolproof, and sufficiently bad input, such as |`\relax|, will break this macro. (So don't do that.) Checking the catcode of the second token in |#1| doesn't seem worth the effort. If |#1| is a single |`| character, then |\@gobbletwo| will eat |#1| and |\@nnil|, so the |\ifx| will compare |\@nnil| and |\relax|.
2247 % \begin{macrocode}
2248 \else
2249 \@nnil
2250 \expandafter\remove@to@nnil\if`#1\relax
2251 \@nnil
2252 \expandafter\ifx\expandafter\@nnil
2253 \@gobbletwo#1\@nnil\relax
2254 \let\@tempb\@empty
2255 \else
2256 \let\@tempb\@nnil
2257 \fi
2258 \else
2259 \@nnil
2260 \let\@tempb\@nnil
2261 \fi
2262 \fi
2263 \fi
2264 \fi
2265 \fi
2266 \fi
2267 \expandafter
2268 \endgroup
2269 \ifx\@tempb\@empty
2270 \M@arg@goodtrue
2271 \else
2272 \M@arg@goodfalse
2273 \fi}
2274 % \end{macrocode}
2275 % Making the |\rulethicknessfactor|, etc.\ counts accessible to the user means that we don't need |\RuleThicknessFactor| and friends anymore, but we keep them for backwards compatibility and convenience. Each of these commands uses |\M@check@int| to check its argument, then calls the appropriate other commands.
2276 % \begin{macrocode}
2277 \protected\def\RuleThicknessFactor#1{%
2278 \M@check@int{#1}%
2279 \ifM@arg@good
2280 \rulethicknessfactor=#1\relax
2281 \else
2282 \M@BadIntegerError\RuleThicknessFactor{\detokenize{#1}}%
2283 \fi}
2284 \protected\def\SurdHorizontalFactor#1{%
2285 \M@check@int{#1}%
2286 \ifM@arg@good
2287 \hsurdfactor=#1\relax
2288 \else
2289 \M@BadIntegerError\SurdHorizontalFactor{\detokenize{#1}}%
2290 \fi}
2291 \protected\def\SurdVerticalFactor#1{%
2292 \M@check@int{#1}%
2293 \ifM@arg@good
2294 \vsurdfactor=#1\relax
2295 \else
2296 \M@BadIntegerError\SurdVerticalFactor{\detokenize{#1}}%
2297 \fi}
2298 % \end{macrocode}
2299 % For the integral italic factor, we input the information to |\charmline|
2300 % \begin{macrocode}
2301 \protected\def\IntegralItalicFactor#1{%
2302 \M@check@int{#1}%
2303 \ifM@arg@good
2304 \charmline{0x222B * * * * * * * * * *
2305 * * * * * * * * * *
2306 * * * * * * * * * *
2307 * * #1}%
2308 \else
2309 \M@BadIntegerError\IntegralItalicFactor{\detokenize{#1}}%
2310 \fi}
2311 % \end{macrocode}
2312 % If automatic font adjustments are disabled, we should also disable the related user-level commands. In this case, each of the font-adjustment macros expands to raise an |\M@NoFontAdjustError| and gobble its argument.
2313 % \begin{macrocode}
2314 \else
2315 \@tfor\@i:=\RuleThicknessFactor\IntegralItalicFactor
2316 \SurdHorizontalFactor\SurdVerticalFactor\charmline
2317 \charmfile\CharmLine\CharmFile\CharmInfo\CharmType
2318 \do{%
2319 \protected\expandafter\edef\@i{%
2320 \noexpand\M@NoFontAdjustError\expandafter\noexpand\@i
2321 \noexpand\@gobble}}
2322 \protected\def\charminfo{\M@NoFontAdjustError\charminfo
2323 \begingroup
2324 \afterassignment\endgroup
2325 \count@}
2326 \protected\def\charmtype{\M@NoFontAdjustError\charmtype
2327 \begingroup
2328 \afterassignment\endgroup
2329 \count@}
2330 \fi
2331 % \end{macrocode}
2332 % These commands should appear in the preamble only.
2333 % \begin{macrocode}
2334 \@onlypreamble\charmline
2335 \@onlypreamble\charmfile
2336 \@onlypreamble\CharmLine
2337 \@onlypreamble\CharmFile
2338 \@onlypreamble\RuleThicknessFactor
2339 \@onlypreamble\IntegralItalicFactor
2340 \@onlypreamble\SurdHorizontalFactor
2341 \@onlypreamble\SurdVerticalFactor
2342 % \end{macrocode}
2343 % We use the next three macros in defining |\simeq| and |\cong|. The construction is clunky and needs the intermediate macro |\st@ck@fl@trel| because |\mathchoice| is a bit of an odd macro. It feels like it should be expandable, but it isn't. Instead, it fully typesets each of its four arguments and then takes the one corresponding to the correct style. This is due to fundamental aspects of how \TeX\ processes math-mode material.
2344 % \begin{macrocode}
2345 \protected\gdef\clap#1{\hb@xt@\z@{\hss#1\hss}}
2346 \protected\def\stack@flatrel#1#2{\expandafter
2347 \st@ck@fl@trel\expandafter#1\@firstofone#2}
2348 \protected\def\st@ck@fl@trel#1#2#3{%
2349 {\setbox0\hbox{$#1#2\m@th$}% contains \mathrel symbol
2350 \setbox1\hbox{$#1#3\m@th$}% gets raised over \box0
2351 \if\wd0>\wd1\relax
2352 \hb@xt@\wd0{%
2353 \hfil
2354 \clap{\raise0.7\ht0\box1}%
2355 \clap{\box0}\hfil}%
2356 \else
2357 \hb@xt@\wd1{%
2358 \hfil
2359 \clap{\raise0.7\ht0\box1}%
2360 \clap{\box0}\hfil}%
2361 \fi}}
2362 % \end{macrocode}
2363 % Some fonts do not contain characters that \textsf{mathfont} can declare as math symbols. We want to make sure that if this happens, \TeX\ prints a message in the |log| file and terminal.
2364 % \begin{macrocode}
2365 \ifnum\tracinglostchars<\tw@
2366 \tracinglostchars\tw@
2367 \fi
2368 % \end{macrocode}
2369 % We |\typeout| a message about local font-change commands.
2370 % \begin{macrocode}
2371 \AtBeginDocument{%
2372 \ifcase\M@num@localfonts
2373 \or
2374 \def\@tempa#1#2#3\@nil{#2}
2375 \wlog{}
2376 \typeout{:: mathfont :: Using
2377 \expandafter\@tempa\M@localfonts\@nil\space
2378 for local font changes.}
2379 \else
2380 \wlog{}
2381 \typeout{:: mathfont :: Using \the\M@num@localfonts\space
2382 fonts for local font changes.}
2383 \fi}
2384 % \end{macrocode}
2385 % A helper macro for printing messages |\AtBeginDocument|. This macro adds characters from |#1| into |\@tempa| until the length of |\@tempa|, as measured by |\count@| becomes $|#2|-2$. If |\@tempa| has too many characters to fit, |\M@addtab@count@tempa| instead ends |\@tempa| with an ellipsis. Then the macro appends spaces to the end of |\@tempa| until it is |#2| characters long, again measured using |\count@|.
2386 % \begin{macrocode}
2387 \def\M@addtab@count@tempa#1#2{%
2388 \let\@tempb\@empty
2389 \@tempcntb\z@
2390 \@tfor\@i:=#1\do{%
2391 \ifnum\count@=\numexpr#2 - 5\relax
2392 \edef\@tempb{\@tempb\@i}
2393 \advance\@tempcntb\@ne
2394 \else
2395 \edef\@tempa{\@tempa\@i}
2396 \advance\count@\@ne
2397 \fi}
2398 \ifnum\@tempcntb<4\relax
2399 \edef\@tempa{\@tempa\@tempb}
2400 \advance\count@\@tempcntb
2401 \else
2402 \edef\@tempa{\@tempa...}
2403 \advance\count@\thr@@
2404 \fi
2405 \@whilenum\count@<#2\do{%
2406 \edef\@tempa{\@tempa\space}
2407 \advance\count@\@ne}}
2408 % \end{macrocode}
2409 % Write to the |log| file |\AtBeginDocument| all font changes carried out by \textsf{mathfont}. The command |\M@fontinfo@begin| accepts accepts a keyword as its |#1| argument and prints a message on the log file showing whether \textsf{mathfont} set a default font for that keyword and, if yes, the name, series, and shape for that font.
2410 % \begin{macrocode}
2411 \def\M@fontinfo@begin#1{%
2412 \expandafter\ifx % next lines are two cs to be compared
2413 \csname ifM@#1\expandafter\endcsname
2414 \csname iftrue\endcsname
2415 \expanded{\noexpand\M@fontinfo@begin@{#1}
2416 \csname M@fontinfo@#1\endcsname}
2417 \else
2418 \bgroup
2419 \let\@tempa\@empty
2420 \count@\z@
2421 \M@addtab@count@tempa{#1}{35}
2422 \M@addtab@count@tempa{No\space change}{78}
2423 \wlog{\@tempa}
2424 \egroup
2425 \fi}
2426 % \end{macrocode}
2427 % Helper macro that handles printing the message. The four arguments appear sequentially on the same line in the log file: |#1| is the keyword, |#2| is the font name, |#3| is the series, and |#4| is the shape. We allocate 18, 30, 15, and 15 characters respectively, for a total of 78 characters. The default width of the log file is 80 characters, so we should fit everything on one line that way.
2428 % \begin{macrocode}
2429 \def\M@fontinfo@begin@#1#2#3#4{%
2430 \bgroup
2431 \let\@tempa\@empty
2432 \count@\z@
2433 \M@addtab@count@tempa{#1}{18}
2434 \M@addtab@count@tempa{font:\space#2}{48}
2435 \M@addtab@count@tempa{series:\space#3}{63}
2436 \M@addtab@count@tempa{shape:\space#4}{78}
2437 % \end{macrocode}
2438 % And print the message.
2439 % \begin{macrocode}
2440 \wlog{\@tempa}
2441 \egroup}
2442 % \end{macrocode}
2443 % The macro |\M@localfonts@begin| does the same thing except for the local font-change commands.
2444 % \begin{macrocode}
2445 \let\M@localfonts@begin\M@fontinfo@begin@
2446 % \end{macrocode}
2447 % And for symbol fonts declared.
2448 % \begin{macrocode}
2449 \let\M@symbolfonts@begin\M@fontinfo@begin@
2450 % \end{macrocode}
2451 % The command for font families is different because we only have two pieces of information to display.
2452 % \begin{macrocode}
2453 \def\M@families@begin#1{%
2454 \bgroup
2455 \let\@tempa\@empty
2456 \count@\z@
2457 \expanded{%
2458 \noexpand\M@addtab@count@tempa
2459 {\csname M@fontid@#1\endcsname}{5}
2460 \noexpand\M@addtab@count@tempa{#1}{78}}
2461 \wlog{\@tempa}
2462 \egroup}
2463 % \end{macrocode}
2464 % Now print the messages. We start with the font families that \textsf{mathfont} uses. We don't need to store a list of font families in |\M@families| because we can simply increment the |fontid| count until we reach a value that is large enough to not have a corresponding font.
2465 % \begin{macrocode}
2466 \AtBeginDocument{%
2467 \wlog{^^J------------------ Changes made by mathfont
2468 in the preamble ------------------}
2469 \wlog{}
2470 \wlog{**********************^^J%
2471 * Font families used *^^J%
2472 **********************}
2473 \ifx\M@families\@empty
2474 \wlog{No font families declared by mathfont.}
2475 \else
2476 \@for\@i:=\M@families\do{%
2477 \expandafter\M@families@begin\expandafter{\@i}}
2478 \fi
2479 \wlog{}
2480 % \end{macrocode}
2481 % Same thing for symbol fonts.
2482 % \begin{macrocode}
2483 \wlog{*************************^^J%
2484 * Symbol fonts declared *^^J%
2485 *************************}
2486 \ifx\M@symbolfonts\@empty
2487 \wlog{No symbol fonts declared by mathfont.}
2488 \else
2489 \@for\@i:=\M@symbolfonts\do{%
2490 \expandafter\M@symbolfonts@begin\@i}
2491 \fi
2492 \wlog{}
2493 % \end{macrocode}
2494 % Character keywords.
2495 % \begin{macrocode}
2496 \wlog{************^^J%
2497 * Keywords *^^J%
2498 ************}
2499 \@for\@i:=\M@keys\do{%
2500 \expandafter\M@fontinfo@begin\expandafter{\@i}}
2501 \wlog{}
2502 % \end{macrocode}
2503 % And information in the |log| file about local font-change commands.
2504 % \begin{macrocode}
2505 \wlog{******************************^^J%
2506 * Local font-change commands *^^J%
2507 ******************************}
2508 \ifnum\M@num@localfonts=\z@
2509 \wlog{No local font change commands declared.}
2510 \else
2511 \@for\@j:=\M@localfonts\do{%
2512 \expandafter\M@localfonts@begin\@j}
2513 \fi
2514 \wlog{}
2515 \wlog{------------------------------- End of changes
2516 -------------------------------}
2517 \wlog{}}
2518 % \end{macrocode}
2519 % Warn the user about possible problems with a multi-word optional package argument in \XeTeX.
2520 % \begin{macrocode}
2521 \ifdefined\XeTeXrevision
2522 \ifM@font@loaded
2523 \AtEndOfPackage{%
2524 \PackageWarningNoLine{mathfont}
2525 {It looks like you specified a font\MessageBreak
2526 when you loaded mathfont. If you run\MessageBreak
2527 into problems with a font whose name\MessageBreak
2528 is multiple words, try using LuaLaTeX\MessageBreak
2529 or call \string\documentfont\space or
2530 \string\mathfont\MessageBreak
2531 manually}}
2532 \fi
2533 \fi
2534 % \end{macrocode}
2535 % If the user passed a font name to \textsf{mathfont}, we set it as the default |\AtEndOfPackage|.
2536 % \begin{macrocode}
2537 \ifM@font@loaded
2538 \AtEndOfPackage{\documentfont\M@font@load}
2539 \fi
2540 % \end{macrocode}
2541 %
2542 %
2543 % \section{Adjust Fonts: Setup}
2544 %
2545 % \suppressfloats[t]
2546 %
2547 % The next three sections implement Lua-based font adjustments and apply only if the user has enabled font adjustment. Most of the implementation happens through Lua code, but we need some \TeX\ code in case the user wants to adjust character metric information. Here is a rough outline of what happens in the next three sections:
2548 % \begin{enumerate}\itemsep\smallskipamount
2549 % \item Initialize a Lua table that contains new metrics for certain characters specific to math mode, such as letters with wider bounding boxes and large operator symbols.
2550 % \item Provide an interface for the user to change this metric information.
2551 % \item Write functions that accept a fontdata object and (a) change top-level math specs to indicate that we have a math function; (b) alter characters according to our Lua table of new metric information; and (c) populate a MathConstants table for the font.
2552 % \item Create callbacks that call these functions. Put a wrapper around them, and insert the wrapper-function into |luaotfload.patch_font|.
2553 % \end{enumerate}
2554 % Step 2 happens on the \TeX\ side of things and is documented next, and everything else happens inside |\directlua|. On the Lua side of things, we store all the functions and character metric information in the table |mathfont|. With the exception of a handful of integers used to track encoding slots, every entry in |mathfont| is either a function or a subtable indexed by an \meta{integer}. The \textit{integer} is a Unicode encoding number and indicates which Unicode character the subtable corresponds to. See tables~2 and 3 for a list of the functions in |mathfont| and the fields in character subtables. See section~10 for discussion of the callbacks for editing fontdata objects.
2555 %
2556 %
2557 % \begin{figure}[tb]
2558 % \centerline{\bfseries Table 2: Fields of Character Subtables in |mathfont|\strut}
2559 % \begin{tabularx}\textwidth{llllX<{\raggedright\arraybackslash}}\toprule
2560 % Field & Type & In |a| & In |e| & Used For\\\midrule
2561 % |type| & string & Yes & Yes & Type is |a| or |e|\\
2562 % |data_rm| & table & Yes & Yes & Information for upright font shapes\\
2563 % |data_it| & table & Yes & Yes & Information for italic font shapes\\
2564 % |num_variants| & integer & No & Yes & Number of large variants\\
2565 % |smash| & integer & No & Yes & Encoding slot for smashed character\\
2566 % |next| & table & No & Yes & Encoding slots for large variants\\
2567 % \bottomrule
2568 % \end{tabularx}
2569 % \end{figure}
2570 %
2571 %
2572 % \begin{figure}[t]
2573 % \centerline{\bfseries Table 3: Functions in |mathfont|\strut}
2574 % \begin{tabularx}\textwidth{lp{1.35in}X<{\raggedright\arraybackslash}}\toprule
2575 % Function & Argument(s) & Used For\\\midrule
2576 % |strint| & number & Format number as a string\\\midrule
2577 % |new_type_a| & |index|, data & Add type |a| entry to |mathfont|\\
2578 % |new_type_e| & |index|, data & Add type |e| entry to |mathfont|\\\midrule
2579 % |add_to_charm| & string of charm info & Add charm info to |mathfont|\\
2580 % |parse_charm| & string of charm info & Split string, validate inputs\\
2581 % |parse_num| & numeric string & Parse numeric value\\\midrule
2582 % |empty| & none & Does nothing\\
2583 % |glyph_info| & character subtable & Get height, width, depth, italic\\
2584 % |make_a_commands| & |index|, offset & Return virtual font commands\\
2585 % |make_a_table| & |index|, charm data, fontdata & Make new subtable for type |a| character\\
2586 % |make_e_commands| & |index|, scale factors & Return virtual font commands\\
2587 % |make_e_table| & |index|, charm data, fontdata & Make new subtable for type |e| character\\
2588 % |smash_glyph| & |index|, fontdata & Make table for smashed char\\
2589 % |utf_16BE| & integer & Return UTF-16BE format\\\midrule
2590 % |adjust_font| & fontdata & Call callbacks\\
2591 % |apply_charm_info| & fontdata & Change character metrics in font\\
2592 % |math_constants| & fontdata & Create MathConstants table\\
2593 % |set_nomath_false| & fontdata & Set |nomath| (top-level flag in the font) to |false|\\\midrule
2594 % |get_font_name| & fontdata & Return font name\\
2595 % |info| & string & Write message in the |log| file\\
2596 % \bottomrule
2597 % \end{tabularx}
2598 % \end{figure}
2599 %
2600 % Changing the top-level |nomath| flag in a font object is easy. Creating a MathConstants table is complicated but largely self-contained. We take a few parameters that the user has set, define traditional \TeX\ math parameters based on the essential parameters of the font, and assign their values to the corresponding entries in a MathConstants table. However, editing character metrics during font loading is convoluted with many moving parts. For every glyph that we want modify, we store character metric information for that glyph as a subtable in |mathfont|. The entries of the subtable describe how to scale the bounding box, scale the glyph itself, or determine math accent placement. For characters of type |a| (``alphabet''), we specify information to stretch the bounding box (not the glyph) horizontally, so we equivalently add extra space around the character. For type |e| (``extensible''), we stretch the bounding box and glyph, so we create an ensemble of scaled versions, which we use as a family of large variants.
2601 %
2602 % Here's how to think about the dynamics of our approach. We use character metric information at three different times: pre-processing, interim processing, and post-processing. In pre-processing, which we implement in this section, we assemble initial character metric information into entries in |mathfont|. In other words, pre-processing means creating the initial |mathfont| subtables and happens during package loading. Interim processing means the user altering entries in |mathfont| and happens through |\charmline| and |\charmfile|. This can occur at any point in the pramble. In post-processing, which we implement in the next section, \textsf{mathfont} extracts information from the current state of the |mathfont| table and uses it to alter a fontdata object. Post-processing happens through the |luaotfload.patch_font| callback and occurs once at the point when \TeX\ loads the font file. As a rule, \LaTeX\ does not like to load fonts before it uses them, so post-processing typically happens |\AtBeginDocument| in the case of the main text font or whenever the user calls a |\text|\meta{font keyword} command or enters math mode. This is also why you cannot adjust fonts that \TeX\ loaded before \textsf{mathfont}.
2603 %
2604 %
2605 % We set |mathnolimitsmode| to 4 to make integral signs look nice. Or at least nicer than they would otherwise.
2606 % \begin{macrocode}
2607 \ifM@adjust@font
2608 \mathnolimitsmode=4\relax
2609 % \end{macrocode}
2610 % We need some error messages. We change the catcode of \expandafter|\textbackslash| to 12 in order to use it freely as a Lua escape character. We change |~| to catcode 0 to define the macros.
2611 % \begin{macrocode}
2612 \bgroup
2613 \catcode`\~=0
2614 ~catcode`~\=12
2615 ~@firstofone{%
2616 ~egroup
2617 ~let~@tempa~%
2618 ~let~%~@percentchar
2619 ~def~M@empty@ssert{"\n\n%
2620 Package mathfont error: Empty charm information.\n\n%
2621 Your argument for \\charmline is empty, or a\n%
2622 line in your \\charmfile is blank. Make sure\n%
2623 your calls to \\charmline and all lines in\n%
2624 your \\charmfile contain integers, floats,\n%
2625 and asterisks separated by commas or spaces.\n"}
2626 ~def~M@missing@ssert{"\n\n%
2627 Package mathfont error: Missing charm entries.\n\n%
2628 I'm having trouble with a character metric.\n%
2629 Your \\charmline or \\charmfile contains\n%
2630 \"".. temp_string .. ",\"\n%
2631 which looks to me like you provided an index\n%
2632 without any commas or spaces to specify the\n%
2633 numbers for charm values. Make sure that you\n%
2634 use commas or spaces to separate each entry\n%
2635 in your charm information.\n"}
2636 ~def~M@number@ssert{"\n\n%
2637 Package mathfont error: Nonnumeric charm value.\n\n%
2638 I'm having trouble with a character metric.\n%
2639 Your \\charmline or \\charmfile contains \""
2640 .. s .. ",\"\n%
2641 which is not a number. Make sure that your\n%
2642 charm information is all integers, floats,\n%
2643 and asterisks separated by commas or spaces.\n"}
2644 ~def~M@index@ssert{"\n\n%
2645 Package mathfont error: Invalid Unicode index.\n\n%
2646 The Unicode index \""
2647 .. temp_string .. "\" is invalid. Make sure\n%
2648 that the first entry in your \\charmline and in each\n%
2649 line of your \\charmfile is an integer between 0 and\n%
2650 1,114,111 (0x10FFFF), possibly with an exclamation\n%
2651 point or question mark.\n"}
2652 ~def~M@bound@ssert{"\n\n%
2653 Package mathfont error: Exceeded Unicode table.\n\n%
2654 You asked me to do something with an encoding slot\n%
2655 number that exceeds the number of slots in the\n%
2656 Unicode table. You are probably seeing this error\n%
2657 because you declared too many type e characters.\n"}
2658 % \end{macrocode}
2659 % We previously defined |\%| to contain a single |%| with catcode 12, so when we put |\%| in an |\edef|, it becomes easy to get |%|'s inside the definition of our next two macros. This is important because it lets us use |string.format| to create informative error and warning messages using straightforward syntax. To insert the Unicode character in the messages, we use |utf8.char| function, which is the Lua code for producing arbitrary Unicode characters.
2660 % \begin{macrocode}
2661 ~edef~M@entries@ssert{string.format("\n\n%
2662 Package mathfont error: Charm values too short.\n\n%
2663 Your charm information for U+~%X ~%s (index ~%d)\n%
2664 needs more entries. Right now you have ~%d\n%
2665 entries (besides the index), but you need at\n%
2666 least ~%d. If you aren't sure what to do, try\n%
2667 adding asterisks to your \\charmline or line in\n%
2668 your \\charmfile. See the user guide for more\n%
2669 information.\n",
2670 index, utf8.char(index), index,
2671 number_of_entries, entries_needed)}
2672 ~edef~M@entries@warning{string.format("\n\n%
2673 Package mathfont warning: Charm values too long.\n\n%
2674 Your charm information for U+~%X ~%s (index ~%d)\n%
2675 has more entries than it needs. Right now you\n%
2676 have ~%d entries (besides the index), but you\n%
2677 only need ~%d. This isn't a problem per se\n%
2678 because I can easily ignore the extra numbers,\n%
2679 but it may indicate confusion about Unicode\n%
2680 characters and charm values. See the user\n%
2681 guide for more information.\n\n",
2682 index, utf8.char(index), index,
2683 number_of_entries, entries_needed)}
2684 % \end{macrocode}
2685 % Error message if the user tries to adjust the left side of the bounding box on a virtual character.
2686 % \begin{macrocode}
2687 ~edef~M@virtual@ssert{string.format("\n\n%
2688 Package mathfont error: Can't adjust left side\n%
2689 of the bounding box on a virtual character.\n\n%
2690 Your charm information for U+~%X ~%s (index ~%d)\n%
2691 instructs me to change the left side of the bounding\n%
2692 box around this character. However, in the font\n%
2693 ~%s,\n%
2694 that character is a virtual character, and I'm not\n%
2695 programmed to change the left side of the bounding\n%
2696 box on a virtual character. To resolve this error,\n%
2697 try including\n%
2698 \\charmline{~%d 0 * * *}\n%
2699 at the end of your document preamble.\n\n",
2700 index, utf8.char(index), index,
2701 mathfont.get_font_name(fontdata), index)}}
2702 \let\%\@tempa
2703 % \end{macrocode}
2704 % The user inputs charm information at the \TeX\ level. We define the macros |\charmline| that interfaces with |mathfont:add_to_charm| directly and |\charmfile| that reads lines from a file and individually feeds them to |\charmline|. The macros |\charminfo| and |\charmtype| print information from |mathfont| about the charm information currently in memory for certain characters.
2705 % \begin{macrocode}
2706 \newluafunction\addtocharm@
2707 \newluafunction\charminfo@
2708 \newluafunction\charmtype@
2709 \directlua{%
2710 local t = lua.get_functions_table()
2711 t[\number\addtocharm@] = function()
2712 mathfont:add_to_charm(token.scan_string())
2713 end
2714 % \end{macrocode}
2715 % We also define the Lua function |\charminfo@| for use in |\charminfo|. This function scans the following integer and prints the charm information for the Unicode character whose index is that integer.
2716 % \begin{macrocode}
2717 t[\number\charminfo@] = function()
2718 local temp = token.scan_int()
2719 temp = mathfont[temp]
2720 % \end{macrocode}
2721 % If |mathfont| contains an entry for index |temp|, gather the charm information from that entry. We will print to \TeX\ a string in the same format as the argument of |\charmline|. We loop through |data_rm|, and on each iteration, we add that entry to a temporary string and then add italic charm information if it is different.
2722 % \begin{macrocode}
2723 if temp then
2724 local temp_str = ""
2725 local temp_rm = {}
2726 local temp_it = {}
2727 % \end{macrocode}
2728 % We have to possibilities depending on the type of the input. For type |a| characters, all entries in |data_rm| and |data_it| are integers, and we can loop the list without issue. For type |e| characters, |data_rm| and |data_it| contain 15 two-entry subtables and three integers, so we have to flatten the list before we use it.
2729 % \begin{macrocode}
2730 for k,v in pairs(temp.data_rm) do
2731 if type(v) == "number" then
2732 temp_rm[k] = v * 1000
2733 temp_it[k] = temp.data_it[k] * 1000
2734 elseif type(v) == "table" then
2735 temp_rm[2*k-1] = v[1] * 1000
2736 temp_rm[2*k] = v[2] * 1000
2737 temp_it[2*k-1] = temp.data_it[k][1] * 1000
2738 temp_it[2*k] = temp.data_it[k][2] * 1000
2739 end
2740 end
2741 % \end{macrocode}
2742 % Now we loop through |temp_rm| and add the contents to |temp_str|.
2743 % \begin{macrocode}
2744 for k,v in pairs(temp_rm) do
2745 if temp_str \noexpand~= "" then
2746 temp_str = temp_str .. " "
2747 end
2748 temp_str = temp_str .. mathfont.strint(v)
2749 % \end{macrocode}
2750 % Now check the corresponding charm entry for italic fonts and add that if different from |v|.
2751 % \begin{macrocode}
2752 if temp_it[k] \noexpand~= v then
2753 temp_str = temp_str .. "/" ..
2754 mathfont.strint(temp_it[k])
2755 end
2756 end
2757 % \end{macrocode}
2758 % Now print the result.
2759 % \begin{macrocode}
2760 tex.print(temp_str)
2761 else
2762 tex.print("none")
2763 end
2764 end
2765 % \end{macrocode}
2766 % Same thing for |\charmtype@|.
2767 % \begin{macrocode}
2768 t[\number\charmtype@] = function()
2769 local temp = token.scan_int()
2770 temp = mathfont[temp]
2771 if temp then
2772 tex.print(temp.type)
2773 else
2774 tex.print("none")
2775 end
2776 end}
2777 \protected\def\charmline{\luafunction\addtocharm@}
2778 % \end{macrocode}
2779 % The argument of |\charmfile| should be a valid filename, and we open it in |\M@Charm|. The macro processes each line of the file as a piece of charm information.
2780 % \begin{macrocode}
2781 \protected\def\charmfile#1{%
2782 \IfFileExists{#1}{%
2783 \begingroup
2784 \endlinechar\m@ne
2785 \immediate\openin\M@Charm{#1}
2786 % \end{macrocode}
2787 % The macro |\next| reads a line into |#1|, feeds it to |\charmline|, and calls itself if the file has more lines. \TeX\ adds an extra line to the end of files it reads (why??), so we check whether the current line is empty before feeding it to |\charmline|. (The last line of the file is empty because we set |\endlinechar| to $-1$. Otherwise, the file would have a spurious |\par| at the end.)
2788 % \begin{macrocode}
2789 \def\next{%
2790 \read\M@Charm to \@tempa
2791 \ifx\@tempa\@empty
2792 \else
2793 \charmline\@tempa
2794 \fi
2795 \ifeof\M@Charm\else % if file has more lines?
2796 \expandafter\next
2797 \fi}
2798 % \end{macrocode}
2799 % Call |\next|, close the file, and end the group.
2800 % \begin{macrocode}
2801 \next
2802 \immediate\closein\M@Charm
2803 \endgroup}
2804 % \end{macrocode}
2805 % If the file does not exist, raise an error.
2806 % \begin{macrocode}
2807 {\M@NoCharmFileError{\detokenize{#1}}}}
2808 % \end{macrocode}
2809 % Alternative names.
2810 % \begin{macrocode}
2811 \let\CharmLine\charmline
2812 \let\CharmFile\charmfile
2813 % \end{macrocode}
2814 % Now the macros |\charminfo| and |\charmtype|. The structure is a bit different because we want them to be fully expandable. The macros don't have an argument. Instead, they call the appropriate |\luafunction|, which scans the next integer and processes it.
2815 % \begin{macrocode}
2816 \def\charminfo{\luafunction\charminfo@}
2817 \def\charmtype{\luafunction\charmtype@}
2818 % \end{macrocode}
2819 % The wrapped versions are more user-friendly. For |\CharmInfo|, we first check whether |mathfont| contains an entry with index |#1|.
2820 % \begin{macrocode}
2821 \protected\def\CharmInfo#1{%
2822 \M@check@int{#1}%
2823 \ifM@arg@good
2824 \begingroup % \begingroup
2825 \edef\@tempa{\charminfo#1}%
2826 \def\@tempb{none}%
2827 \edef\@tempc{\number#1}%
2828 % \end{macrocode}
2829 % Now the actual check. If there is no entry, we print a message saying so.
2830 % \begin{macrocode}
2831 \ifx\@tempa\@tempb
2832 \expandafter\endgroup % first branch \endgroup
2833 \expanded{\showtokens{no charm info assigned to
2834 index \@tempc}}%
2835 % \end{macrocode}
2836 % If yes, we print the charm information to the terminal.
2837 % \begin{macrocode}
2838 \else
2839 \expandafter\endgroup % second branch \endgroup
2840 \expanded{\showtokens{index \@tempc\space
2841 has charm info: \@tempa}}%
2842 \fi
2843 \else
2844 \M@BadIntegerError\CharmInfo{\detokenize{#1}}%
2845 \fi}
2846 % \end{macrocode}
2847 % Now for |\CharmType|.
2848 % \begin{macrocode}
2849 \protected\def\CharmType#1{%
2850 \M@check@int{#1}%
2851 \ifM@arg@good
2852 \begingroup
2853 \edef\@tempa{\number#1}%
2854 \expandafter\endgroup
2855 \expanded{\showtokens{index \@tempa\space has type
2856 \charmtype\numexpr\@tempa\relax}}%
2857 \else
2858 \M@BadIntegerError\CharmType{\detokenize{#1}}%
2859 \fi}
2860 % \end{macrocode}
2861 % This concludes the \TeX-based portion of font adjustments. The rest of this section and the next two sections are the Lua code that adapts a text font for math mode. First, we create the |mathfont| table. We use |mathfont.encoding_slot| in |new_type_e| to keep track of the encoding slots where we will artificially add large versions of type |e| characters during loading.
2862 % \begin{macrocode}
2863 \directlua{
2864 mathfont = {}
2865 mathfont.extra_chars = 0xFA000
2866 mathfont.encoding_slot = 0xFA010
2867 mathfont.fakel = mathfont.extra_chars + 4
2868 mathfont.faker = mathfont.extra_chars + 5
2869 mathfont.fakell = mathfont.extra_chars + 6
2870 mathfont.fakerr = mathfont.extra_chars + 7
2871 % \end{macrocode}
2872 % Helper function for use in |\charminfo@|.
2873 % \begin{macrocode}
2874 function mathfont.strint(i)
2875 if i == (i // 1) then
2876 return string.format("\@percentchar d", i)
2877 else
2878 return tostring(i)
2879 end
2880 end
2881 % \end{macrocode}
2882 % Each character whose metrics we want to change will have one of two types: |a| for alphabet or |e| for extensible. We begin with type |a|. The |index| is the base-10 Unicode encoding value of the character that we will later modify. The |data| arguments are tables with 4 entries that store sizing information and information regarding accent placement. We divide the information by 1000 as is standard in \TeX.
2883 % \begin{macrocode}
2884 function mathfont:new_type_a(index, data_rm, data_it)
2885 self[index] = {}
2886 self[index].type = "a"
2887 self[index].data_rm = {}
2888 self[index].data_it = {}
2889 for i = 1, 4, 1 do
2890 self[index].data_rm[i] = data_rm[i] / 1000
2891 self[index].data_it[i] = data_it[i] / 1000
2892 end
2893 end
2894 % \end{macrocode}
2895 % Initializing type |e| characters is more complicated. The |index| and |data| arguments are the same as in the type |a| case, and we process them similarly. The entries in |mathfont| for type |e| characters contain additional information. The |smash| value is a Unicode slot where we store a smashed version of the glyph with no height, depth, or width, which we need to scale the glyph correctly. The |num_variants| attribute is the number of slots in |next|, which we shorten to |v| for notational convenience.
2896 % \begin{macrocode}
2897 function mathfont:new_type_e(index, data_rm, data_it)
2898 self[index] = {}
2899 self[index].type = "e"
2900 self[index].smash = self.encoding_slot
2901 local v = (\string# data_rm - 3) / 2
2902 self[index].num_variants = v
2903 % \end{macrocode}
2904 % Check that the user hasn't exhausted the Unicode table. (Unlikely, but you never know.)
2905 % \begin{macrocode}
2906 if self.encoding_slot + v + 1 > 0x10FFFF then
2907 error(\M@bound@ssert)
2908 end
2909 % \end{macrocode}
2910 % Now make lists that store encoding slots and scale factors. We have the following lists:
2911 % \begin{itemize}[nosep]
2912 % \item |next|: list of encoding slots
2913 % \item |data_rm|: scale factors for upright font shapes
2914 % \item |data_it|: scale factors for italic font shapes
2915 % \end{itemize}
2916 % Start with making blank lists in the subtable in |mathfont|.
2917 % \begin{macrocode}
2918 self[index].next = {}
2919 self[index].data_rm = {}
2920 self[index].data_it = {}
2921 % \end{macrocode}
2922 % We assemble these lists in a single loop, and they all have |v| elements. For |next|, we append consecutive integers to the list. For the scale factors, we expect |data_rm| and |data_it| to have $2|v|+3$ entries, which we consider in pairs. The $i$th pair (i.e.\ entries $2i-1$ and $2i$ of |data_rm| or |data_it|) encodes the horizontal and vertical scale factors for the $i$th large variant, and we add those scale factors as two-element sublists to the new lists on the $i$th iteration.
2923 % \begin{macrocode}
2924 for i = 1, v, 1 do
2925 self[index].next[i] = self.encoding_slot + i
2926 self[index].data_rm[i] = {data_rm[2*i-1] / 1000,
2927 data_rm[2*i] / 1000}
2928 self[index].data_it[i] = {data_it[2*i-1] / 1000,
2929 data_it[2*i] / 1000}
2930 end
2931 % \end{macrocode}
2932 % The final entries of |data_rm| and |data_it| contain information about accent placement and italic correction. We add those values to the subtable as well.
2933 % \begin{macrocode}
2934 for i = 1, 3, 1 do
2935 self[index].data_rm[2*v+i] = data_rm[2*v+i] / 1000
2936 self[index].data_it[2*v+i] = data_it[2*v+i] / 1000
2937 end
2938 % \end{macrocode}
2939 % Finally, update the |encoding_slot|.
2940 % \begin{macrocode}
2941 self.encoding_slot = self.encoding_slot + v + 1
2942 end
2943 % \end{macrocode}
2944 % Interim processing. We let the user edit resizing and accent information for the characters in |mathfont|. The main editing function is |mathfont:add_to_charm|, which incorporates the user's information into the tables already in |mathfont|. It expects a single string of integers, floats, or asterisks separated by spaces or commas, and it immediately passes the argument to |parse_charm|, which processes it into tables that we incorporate into subtables of |mathfont|. We begin with a helper function to parse a (numeric) string. If this function returns a number, the number is properly scaled (divided by 1000).
2945 % \begin{macrocode}
2946 function mathfont.parse_num(s)
2947 if s == "*" then
2948 return s
2949 else
2950 local temp = tonumber(s)
2951 if temp then
2952 return temp / 1000
2953 else
2954 error(\M@number@ssert)
2955 end
2956 end
2957 end
2958 % \end{macrocode}
2959 % Now |parse_charm|. We begin by setting up tables to store the parsed string contents. We store the Unicode index value in |index|.
2960 % \begin{macrocode}
2961 function mathfont.parse_charm(charm_input)
2962 local index = 0
2963 local charm_string = charm_input
2964 local temp_string = ""
2965 % \end{macrocode}
2966 % Some preprocessing before we parse the string. Specifically, we
2967 % \begin{enumerate}
2968 % \item Get rid of any duplicate spaces
2969 % \item Remove any leading or trailing space, if present
2970 % \item Remove any spaces around slashes or commas
2971 % \item Replace any remaining spaces with commas
2972 % \end{enumerate}
2973 % After completion of the replacements, we should have a new string with same numeric/override information as the original |charm_input| except without any spaces and all (pairs of) entries separated by commas. Step 1: duplicate spaces.
2974 % \begin{macrocode}
2975 while string.find(charm_string, "\space\space") do
2976 charm_string = string.gsub(charm_string, "\space\space", " ")
2977 end
2978 % \end{macrocode}
2979 % Step 2: leading/trailing spaces.
2980 % \begin{macrocode}
2981 if string.sub(charm_string, 1, 1) == " " then
2982 charm_string = string.sub(charm_string, 2)
2983 end
2984 if string.sub(charm_string, -1) == " " then
2985 charm_string = string.sub(charm_string, 1, -2)
2986 end
2987 % \end{macrocode}
2988 % Step 3: space around punctuation. We don't replace \verb*.! . or \verb*.? . because the space in those cases could be separating two charm entries.
2989 % \begin{macrocode}
2990 charm_string = string.gsub(charm_string, ", ", ",")
2991 charm_string = string.gsub(charm_string, " ,", ",")
2992 charm_string = string.gsub(charm_string, "/ ", "/")
2993 charm_string = string.gsub(charm_string, " /", "/")
2994 % \end{macrocode}
2995 % Step 4: add commas.
2996 % \begin{macrocode}
2997 charm_string = string.gsub(charm_string, " ", ",")
2998 % \end{macrocode}
2999 % Check that |charm_string| is not empty.
3000 % \begin{macrocode}
3001 if charm_string == "" then
3002 error(\M@empty@ssert)
3003 end
3004 % \end{macrocode}
3005 % Check that |charm_string| contains at least one comma. If it does not, we raise an error.
3006 % \begin{macrocode}
3007 if not string.find(charm_string, ",") then
3008 temp_string = charm_input
3009 error(\M@missing@ssert)
3010 end
3011 % \end{macrocode}
3012 % We're ready to parse the entries. We remove the first entry manually since it is the index and has different formatting possibilities from the other entries.
3013 % \begin{macrocode}
3014 local sep = string.find(charm_string, ",")
3015 temp_string = string.sub(charm_string, 1, sep-1)
3016 % \end{macrocode}
3017 % Now check that the index is a (valid) number. Handle the case of possible asterisk at the end of |temp_string|.
3018 % \begin{macrocode}
3019 local exc
3020 if string.sub(temp_string, -1, -1) == "!" then
3021 index = tonumber(string.sub(temp_string, 1, -2))
3022 exc = 1
3023 elseif string.sub(temp_string, -1, -1) == "?" then
3024 index = tonumber(string.sub(temp_string, 1, -2))
3025 exc = 2
3026 else
3027 index = tonumber(temp_string)
3028 exc = 0
3029 end
3030 if index then
3031 assert(index == index // 1 and
3032 index >= 0 and
3033 index <= 1114111, \M@index@ssert)
3034 else
3035 error(\M@index@ssert)
3036 end
3037 charm_string = string.sub(charm_string, sep+1)
3038 % \end{macrocode}
3039 % Create the lists that we will use to store the information from |charm_string|.
3040 % \begin{macrocode}
3041 local split_string_rm = {}
3042 local split_string_it = {}
3043 % \end{macrocode}
3044 % We loop through |charm_string| as long as it contains characters. At each iteration, we store the location of the first comma in |sep|. We remove the portion of |charm_string| preceding the first comma and store it in |temp_string|, and we save the remaining portion of |charm_string| for processing on the next iteration of the loop. We use |i| as a dummy variable to track loop iterations.
3045 % \begin{macrocode}
3046 local i = 1
3047 while charm_string do
3048 sep = string.find(charm_string, ",")
3049 if sep then
3050 temp_string = string.sub(charm_string, 1, sep-1)
3051 charm_string = string.sub(charm_string, sep+1)
3052 % \end{macrocode}
3053 % If the current value of |charm_string| does not contain a comma, then it must be the last portion, and we set |charm_string| to |nil|.
3054 % \begin{macrocode}
3055 else
3056 temp_string = charm_string
3057 charm_string = nil
3058 end
3059 % \end{macrocode}
3060 % First check whether |temp_string| contains a |/| character. If yes, we have two values to process, and if not, we have one.
3061 % \begin{macrocode}
3062 sep = string.find(temp_string, "/")
3063 if sep then
3064 % \end{macrocode}
3065 % The information for upright font shapes comes from the first portion of |temp_string|.
3066 % \begin{macrocode}
3067 split_string_rm[i] = mathfont.parse_num(
3068 string.sub(temp_string, 1, sep-1))
3069 % \end{macrocode}
3070 % Information for italic shapes comes from the latter portion of |temp_string|.
3071 % \begin{macrocode}
3072 split_string_it[i] = mathfont.parse_num(
3073 string.sub(temp_string, sep+1))
3074 % \end{macrocode}
3075 % For the case without a |/|, the same information goes in both sets of lists.
3076 % \begin{macrocode}
3077 else
3078 local temp = mathfont.parse_num(temp_string)
3079 split_string_rm[i] = temp
3080 split_string_it[i] = temp
3081 end
3082 % \end{macrocode}
3083 % Increment |i|, end the loop, and return the charm information.
3084 % \begin{macrocode}
3085 i = i + 1
3086 end
3087 return {index, exc, split_string_rm, split_string_it}
3088 end
3089 % \end{macrocode}
3090 % We feed the user's charm information directly to |mathfont:add_to_charm|, which processes the information and stores it in |mathfont|. It first calls |parse_charm| to parse the input and then modifies |mathfont| accordingly. After being parsed, the user's input lives in |charm_rm| and |charm_it|. The |index| is the Unicode value of the character whose information we want to modify, and the |number_of_entries| is the length of |charm_metrics|.
3091 % \begin{macrocode}
3092 function mathfont:add_to_charm(charm_string)
3093 local temp = self.parse_charm(charm_string)
3094 local index = temp[1]
3095 local force_type = temp[2]
3096 local data_rm = temp[3]
3097 local data_it = temp[4]
3098 local number_of_entries = \string# data_rm
3099 % \end{macrocode}
3100 % If |mathfont| does not already have an entry for the Unicode character |index|, we create an entry with type |a| or |e| depending on the value of |force_type|.
3101 % \begin{macrocode}
3102 if not self[index] then
3103 mathfont.info(string.format("Setting up charm entries for
3104 U+\@percentchar X \@percentchar s (index \@percentchar d)",
3105 index, utf8.char(index), index))
3106 if force_type == 1 then
3107 temp = {}
3108 for i = 1, 30, 1 do
3109 temp[i] = 1000
3110 end
3111 for i = 31, 33, 1 do
3112 temp[i] = 0
3113 end
3114 self:new_type_e(index, temp, temp)
3115 else
3116 self:new_type_a(index, {0, 0, 0, 0}, {0, 0, 0, 0})
3117 end
3118 else
3119 % \end{macrocode}
3120 % If |mathfont| does already have an entry for the character and |force_type| is positive, check whether the type of the entry in |mathfont| matches the value of |force_type|. If not, change the type by resetting the entry in |mathfont|. First, the case where the character has type |a|, and we want to change it to type |e|. We save the top and bottom accent values to use in setting up the new charm information.
3121 % \begin{macrocode}
3122 if (self[index].type == "a") and (force_type == 1) then
3123 local temp_rm = {}
3124 local temp_it = {}
3125 for i = 1, 30, 1 do
3126 temp_rm[i] = 1000
3127 temp_it[i] = 1000
3128 end
3129 temp_rm[31] = self[index].data_rm[3]
3130 temp_rm[32] = self[index].data_rm[4]
3131 temp_rm[33] = 0
3132 temp_it[31] = self[index].data_it[3]
3133 temp_it[32] = self[index].data_it[4]
3134 temp_it[33] = 0
3135 self:new_type_e(index, temp_rm, temp_it)
3136 % \end{macrocode}
3137 % The process to convert to type |a| is simpler but fairly similar.
3138 % \begin{macrocode}
3139 elseif (self[index].type == "e") and (force_type == 2) then
3140 self:new_type_a(index, {0, 0,
3141 self[index].data_rm[31],
3142 self[index].data_rm[32]},
3143 {0, 0,
3144 self[index].data_it[31],
3145 self[index].data_it[32]})
3146 end
3147 end
3148 % \end{macrocode}
3149 % Handling the user's input depends on the type of entry |index|. The basic procedure is to first check the number of inputs, and if the user provided enough entries, we update each entries in the |mathfont| subtable. For every asterisk, we leave the corresponding subtable entries unaltered. For type |a|, we need four entries besides the |index|. The first two determine the left and right offset, and the last two determine accent placement.
3150 % \begin{macrocode}
3151 if self[index].type == "a" then
3152 local entries_needed = 4
3153 % \end{macrocode}
3154 % Check number of entries. If it is too small, we issue an error, and if it is too large, we print a warning.
3155 % \begin{macrocode}
3156 if number_of_entries < entries_needed then
3157 error(\M@entries@ssert)
3158 elseif number_of_entries > entries_needed then
3159 texio.write_nl(\M@entries@warning)
3160 end
3161 % \end{macrocode}
3162 % Now update the table entries. The data outputs from |parse_charm| have been properly scaled (divided by 1000), so we don't have to worry about rescaling in this function.
3163 % \begin{macrocode}
3164 for i = 1, 4, 1 do
3165 if data_rm[i] \noexpand~= "*" then
3166 self[index].data_rm[i] = data_rm[i]
3167 end
3168 if data_it[i] \noexpand~= "*" then
3169 self[index].data_it[i] = data_it[i]
3170 end
3171 end
3172 % \end{macrocode}
3173 % Now do type |e|. The number of entries in the |data| lists must be at least $2*|tot_variants|+3$. We loop through the information and, for each $i$th pair of charm values, set those numbers to be the horizontal and vertical stretch information for the $i$th variant.
3174 % \begin{macrocode}
3175 elseif self[index].type == "e" then
3176 local tot_variants = self[index].num_variants
3177 local entries_needed = 2 * tot_variants + 3
3178 % \end{macrocode}
3179 % Again check number of entries.
3180 % \begin{macrocode}
3181 if number_of_entries < entries_needed then
3182 error(\M@entries@ssert)
3183 elseif number_of_entries > entries_needed then
3184 texio.write_nl(\M@entries@warning)
3185 end
3186 % \end{macrocode}
3187 % Now store the charm information. Again, we scaled the |data_rm| and |data_it| values in |parse_charm|, so we don't have to divide by 1000 here.
3188 % \begin{macrocode}
3189 for i = 1, tot_variants, 1 do
3190 if data_rm[2*i-1] \noexpand~= "*" then
3191 self[index].data_rm[i][1] = data_rm[2*i-1]
3192 end
3193 if data_rm[2*i] \noexpand~= "*" then
3194 self[index].data_rm[i][2] = data_rm[2*i]
3195 end
3196 if data_it[2*i-1] \noexpand~= "*" then
3197 self[index].data_it[i][1] = data_it[2*i-1]
3198 end
3199 if data_it[2*i] \noexpand~= "*" then
3200 self[index].data_it[i][2] = data_it[2*i]
3201 end
3202 end
3203 % \end{macrocode}
3204 % The final entries for type |e| are the accent and italic correction information.
3205 % \begin{macrocode}
3206 for i = tot_variants + 1, tot_variants + 3, 1 do
3207 if data_rm[i] \noexpand~= "*" then
3208 self[index].data_rm[i] = data_rm[i]
3209 end
3210 if data_it[i] \noexpand~= "*" then
3211 self[index].data_it[i] = data_it[i]
3212 end
3213 end
3214 end
3215 end
3216 % \end{macrocode}
3217 % We end this section with three general-purpose Lua functions. The first function, |utf_16BE|, accepts a nonnegative integer and returns its representation in UTF-16 big-endian format. Let $x$ be a nonnegative integer at most 0x10FFFF. Here are the steps to convert $x$ to its big-endian representation:
3218 % \begin{enumerate}
3219 % \item If $x\leq\hbox{0xFFFF}$, keep $x$ as is. Its representation is a single four-digit hexadecimal number.
3220 % \item If $x\geq\hbox{0x10000}$, we represent $x$ as two four-digit hexadecimal numbers. First, subtract 0x10000 from $x$, and the result $y$ is a number between 0 and 0xFFFFF.
3221 % \item Equivalently, we can think of $y$ as a twenty-digit binary number. (Five hexadecimal digits store the same information as twenty binary digits.)
3222 % \item Take the 10 left-most digits of $y$ (integer divide by $2^{10}=1024$), and add them to 0xD800. The result $z_1$ is the first hexadecimal number.
3223 % \item Take the 10 right-most digits of $y$ (remainder after dividing by $2^{10}=1024$), and add them to 0xDC00. The result $z_2$ is the second hexadecimal number.
3224 % \item The big-endian representation of $x$ is the string $z_1z_2$.
3225 % \end{enumerate}
3226 % The purpose of big-endian representation is to encode Unicode characters beyond U+FFFF while still using four-digit hexadecimal numbers.
3227 % \begin{macrocode}
3228 function mathfont.utf_16BE(integer)
3229 if integer > 0x10FFFF then
3230 error(\M@bound@ssert)
3231 end
3232 local temp = string.format("\@percentchar X", integer)
3233 if \string# temp <= 4 then
3234 while \string# temp < 4 do
3235 temp = "0" .. temp
3236 end
3237 else
3238 temp = integer - 0x10000
3239 local left_bits = 0xD800 + temp // 1024
3240 local right_bits = 0xDC00 + temp \@percentchar 1024
3241 temp = string.format("\@percentchar X\@percentchar X",
3242 left_bits, right_bits)
3243 end
3244 return temp
3245 end
3246 % \end{macrocode}
3247 % The |glyph_info| function does exactly what it sounds like. It accepts a character table from a font and returns the width, height, depth, and italic correction values.
3248 % \begin{macrocode}
3249 function mathfont.glyph_info(char)
3250 local glyph_width = char.width or 0
3251 local glyph_height = char.height or 0
3252 local glyph_depth = char.depth or 0
3253 local glyph_italic = char.italic or 0
3254 return glyph_width, glyph_height, glyph_depth, glyph_italic
3255 end
3256 % \end{macrocode}
3257 % The |smash_glyph| function returns a character table that will produce a smashed version of the Unicode character with value |index|. The character has no width, height, or depth, and we typeset the glyph virtually using a |char| command.
3258 % \begin{macrocode}
3259 function mathfont.smash_glyph(index)
3260 local smash_table = {}
3261 smash_table.width = 0
3262 smash_table.height = 0
3263 smash_table.depth = 0
3264 smash_table.commands = {{"char", index}}
3265 return smash_table
3266 end
3267 % \end{macrocode}
3268 % An empty function that does nothing. Used later for creating callbacks.
3269 % \begin{macrocode}
3270 function mathfont.empty(arg)
3271 end
3272 % \end{macrocode}
3273 %
3274 %
3275 %
3276 % \section{Adjust Fonts: Changes}
3277 % \suppressfloats[t]
3278 %
3279 %
3280 %
3281 % This section contains the Lua functions that actually modify the font during loading. The three functions |set_nomath_false|, |math_constants|, and |apply_charm_info| do most of the heavy lifting, and we set them as the default behavior for three callbacks. In total, \textsf{mathfont} defines seven different callbacks and calls them inside the function |adjust_font|---see table~4 for a list. Each callback accepts a fontdata object as an argument and returns nothing. You can use these callbacks to change \textsf{mathfont}'s default modifications or to modify a fontdata object before or after \textsf{mathfont} looks at it. Be aware that if you add a function to any of the |disable_nomath|, |add_math_constants|, or |fix_character_metrics| callbacks, Lua\TeX\ will not call the default |mathfont| function associated with the callback anymore. In other words, do not mess with these three callbacks unless you are duplicating the functionality of the corresponding ``Default Behavior'' function from table~4.
3282 %
3283 % \begin{figure}[bt]
3284 % \centerline{\bfseries Table 4: Callbacks Created by \textsf{mathfont}\strut}
3285 % \begin{tabularx}\textwidth{lX}\toprule
3286 % Callback Name & Default Behavior\\\midrule
3287 % |"mathfont.inspect_font"| & None\\\midrule
3288 % |"mathfont.pre_adjust"| & None\\
3289 % |"mathfont.disable_nomath"| & |mathfont.set_nomath_false|\\
3290 % |"mathfont.add_math_constants"| & |mathfont.math_constants|\\
3291 % |"mathfont.fix_character_metrics"|& |mathfont.apply_charm_info|\\
3292 % |"mathfont.post_adjust"| & None\\\midrule
3293 % |"mathfont.finishing_touches"| & None\\\bottomrule
3294 % \end{tabularx}
3295 % \end{figure}
3296 %
3297 %
3298 %
3299 % We begin with the functions that create new character subtables for inclusion in a font object, and we think of these new subtables as modified versions of characters already present in a given font. The functions for assembling character tables take three arguments. The |index| argument is the Unicode index of the modified character. The |charm_data| argument is the subtable in |mathfont| of charm information that corresponds to |index|, and the |fontdata| argument is a font object. For type |a|, we change the width of the bounding box and horizontal glyph positioning, and for type |e|, we scale the glyph to create large variants and change the italic correction. For both types, we modify accent placement. We add five categories of information into our new character tables: glyph dimensions, Unicode encoding bits, (possible) virtual font commands, accent placement dimensions, and math kerning.
3300 %
3301 % The |:make_a_table| returns a character table for type |a| characters. We build up the subtable in the variable |a_table|, and we eventually return |a_table| at the end of the function. We let |char| be a shorthand for the subtable at |index| in |fontdata|, and |slant| is the font's |slant| parameter. In upright fonts, |slant| is generally 0, and in italic fonts, |slant| is generally positive.
3302 % \begin{macrocode}
3303 function mathfont:make_a_table(index, charm_data, fontdata)
3304 local a_table = {}
3305 local char = fontdata.characters[index] or {}
3306 local ex = fontdata.parameters.x_height or 0
3307 local slant = (fontdata.parameters.slant or 0)/ 65536
3308 % \end{macrocode}
3309 % Get the dimensions of the character. We determine the new bounding box dimensions, horizontal glyph placement, and accent placement in terms of the character's original width (plus italic correction).
3310 % \begin{macrocode}
3311 local width, height, depth, italic = self.glyph_info(char)
3312 % \end{macrocode}
3313 % Incorporate the italic correction into the character width.
3314 % \begin{macrocode}
3315 width = width + italic
3316 % \end{macrocode}
3317 % We extract charm information from |charm_data| depending on whether the font is slanted or not.
3318 % \begin{macrocode}
3319 local left_stretch
3320 local right_stretch
3321 local top_accent
3322 local bot_accent
3323 if slant == 0 then
3324 left_stretch = charm_data.data_rm[1]
3325 right_stretch = charm_data.data_rm[2]
3326 top_accent = charm_data.data_rm[3]
3327 bot_accent = charm_data.data_rm[4]
3328 else
3329 left_stretch = charm_data.data_it[1]
3330 right_stretch = charm_data.data_it[2]
3331 top_accent = charm_data.data_it[3]
3332 bot_accent = charm_data.data_it[4]
3333 end
3334 % \end{macrocode}
3335 % The new width is $1+|left_stretch|+|right_stretch|$ times the original width. The horizontal offset that appears in the commands is the |left_stretch| portion of the new width.
3336 % \begin{macrocode}
3337 local offset = width * left_stretch
3338 a_table.width = width * (1 + left_stretch + right_stretch)
3339 a_table.height = height
3340 a_table.depth = depth
3341 a_table.italic = 0
3342 % \end{macrocode}
3343 % Unicode information attached to the character.
3344 % \begin{macrocode}
3345 a_table.unicode = index
3346 a_table.tounicode = self.utf_16BE(index)
3347 a_table.index = char.index
3348 % \end{macrocode}
3349 % If |left_stretch| is nonzero, we have to turn the character into a virtual character that typesets the glyph through a |char| command---that is the only way to add space on the left of the glyph. (A nonzero |right_stretch| is easier because we only have to extend the bounding box.)
3350 % \begin{macrocode}
3351 if offset \noexpand~= 0 then
3352 if char.commands then
3353 error(\M@virtual@ssert)
3354 else
3355 a_table.commands = {{"right", offset}, {"char", index}}
3356 end
3357 end
3358 % \end{macrocode}
3359 % We calculate accent placement in two steps. The first step is to calculate a ``base'' accent position from character and font properties, and then we modify the base position according to charm information. If the font contains a |top_accent| value for the character, we take that value as our base accent position.
3360 % \begin{macrocode}
3361 local top_base
3362 if char.top_accent then
3363 top_base = char.top_accent
3364 % \end{macrocode}
3365 % If the font does not contain a |top_accent| value, which for text fonts is the more likely possibility, we have to create the base accent position ourselves. We use an approach similar to how \TeX\ positions accents in text mode. If the character is less than 1ex tall, the base accent position is halfway across the character's bounding box, i.e.\ any horizontal offset plus half the original width and half the italic correction. If the character is taller than 1ex, we move the base accent position right by the font's |slant| value times the character's height above 1ex. The base accent position in this approach does not change when the user changes the |left_stretch| or |right_stretch| values in the charm information.
3366 % \begin{macrocode}
3367 else
3368 top_base = offset + 0.5 * width
3369 if height > ex then
3370 top_base = top_base + slant * (height - ex)
3371 end
3372 end
3373 % \end{macrocode}
3374 % We take a similar approach for the bottom accent. For the base accent position, we subtract the |slant| times 1ex.
3375 % \begin{macrocode}
3376 local bot_base
3377 if char.bot_accent then
3378 bot_base = char.bot_accent
3379 else
3380 bot_base = offset + 0.5 * width - slant * ex
3381 end
3382 % \end{macrocode}
3383 % Now add the accent information to the font.
3384 % \begin{macrocode}
3385 a_table.top_accent = top_base + top_accent * width
3386 a_table.bot_accent = bot_base + bot_accent * width
3387 % \end{macrocode}
3388 % \TeX\ shifts superscripts (but not subscripts) right by the italic correction. We added italic correction to the character's width. Effectively, that shifts any superscript right relative to the character's original bounding box, so our changes to the character result in superscripts that behave the way we expect. However, the larger bounding box also affects subscripts, which we don't want, so we implement a mathkern table that moves any subscripts left by the italic correction. A mathkern table contains up to four subtables, one for each corner of the character. Within each subtable, we store pairs of |height| and |kern| values, where |height| means to apply |kern| to exponents at that height. In this case, we have a |kern| value of minus italic correction in the lower right corner.
3389 % \begin{macrocode}
3390 a_table.mathkern = {}
3391 a_table.mathkern.top_right = {{height = 0, kern = 0}}
3392 a_table.mathkern.bottom_right = {{height = 0, kern = -italic}}
3393 a_table.mathkern.top_left = {{height = 0, kern = 0}}
3394 a_table.mathkern.bottom_left = {{height = 0, kern = 0}}
3395 return a_table
3396 end
3397 % \end{macrocode}
3398 % For type |e| characters, we add several virtual characters to the font, and we use |make_e_commands| to produce their commands tables. The commands tables from this function produces a scaled version of the glyph in slot |index|. The |pdf| command sends code directly to the pdf backend that handles the transformation. The |q| specification induces a linear transformation of the output, which in this case is a dilation by |h_stretch| and |v_stretch| factors. The |Q| command restores the original coordinate system.
3399 % \begin{macrocode}
3400 function mathfont.make_e_commands(index, h_stretch, v_stretch)
3401 local c_1 = {"pdf", "origin",
3402 string.format("q \@percentchar s 0 0 \@percentchar s 0 0 cm",
3403 h_stretch, v_stretch)}
3404 local c_2 = {"char", index}
3405 local c_3 = {"pdf", "origin", "Q"}
3406 return {c_1, c_2, c_3}
3407 end
3408 % \end{macrocode}
3409 % The function for type |e| characters returns a list of character subtables because we need to create multiple characters at once. Specifically, the function returns a new subtable for the original character plus one subtable for each larger variant. The structure is similar to |:make_type_a|, except that we scale the glyph instead of enlarging the bounding box.
3410 % \begin{macrocode}
3411 function mathfont:make_e_table(index, charm_data, fontdata)
3412 local e_table = {}
3413 local char = fontdata.characters[index] or {}
3414 local ex = fontdata.parameters.x_height or 0
3415 local slant = (fontdata.parameters.slant or 0) / 65536
3416 local width, height, depth, italic = self.glyph_info(char)
3417 % \end{macrocode}
3418 % Extract the charm information other than scale factors. Here |_sc| is short for scale.
3419 % \begin{macrocode}
3420 local v = charm_data.num_variants
3421 local smash = charm_data.smash
3422 local next = charm_data.next
3423 local top_accent_sc
3424 local bot_accent_sc
3425 local italic_sc
3426 if slant == 0 then
3427 top_accent_sc = charm_data.data_rm[2*v+1]
3428 bot_accent_sc = charm_data.data_rm[2*v+2]
3429 italic_sc = charm_data.data_rm[2*v+3]
3430 else
3431 top_accent_sc = charm_data.data_it[2*v+1]
3432 bot_accent_sc = charm_data.data_it[2*v+2]
3433 italic_sc = charm_data.data_it[2*v+3]
3434 end
3435 % \end{macrocode}
3436 % Calculate accent placement for the original glyph, and rescale the italic correction. We calculate accent placement similarly to type |a|, and we change the italic correction afterwards to ensure that accent placement is independent of |italic_scale|. Unlike with type |a|, we do not enlarge the bounding box on the left side of the character, so the base accent placement does not contain |offset|.
3437 % \begin{macrocode}
3438 local top_base
3439 if char.top_accent then
3440 top_base = char.top_accent
3441 else
3442 top_base = 0.5 * width
3443 if height > ex then
3444 top_base = top_base + slant * (height - ex)
3445 end
3446 end
3447 local bot_base = char.bot_accent or (0.5 * width - slant * ex)
3448 local top_accent = top_base + top_accent_sc * (width + italic)
3449 local bot_accent = bot_base + bot_accent_sc * (width + italic)
3450 italic = italic + italic_sc * (width + italic)
3451 % \end{macrocode}
3452 % Store the Unicode encoding slot for reference later
3453 % \begin{macrocode}
3454 local tounicode = self.utf_16BE(index)
3455 % \end{macrocode}
3456 % We create a number of entries in |e_table| equal to one plus the number of variants we want, which is stored in |charm_data.num_variants|. We begin with the first entry. This isn't a full character subtable because for the small version of the big operator, we won't replace the subtable already in |fontdata| but rather will add the information here into that subtable.
3457 % \begin{macrocode}
3458 e_table[1] = {}
3459 e_table[1].italic = italic
3460 e_table[1].unicode = index
3461 e_table[1].tounicode = self.utf_16BE(index)
3462 e_table[1].top_accent = top_accent
3463 e_table[1].bot_accent = bot_accent
3464 e_table[1].next = next[1]
3465 % \end{macrocode}
3466 % Now loop through the large variants, and add each one to |e_table|. We begin by extracting the scale factors for the particular large variant.
3467 % \begin{macrocode}
3468 local h_stretch
3469 local v_stretch
3470 for i = 2, v + 1, 1 do
3471 if slant == 0 then
3472 h_stretch = charm_data.data_rm[i-1][1]
3473 v_stretch = charm_data.data_rm[i-1][2]
3474 else
3475 h_stretch = charm_data.data_it[i-1][1]
3476 v_stretch = charm_data.data_it[i-1][2]
3477 end
3478 % \end{macrocode}
3479 % Now add the entries for the subtable.
3480 % \begin{macrocode}
3481 e_table[i] = {}
3482 e_table[i].width = width * h_stretch
3483 e_table[i].height = height * v_stretch
3484 e_table[i].depth = depth * v_stretch
3485 e_table[i].italic = italic * h_stretch
3486 % \end{macrocode}
3487 % Add the Unicode information.
3488 % \begin{macrocode}
3489 e_table[i].unicode = index
3490 e_table[i].tounicode = tounicode
3491 % \end{macrocode}
3492 % Accent placement.
3493 % \begin{macrocode}
3494 e_table[i].top_accent = top_accent * h_stretch
3495 e_table[i].bot_accent = bot_accent * h_stretch
3496 % \end{macrocode}
3497 % Add the commands.
3498 % \begin{macrocode}
3499 e_table[i].commands =
3500 self.make_e_commands(smash, h_stretch, v_stretch)
3501 % \end{macrocode}
3502 % If we aren't dealing with the last entry in the table, we need to add the character's |next| field. The next larger variant after the |i|th character will the the ${|i|}+1$st character, and we can extract the index from the |charm_information|.
3503 % \begin{macrocode}
3504 if i <= v then
3505 e_table[i].next = charm_data.next[i]
3506 end
3507 end
3508 return e_table
3509 end
3510 % \end{macrocode}
3511 % Before we get to the main font-changing functions, we code |make_fake_angle|, which returns a character table for the fake angle brackets. The idea is to transform a guillement such that the top 90\% of the original bounding box lines up with the full bounding box (height plus depth) of the left parenthesis (U+28). We make the fake angle brackets as follows:
3512 % \begin{enumerate}
3513 % \item Take a (single or double) guillemet, and let $h$ be its height. We assume the guillemet has no depth.
3514 % \item Let $h_p$ and $d_p$ be the height and depth respectively of the left parenthesis.
3515 % \item Our transformation of the guillement will involve a translation and a dilation. The translation should lower the basepoint of the guillemet such that if $p$ is the proportion of the guillemet that is below the baseline after translation, then $(p-0.1\sigma)h=d_p$, where $\sigma$ is the scale factor, assuming we apply the translation before the dilation. (The dilation fixes the current position within the virtual character regardless of its relation to the baseline.) This means $ph=d_p+0.1h\sigma$.
3516 % \item The scale factor for the dilation is
3517 % \[
3518 % \sigma=\frac{h_p+d_p}{0.9h},
3519 % \]
3520 % so 90\% of the guillemet height becomes equal to the size of the parenthesis.
3521 % \end{enumerate}
3522 % The function accepts the index of a guillemet as |index| and the index of the smashed guillemet as |smash|. The |slot| argument is the encoding slot of the angle bracket. First, extract relevant character and font dimensions.
3523 % \begin{macrocode}
3524 function mathfont:make_fake_angle(index, smash, slot, fontdata)
3525 local fab_table = {} % fab for fake angle bracket
3526 local chars = fontdata.characters
3527 local lp = chars[40] or {} % lp for left parenthesis
3528 local lp_width, lp_height, lp_depth, lp_italic =
3529 self.glyph_info(lp)
3530 local g = chars[index] or {} % g for guillemet
3531 local g_width, g_height, g_depth, g_italic = self.glyph_info(g)
3532 local ex = fontdata.parameters.x_height or 0
3533 local slant = (fontdata.parameters.slant or 0) / 65536
3534 % \end{macrocode}
3535 % We compute the dimensions of our fake angle bracket.
3536 % \begin{macrocode}
3537 local factor
3538 if g_height \noexpand~= 0 then
3539 factor = (lp_height + lp_depth) / (0.9 * g_height)
3540 else
3541 factor = 1
3542 end
3543 local shift = lp_depth + 0.1 * factor * g_height
3544 % \end{macrocode}
3545 % Now populate |fab_table|.
3546 % \begin{macrocode}
3547 fab_table.height = lp_height
3548 fab_table.depth = lp_depth
3549 fab_table.width = g_width
3550 fab_table.italic = g_italic
3551 % \end{macrocode}
3552 % Unicode information.
3553 % \begin{macrocode}
3554 fab_table.unicode = slot
3555 fab_table.tounicode = self.utf_16BE(slot)
3556 % \end{macrocode}
3557 % We calculate accent placement information the same way as we have been doing for type |a| and type |e| characters.
3558 % \begin{macrocode}
3559 if g.top_accent then
3560 fab_table.top_accent = g.top_accent
3561 else
3562 if g_height > ex then
3563 fab_table.top_accent = 0.5 * g_width +
3564 slant * (g_height - ex)
3565 else
3566 fab_table.top_accent = 0.5 * g_width
3567 end
3568 end
3569 fab_table.bot_accent = g.bot_accent or
3570 (0.5 * g_width - slant * ex)
3571 % \end{macrocode}
3572 % Commands.
3573 % \begin{macrocode}
3574 fab_table.commands = {
3575 {"down", shift},
3576 {"pdf", "origin",
3577 string.format("q 1 0 0 \@percentchar s 0 0 cm", factor)},
3578 {"char", smash},
3579 {"pdf", "origin", "Q"},
3580 {"down", -shift}}
3581 return fab_table
3582 end
3583 % \end{macrocode}
3584 % Similar function that returns the character subtable for a nabla (inverted increment symbol/capital Delta). Again, |index| is the encoding slot for an increment symbol, and |smash| is the encoding slot for a smashed version of an increment.
3585 % \begin{macrocode}
3586 function mathfont:make_nabla(index, smash, slot, fontdata)
3587 local n_table = {} % n for nabla
3588 local i = fontdata.characters[index] % i for increment
3589 local i_width, i_height, i_depth, i_italic = self.glyph_info(i)
3590 % \end{macrocode}
3591 % Now populate |n_table|.
3592 % \begin{macrocode}
3593 n_table.width = i_width
3594 n_table.height = i_height
3595 n_table.depth = i_depth
3596 n_table.italic = i_italic
3597 % \end{macrocode}
3598 % Unicode information.
3599 % \begin{macrocode}
3600 n_table.unicode = slot
3601 n_table.tounicode = self.utf_16BE(slot)
3602 % \end{macrocode}
3603 % Take accent placement values from the increment symbol if they exist.
3604 % \begin{macrocode}
3605 if i.top_accent then
3606 n_table.bot_accent = i_width - i.top_accent
3607 end
3608 if i.bot_accent then
3609 n_table.top_accent = i_width - i.bot_accent
3610 end
3611 % \end{macrocode}
3612 % Commands. We reflect the increment glyph horizontally and vertically.
3613 % \begin{macrocode}
3614 n_table.commands = {
3615 {"down", -i_height},
3616 {"right", i_width},
3617 {"pdf", "origin", "q -1 0 0 -1 0 0 cm"},
3618 {"char", smash},
3619 {"pdf", "origin", "Q"},
3620 {"right", -i_width},
3621 {"down", i_height}}
3622 return n_table
3623 end
3624 % \end{macrocode}
3625 % We come to the functions that modify the font. We need to accomplish three tasks, and we define separate functions for each one. First, we set the font's |nomath| entry to |false|. Second, we incorporate the modifications based on charm information into the font, i.e.\ set the font's character subtables using the previous functions from this section. Third, we need to add a MathConstants table. The first task is very easy.
3626 % \begin{macrocode}
3627 function mathfont.set_nomath_false(fontdata)
3628 fontdata.nomath = false
3629 fontdata.oldmath = false
3630 end
3631 % \end{macrocode}
3632 % The second task is more involved. The basic idea is to loop through |mathfont|, and whenever we find an entry that is a subtable, we treat it as charm information that we use to modify the font object. We begin by storing the character information from the font in |chars| for easier reference later.
3633 % \begin{macrocode}
3634 function mathfont.apply_charm_info(fontdata)
3635 local chars = fontdata.characters or {}
3636 % \end{macrocode}
3637 % Before we loop through the charm data, we need to make a few changes to the font, namely add fake angle brackets, add nabla, and trim the bounding box on the surd. First, we add fake angle brackets. We use |mathfont.extra_chars| to track where we put the extra (virtual) characters in the font.
3638 % \begin{macrocode}
3639 local temp = mathfont.extra_chars
3640 chars[temp] = mathfont.smash_glyph(0x2039) % smashed \lguil
3641 chars[temp+1] = mathfont.smash_glyph(0x203A) % smashed \rguil
3642 chars[temp+2] = mathfont.smash_glyph(0xAB) % smashed \llguil
3643 chars[temp+3] = mathfont.smash_glyph(0xBB) % smashed \rrguil
3644 % \end{macrocode}
3645 % Now add the characters to the font.
3646 % \begin{macrocode}
3647 chars[mathfont.fakel] = mathfont:make_fake_angle( %\fakelangle
3648 0x2039, temp, 0x27E8, fontdata)
3649 chars[mathfont.faker] = mathfont:make_fake_angle( %\fakerangle
3650 0x203A, temp+1, 0x27E9, fontdata)
3651 chars[mathfont.fakell] = mathfont:make_fake_angle( %\fakellangle
3652 0xAB, temp+2, 0x27EA, fontdata)
3653 chars[mathfont.fakerr] = mathfont:make_fake_angle( %\fakerrangle
3654 0xBB, temp+3, 0x27EB, fontdata)
3655 % \end{macrocode}
3656 % If the function doesn't have an increment character, copy a capital Delta if it exists in the font.
3657 % \begin{macrocode}
3658 if chars[0x394] and (not chars[0x2206]) then
3659 chars[0x2206] = {}
3660 for k,v in pairs(chars[0x394]) do
3661 chars[0x2206][k] = v
3662 end
3663 chars[0x2206].commands = {{"char", 0x394}}
3664 end
3665 % \end{macrocode}
3666 % Add the nabla (inverted increment/capital Delta) character to the font if it is missing.
3667 % \begin{macrocode}
3668 if chars[0x2206] and (not chars[0x2207]) then
3669 chars[temp+8] = mathfont.smash_glyph(0x2206)
3670 chars[0x2207] = mathfont:make_nabla(
3671 0x2206, temp+8, 0x2207, fontdata)
3672 end
3673 % \end{macrocode}
3674 % We trim the bounding box on the surd if the user requests it. Some text fonts extend the bounding box of the surd past the edge of the glyph, and we trim the edge of the box according to the values of |\vsurdfactor| and |\hsurdfactor|.
3675 % \begin{macrocode}
3676 if chars[0x221A] then
3677 local hsurd = tex.getcount("hsurdfactor") / 1000
3678 local vsurd = tex.getcount("vsurdfactor") / 1000
3679 chars[0x221A].width = hsurd * chars[0x221A].width
3680 chars[0x221A].height = vsurd * chars[0x221A].height
3681 end
3682 % \end{macrocode}
3683 % Perform the loop. We care about entries |info| whose index is a number because those entries are the charm information that determines how we modify the font object. We ignore charm information for any characters not present in the font.
3684 % \begin{macrocode}
3685 for index, info in pairs(mathfont) do
3686 if type(index) == "number" and chars[index] then
3687 % \end{macrocode}
3688 % One each iteration of the loop, we start by checking the |type| of the current entry because the handling of the font object varies based on the character type. For characters of type |a|, we insert our character subtable into the font object.
3689 % \begin{macrocode}
3690 if info.type == "a" then
3691 chars[index] = mathfont:make_a_table(index,info,fontdata)
3692 % \end{macrocode}
3693 % For type |e| we have to add entries to |chars[index]| and insert multiple character subtables into the font, namely one for the smashed version of the base glyph and others corresponding to the large variants.
3694 % \begin{macrocode}
3695 elseif info.type == "e" then
3696 local variants_table =
3697 mathfont:make_e_table(index, info, fontdata)
3698 % \end{macrocode}
3699 % First add entries to the subtable for the base glyph.
3700 % \begin{macrocode}
3701 for k,v in pairs(variants_table[1]) do
3702 chars[index][k] = v
3703 end
3704 % \end{macrocode}
3705 % Smashed version of the glyph.
3706 % \begin{macrocode}
3707 chars[info.smash] = mathfont.smash_glyph(index)
3708 % \end{macrocode}
3709 % Now add the large variants.
3710 % \begin{macrocode}
3711 for i = 1, info.num_variants, 1 do
3712 chars[info.next[i]] = variants_table[i+1]
3713 end
3714 end
3715 end
3716 end
3717 end
3718 % \end{macrocode}
3719 % The |populate_math_constants| function is even longer because we need to add a full MathConstants table to the font object, which has some fifty parameters that we need to set. (But the mechanics behind the function are simpler than |apply_charm_info|.) We set the font parameters in terms of traditional \TeX\ |\fontdimen| parameters. Besides the eight essential parameters found in all fonts, \TeX\ traditionally uses some fifteen extra parameters to typeset math formulas. To preserve whatever structure may already exist in the font object, we do not override any MathConstants that the font already contains. For brevity, we let |MC| be a shortcut for the MathConstants table.
3720 % \begin{macrocode}
3721 function mathfont.math_constants(fontdata)
3722 fontdata.MathConstants = fontdata.MathConstants or {}
3723 local MC = fontdata.MathConstants
3724 % \end{macrocode}
3725 % First evaluate the dimensions from the font object that we will use in determining other math parameter values. The |A_height| is the height of the capital ``A'' character, and the |y_depth| is the depth of the lower-case ``y'' character. Both will be 0 if the font does not have the correct character.
3726 % \begin{macrocode}
3727 local size = fontdata.size or 0
3728 local ex = fontdata.parameters.x_height or 0
3729 local em = fontdata.parameters.quad or 0
3730 local A_height = 0
3731 local y_depth = 0
3732 if fontdata.characters[65] then
3733 A_height = fontdata.characters[65].height or 0 % A
3734 end
3735 if fontdata.characters[121] then
3736 y_depth = fontdata.characters[121].depth or 0 % y
3737 end
3738 % \end{macrocode}
3739 % We begin by setting the axis height and default rule thickness. We need to start with these parameters because we will use them to calculate other constants. We set both values to 0 initially and then change them.
3740 % \begin{macrocode}
3741 local axis = 0
3742 local rule_thickness = 0
3743 % \end{macrocode}
3744 % Set the default rule thickness. If the font already has a value set for the parameter |FractionRuleThickness|, we take that as the default rule thickness, and otherwise we set it to be 1/18 of the font size times the adjustment factor from |\rulethicknessfactor|.
3745 % \begin{macrocode}
3746 if MC.FractionRuleThickness then
3747 rule_thickness = MC.FractionRuleThickness
3748 else
3749 local temp =
3750 tex.getcount("rulethicknessfactor") / 1000
3751 rule_thickness = (size / 18) * temp
3752 MC.FractionRuleThickness = rule_thickness
3753 end
3754 % \end{macrocode}
3755 % If the font has an |AxisHeight|, we take that value as the |axis|. If the font does not have |AxisHeight| already set, we set the axis to be the height of a minus sign, which has position U+2212 (8722 in decimal). As a fallback, we set the axis to 0.8ex if the font does not have a character in slot U+2212.
3756 % \begin{macrocode}
3757 if MC.AxisHeight then
3758 axis = MC.AxisHeight
3759 else
3760 if fontdata.characters[8722] then
3761 axis = fontdata.characters[8722].height - rule_thickness / 2
3762 else
3763 axis = 0.8 * ex
3764 end
3765 MC.AxisHeight = axis
3766 end
3767 % \end{macrocode}
3768 % Apart from the axis height and rule thickness, we can group the traditional mathematics |\fontdimen| parameters into three categories: four for large operators, five for fractions, and six for superscripts and subscripts. (OpenType math does not use the fifth large-operator parameter $\xi_{13}$ and the seventh script parameter $\sigma_{14}$.) We define variables with the same names as their traditional references from Appendix G in the \textit{\TeX Book}. I have taken the design approach of using twice the rule height as a standard minimum clearance, and I am assuming that script styles are roughly 70\% as large as text and display styles. We begin with the parameters for large operators.
3769 %
3770 % The parameter $\xi_9$ is the minimum clearance between the top of a large operator and the limit above it, and we set it to be twice the rule thickness. Before ensuring that the bottom of the upper limit is at least $\xi_9$ away from the operator character, \TeX\ attempts to position the baseline of the limit at $\xi_{10}$ distance above the operator character, and we set $\xi_{10}$ to be slightly larger than $\xi_9$. If the upper limit has no decender, \TeX\ will raise its baseline by $\xi_{10}$, and if it has a descener, \TeX\ will position the bottom of the descender to be $\xi_9$ above the operator, which in practice means it will be higher than limits without descenders. This approach balances the desire for consistency in whitespace with the desire for consistency in baseline height. Similarly, we set the minimum clearance $\xi_{11}$ for the lower limit to be equal to the attempted clearance for the upper limit, and the attempted clearance $\xi_{12}$ for the lower limit will be the minimum clearance plus the average of the |\scriptfont| x-height and |\scriptfont| A-height.
3771 % \begin{macrocode}
3772 local xi_9 = 2 * rule_thickness % top limit min clearance
3773 local xi_10 = xi_9 + 0.35 * y_depth % bottom limit try placement
3774 local xi_11 = xi_10 % top limit min clearance
3775 local xi_12 = xi_10 + 0.35 * (A_height + ex) % bottom attempt
3776 % \end{macrocode}
3777 % Our general approach for |\displaystyle| fractions is to place the baseline of the numerator numerator at a distance above the fraction rule of 1.5 times the rule height plus descender depth plus a small extra space. The minimum clearance will be the rule height, so we expect the numerator to strictly exceed the minimum clearance in most situations. Doing so produces consistent baselines of numerators and gives our value for $\sigma_8$, the attempted height of the numerator in |\displaystyle| fractions. For smaller styles, we use a single rule height as clearance, so we add $0.5*|rule_thickness|+|y_depth|$ scaled down by 0.7 to the rule thickness. The minimum clearance for numerator and denominator are separate OpenType parameters, and we set them later. The extra 0.1 A-height in the attempted clearance relative to the minimum clearance appears because we measure attempted clearance from the axis, whereas we measure minimum clearance from the top or bottom of the fraction rule.
3778 % \begin{macrocode}
3779 local sigma_8 = axis + 1.5 * rule_thickness + y_depth +
3780 0.1 * A_height
3781 local sigma_9 = axis + 1.35 * rule_thickness + 0.7 * y_depth +
3782 0.07 * A_height
3783 local sigma_10 = sigma_9
3784 % \end{macrocode}
3785 % Our approach in the denominators is the same except that we add half the descender depth to the minimum clearance. This creates extra space below the fraction rule so that the typographical color above the rule matches that below the rule when the numerator contains descenders.
3786 % \begin{macrocode}
3787 local sigma_11 = -axis + 1.5 * rule_thickness +
3788 0.5 * y_depth + 1.1 * A_height
3789 local sigma_12 = -axis + 1.35 * rule_thickness +
3790 0.35 * y_depth + 0.77 * A_height
3791 % \end{macrocode}
3792 % For superscripts we think in terms of the top of the superscript. We raise the baseline of the superscript by the desired height of the superscript top minus the |\scriptfont| A-height. Choosing $1.3*|A_height|$ for regular styles and $1.2*|A_height|$ for cramped styles was a design choice that worked well. The attempted drop for subscripts is one-fifth the A-height or slightly more than the y-depth, whichever is greater. This way the subscript baseline is slightly lower than any descenders, and for fonts without descenders, we still clearly lower the subscript. Setting $\sigma_{18}$ and $\sigma_{19}$ was another design choice that worked well.
3793 % \begin{macrocode}
3794 local sigma_13 = 0.6 * A_height % attempted superscript height
3795 local sigma_15 = 0.5 * A_height % attempt for cramped scripts
3796 local sigma_16 = 1.1 * y_depth % attempted subscript lower
3797 if sigma_16 < 0.2 * A_height then
3798 sigma_16 = 0.2 * A_height
3799 end
3800 local sigma_17 = sigma_16 % sigma_16 when superscript
3801 local sigma_18 = 0.5 * A_height % superscript lower for boxed
3802 local sigma_19 = 0.1 * A_height % subscript lower for boxed
3803 % \end{macrocode}
3804 % The MathConstants themselves come from the Unicode equivalents of the traditional \TeX\ |\fontdimen| parameters where appropriate. Where not appropriate, I made design choices as indicated. Setting the next three parameters was purely a design choice.
3805 % \begin{macrocode}
3806 if not MC.DisplayOperatorMinHeight then
3807 MC.DisplayOperatorMinHeight = 1.8 * A_height
3808 end
3809 if not MC.FractionDelimiterDisplayStyleSize then
3810 MC.FractionDelimiterDisplayStyleSize = 2 * size
3811 end
3812 if not MC.FractionDelimiterSize then
3813 MC.FractionDelimiterSize = 1.3 * size
3814 end
3815 if not MC.FractionDenominatorDisplayStyleShiftDown then
3816 MC.FractionDenominatorDisplayStyleShiftDown = sigma_11
3817 end
3818 if not MC.FractionDenominatorShiftDown then
3819 MC.FractionDenominatorShiftDown = sigma_12
3820 end
3821 % \end{macrocode}
3822 % We set the minium clearance for the numerator to be twice the rule height in |\displaystyle| and the rule height in other styles. Our approach in setting the attempted height of the numerator ($\sigma_8$ and $\sigma_9$) was to add the minimum clearance plus the descender depth plus a small extra space, so in general, we do not expect the numerator to run into the minimum clearance. For the denominator, we do the same thing except add half the descender depth to the clearance, which balances the amount of color above and below the fraction rule and is similar to what we did for the lower limits on big operators when we set $\xi_{11}$ larger than $\xi_9$.
3823 % \begin{macrocode}
3824 if not MC.FractionDenominatorDisplayStyleGapMin then
3825 MC.FractionDenominatorDisplayStyleGapMin =
3826 rule_thickness + 0.5 * y_depth
3827 end % that MathConstants entry has a long name lol
3828 if not MC.FractionDenominatorGapMin then
3829 MC.FractionDenominatorGapMin =
3830 rule_thickness + 0.35 * y_depth
3831 end
3832 if not MC.FractionNumeratorDisplayStyleShiftUp then
3833 MC.FractionNumeratorDisplayStyleShiftUp = sigma_8
3834 end
3835 if not MC.FractionNumeratorShiftUp then
3836 MC.FractionNumeratorShiftUp = sigma_9
3837 end
3838 if not MC.FractionNumeratorDisplayStyleGapMin then
3839 MC.FractionNumeratorDisplayStyleGapMin = rule_thickness
3840 end
3841 if not MC.FractionNumeratorGapMin then
3842 MC.FractionNumeratorGapMin = rule_thickness
3843 end
3844 % \end{macrocode}
3845 % The |SkewedFractionHorizontalGap| and |SkewedFractionVerticalGap| take the values that Lua\TeX would set for a traditional \TeX\ font.
3846 % \begin{macrocode}
3847 if not MC.SkewedFractionHorizontalGap then
3848 MC.SkewedFractionHorizontalGap = 0.5 * em
3849 end
3850 if not MC.SkewedFractionVerticalGap then
3851 MC.SkewedFractionVerticalGap = ex
3852 end
3853 % \end{macrocode}
3854 % The |UpperLimit| and |LowerLimit| dimensions correspond exactly to traditional \TeX\ math |\fontdimen| parameters.
3855 % \begin{macrocode}
3856 if not MC.UpperLimitBaselineRiseMin then
3857 MC.UpperLimitBaselineRiseMin = xi_11
3858 end
3859 if not MC.UpperLimitGapMin then
3860 MC.UpperLimitGapMin = xi_9
3861 end
3862 if not MC.LowerLimitBaselineDropMin then
3863 MC.LowerLimitBaselineDropMin = xi_12
3864 end
3865 if not MC.LowerLimitGapMin then
3866 MC.LowerLimitGapMin = xi_10
3867 end
3868 % \end{macrocode}
3869 % Traditional \TeX\ doesn't have stack objects, but they are meant to be similar to large operators, so we set the same parameters.
3870 % \begin{macrocode}
3871 if not MC.StretchStackGapBelowMin then
3872 MC.StretchStackGapBelowMin = xi_10
3873 end
3874 if not MC.StretchStackTopShiftUp then
3875 MC.StretchStackTopShiftUp = xi_11
3876 end
3877 if not MC.StretchStackGapAboveMin then
3878 MC.StretchStackGapAboveMin = xi_9
3879 end
3880 if not MC.StretchStackBottomShiftDown then
3881 MC.StretchStackBottomShiftDown = xi_12
3882 end
3883 % \end{macrocode}
3884 % For the three |Overbar| parameters, we take the approach that the bar itself should be as thick as the rule height. The gap will be twice the rule height, and the extra clearance will be a single rule height.
3885 % \begin{macrocode}
3886 if not MC.OverbarExtraAscender then
3887 MC.OverbarExtraAscender = rule_thickness
3888 end
3889 if not MC.OverbarRuleThickness then
3890 MC.OverbarRuleThickness = rule_thickness
3891 end
3892 if not MC.OverbarVerticalGap then
3893 MC.OverbarVerticalGap = 2 * rule_thickness
3894 end
3895 % \end{macrocode}
3896 % For the radical sign, we take the same approach as with the |Overbar| parameters. We insert one rule thickness of extra space above the radical symbol and two rule thickness of extra space under it. For |\textstyle| and smaller, we reduce the space to a single rule height.
3897 % \begin{macrocode}
3898 if not MC.RadicalExtraAscender then
3899 MC.RadicalExtraAscender = rule_thickness
3900 end
3901 if not MC.RadicalRuleThickness then
3902 MC.RadicalRuleThickness = rule_thickness
3903 end
3904 if not MC.RadicalDisplayStyleVerticalGap then
3905 MC.RadicalDisplayStyleVerticalGap = 2 * rule_thickness
3906 end
3907 if not MC.RadicalVerticalGap then
3908 MC.RadicalVerticalGap = rule_thickness
3909 end
3910 % \end{macrocode}
3911 % The final three |Radical| parameters aren't used if we handle degree placement at the macro level rather than at the font level. We set them to the default values that Lua\TeX\ uses for traditional tfm fonts.
3912 % \begin{macrocode}
3913 if not MC.RadicalKernBeforeDegree then
3914 MC.RadicalKernBeforeDegree = (5/18) * em
3915 end
3916 if not MC.RadicalKernAfterDegree then
3917 MC.RadicalKernAfterDegree = (10/18) * em
3918 end
3919 if not MC.RadicalDegreeBottomRaisePercent then
3920 MC.RadicalDegreeBottomRaisePercent = 60
3921 end
3922 % \end{macrocode}
3923 % The |SpaceAfterScript| is a design choice. Somewhat arbitrary.
3924 % \begin{macrocode}
3925 if not MC.SpaceAfterScript then
3926 MC.SpaceAfterScript = 0.1 * em
3927 end
3928 % \end{macrocode}
3929 % The |Stack| parameters come from their traditional |\fontdimen| analogues.
3930 % \begin{macrocode}
3931 if not MC.StackBottomDisplayStyleShiftDown then
3932 MC.StackBottomDisplayStyleShiftDown = sigma_11
3933 end
3934 if not MC.StackBottomShiftDown then
3935 MC.StackBottomShiftDown = sigma_12
3936 end
3937 if not MC.StackTopDisplayStyleShiftUp then
3938 MC.StackTopDisplayStyleShiftUp = sigma_8
3939 end
3940 if not MC.StackTopShiftUp then
3941 MC.StackTopShiftUp = sigma_10
3942 end
3943 % \end{macrocode}
3944 % Traditionally \TeX\ uses an internal method rather than a parameter to determine the minimum distance between two boxes in an |\atop| stack. We set the minimum distance to be one rule thickness plus the combined minimum clearance for numerators and denominators in fractions. For |\displaystyle|, that gives us
3945 % \[
3946 % |rule_thickness|+(2*|rule_thickness|)+(2*|rule_thickness|+0.5*|y_depth|)
3947 % \]
3948 % For smaller styles, we use single rule height values and scale down the |y_depth| by 0.7.
3949 % \begin{macrocode}
3950 if not MC.StackDisplayStyleGapMin then
3951 MC.StackDisplayStyleGapMin =
3952 5 * rule_thickness + 0.5 * y_depth
3953 end
3954 if not MC.StackGapMin then
3955 MC.StackGapMin = 3 * rule_thickness + 0.35 * y_depth
3956 end
3957 % \end{macrocode}
3958 % With three exceptions, superscript and subscript parameters come from traditional \TeX\ dimensions.
3959 % \begin{macrocode}
3960 if not MC.SubscriptShiftDown then
3961 MC.SubscriptShiftDown = sigma_16
3962 end
3963 if not MC.SubscriptBaselineDropMin then
3964 MC.SubscriptBaselineDropMin = sigma_19
3965 end
3966 if not MC.SubscriptShiftDownWithSuperscript then
3967 MC.SubscriptShiftDownWithSuperscript = sigma_17
3968 end
3969 % \end{macrocode}
3970 % The top of a subscript should be less than half the A-height. This is a somewhat arbitrary design choice.
3971 % \begin{macrocode}
3972 if not MC.SubscriptTopMax then
3973 MC.SubscriptTopMax = 0.5 * A_height
3974 end
3975 % \end{macrocode}
3976 % The minimum gap between superscripts and subscripts will be the height of the rule. This is less space than \TeX\ traditionally allocates.
3977 % \begin{macrocode}
3978 if not MC.SubSuperscriptGapMin then
3979 MC.SubSuperscriptGapMin = rule_thickness
3980 end
3981 % \end{macrocode}
3982 % We set the minimum height for the bottom of a subscript to be the height of a superscript in cramped styles minus the depth of a possible descender. Theoretically this is the lowest that any portion of a superscript should ever be if it contains only text.
3983 % \begin{macrocode}
3984 if not MC.SuperscriptBottomMin then
3985 MC.SuperscriptBottomMin = sigma_15 - 0.7 * y_depth
3986 end
3987 if not MC.SuperscriptBaselineDropMax then
3988 MC.SuperscriptBaselineDropMax = sigma_18
3989 end
3990 if not MC.SuperscriptShiftUp then
3991 MC.SuperscriptShiftUp = sigma_13
3992 end
3993 if not MC.SuperscriptShiftUpCramped then
3994 MC.SuperscriptShiftUpCramped = sigma_15
3995 end
3996 % \end{macrocode}
3997 % If the superscript and subscript overlap, we choose the new position such that the baselines of subscripts are roughly consistent across subformulas. In this case, the bottom of the superscript box will rise at most to the point such that a subscript containing only text at 70\% of the next-larger style will align with all similar subscripts. The top of the subscript will have approximate height $-\sigma_{16}+0.7*|A_height|$ above the baseline, so to find our desired position for the bottom of the superscript, we add the minimum clearance of a single rule thickness. Putting this parameter in terms of the subscript sizing is necessary because we don't know how large the descender will be in a given subscript.
3998 % \begin{macrocode}
3999 if not MC.SuperscriptBottomMaxWithSubscript then
4000 MC.SuperscriptBottomMaxWithSubscript =
4001 -sigma_16 + 0.7 * A_height + rule_thickness
4002 end
4003 % \end{macrocode}
4004 % As with the |Overbar| parameters, we set the extra clearance to be the rule height and the gap to be twice the rule height.
4005 % \begin{macrocode}
4006 if not MC.UnderbarExtraDescender then
4007 MC.UnderbarExtraDescender = rule_thickness
4008 end
4009 if not MC.UnderbarRuleThickness then
4010 MC.UnderbarRuleThickness = rule_thickness
4011 end
4012 if not MC.UnderbarVerticalGap then
4013 MC.UnderbarVerticalGap = 2 * rule_thickness
4014 end
4015 % \end{macrocode}
4016 % No reason not to set |MinConnectorOverlap| to 0. It doesn't matter for our purposes because \textsf{mathfont} doesn't use extensibles.
4017 % \begin{macrocode}
4018 if not MC.MinConnectorOverlap then
4019 MC.MinConnectorOverlap = 0
4020 end
4021 end
4022 % \end{macrocode}
4023 % Time for callbacks! We create seven of them.
4024 % \begin{macrocode}
4025 luatexbase.create_callback("mathfont.inspect_font",
4026 "simple", mathfont.empty)
4027 luatexbase.create_callback("mathfont.pre_adjust",
4028 "simple", mathfont.empty)
4029 luatexbase.create_callback("mathfont.disable_nomath",
4030 "simple", mathfont.set_nomath_false)
4031 luatexbase.create_callback("mathfont.add_math_constants",
4032 "simple", mathfont.math_constants)
4033 luatexbase.create_callback("mathfont.fix_character_metrics",
4034 "simple", mathfont.apply_charm_info)
4035 luatexbase.create_callback("mathfont.post_adjust",
4036 "simple", mathfont.empty)
4037 luatexbase.create_callback("mathfont.finishing_touches",
4038 "simple", mathfont.empty)
4039 % \end{macrocode}
4040 % The functions |mathfont.info| and |mathfont.get_font_name| are used for informational messaging. The first prints a message in the |log| file, and the second returns a font name.
4041 % \begin{macrocode}
4042 function mathfont.info(msg)
4043 texio.write_nl("log", "Package mathfont Info: " .. msg)
4044 end
4045 function mathfont.get_font_name(fontdata)
4046 return fontdata.psname or
4047 fontdata.fullname or
4048 fontdata.name or "<unknown font name>"
4049 end
4050 % \end{macrocode}
4051 % The |adjust_font| function is what actually goes in |luaotfload.patch_font|. This function calls the six callbacks at appropriate times and writes informational messages in the |log| file. We adjust the font object when |nomath| is |false| and the font is loaded in |base| mode. I am assuming that the user will usually load text-only fonts in |node| or |harf| mode, and then \textsf{mathfont} does not need to (and probably should not) alter that particular font. Unfortunately, there does not appear to be a better way to notate that we will use a font for text versus math when declaring it with |\DeclareFontSize|. I would ideally set |script=math| with the rest of the OpenType font features, but \textsf{luaotfload} ignores |script| declarations that aren't built into the font.
4052 % \begin{macrocode}
4053 function mathfont.adjust_font(fontdata)
4054 luatexbase.call_callback("mathfont.inspect_font", fontdata)
4055 local the_font = mathfont.get_font_name(fontdata)
4056 if fontdata.nomath and
4057 fontdata.properties and
4058 fontdata.properties.mode and
4059 fontdata.properties.mode == "base" then
4060 luatexbase.call_callback("mathfont.pre_adjust",
4061 fontdata)
4062 luatexbase.call_callback("mathfont.disable_nomath",
4063 fontdata)
4064 luatexbase.call_callback("mathfont.add_math_constants",
4065 fontdata)
4066 luatexbase.call_callback("mathfont.fix_character_metrics",
4067 fontdata)
4068 luatexbase.call_callback("mathfont.post_adjust",
4069 fontdata)
4070 end
4071 luatexbase.call_callback("mathfont.finishing_touches", fontdata)
4072 end
4073 % \end{macrocode}
4074 % Finally, add the processing function to \textsf{luaotfload}'s |patch_font| callback.
4075 % \begin{macrocode}
4076 luatexbase.add_to_callback("luaotfload.patch_font",
4077 mathfont.adjust_font, "mathfont.adjust_font")
4078 % \end{macrocode}
4079 %
4080 %
4081 %
4082 % \section{Adjust Fonts: Metrics}
4083 %
4084 %
4085 %
4086 % This section contains the default charm information for the characters that \textsf{mathfont} adjusts upon loading a font. We start with uppercase Latin letters. The first set of numbers applies to upright fonts, and the second set applies to italic/slanted fonts.
4087 % \begin{macrocode}
4088 mathfont:new_type_a(0x41, {0,0,0,0}, {50,0,150,0}) %A
4089 mathfont:new_type_a(0x42, {0,0,0,0}, {0,0,0,0}) %B
4090 mathfont:new_type_a(0x43, {0,0,50,0}, {0,0,50,0}) %C
4091 mathfont:new_type_a(0x44, {0,0,0,0}, {50,0,0,0}) %D
4092 mathfont:new_type_a(0x45, {0,0,0,0}, {50,0,0,0}) %E
4093 mathfont:new_type_a(0x46, {0,0,0,0}, {50,0,0,0}) %F
4094 mathfont:new_type_a(0x47, {0,0,0,0}, {0,0,0,0}) %G
4095 mathfont:new_type_a(0x48, {0,0,0,0}, {50,0,0,0}) %H
4096 mathfont:new_type_a(0x49, {0,0,0,0}, {50,0,50,0}) %I
4097 mathfont:new_type_a(0x4A, {0,0,100,0}, {50,0,100,0}) %J
4098 mathfont:new_type_a(0x4B, {0,0,0,0}, {50,0,0,0}) %K
4099 mathfont:new_type_a(0x4C, {0,0,-200,0}, {50,0,-100,0}) %L
4100 mathfont:new_type_a(0x4D, {0,0,0,0}, {50,0,0,0}) %M
4101 mathfont:new_type_a(0x4E, {0,0,0,0}, {50,0,0,0}) %N
4102 mathfont:new_type_a(0x4F, {0,0,0,0}, {0,0,50,0}) %O
4103 mathfont:new_type_a(0x50, {0,0,0,0}, {50,0,0,0}) %P
4104 mathfont:new_type_a(0x51, {0,0,0,0}, {0,0,50,0}) %Q
4105 mathfont:new_type_a(0x52, {0,0,0,0}, {50,0,0,0}) %R
4106 mathfont:new_type_a(0x53, {0,0,0,0}, {0,0,0,0}) %S
4107 mathfont:new_type_a(0x54, {0,0,0,0}, {0,0,0,0}) %T
4108 mathfont:new_type_a(0x55, {0,0,0,0}, {0,0,0,0}) %U
4109 mathfont:new_type_a(0x56, {0,0,0,0}, {0,0,0,0}) %V
4110 mathfont:new_type_a(0x57, {0,0,0,0}, {0,0,0,0}) %W
4111 mathfont:new_type_a(0x58, {0,0,0,0}, {50,0,0,0}) %X
4112 mathfont:new_type_a(0x59, {0,0,0,0}, {0,0,0,0}) %Y
4113 mathfont:new_type_a(0x5A, {0,0,0,0}, {50,0,0,0}) %Z
4114 % \end{macrocode}
4115 % Lowercase Latin letters.
4116 % \begin{macrocode}
4117 mathfont:new_type_a(0x61, {0,0,0,0}, {0,0,0,0}) %a
4118 mathfont:new_type_a(0x62, {0,0,0,0}, {0,0,0,0}) %b
4119 mathfont:new_type_a(0x63, {0,0,0,0}, {0,0,100,0}) %c
4120 mathfont:new_type_a(0x64, {0,0,0,0}, {0,0,0,0}) %d
4121 mathfont:new_type_a(0x65, {0,0,0,0}, {0,0,100,0}) %e
4122 mathfont:new_type_a(0x66, {0,400,300,0}, {150,0,50,0}) %f
4123 mathfont:new_type_a(0x67, {0,0,0,0}, {0,0,0,0}) %g
4124 mathfont:new_type_a(0x68, {0,0,0,0}, {0,0,0,0}) %h
4125 mathfont:new_type_a(0x69, {0,0,0,0}, {0,0,0,0}) %i
4126 mathfont:new_type_a(0x6A, {100,0,0,0}, {200,0,0,0}) %j
4127 mathfont:new_type_a(0x6B, {0,0,0,0}, {0,0,0,0}) %k
4128 mathfont:new_type_a(0x6C, {0,0,0,0}, {0,0,0,0}) %l
4129 mathfont:new_type_a(0x6D, {0,0,0,0}, {0,0,50,0}) %m
4130 mathfont:new_type_a(0x6E, {0,0,0,0}, {0,0,50,0}) %n
4131 mathfont:new_type_a(0x6F, {0,0,0,0}, {0,0,100,0}) %o
4132 mathfont:new_type_a(0x70, {0,0,0,0}, {0,0,100,0}) %p
4133 mathfont:new_type_a(0x71, {0,0,0,0}, {0,0,0,0}) %q
4134 mathfont:new_type_a(0x72, {0,0,0,0}, {0,0,50,0}) %r
4135 mathfont:new_type_a(0x73, {0,0,0,0}, {0,0,0,0}) %s
4136 mathfont:new_type_a(0x74, {0,0,0,0}, {0,0,0,0}) %t
4137 mathfont:new_type_a(0x75, {0,0,0,0}, {0,0,0,0}) %u
4138 mathfont:new_type_a(0x76, {0,0,0,0}, {0,0,50,0}) %v
4139 mathfont:new_type_a(0x77, {0,0,0,0}, {0,0,50,0}) %w
4140 mathfont:new_type_a(0x78, {0,0,0,0}, {0,0,50,0}) %x
4141 mathfont:new_type_a(0x79, {0,0,0,0}, {0,0,50,0}) %y
4142 mathfont:new_type_a(0x7A, {0,0,0,0}, {0,0,0,0}) %z
4143 mathfont:new_type_a(0x131, {0,0,0,0}, {0,0,50,0}) %\imath
4144 mathfont:new_type_a(0x237, {0,0,0,0}, {200,0,50,0}) %\jmath
4145 % \end{macrocode}
4146 % Uppercase Greek characters.
4147 % \begin{macrocode}
4148 mathfont:new_type_a(0x391, {0,0,0,0}, {50,0,150,0}) %\Alpha
4149 mathfont:new_type_a(0x392, {0,0,0,0}, {50,0,0,0}) %\Beta
4150 mathfont:new_type_a(0x393, {0,0,0,0}, {50,0,0,0}) %\Gamma
4151 mathfont:new_type_a(0x394, {0,0,0,0}, {50,0,150,0}) %\Delta
4152 mathfont:new_type_a(0x395, {0,0,0,0}, {50,0,0,0}) %\Epsilon
4153 mathfont:new_type_a(0x396, {0,0,0,0}, {50,0,0,0}) %\Zeta
4154 mathfont:new_type_a(0x397, {0,0,0,0}, {50,0,0,0}) %\Eta
4155 mathfont:new_type_a(0x398, {0,0,0,0}, {0,0,50,0}) %\Theta
4156 mathfont:new_type_a(0x399, {0,0,0,0}, {50,0,0,0}) %\Iota
4157 mathfont:new_type_a(0x39A, {0,0,0,0}, {50,0,0,0}) %\Kappa
4158 mathfont:new_type_a(0x39B, {0,0,0,0}, {0,0,150,0}) %\Lambda
4159 mathfont:new_type_a(0x39C, {0,0,0,0}, {50,0,0,0}) %\Mu
4160 mathfont:new_type_a(0x39D, {0,0,0,0}, {50,0,0,0}) %\Nu
4161 mathfont:new_type_a(0x39E, {0,0,0,0}, {0,0,0,0}) %\Xi
4162 mathfont:new_type_a(0x39F, {0,0,0,0}, {0,0,50,0}) %\Omicron
4163 mathfont:new_type_a(0x3A0, {0,0,0,0}, {50,0,0,0}) %\Pi
4164 mathfont:new_type_a(0x3A1, {0,0,0,0}, {50,0,0,0}) %\Rho
4165 mathfont:new_type_a(0x3A3, {0,0,0,0}, {50,0,0,0}) %\Sigma
4166 mathfont:new_type_a(0x3A4, {0,0,0,0}, {0,0,0,0}) %\Tau
4167 mathfont:new_type_a(0x3A5, {0,0,0,0}, {0,0,0,0}) %\Upsilon
4168 mathfont:new_type_a(0x3A6, {0,0,0,0}, {0,0,50,0}) %\Phi
4169 mathfont:new_type_a(0x3A7, {0,0,0,0}, {50,0,0,0}) %\Chi
4170 mathfont:new_type_a(0x3A8, {0,0,0,0}, {0,0,0,0}) %\Psi
4171 mathfont:new_type_a(0x3A9, {0,0,0,0}, {0,0,50,0}) %\Omega
4172 mathfont:new_type_a(0x3F4, {0,0,0,0}, {0,0,50,0}) %\varTheta
4173 % \end{macrocode}
4174 % Lowercase Greek characters.
4175 % \begin{macrocode}
4176 mathfont:new_type_a(0x3B1, {0,0,0,0}, {0,0,0,0}) %\alpha
4177 mathfont:new_type_a(0x3B2, {0,0,0,0}, {0,0,0,0}) %\beta
4178 mathfont:new_type_a(0x3B3, {0,0,0,0}, {0,0,0,0}) %\gamma
4179 mathfont:new_type_a(0x3B4, {0,0,0,0}, {0,0,0,0}) %\delta
4180 mathfont:new_type_a(0x3B5, {0,0,50,0}, {0,0,50,0}) %\epsilon
4181 mathfont:new_type_a(0x3B6, {0,0,50,0}, {0,0,0,0}) %\zeta
4182 mathfont:new_type_a(0x3B7, {0,0,50,0}, {0,0,0,0}) %\eta
4183 mathfont:new_type_a(0x3B8, {0,0,0,0}, {0,0,100,0}) %\theta
4184 mathfont:new_type_a(0x3B9, {0,0,0,0}, {0,0,50,0}) %\iota
4185 mathfont:new_type_a(0x3BA, {0,0,0,0}, {0,0,0,0}) %\kappa
4186 mathfont:new_type_a(0x3BB, {0,0,-150,0}, {0,0,-100,0}) %\lambda
4187 mathfont:new_type_a(0x3BC, {0,0,0,0}, {0,0,100,0}) %\mu
4188 mathfont:new_type_a(0x3BD, {0,0,0,0}, {0,0,50,0}) %\nu
4189 mathfont:new_type_a(0x3BE, {0,0,0,0}, {0,0,50,0}) %\xi
4190 mathfont:new_type_a(0x3BF, {0,0,0,0}, {0,0,50,0}) %\omicron
4191 mathfont:new_type_a(0x3C0, {0,0,0,0}, {0,0,0,0}) %\pi
4192 mathfont:new_type_a(0x3C1, {0,0,0,0}, {0,0,50,0}) %\rho
4193 mathfont:new_type_a(0x3C3, {0,0,0,0}, {0,0,0,0}) %\sigma
4194 mathfont:new_type_a(0x3C4, {0,0,0,0}, {0,0,50,0}) %\tau
4195 mathfont:new_type_a(0x3C5, {0,0,0,0}, {0,0,0,0}) %\upsilon
4196 mathfont:new_type_a(0x3C6, {0,0,0,0}, {0,0,0,0}) %\phi
4197 mathfont:new_type_a(0x3C7, {0,0,0,0}, {50,0,50,0}) %\chi
4198 mathfont:new_type_a(0x3C8, {0,0,0,0}, {0,0,0,0}) %\psi
4199 mathfont:new_type_a(0x3C9, {0,0,0,0}, {0,0,50,0}) %\omega
4200 mathfont:new_type_a(0x3D0, {0,0,0,0}, {0,0,0,0}) %\varbeta
4201 mathfont:new_type_a(0x3F5, {0,0,0,0}, {0,0,50,0}) %\varepsilon
4202 mathfont:new_type_a(0x3D1, {0,0,150,0}, {0,0,100,0}) %\vartheta
4203 mathfont:new_type_a(0x3F1, {0,0,0,0}, {0,0,50,0}) %\varrho
4204 mathfont:new_type_a(0x3C2, {0,0,100,0}, {0,0,50,0}) %\varsigma
4205 mathfont:new_type_a(0x3D5, {0,0,0,0}, {0,0,100,0}) %\varphi
4206 % \end{macrocode}
4207 % We add the charm information for delimiters and other resizable characters. We divide the characters into four categories depending on how we want to magnify the base glyph to create large variants: delimiters, big operators, vertical characters, and the integral sign. We automate the process by putting charm information for each category of character into a separate table and feeding the whole thing to a wrapper around |:new_type_e|.
4208 % \begin{macrocode}
4209 local delim_glyphs = {40, % (
4210 41, % )
4211 47, % /
4212 91, % [
4213 92, % backslash
4214 93, % ]
4215 123, % {
4216 125, % }
4217 8249, % \lguil
4218 8250, % \rguil
4219 171, % \llguil
4220 187, % \rrguil
4221 mathfont.fakel, % \fakelangle
4222 mathfont.faker, % \fakerangle
4223 mathfont.fakell, % \fakellangle
4224 mathfont.fakerr} % \fakerrangle
4225 local big_op_glyphs = {33, % !
4226 35, % #
4227 36, % $
4228 37, % %
4229 38, % &
4230 43, % +
4231 63, % ?
4232 64, % @
4233 167, % \S
4234 215, % \times
4235 247, % \div
4236 8719, % \prod
4237 8721, % \sum
4238 8720, % \coprod
4239 8897, % \bigvee
4240 8896, % \bigwedge
4241 8899, % \bigcup
4242 8898, % \bigcap
4243 10753, % \bigoplus
4244 10754, % \bigotimes
4245 10752, % \bigodot
4246 10757, % \bigsqcap
4247 10758} % \bigsqcup
4248 local vert_glyphs = {124, 8730} % | and \surd
4249 local int_glyphs = {8747, % \intop
4250 8748, % \iint
4251 8749, % \iiint
4252 8750, % \oint
4253 8751, % \oiint
4254 8752} % \oiiint
4255 % \end{macrocode}
4256 % Each category of type |e| character will have its own table of charm information with different magnification values. each table is initially empty.
4257 % \begin{macrocode}
4258 local delim_scale = {}
4259 local big_op_scale = {}
4260 local vert_scale = {}
4261 local int_scale = {}
4262 % \end{macrocode}
4263 % Populate each table with magnification information. For every type |e| character we will create fifteen larger variants in the font. Delimiters stretch mostly vertically and some horzontally. Vertical characters stretch vertically only, so their horizontal scale factors are all constant. Big operators stretch the same in vertical and horizoontal directions.
4264 % \begin{macrocode}
4265 for i = 1, 15, 1 do
4266 delim_scale[2*i-1] = 1000 + 100*i % delimiters - horizontal
4267 delim_scale[2*i] = 1000 + 500*i % delimiters - vertical
4268 vert_scale[2*i-1] = 1000
4269 vert_scale[2*i] = 1000 + 500*i % vertically scaled chars
4270 big_op_scale[2*i-1] = 1000 + 100*i % big operators - horizontal
4271 big_op_scale[2*i] = 1000 + 100*i % big operators - vertical
4272 % \end{macrocode}
4273 % The integral sign is different. Visually, we would like an integral symbol that is larger than the large operators, which means that the integral sign should have no variants between the font's value of |\Umathoperatorsize| and the desired larger size. Accordingly, I decided it would be easiest to have large variants of the integral sign jump by large enough scale factors that the smallest variant larger than the regular size is already significantly larger than the |\Umathoperatorsize| setting in |populate_math_constants|. Effectively this means that the user should take the size of the integral operator as fixed and should set |\Umathoperatorsize| to make all other big operators the desired size.
4274 % \begin{macrocode}
4275 int_scale[2*i-1] = 1000 + 500*i % integral sign - horizontal
4276 int_scale[2*i] = 1000 + 1500*i % integral sign - vertical
4277 end
4278 % \end{macrocode}
4279 % We do not modify accent placement or italic corrections.
4280 % \begin{macrocode}
4281 delim_scale[31] = 0
4282 delim_scale[32] = 0
4283 delim_scale[33] = 0
4284 big_op_scale[31] = 0
4285 big_op_scale[32] = 0
4286 big_op_scale[33] = 0
4287 vert_scale[31] = 0
4288 vert_scale[32] = 0
4289 vert_scale[33] = 0
4290 int_scale[31] = 0
4291 int_scale[32] = 0
4292 int_scale[33] = 0
4293 % \end{macrocode}
4294 % The wrapper for |:new_type_e|. We feed it a list of characters to create charm information for and a table of scaling information.
4295 % \begin{macrocode}
4296 function mathfont:add_extensible_variants(char_list, scale_list)
4297 local variants = (\string# scale_list - 3) / 2
4298 for i = 1, \string# char_list, 1 do
4299 self:new_type_e(char_list[i], scale_list, scale_list)
4300 end
4301 end
4302 % \end{macrocode}
4303 % Add the charm information for the type |e| characters.
4304 % \begin{macrocode}
4305 mathfont:add_extensible_variants(delim_glyphs, delim_scale)
4306 mathfont:add_extensible_variants(big_op_glyphs, big_op_scale)
4307 mathfont:add_extensible_variants(vert_glyphs, vert_scale)
4308 mathfont:add_extensible_variants(int_glyphs, int_scale)
4309 % \end{macrocode}
4310 % Finally, end the call to |\directlua| and balance the preceeding conditional.
4311 % \begin{macrocode}
4312 }
4313 \fi % matches previous \ifM@adjust@font
4314 % \end{macrocode}
4315 %
4316 %
4317 %
4318 %
4319 % \section{Unicode Hex Values}
4320 %
4321 % For this section, we don't want any |\endlinechar|s present when \TeX\ scans things because we want to eliminate any extra spaces, so before anything else, we set |\endlinechar| to $-1$.
4322 % \begin{macrocode}
4323 \count@\endlinechar
4324 \endlinechar\m@ne
4325 % \end{macrocode}
4326 % We have to save |\mathchar@type| to use after |\begin{document}| because \LaTeX\ feeds it to |\@onlypreamble|.
4327 % \begin{macrocode}
4328 \let\@@mathchar@type\mathchar@type
4329 % \end{macrocode}
4330 % We define |\M@sym@|, which is a wrapper around |\Umathchardef| or |\Umathcode| and is \textsf{mathfont}'s version of |\DeclareMathSymbol|. Before version 3.0, \textsf{mathfont} used |\DeclareMathSymbol|, but we create our own version to support Unicode input. The command first checks whether |#1| is a control sequence. If yes, we define it using |\Umathchardef| and again using |\Umathcode|. Otherwise, we define it once with |\Umathcode|.
4331 % \begin{macrocode}
4332 \def\M@sym@#1#2#3#4{
4333 \ifcat\relax\noexpand#1
4334 % \end{macrocode}
4335 % Check if we're redefining a previously declared math symbol. We put |mathchar| in |\if@| so we don't have to check for |\mathchar| and |\Umathchar| separately. We use |\string| so that the letters in |mathchar| have catcode 12 when we check for their presence in |\meaning#1| with |\in@|. If |#1| is undefined, |\in@| will set |\ifin@| to false.
4336 % \begin{macrocode}
4337 \expandafter\in@\expanded
4338 {{\expandafter\@gobble\string\mathchar}{\meaning#1}}
4339 \ifin@
4340 % \end{macrocode}
4341 % Now redeclare the symbol.
4342 % \begin{macrocode}
4343 \Umathchardef#1=+\@@mathchar@type#2
4344 +\csname sym#3\endcsname+#4\relax
4345 % \end{macrocode}
4346 % The next two lines implement Unicode input.
4347 % \begin{macrocode}
4348 \Umathcode #4=+\@@mathchar@type#2
4349 +\csname sym#3\endcsname+#4\relax
4350 % \end{macrocode}
4351 % If |#1| does not code for a math symbol, we check whether it is already defined. If no, we define it, and if yes, we issue an error. Again, we implement Unicode input.
4352 % \begin{macrocode}
4353 \else
4354 \ifx#1\@undefined
4355 \Umathchardef#1=+\@@mathchar@type#2
4356 +\csname sym#3\endcsname+#4\relax
4357 \Umathcode #4=+\@@mathchar@type#2
4358 +\csname sym#3\endcsname+#4\relax
4359 \else
4360 \@latex@error{Command "\string#1" already defined}\@eha
4361 \fi
4362 \fi
4363 % \end{macrocode}
4364 % Easy to deal with the case where |#1| is a single character.
4365 % \begin{macrocode}
4366 \else
4367 \Umathcode`#1=+\@@mathchar@type#2+\csname sym#3\endcsname
4368 +#4\relax
4369 \fi}
4370 % \end{macrocode}
4371 % Similar deal for accents; |\M@acc@| is our version of |\DeclareMathAccent|. Newer versions of the \LaTeX\ kernel define math accents as robust commands, so we have to incorporate a check for robustness as well. We let |\@tempswa| be true or false according to whether we can (re)define the control sequence |#1| as a math accent.
4372 % \begin{macrocode}
4373 \def\M@acc@#1#2#3#4{
4374 \begingroup
4375 \@tempswatrue
4376 \ifdefined#1
4377 \expandafter\in@\expanded{
4378 {\expandafter\@gobble\string\mathaccent}
4379 {\meaning#1}}
4380 \ifin@
4381 \else
4382 \begingroup
4383 \escapechar\m@ne
4384 \expandafter
4385 \endgroup
4386 \expandafter\in@\expanded{
4387 {\string\mathaccent}
4388 {\expandafter\meaning\csname\string#1\space\endcsname}}
4389 \ifin@
4390 \else
4391 \@tempswafalse
4392 \fi
4393 \fi
4394 \fi
4395 \expandafter
4396 \endgroup
4397 % \end{macrocode}
4398 % Now (re)define the command or issue an error.
4399 % \begin{macrocode}
4400 \if@tempswa
4401 \protected\edef#1{\Umathaccent+\@@mathchar@type#2
4402 +\csname sym#3\endcsname+#4\relax}
4403 \else
4404 \@latex@error{Command "\string#1" already defined}\@eha
4405 \fi}
4406 % \end{macrocode}
4407 % Set upper-case Latin characters. We use an |\edef| for |\M@upper@id| because every expansion now will save \LaTeX\ twenty-six expansions later when it evaluates each |\DeclareMathSymbol|. If the user has enabled Lua font adjustments, we set the mathcodes to use encoding slots in the Math Alphanumeric Symbols block.
4408 % \begin{macrocode}
4409 \def\M@upper@set{
4410 \edef\M@upper@id{M\@tempc-\M@uppershape}
4411 \M@sym@{A}{\mathalpha}{\M@upper@id}{`A}
4412 \M@sym@{B}{\mathalpha}{\M@upper@id}{`B}
4413 \M@sym@{C}{\mathalpha}{\M@upper@id}{`C}
4414 \M@sym@{D}{\mathalpha}{\M@upper@id}{`D}
4415 \M@sym@{E}{\mathalpha}{\M@upper@id}{`E}
4416 \M@sym@{F}{\mathalpha}{\M@upper@id}{`F}
4417 \M@sym@{G}{\mathalpha}{\M@upper@id}{`G}
4418 \M@sym@{H}{\mathalpha}{\M@upper@id}{`H}
4419 \M@sym@{I}{\mathalpha}{\M@upper@id}{`I}
4420 \M@sym@{J}{\mathalpha}{\M@upper@id}{`J}
4421 \M@sym@{K}{\mathalpha}{\M@upper@id}{`K}
4422 \M@sym@{L}{\mathalpha}{\M@upper@id}{`L}
4423 \M@sym@{M}{\mathalpha}{\M@upper@id}{`M}
4424 \M@sym@{N}{\mathalpha}{\M@upper@id}{`N}
4425 \M@sym@{O}{\mathalpha}{\M@upper@id}{`O}
4426 \M@sym@{P}{\mathalpha}{\M@upper@id}{`P}
4427 \M@sym@{Q}{\mathalpha}{\M@upper@id}{`Q}
4428 \M@sym@{R}{\mathalpha}{\M@upper@id}{`R}
4429 \M@sym@{S}{\mathalpha}{\M@upper@id}{`S}
4430 \M@sym@{T}{\mathalpha}{\M@upper@id}{`T}
4431 \M@sym@{U}{\mathalpha}{\M@upper@id}{`U}
4432 \M@sym@{V}{\mathalpha}{\M@upper@id}{`V}
4433 \M@sym@{W}{\mathalpha}{\M@upper@id}{`W}
4434 \M@sym@{X}{\mathalpha}{\M@upper@id}{`X}
4435 \M@sym@{Y}{\mathalpha}{\M@upper@id}{`Y}
4436 \M@sym@{Z}{\mathalpha}{\M@upper@id}{`Z}}
4437 % \end{macrocode}
4438 % Set lower-case Latin characters.
4439 % \begin{macrocode}
4440 \def\M@lower@set{
4441 \edef\M@lower@id{M\@tempc-\M@lowershape}
4442 \M@sym@{a}{\mathalpha}{\M@lower@id}{`a}
4443 \M@sym@{b}{\mathalpha}{\M@lower@id}{`b}
4444 \M@sym@{c}{\mathalpha}{\M@lower@id}{`c}
4445 \M@sym@{d}{\mathalpha}{\M@lower@id}{`d}
4446 \M@sym@{e}{\mathalpha}{\M@lower@id}{`e}
4447 \M@sym@{f}{\mathalpha}{\M@lower@id}{`f}
4448 \M@sym@{g}{\mathalpha}{\M@lower@id}{`g}
4449 \M@sym@{h}{\mathalpha}{\M@lower@id}{`h}
4450 \M@sym@{i}{\mathalpha}{\M@lower@id}{`i}
4451 \M@sym@{j}{\mathalpha}{\M@lower@id}{`j}
4452 \M@sym@{k}{\mathalpha}{\M@lower@id}{`k}
4453 \M@sym@{l}{\mathalpha}{\M@lower@id}{`l}
4454 \M@sym@{m}{\mathalpha}{\M@lower@id}{`m}
4455 \M@sym@{n}{\mathalpha}{\M@lower@id}{`n}
4456 \M@sym@{o}{\mathalpha}{\M@lower@id}{`o}
4457 \M@sym@{p}{\mathalpha}{\M@lower@id}{`p}
4458 \M@sym@{q}{\mathalpha}{\M@lower@id}{`q}
4459 \M@sym@{r}{\mathalpha}{\M@lower@id}{`r}
4460 \M@sym@{s}{\mathalpha}{\M@lower@id}{`s}
4461 \M@sym@{t}{\mathalpha}{\M@lower@id}{`t}
4462 \M@sym@{u}{\mathalpha}{\M@lower@id}{`u}
4463 \M@sym@{v}{\mathalpha}{\M@lower@id}{`v}
4464 \M@sym@{w}{\mathalpha}{\M@lower@id}{`w}
4465 \M@sym@{x}{\mathalpha}{\M@lower@id}{`x}
4466 \M@sym@{y}{\mathalpha}{\M@lower@id}{`y}
4467 \M@sym@{z}{\mathalpha}{\M@lower@id}{`z}
4468 \M@sym@{\imath}{\mathalpha}{\M@lower@id}{"131}
4469 \M@sym@{\jmath}{\mathalpha}{\M@lower@id}{"237}
4470 \let\hbar\@undefined
4471 \M@sym@{\hbar}{\mathord}{\M@lower@id}{"127}}
4472 % \end{macrocode}
4473 % Set diacritics.
4474 % \begin{macrocode}
4475 \def\M@diacritics@set{
4476 \edef\M@diacritics@id{M\@tempc-\M@diacriticsshape}
4477 \M@acc@{\acute} {\mathalpha}{\M@diacritics@id}{"B4}
4478 \M@acc@{\aacute} {\mathalpha}{\M@diacritics@id}{"2DD}
4479 \M@acc@{\dot} {\mathalpha}{\M@diacritics@id}{"2D9}
4480 \M@acc@{\ddot} {\mathalpha}{\M@diacritics@id}{"A8}
4481 \M@acc@{\grave} {\mathalpha}{\M@diacritics@id}{"60}
4482 \M@acc@{\breve} {\mathalpha}{\M@diacritics@id}{"2D8}
4483 \M@acc@{\hat} {\mathalpha}{\M@diacritics@id}{"2C6}
4484 \M@acc@{\check} {\mathalpha}{\M@diacritics@id}{"2C7}
4485 \M@acc@{\bar} {\mathalpha}{\M@diacritics@id}{"2C9}
4486 \M@acc@{\mathring}{\mathalpha}{\M@diacritics@id}{"2DA}
4487 \M@acc@{\tilde} {\mathalpha}{\M@diacritics@id}{"2DC}}
4488 % \end{macrocode}
4489 % Set capital Greek characters.
4490 % \begin{macrocode}
4491 \def\M@greekupper@set{
4492 \edef\M@greekupper@id{M\@tempc-\M@greekuppershape}
4493 \M@sym@{\Alpha} {\mathalpha}{\M@greekupper@id}{"391}
4494 \M@sym@{\Beta} {\mathalpha}{\M@greekupper@id}{"392}
4495 \M@sym@{\Gamma} {\mathalpha}{\M@greekupper@id}{"393}
4496 \M@sym@{\Delta} {\mathalpha}{\M@greekupper@id}{"394}
4497 \M@sym@{\Epsilon} {\mathalpha}{\M@greekupper@id}{"395}
4498 \M@sym@{\Zeta} {\mathalpha}{\M@greekupper@id}{"396}
4499 \M@sym@{\Eta} {\mathalpha}{\M@greekupper@id}{"397}
4500 \M@sym@{\Theta} {\mathalpha}{\M@greekupper@id}{"398}
4501 \M@sym@{\Iota} {\mathalpha}{\M@greekupper@id}{"399}
4502 \M@sym@{\Kappa} {\mathalpha}{\M@greekupper@id}{"39A}
4503 \M@sym@{\Lambda} {\mathalpha}{\M@greekupper@id}{"39B}
4504 \M@sym@{\Mu} {\mathalpha}{\M@greekupper@id}{"39C}
4505 \M@sym@{\Nu} {\mathalpha}{\M@greekupper@id}{"39D}
4506 \M@sym@{\Xi} {\mathalpha}{\M@greekupper@id}{"39E}
4507 \M@sym@{\Omicron} {\mathalpha}{\M@greekupper@id}{"39F}
4508 \M@sym@{\Pi} {\mathalpha}{\M@greekupper@id}{"3A0}
4509 \M@sym@{\Rho} {\mathalpha}{\M@greekupper@id}{"3A1}
4510 \M@sym@{\Sigma} {\mathalpha}{\M@greekupper@id}{"3A3}
4511 \M@sym@{\Tau} {\mathalpha}{\M@greekupper@id}{"3A4}
4512 \M@sym@{\Upsilon} {\mathalpha}{\M@greekupper@id}{"3A5}
4513 \M@sym@{\Phi} {\mathalpha}{\M@greekupper@id}{"3A6}
4514 \M@sym@{\Chi} {\mathalpha}{\M@greekupper@id}{"3A7}
4515 \M@sym@{\Psi} {\mathalpha}{\M@greekupper@id}{"3A8}
4516 \M@sym@{\Omega} {\mathalpha}{\M@greekupper@id}{"3A9}
4517 \M@sym@{\varTheta}{\mathalpha}{\M@greekupper@id}{"3F4}
4518 % \end{macrocode}
4519 % Declare |\increment| and |\nabla| if they haven't already been declared in the |symbols| or |extsymbols| fonts.
4520 % \begin{macrocode}
4521 \ifM@adjust@font
4522 \ifM@symbols\else
4523 \M@sym@{\increment}
4524 {\mathord}{\M@greekupper@id}{"2206}
4525 \M@sym@{\nabla}
4526 {\mathord}{\M@greekupper@id}{"2207}
4527 \fi
4528 \else
4529 \ifM@symbols\else
4530 \M@sym@{\increment}
4531 {\mathord}{\M@greekupper@id}{"2206}
4532 \fi
4533 \ifM@extsymbols\else
4534 \M@sym@{\nabla}
4535 {\mathord}{\M@greekupper@id}{"2207}
4536 \fi
4537 \fi}
4538 % \end{macrocode}
4539 % Set minuscule Greek characters.
4540 % \begin{macrocode}
4541 \def\M@greeklower@set{
4542 \edef\M@greeklower@id{M\@tempc-\M@greeklowershape}
4543 \M@sym@{\alpha} {\mathalpha}{\M@greeklower@id}{"3B1}
4544 \M@sym@{\beta} {\mathalpha}{\M@greeklower@id}{"3B2}
4545 \M@sym@{\gamma} {\mathalpha}{\M@greeklower@id}{"3B3}
4546 \M@sym@{\delta} {\mathalpha}{\M@greeklower@id}{"3B4}
4547 \M@sym@{\epsilon} {\mathalpha}{\M@greeklower@id}{"3B5}
4548 \M@sym@{\zeta} {\mathalpha}{\M@greeklower@id}{"3B6}
4549 \M@sym@{\eta} {\mathalpha}{\M@greeklower@id}{"3B7}
4550 \M@sym@{\theta} {\mathalpha}{\M@greeklower@id}{"3B8}
4551 \M@sym@{\iota} {\mathalpha}{\M@greeklower@id}{"3B9}
4552 \M@sym@{\kappa} {\mathalpha}{\M@greeklower@id}{"3BA}
4553 \M@sym@{\lambda} {\mathalpha}{\M@greeklower@id}{"3BB}
4554 \M@sym@{\mu} {\mathalpha}{\M@greeklower@id}{"3BC}
4555 \M@sym@{\nu} {\mathalpha}{\M@greeklower@id}{"3BD}
4556 \M@sym@{\xi} {\mathalpha}{\M@greeklower@id}{"3BE}
4557 \M@sym@{\omicron} {\mathalpha}{\M@greeklower@id}{"3BF}
4558 \M@sym@{\pi} {\mathalpha}{\M@greeklower@id}{"3C0}
4559 \M@sym@{\rho} {\mathalpha}{\M@greeklower@id}{"3C1}
4560 \M@sym@{\sigma} {\mathalpha}{\M@greeklower@id}{"3C3}
4561 \M@sym@{\tau} {\mathalpha}{\M@greeklower@id}{"3C4}
4562 \M@sym@{\upsilon} {\mathalpha}{\M@greeklower@id}{"3C5}
4563 \M@sym@{\phi} {\mathalpha}{\M@greeklower@id}{"3C6}
4564 \M@sym@{\chi} {\mathalpha}{\M@greeklower@id}{"3C7}
4565 \M@sym@{\psi} {\mathalpha}{\M@greeklower@id}{"3C8}
4566 \M@sym@{\omega} {\mathalpha}{\M@greeklower@id}{"3C9}
4567 \M@sym@{\varbeta} {\mathalpha}{\M@greeklower@id}{"3D0}
4568 \M@sym@{\varepsilon}{\mathalpha}{\M@greeklower@id}{"3F5}
4569 \M@sym@{\varkappa} {\mathalpha}{\M@greeklower@id}{"3F0}
4570 \M@sym@{\vartheta} {\mathalpha}{\M@greeklower@id}{"3D1}
4571 \M@sym@{\varrho} {\mathalpha}{\M@greeklower@id}{"3F1}
4572 \M@sym@{\varsigma} {\mathalpha}{\M@greeklower@id}{"3C2}
4573 \M@sym@{\varphi} {\mathalpha}{\M@greeklower@id}{"3D5}}
4574 % \end{macrocode}
4575 % Set capital ancient Greek characters.
4576 % \begin{macrocode}
4577 \def\M@agreekupper@set{
4578 \edef\M@agreekupper@id{M\@tempc-\M@agreekuppershape}
4579 \M@sym@{\Heta} {\mathalpha}{\M@agreekupper@id}{"370}
4580 \M@sym@{\Sampi} {\mathalpha}{\M@agreekupper@id}{"3E0}
4581 \M@sym@{\Digamma} {\mathalpha}{\M@agreekupper@id}{"3DC}
4582 \M@sym@{\Koppa} {\mathalpha}{\M@agreekupper@id}{"3D8}
4583 \M@sym@{\Stigma} {\mathalpha}{\M@agreekupper@id}{"3DA}
4584 \M@sym@{\Sho} {\mathalpha}{\M@agreekupper@id}{"3F7}
4585 \M@sym@{\San} {\mathalpha}{\M@agreekupper@id}{"3FA}
4586 \M@sym@{\varSampi} {\mathalpha}{\M@agreekupper@id}{"372}
4587 \M@sym@{\varDigamma}{\mathalpha}{\M@agreekupper@id}{"376}
4588 \M@sym@{\varKoppa} {\mathalpha}{\M@agreekupper@id}{"3DE}}
4589 % \end{macrocode}
4590 % Set minuscule ancient Greek characters.
4591 % \begin{macrocode}
4592 \def\M@agreeklower@set{
4593 \edef\M@agreeklower@id{M\@tempc-\M@agreeklowershape}
4594 \M@sym@{\heta} {\mathalpha}{\M@agreeklower@id}{"371}
4595 \M@sym@{\sampi} {\mathalpha}{\M@agreeklower@id}{"3E1}
4596 \M@sym@{\digamma} {\mathalpha}{\M@agreeklower@id}{"3DD}
4597 \M@sym@{\koppa} {\mathalpha}{\M@agreeklower@id}{"3D9}
4598 \M@sym@{\stigma} {\mathalpha}{\M@agreeklower@id}{"3DB}
4599 \M@sym@{\sho} {\mathalpha}{\M@agreeklower@id}{"3F8}
4600 \M@sym@{\san} {\mathalpha}{\M@agreeklower@id}{"3FB}
4601 \M@sym@{\varsampi} {\mathalpha}{\M@agreeklower@id}{"373}
4602 \M@sym@{\vardigamma}{\mathalpha}{\M@agreeklower@id}{"377}
4603 \M@sym@{\varkoppa} {\mathalpha}{\M@agreeklower@id}{"3DF}}
4604 % \end{macrocode}
4605 % Set capital Cyrillic characters.
4606 % \begin{macrocode}
4607 \def\M@cyrillicupper@set{
4608 \edef\M@cyrillicupper@id{M\@tempc-\M@cyrillicuppershape}
4609 \M@sym@{\cyrA} {\mathalpha}{\M@cyrillicupper@id}{"410}
4610 \M@sym@{\cyrBe} {\mathalpha}{\M@cyrillicupper@id}{"411}
4611 \M@sym@{\cyrVe} {\mathalpha}{\M@cyrillicupper@id}{"412}
4612 \M@sym@{\cyrGhe} {\mathalpha}{\M@cyrillicupper@id}{"413}
4613 \M@sym@{\cyrDe} {\mathalpha}{\M@cyrillicupper@id}{"414}
4614 \M@sym@{\cyrIe} {\mathalpha}{\M@cyrillicupper@id}{"415}
4615 \M@sym@{\cyrZhe} {\mathalpha}{\M@cyrillicupper@id}{"416}
4616 \M@sym@{\cyrZe} {\mathalpha}{\M@cyrillicupper@id}{"417}
4617 \M@sym@{\cyrI} {\mathalpha}{\M@cyrillicupper@id}{"418}
4618 \M@sym@{\cyrKa} {\mathalpha}{\M@cyrillicupper@id}{"41A}
4619 \M@sym@{\cyrEl} {\mathalpha}{\M@cyrillicupper@id}{"41B}
4620 \M@sym@{\cyrEm} {\mathalpha}{\M@cyrillicupper@id}{"41C}
4621 \M@sym@{\cyrEn} {\mathalpha}{\M@cyrillicupper@id}{"41D}
4622 \M@sym@{\cyrO} {\mathalpha}{\M@cyrillicupper@id}{"41E}
4623 \M@sym@{\cyrPe} {\mathalpha}{\M@cyrillicupper@id}{"41F}
4624 \M@sym@{\cyrEr} {\mathalpha}{\M@cyrillicupper@id}{"420}
4625 \M@sym@{\cyrEs} {\mathalpha}{\M@cyrillicupper@id}{"421}
4626 \M@sym@{\cyrTe} {\mathalpha}{\M@cyrillicupper@id}{"422}
4627 \M@sym@{\cyrU} {\mathalpha}{\M@cyrillicupper@id}{"423}
4628 \M@sym@{\cyrEf} {\mathalpha}{\M@cyrillicupper@id}{"424}
4629 \M@sym@{\cyrHa} {\mathalpha}{\M@cyrillicupper@id}{"425}
4630 \M@sym@{\cyrTse} {\mathalpha}{\M@cyrillicupper@id}{"426}
4631 \M@sym@{\cyrChe} {\mathalpha}{\M@cyrillicupper@id}{"427}
4632 \M@sym@{\cyrSha} {\mathalpha}{\M@cyrillicupper@id}{"428}
4633 \M@sym@{\cyrShcha}{\mathalpha}{\M@cyrillicupper@id}{"429}
4634 \M@sym@{\cyrHard} {\mathalpha}{\M@cyrillicupper@id}{"42A}
4635 \M@sym@{\cyrYeru} {\mathalpha}{\M@cyrillicupper@id}{"42B}
4636 \M@sym@{\cyrSoft} {\mathalpha}{\M@cyrillicupper@id}{"42C}
4637 \M@sym@{\cyrE} {\mathalpha}{\M@cyrillicupper@id}{"42D}
4638 \M@sym@{\cyrYu} {\mathalpha}{\M@cyrillicupper@id}{"42E}
4639 \M@sym@{\cyrYa} {\mathalpha}{\M@cyrillicupper@id}{"42F}
4640 \M@sym@{\cyrvarI} {\mathalpha}{\M@cyrillicupper@id}{"419}}
4641 % \end{macrocode}
4642 % Set minuscule Cyrillic characters.
4643 % \begin{macrocode}
4644 \def\M@cyrilliclower@set{
4645 \edef\M@cyrilliclower@id{M\@tempc-\M@cyrilliclowershape}
4646 \M@sym@{\cyra} {\mathalpha}{\M@cyrilliclower@id}{"430}
4647 \M@sym@{\cyrbe} {\mathalpha}{\M@cyrilliclower@id}{"431}
4648 \M@sym@{\cyrve} {\mathalpha}{\M@cyrilliclower@id}{"432}
4649 \M@sym@{\cyrghe} {\mathalpha}{\M@cyrilliclower@id}{"433}
4650 \M@sym@{\cyrde} {\mathalpha}{\M@cyrilliclower@id}{"434}
4651 \M@sym@{\cyrie} {\mathalpha}{\M@cyrilliclower@id}{"435}
4652 \M@sym@{\cyrzhe} {\mathalpha}{\M@cyrilliclower@id}{"436}
4653 \M@sym@{\cyrze} {\mathalpha}{\M@cyrilliclower@id}{"437}
4654 \M@sym@{\cyri} {\mathalpha}{\M@cyrilliclower@id}{"438}
4655 \M@sym@{\cyrka} {\mathalpha}{\M@cyrilliclower@id}{"43A}
4656 \M@sym@{\cyrel} {\mathalpha}{\M@cyrilliclower@id}{"43B}
4657 \M@sym@{\cyrem} {\mathalpha}{\M@cyrilliclower@id}{"43C}
4658 \M@sym@{\cyren} {\mathalpha}{\M@cyrilliclower@id}{"43D}
4659 \M@sym@{\cyro} {\mathalpha}{\M@cyrilliclower@id}{"43E}
4660 \M@sym@{\cyrpe} {\mathalpha}{\M@cyrilliclower@id}{"43F}
4661 \M@sym@{\cyrer} {\mathalpha}{\M@cyrilliclower@id}{"440}
4662 \M@sym@{\cyres} {\mathalpha}{\M@cyrilliclower@id}{"441}
4663 \M@sym@{\cyrte} {\mathalpha}{\M@cyrilliclower@id}{"442}
4664 \M@sym@{\cyru} {\mathalpha}{\M@cyrilliclower@id}{"443}
4665 \M@sym@{\cyref} {\mathalpha}{\M@cyrilliclower@id}{"444}
4666 \M@sym@{\cyrha} {\mathalpha}{\M@cyrilliclower@id}{"445}
4667 \M@sym@{\cyrtse} {\mathalpha}{\M@cyrilliclower@id}{"446}
4668 \M@sym@{\cyrche} {\mathalpha}{\M@cyrilliclower@id}{"447}
4669 \M@sym@{\cyrsha} {\mathalpha}{\M@cyrilliclower@id}{"448}
4670 \M@sym@{\cyrshcha}{\mathalpha}{\M@cyrilliclower@id}{"449}
4671 \M@sym@{\cyrhard} {\mathalpha}{\M@cyrilliclower@id}{"44A}
4672 \M@sym@{\cyryeru} {\mathalpha}{\M@cyrilliclower@id}{"44B}
4673 \M@sym@{\cyrsoft} {\mathalpha}{\M@cyrilliclower@id}{"44C}
4674 \M@sym@{\cyre} {\mathalpha}{\M@cyrilliclower@id}{"44D}
4675 \M@sym@{\cyryu} {\mathalpha}{\M@cyrilliclower@id}{"44E}
4676 \M@sym@{\cyrya} {\mathalpha}{\M@cyrilliclower@id}{"44F}
4677 \M@sym@{\cyrvari} {\mathalpha}{\M@cyrilliclower@id}{"439}}
4678 % \end{macrocode}
4679 % Set Hebrew characters.
4680 % \begin{macrocode}
4681 \def\M@hebrew@set{
4682 \edef\M@hebrew@id{M\@tempc-\M@hebrewshape}
4683 \M@sym@{\aleph} {\mathalpha}{\M@hebrew@id}{"5D0}
4684 \M@sym@{\beth} {\mathalpha}{\M@hebrew@id}{"5D1}
4685 \M@sym@{\gimel} {\mathalpha}{\M@hebrew@id}{"5D2}
4686 \M@sym@{\daleth} {\mathalpha}{\M@hebrew@id}{"5D3}
4687 \M@sym@{\he} {\mathalpha}{\M@hebrew@id}{"5D4}
4688 \M@sym@{\vav} {\mathalpha}{\M@hebrew@id}{"5D5}
4689 \M@sym@{\zayin} {\mathalpha}{\M@hebrew@id}{"5D6}
4690 \M@sym@{\het} {\mathalpha}{\M@hebrew@id}{"5D7}
4691 \M@sym@{\tet} {\mathalpha}{\M@hebrew@id}{"5D8}
4692 \M@sym@{\yod} {\mathalpha}{\M@hebrew@id}{"5D9}
4693 \M@sym@{\kaf} {\mathalpha}{\M@hebrew@id}{"5DB}
4694 \M@sym@{\lamed} {\mathalpha}{\M@hebrew@id}{"5DC}
4695 \M@sym@{\mem} {\mathalpha}{\M@hebrew@id}{"5DE}
4696 \M@sym@{\nun} {\mathalpha}{\M@hebrew@id}{"5E0}
4697 \M@sym@{\samekh} {\mathalpha}{\M@hebrew@id}{"5E1}
4698 \M@sym@{\ayin} {\mathalpha}{\M@hebrew@id}{"5E2}
4699 \M@sym@{\pe} {\mathalpha}{\M@hebrew@id}{"5E4}
4700 \M@sym@{\tsadi} {\mathalpha}{\M@hebrew@id}{"5E6}
4701 \M@sym@{\qof} {\mathalpha}{\M@hebrew@id}{"5E7}
4702 \M@sym@{\resh} {\mathalpha}{\M@hebrew@id}{"5E8}
4703 \M@sym@{\shin} {\mathalpha}{\M@hebrew@id}{"5E9}
4704 \M@sym@{\tav} {\mathalpha}{\M@hebrew@id}{"5EA}
4705 \M@sym@{\varkaf} {\mathalpha}{\M@hebrew@id}{"5DA}
4706 \M@sym@{\varmem} {\mathalpha}{\M@hebrew@id}{"5DD}
4707 \M@sym@{\varnun} {\mathalpha}{\M@hebrew@id}{"5DF}
4708 \M@sym@{\varpe} {\mathalpha}{\M@hebrew@id}{"5E3}
4709 \M@sym@{\vartsadi}{\mathalpha}{\M@hebrew@id}{"5E5}}
4710 % \end{macrocode}
4711 % Set digits.
4712 % \begin{macrocode}
4713 \def\M@digits@set{
4714 \edef\M@digits@id{M\@tempc-\M@digitsshape}
4715 \M@sym@{0}{\mathalpha}{\M@digits@id}{`0}
4716 \M@sym@{1}{\mathalpha}{\M@digits@id}{`1}
4717 \M@sym@{2}{\mathalpha}{\M@digits@id}{`2}
4718 \M@sym@{3}{\mathalpha}{\M@digits@id}{`3}
4719 \M@sym@{4}{\mathalpha}{\M@digits@id}{`4}
4720 \M@sym@{5}{\mathalpha}{\M@digits@id}{`5}
4721 \M@sym@{6}{\mathalpha}{\M@digits@id}{`6}
4722 \M@sym@{7}{\mathalpha}{\M@digits@id}{`7}
4723 \M@sym@{8}{\mathalpha}{\M@digits@id}{`8}
4724 \M@sym@{9}{\mathalpha}{\M@digits@id}{`9}}
4725 % \end{macrocode}
4726 % Set new operator font.
4727 % We change the |\fam| to the user's requested symbol font for math operators.
4728 % \begin{macrocode}
4729 \def\M@operator@set{
4730 \edef\operator@font{\mathgroup
4731 \csname symM\@tempc-\M@operatorshape\endcsname}}
4732 % \end{macrocode}
4733 % Set delimiters.
4734 % \begin{macrocode}
4735 \ifM@adjust@font
4736 \def\M@delimiters@set{
4737 \edef\M@delimiters@id{M\@tempc-\M@delimitersshape}
4738 \edef\M@delimiters@num{
4739 \csname sym\M@delimiters@id\endcsname}
4740 \M@sym@{(} {\mathopen} {\M@delimiters@id}{"28}
4741 \M@sym@{)} {\mathclose}{\M@delimiters@id}{"29}
4742 \M@sym@{[} {\mathopen} {\M@delimiters@id}{"5B}
4743 \M@sym@{]} {\mathclose}{\M@delimiters@id}{"5D}
4744 \M@sym@{\leftbrace} {\mathopen} {\M@delimiters@id}{"7B}
4745 \M@sym@{\rightbrace}{\mathclose}{\M@delimiters@id}{"7D}
4746 % \end{macrocode}
4747 % Set |\Udelcode|s for delimiters that come from individual characters.
4748 % \begin{macrocode}
4749 \Udelcode"28+\M@delimiters@num+"28\relax % (
4750 \Udelcode"29+\M@delimiters@num+"29\relax % )
4751 \Udelcode"2F+\M@delimiters@num+"2F\relax % /
4752 \Udelcode"5B+\M@delimiters@num+"5B\relax % [
4753 \Udelcode"5D+\M@delimiters@num+"5D\relax % ]
4754 \Udelcode"7C+\M@delimiters@num+"7C\relax % |
4755 \ifM@symbols\else
4756 \M@sym@{|}{\mathord}{\M@delimiters@id}{"7C}
4757 \fi
4758 \let\vert=|
4759 % \end{macrocode}
4760 % For the delimiters that come from control sequences, we use |\edef| and |\Udelimiter|.
4761 % \begin{macrocode}
4762 \protected\def\backslash{
4763 \ifmmode\mathbackslash\else\textbackslash\fi}
4764 \protected\edef\mathbackslash{
4765 \Udelimiter+2+\M@delimiters@num+92\relax}
4766 \protected\edef\lbrace{
4767 \Udelimiter+4+\M@delimiters@num+123\relax}
4768 \protected\edef\rbrace{
4769 \Udelimiter+5+\M@delimiters@num+125\relax}
4770 \protected\edef\lguil{
4771 \Udelimiter+4+\M@delimiters@num+8249\relax}
4772 \protected\edef\rguil{
4773 \Udelimiter+5+\M@delimiters@num+8250\relax}
4774 \protected\edef\llguil{
4775 \Udelimiter+4+\M@delimiters@num+171\relax}
4776 \protected\edef\rrguil{
4777 \Udelimiter+5+\M@delimiters@num+187\relax}
4778 \protected\edef\fakelangle{
4779 \Udelimiter+4+\M@delimiters@num
4780 +\directlua{tex.print(mathfont.fakel)}\relax}
4781 \protected\edef\fakerangle{
4782 \Udelimiter+5+\M@delimiters@num
4783 +\directlua{tex.print(mathfont.faker)}\relax}
4784 \protected\edef\fakellangle{
4785 \Udelimiter+4+\M@delimiters@num
4786 +\directlua{tex.print(mathfont.fakell)}\relax}
4787 \protected\edef\fakerrangle{
4788 \Udelimiter+5+\M@delimiters@num
4789 +\directlua{tex.print(mathfont.fakerr)}\relax}}
4790 \else
4791 \def\M@delimiters@set{
4792 \edef\M@delimiters@id{M\@tempc-\M@delimitersshape}
4793 \M@sym@{(} {\mathopen} {\M@delimiters@id}{"28}
4794 \M@sym@{)} {\mathclose}{\M@delimiters@id}{"29}
4795 \M@sym@{[} {\mathopen} {\M@delimiters@id}{"5B}
4796 \M@sym@{]} {\mathclose}{\M@delimiters@id}{"5D}
4797 \M@sym@{\lguil} {\mathopen} {\M@delimiters@id}{"2039}
4798 \M@sym@{\rguil} {\mathclose}{\M@delimiters@id}{"203A}
4799 \M@sym@{\llguil} {\mathopen} {\M@delimiters@id}{"AB}
4800 \M@sym@{\rrguil} {\mathclose}{\M@delimiters@id}{"BB}
4801 \M@sym@{\leftbrace} {\mathopen} {\M@delimiters@id}{"7B}
4802 \M@sym@{\rightbrace}{\mathclose}{\M@delimiters@id}{"7D}}
4803 \fi
4804 % \end{macrocode}
4805 % Radicals. When we define |\surd| to typeset U+221A, |\M@sym@| sets the |\Umathcode| of \textsurd\ to be a surd symbol. However, if we modified the font, we know the surd character in the requested font can successfully make a square root expression, so we override the definition from |\M@sym@| to turn \textsurd\ to an active character in math mode.
4806 % \begin{macrocode}
4807 \ifM@adjust@font
4808 \def\M@radical@set{
4809 \edef\M@radical@id{M\@tempc-\M@radicalshape}
4810 \let\surd\@undefined
4811 \M@sym@{\surd}{\mathord}{\M@radical@id}{"221A}
4812 % \end{macrocode}
4813 % Now set the |\mathcode| of \textsurd\ to 8000. This is probably me being paranoid, but I wanted to stick to ascii characters in the sty file. We use |\directlua| to print the surd character instead. This also has the advantage of printing an active character, so we don't have to scan any tokens.
4814 % \begin{macrocode}
4815 \expandafter\protected\expandafter\def\directlua{
4816 tex.cprint(13, utf8.char(0x221A))}
4817 {\ifmmode\expandafter\sqrt\else\Uchar"221A\relax\fi}
4818 \mathcode"221A="8000\relax
4819 \edef\@sqrts@gn##1{\Uradical+\number
4820 \csname sym\M@radical@id\endcsname+"221A\relax{##1}}
4821 % \end{macrocode}
4822 % We redefine |\r@@t|, which typesets the degree symbol on an $n$th root. We set the placement so that right side of the box containing the degree lies 60\% of the horizontal distance across the surd symbol, and the baseline of the degree symbol is 60\% of the vertical distance up the surd.
4823 % \begin{macrocode}
4824 \def\r@@t##1##2{
4825 \setbox\z@\hbox{$\m@th##1\sqrtsign{##2}$}
4826 \setbox\surdbox\hbox{$\m@th##1\@sqrts@gn{
4827 \hbox{\vphantom{$\m@th##1##2$}}}$}
4828 \dimen@\ht\surdbox
4829 \advance\dimen@\dp\surdbox
4830 \dimen@=0.6\dimen@
4831 \advance\dimen@-\dp\surdbox
4832 \ifdim\wd\rootbox<0.6\wd\surdbox
4833 \kern0.6\wd\surdbox
4834 \else
4835 \kern\wd\rootbox
4836 \fi
4837 \raise\dimen@\hbox{\llap{\copy\rootbox}}
4838 \kern-0.6\wd\surdbox
4839 \box\z@}
4840 \protected\def\sqrtsign##1{
4841 \@sqrts@gn{\mkern\radicandoffset##1}}}
4842 \else
4843 \def\M@radical@set{
4844 \edef\M@radical@id{M\@tempc-\M@radicalshape}
4845 \let\surd\@undefined
4846 \M@sym@{\surd}{\mathord}{\M@radical@id}{"221A}}
4847 \fi
4848 % \end{macrocode}
4849 % Big operators.
4850 % \begin{macrocode}
4851 \def\M@bigops@set{
4852 \edef\M@bigops@id{M\@tempc-\M@bigopsshape}
4853 \let\sum\@undefined
4854 \let\prod\@undefined
4855 \M@sym@{\sum} {\mathop}{\M@bigops@id}{"2211}
4856 \M@sym@{\prod} {\mathop}{\M@bigops@id}{"220F}
4857 \M@sym@{\intop}{\mathop}{\M@bigops@id}{"222B}}
4858 % \end{macrocode}
4859 % Extended big operators.
4860 % \begin{macrocode}
4861 \def\M@extbigops@set{
4862 \edef\M@extbigops@id{M\@tempc-\M@extbigopsshape}
4863 \let\coprod\@undefined
4864 \let\bigvee\@undefined
4865 \let\bigwedge\@undefined
4866 \let\bigcup\@undefined
4867 \let\bigcap\@undefined
4868 \let\bigoplus\@undefined
4869 \let\bigotimes\@undefined
4870 \let\bigodot\@undefined
4871 \let\bigsqcup\@undefined
4872 \M@sym@{\coprod} {\mathop}{\M@extbigops@id}{"2210}
4873 \M@sym@{\bigvee} {\mathop}{\M@extbigops@id}{"22C1}
4874 \M@sym@{\bigwedge} {\mathop}{\M@extbigops@id}{"22C0}
4875 \M@sym@{\bigcup} {\mathop}{\M@extbigops@id}{"22C3}
4876 \M@sym@{\bigcap} {\mathop}{\M@extbigops@id}{"22C2}
4877 \M@sym@{\iintop} {\mathop}{\M@extbigops@id}{"222C}
4878 \M@sym@{\iiintop} {\mathop}{\M@extbigops@id}{"222D}
4879 \M@sym@{\ointop} {\mathop}{\M@extbigops@id}{"222E}
4880 \M@sym@{\oiintop} {\mathop}{\M@extbigops@id}{"222F}
4881 \M@sym@{\oiiintop} {\mathop}{\M@extbigops@id}{"2230}
4882 \M@sym@{\bigoplus} {\mathop}{\M@extbigops@id}{"2A01}
4883 \M@sym@{\bigotimes}{\mathop}{\M@extbigops@id}{"2A02}
4884 \M@sym@{\bigodot} {\mathop}{\M@extbigops@id}{"2A00}
4885 \M@sym@{\bigsqcap} {\mathop}{\M@extbigops@id}{"2A05}
4886 \M@sym@{\bigsqcup} {\mathop}{\M@extbigops@id}{"2A06}
4887 \protected\def\iint{\iintop\nolimits}
4888 \protected\def\iiint{\iiintop\nolimits}
4889 \protected\def\oint{\ointop\nolimits}
4890 \protected\def\oiint{\oiintop\nolimits}
4891 \protected\def\oiiint{\oiiintop\nolimits}}
4892 % \end{macrocode}
4893 % Set symbols.
4894 % \begin{macrocode}
4895 \def\M@symbols@set{
4896 \edef\M@symbols@id{M\@tempc-\M@symbolsshape}
4897 \let\colon\@undefined
4898 \let\mathellipsis\@undefined
4899 % \end{macrocode}
4900 % Before we start declaring symbols, specifically minus or equals signs, we have to address a minor clash with \textsf{amsmath}. That package defines |\relbar| and |\Relbar| as essentially a minus and equals sign respectively. However, those two control sequences are for making arrows, so they should come from the |arrows| font, not the |symbols| font. If the user already called |\mathfont| with the |arrows| keyword, we do nothing because |\M@arrows@set| defines |\relbar| and |\Relbar| correctly. If not, we make these two control sequences be the current minus and equals sign (before the font changes in |\M@symbols@set|) because that's as good a choice as any, and we prevent \textsf{amsmath} from changing them to the |symbols| font. Users or package authors who want to modify |\relbar| or |\Relbar| should change |\@relbar| or |\@Relbar| respectively.
4901 % \begin{macrocode}
4902 \ifM@arrows\else
4903 \Umathcharnumdef\@relbar=\Umathcodenum`\-
4904 \Umathcharnumdef\@Relbar=\Umathcodenum`\=
4905 \protected\def\relbar{\mathrel
4906 {\mathpalette\mathsm@sh\@relbar}}
4907 \protected\def\Relbar{\@Relbar}
4908 % \end{macrocode}
4909 % We redefine stuff if \textsf{amsmath} gets loaded after \textsf{mathfont}.
4910 % \begin{macrocode}
4911 \@ifpackageloaded{amsmath}
4912 {\relax}{
4913 \let\@@relbar\relbar
4914 \let\@@Relbar\Relbar
4915 \AtBeginDocument{\ifM@arrows\else
4916 \@ifpackageloaded{amsmath}{
4917 \let\relbar\@@relbar
4918 \let\Relbar\@@Relbar}
4919 {\relax}
4920 \fi}}
4921 \fi
4922 % \end{macrocode}
4923 % If the user enabled Lua-based font asjustments, we declare a few more big operators for fun. For brevity, we put the |adjust@font| conditional here rather than redefining |\M@symbols@set|. Apparently, \textsf{newtx} defines |\bigtimes|, so in case that package gets loaded ahead of \textsf{mathfont}, we should make sure to clear that definition. It's important to declare the big operators before the normal versions of these characters so that |\M@sym@| defines the correct |\Umathcode| for them.
4924 % \begin{macrocode}
4925 \ifM@adjust@font
4926 \let\bigtimes\@undefined
4927 \M@sym@{\bigat} {\mathop}{\M@symbols@id}{"40}
4928 \M@sym@{\bighash} {\mathop}{\M@symbols@id}{"23}
4929 \M@sym@{\bigdollar} {\mathop}{\M@symbols@id}{"24}
4930 \M@sym@{\bigpercent}{\mathop}{\M@symbols@id}{"25}
4931 \M@sym@{\bigand} {\mathop}{\M@symbols@id}{"26}
4932 \M@sym@{\bigplus} {\mathop}{\M@symbols@id}{"2B}
4933 \M@sym@{\bigp} {\mathop}{\M@symbols@id}{"21}
4934 \M@sym@{\bigq} {\mathop}{\M@symbols@id}{"3F}
4935 \M@sym@{\bigS} {\mathop}{\M@symbols@id}{"A7}
4936 \M@sym@{\bigtimes} {\mathop}{\M@symbols@id}{"D7}
4937 \M@sym@{\bigdiv} {\mathop}{\M@symbols@id}{"F7}
4938 % \end{macrocode}
4939 % Define |\nabla| here if we're adjusting the font. If we are not doing that, this declaration goes in |extsymbols|.
4940 % \begin{macrocode}
4941 \M@sym@{\nabla} {\mathord}{\M@symbols@id}{"2207}
4942 \fi
4943 % \end{macrocode}
4944 % The rest of the symbols.
4945 % \begin{macrocode}
4946 \M@sym@{.} {\mathord} {\M@symbols@id}{"2E}
4947 \M@sym@{@} {\mathord} {\M@symbols@id}{"40}
4948 \M@sym@{'} {\mathord} {\M@symbols@id}{"2032}
4949 \M@sym@{\prime} {\mathord} {\M@symbols@id}{"2032}
4950 \M@sym@{"} {\mathord} {\M@symbols@id}{"2033}
4951 \M@sym@{\mathhash} {\mathord} {\M@symbols@id}{"23}
4952 \M@sym@{\mathdollar} {\mathord} {\M@symbols@id}{"24}
4953 \M@sym@{\mathpercent} {\mathord} {\M@symbols@id}{"25}
4954 \M@sym@{\mathand} {\mathord} {\M@symbols@id}{"26}
4955 \M@sym@{\mathparagraph}{\mathord} {\M@symbols@id}{"B6}
4956 \M@sym@{\mathsection} {\mathord} {\M@symbols@id}{"A7}
4957 \let\mathsterling\@undefined
4958 \M@sym@{\mathsterling} {\mathord} {\M@symbols@id}{"A3}
4959 \M@sym@{\neg} {\mathord} {\M@symbols@id}{"AC}
4960 \M@sym@{\mid} {\mathrel} {\M@symbols@id}{"7C}
4961 \M@sym@{|} {\mathord} {\M@symbols@id}{"7C}
4962 \M@sym@{\infty} {\mathord} {\M@symbols@id}{"221E}
4963 \M@sym@{\partial} {\mathord} {\M@symbols@id}{"2202}
4964 \M@sym@{\degree} {\mathord} {\M@symbols@id}{"B0}
4965 \M@sym@{\increment} {\mathord} {\M@symbols@id}{"2206}
4966 \M@sym@{+} {\mathbin} {\M@symbols@id}{"2B}
4967 \M@sym@{-} {\mathbin} {\M@symbols@id}{"2212}
4968 \M@sym@{*} {\mathbin} {\M@symbols@id}{"2A}
4969 \M@sym@{\times} {\mathbin} {\M@symbols@id}{"D7}
4970 \M@sym@{/} {\mathord} {\M@symbols@id}{"2F}
4971 \M@sym@{\fractionslash}{\mathord} {\M@symbols@id}{"2215}
4972 \M@sym@{\div} {\mathbin} {\M@symbols@id}{"F7}
4973 \M@sym@{\pm} {\mathbin} {\M@symbols@id}{"B1}
4974 \M@sym@{\bullet} {\mathbin} {\M@symbols@id}{"2022}
4975 \M@sym@{\dagger} {\mathbin} {\M@symbols@id}{"2020}
4976 \M@sym@{\ddagger} {\mathbin} {\M@symbols@id}{"2021}
4977 \M@sym@{\cdot} {\mathbin} {\M@symbols@id}{"2219}
4978 \M@sym@{\setminus} {\mathbin} {\M@symbols@id}{"5C}
4979 \M@sym@{=} {\mathrel} {\M@symbols@id}{"3D}
4980 \M@sym@{<} {\mathrel} {\M@symbols@id}{"3C}
4981 \M@sym@{>} {\mathrel} {\M@symbols@id}{"3E}
4982 \M@sym@{\leq} {\mathrel} {\M@symbols@id}{"2264}
4983 \M@sym@{\geq} {\mathrel} {\M@symbols@id}{"2265}
4984 \M@sym@{\sim} {\mathrel} {\M@symbols@id}{"7E}
4985 \M@sym@{\approx} {\mathrel} {\M@symbols@id}{"2248}
4986 \M@sym@{\equiv} {\mathrel} {\M@symbols@id}{"2261}
4987 \M@sym@{\parallel} {\mathrel} {\M@symbols@id}{"2016}
4988 \M@sym@{\colon} {\mathpunct}{\M@symbols@id}{"3A}
4989 \M@sym@{:} {\mathrel} {\M@symbols@id}{"3A}
4990 \M@sym@{?} {\mathclose}{\M@symbols@id}{"3F}
4991 \M@sym@{!} {\mathclose}{\M@symbols@id}{"21}
4992 \M@sym@{\comma} {\mathord} {\M@symbols@id}{"2C}
4993 \M@sym@{,} {\mathpunct}{\M@symbols@id}{"2C}
4994 \M@sym@{;} {\mathpunct}{\M@symbols@id}{"3B}
4995 \M@sym@{\mathellipsis} {\mathinner}{\M@symbols@id}{"2026}
4996 % \end{macrocode}
4997 % Now a bit of housekeeping. We redefine |\#|, |\%|, and |\&| as |\protected| macros that expand to previously declared |\mathhash|, etc.\ commands in math mode and retain their standard |\char| definitions otherwise. Other commands that function in both math and horizontal modes such as |\S| or |\dag| also use this technique. Then we define macros |\cong| and |\simeq| if the user hasn't called |\mathfont| with |extsymbols|.
4998 % \begin{macrocode}
4999 \protected\def\#{\ifmmode\mathhash\else\char"23\relax\fi}
5000 \protected\def\%{\ifmmode\mathpercent\else\char"25\relax\fi}
5001 \protected\def\&{\ifmmode\mathand\else\char"26\relax\fi}
5002 \ifM@extsymbols\else
5003 \protected\def\simeq{
5004 \mathrel{\mathpalette\stack@flatrel{{-}{\sim}}}}
5005 \protected\def\cong{
5006 \mathrel{\mathpalette\stack@flatrel{{=}{\sim}}}}
5007 \fi
5008 \protected\def\models{\mathrel{|}\joinrel\mathrel{=}}
5009 % \end{macrocode}
5010 % New definition for |\not|. We define it to accept a |#1| argument, which we store in an |\hbox| in the appropriate style. Then we typeset a |/| halfway across the distance of the |\hbox| and the |\hbox| itself. This approach manually positions the |/| halfway across the |#1| subformula instead of using a character that appears to the right of a slim bounding box as in traditional \TeX. In case any users want to access the old |\not| definition, we save it as |\negslash|.
5011 % \begin{macrocode}
5012 \let\negslash\not
5013 \protected\def\not##1{\mathrel{\mathchoice
5014 {\setbox\@tempboxa\hbox{$\displaystyle##1\m@th$}
5015 \hbox{\hb@xt@\wd\@tempboxa{\hss$\displaystyle/\m@th$\hss}
5016 \llap{\box\@tempboxa}}}
5017 {\setbox\@tempboxa\hbox{$\textstyle##1\m@th$}
5018 \hbox{\hb@xt@\wd\@tempboxa{\hss$\textstyle/\m@th$\hss}
5019 \llap{\box\@tempboxa}}}
5020 {\setbox\@tempboxa\hbox{$\scriptstyle##1\m@th$}
5021 \hbox{\hb@xt@\wd\@tempboxa{\hss$\scriptstyle/\m@th$\hss}
5022 \llap{\box\@tempboxa}}}
5023 {\setbox\@tempboxa\hbox{$\scriptscriptstyle##1\m@th$}
5024 \hbox{\hb@xt@\wd\@tempboxa{\hss{$\scriptscriptstyle/
5025 \m@th$\hss}
5026 \llap{\box\@tempboxa}}}}}}}
5027 % \end{macrocode}
5028 % Set extended symbols.
5029 % \begin{macrocode}
5030 \def\M@extsymbols@set{
5031 \edef\M@extsymbols@id{M\@tempc-\M@extsymbolsshape}
5032 \let\angle\@undefined
5033 \let\simeq\@undefined
5034 \let\sqsubset\@undefined
5035 \let\sqsupset\@undefined
5036 \let\bowtie\@undefined
5037 \let\doteq\@undefined
5038 \let\neq\@undefined
5039 \M@sym@{\wp} {\mathord}{\M@extsymbols@id}{"2118}
5040 \M@sym@{\ell} {\mathord}{\M@extsymbols@id}{"2113}
5041 \M@sym@{\forall} {\mathord}{\M@extsymbols@id}{"2200}
5042 \M@sym@{\exists} {\mathord}{\M@extsymbols@id}{"2203}
5043 \M@sym@{\emptyset} {\mathord}{\M@extsymbols@id}{"2205}
5044 \M@sym@{\in} {\mathord}{\M@extsymbols@id}{"2208}
5045 \M@sym@{\ni} {\mathord}{\M@extsymbols@id}{"220B}
5046 \M@sym@{\mp} {\mathord}{\M@extsymbols@id}{"2213}
5047 \M@sym@{\angle} {\mathord}{\M@extsymbols@id}{"2220}
5048 \M@sym@{\top} {\mathord}{\M@extsymbols@id}{"22A4}
5049 \M@sym@{\bot} {\mathord}{\M@extsymbols@id}{"22A5}
5050 \M@sym@{\vdash} {\mathord}{\M@extsymbols@id}{"22A2}
5051 \M@sym@{\dashv} {\mathord}{\M@extsymbols@id}{"22A3}
5052 \M@sym@{\flat} {\mathord}{\M@extsymbols@id}{"266D}
5053 \M@sym@{\natural} {\mathord}{\M@extsymbols@id}{"266E}
5054 \M@sym@{\sharp} {\mathord}{\M@extsymbols@id}{"266F}
5055 \M@sym@{\fflat} {\mathord}{\M@extsymbols@id}{"1D12B}
5056 \M@sym@{\ssharp} {\mathord}{\M@extsymbols@id}{"1D12A}
5057 \M@sym@{\bclubsuit} {\mathord}{\M@extsymbols@id}{"2663}
5058 \M@sym@{\bdiamondsuit} {\mathord}{\M@extsymbols@id}{"2666}
5059 \M@sym@{\bheartsuit} {\mathord}{\M@extsymbols@id}{"2665}
5060 \M@sym@{\bspadesuit} {\mathord}{\M@extsymbols@id}{"2660}
5061 \M@sym@{\wclubsuit} {\mathord}{\M@extsymbols@id}{"2667}
5062 \M@sym@{\wdiamondsuit} {\mathord}{\M@extsymbols@id}{"2662}
5063 \M@sym@{\wheartsuit} {\mathord}{\M@extsymbols@id}{"2661}
5064 \M@sym@{\wspadesuit} {\mathord}{\M@extsymbols@id}{"2664}
5065 \let\spadesuit\bspadesuit
5066 \let\heartsuit\wheartsuit
5067 \let\diamondsuit\wdiamondsuit
5068 \let\clubsuit\bclubsuit
5069 \M@sym@{\wedge} {\mathbin}{\M@extsymbols@id}{"2227}
5070 \M@sym@{\vee} {\mathbin}{\M@extsymbols@id}{"2228}
5071 \M@sym@{\cap} {\mathord}{\M@extsymbols@id}{"2229}
5072 \M@sym@{\cup} {\mathbin}{\M@extsymbols@id}{"222A}
5073 \M@sym@{\sqcap} {\mathbin}{\M@extsymbols@id}{"2293}
5074 \M@sym@{\sqcup} {\mathbin}{\M@extsymbols@id}{"2294}
5075 \M@sym@{\amalg} {\mathbin}{\M@extsymbols@id}{"2A3F}
5076 \M@sym@{\wr} {\mathbin}{\M@extsymbols@id}{"2240}
5077 \M@sym@{\ast} {\mathbin}{\M@extsymbols@id}{"2217}
5078 \M@sym@{\star} {\mathbin}{\M@extsymbols@id}{"22C6}
5079 \M@sym@{\diamond} {\mathbin}{\M@extsymbols@id}{"22C4}
5080 \M@sym@{\varcdot} {\mathbin}{\M@extsymbols@id}{"22C5}
5081 \M@sym@{\varsetminus} {\mathbin}{\M@extsymbols@id}{"2216}
5082 \M@sym@{\oplus} {\mathbin}{\M@extsymbols@id}{"2295}
5083 \M@sym@{\otimes} {\mathbin}{\M@extsymbols@id}{"2297}
5084 \M@sym@{\ominus} {\mathbin}{\M@extsymbols@id}{"2296}
5085 \M@sym@{\odiv} {\mathbin}{\M@extsymbols@id}{"2A38}
5086 \M@sym@{\oslash} {\mathbin}{\M@extsymbols@id}{"2298}
5087 \M@sym@{\odot} {\mathbin}{\M@extsymbols@id}{"2299}
5088 \M@sym@{\sqplus} {\mathbin}{\M@extsymbols@id}{"229E}
5089 \M@sym@{\sqtimes} {\mathbin}{\M@extsymbols@id}{"22A0}
5090 \M@sym@{\sqminus} {\mathbin}{\M@extsymbols@id}{"229F}
5091 \M@sym@{\sqdot} {\mathbin}{\M@extsymbols@id}{"22A1}
5092 \M@sym@{\in} {\mathrel}{\M@extsymbols@id}{"2208}
5093 \M@sym@{\ni} {\mathrel}{\M@extsymbols@id}{"220B}
5094 \M@sym@{\subset} {\mathrel}{\M@extsymbols@id}{"2282}
5095 \M@sym@{\supset} {\mathrel}{\M@extsymbols@id}{"2283}
5096 \M@sym@{\subseteq} {\mathrel}{\M@extsymbols@id}{"2286}
5097 \M@sym@{\supseteq} {\mathrel}{\M@extsymbols@id}{"2287}
5098 \M@sym@{\sqsubset} {\mathrel}{\M@extsymbols@id}{"228F}
5099 \M@sym@{\sqsupset} {\mathrel}{\M@extsymbols@id}{"2290}
5100 \M@sym@{\sqsubseteq} {\mathrel}{\M@extsymbols@id}{"2291}
5101 \M@sym@{\sqsupseteq} {\mathrel}{\M@extsymbols@id}{"2292}
5102 \M@sym@{\triangleleft} {\mathrel}{\M@extsymbols@id}{"22B2}
5103 \M@sym@{\triangleright} {\mathrel}{\M@extsymbols@id}{"22B3}
5104 \M@sym@{\trianglelefteq} {\mathrel}{\M@extsymbols@id}{"22B4}
5105 \M@sym@{\trianglerighteq} {\mathrel}{\M@extsymbols@id}{"22B5}
5106 \M@sym@{\propto} {\mathrel}{\M@extsymbols@id}{"221D}
5107 \M@sym@{\bowtie} {\mathrel}{\M@extsymbols@id}{"22C8}
5108 \M@sym@{\hourglass} {\mathrel}{\M@extsymbols@id}{"29D6}
5109 \M@sym@{\therefore} {\mathrel}{\M@extsymbols@id}{"2234}
5110 \M@sym@{\because} {\mathrel}{\M@extsymbols@id}{"2235}
5111 \M@sym@{\ratio} {\mathrel}{\M@extsymbols@id}{"2236}
5112 \M@sym@{\proportion} {\mathrel}{\M@extsymbols@id}{"2237}
5113 \M@sym@{\ll} {\mathrel}{\M@extsymbols@id}{"226A}
5114 \M@sym@{\gg} {\mathrel}{\M@extsymbols@id}{"226B}
5115 \M@sym@{\lll} {\mathrel}{\M@extsymbols@id}{"22D8}
5116 \M@sym@{\ggg} {\mathrel}{\M@extsymbols@id}{"22D9}
5117 \M@sym@{\leqq} {\mathrel}{\M@extsymbols@id}{"2266}
5118 \M@sym@{\geqq} {\mathrel}{\M@extsymbols@id}{"2267}
5119 \M@sym@{\lapprox} {\mathrel}{\M@extsymbols@id}{"2A85}
5120 \M@sym@{\gapprox} {\mathrel}{\M@extsymbols@id}{"2A86}
5121 \M@sym@{\simeq} {\mathrel}{\M@extsymbols@id}{"2243}
5122 \M@sym@{\eqsim} {\mathrel}{\M@extsymbols@id}{"2242}
5123 \M@sym@{\simeqq} {\mathrel}{\M@extsymbols@id}{"2245}
5124 \let\cong\simeqq
5125 \M@sym@{\approxeq} {\mathrel}{\M@extsymbols@id}{"224A}
5126 \M@sym@{\sssim} {\mathrel}{\M@extsymbols@id}{"224B}
5127 \M@sym@{\seq} {\mathrel}{\M@extsymbols@id}{"224C}
5128 \M@sym@{\doteq} {\mathrel}{\M@extsymbols@id}{"2250}
5129 \M@sym@{\coloneq} {\mathrel}{\M@extsymbols@id}{"2254}
5130 \M@sym@{\eqcolon} {\mathrel}{\M@extsymbols@id}{"2255}
5131 \M@sym@{\ringeq} {\mathrel}{\M@extsymbols@id}{"2257}
5132 \M@sym@{\arceq} {\mathrel}{\M@extsymbols@id}{"2258}
5133 \M@sym@{\wedgeeq} {\mathrel}{\M@extsymbols@id}{"2259}
5134 \M@sym@{\veeeq} {\mathrel}{\M@extsymbols@id}{"225A}
5135 \M@sym@{\stareq} {\mathrel}{\M@extsymbols@id}{"225B}
5136 \M@sym@{\triangleeq} {\mathrel}{\M@extsymbols@id}{"225C}
5137 \M@sym@{\defeq} {\mathrel}{\M@extsymbols@id}{"225D}
5138 \M@sym@{\qeq} {\mathrel}{\M@extsymbols@id}{"225F}
5139 \M@sym@{\lsim} {\mathrel}{\M@extsymbols@id}{"2272}
5140 \M@sym@{\gsim} {\mathrel}{\M@extsymbols@id}{"2273}
5141 \M@sym@{\prec} {\mathrel}{\M@extsymbols@id}{"227A}
5142 \M@sym@{\succ} {\mathrel}{\M@extsymbols@id}{"227B}
5143 \M@sym@{\preceq} {\mathrel}{\M@extsymbols@id}{"227C}
5144 \M@sym@{\succeq} {\mathrel}{\M@extsymbols@id}{"227D}
5145 \M@sym@{\preceqq} {\mathrel}{\M@extsymbols@id}{"2AB3}
5146 \M@sym@{\succeqq} {\mathrel}{\M@extsymbols@id}{"2AB4}
5147 \M@sym@{\precsim} {\mathrel}{\M@extsymbols@id}{"227E}
5148 \M@sym@{\succsim} {\mathrel}{\M@extsymbols@id}{"227F}
5149 \M@sym@{\precapprox} {\mathrel}{\M@extsymbols@id}{"2AB7}
5150 \M@sym@{\succapprox} {\mathrel}{\M@extsymbols@id}{"2AB8}
5151 \M@sym@{\precprec} {\mathrel}{\M@extsymbols@id}{"2ABB}
5152 \M@sym@{\succsucc} {\mathrel}{\M@extsymbols@id}{"2ABC}
5153 \M@sym@{\asymp} {\mathrel}{\M@extsymbols@id}{"224D}
5154 \M@sym@{\nin} {\mathrel}{\M@extsymbols@id}{"2209}
5155 \M@sym@{\nni} {\mathrel}{\M@extsymbols@id}{"220C}
5156 \M@sym@{\nsubset} {\mathrel}{\M@extsymbols@id}{"2284}
5157 \M@sym@{\nsupset} {\mathrel}{\M@extsymbols@id}{"2285}
5158 \M@sym@{\nsubseteq} {\mathrel}{\M@extsymbols@id}{"2288}
5159 \M@sym@{\nsupseteq} {\mathrel}{\M@extsymbols@id}{"2289}
5160 \M@sym@{\subsetneq} {\mathrel}{\M@extsymbols@id}{"228A}
5161 \M@sym@{\supsetneq} {\mathrel}{\M@extsymbols@id}{"228B}
5162 \M@sym@{\nsqsubseteq} {\mathrel}{\M@extsymbols@id}{"22E2}
5163 \M@sym@{\nsqsupseteq} {\mathrel}{\M@extsymbols@id}{"22E3}
5164 \M@sym@{\sqsubsetneq} {\mathrel}{\M@extsymbols@id}{"22E4}
5165 \M@sym@{\sqsupsetneq} {\mathrel}{\M@extsymbols@id}{"22E5}
5166 \M@sym@{\neq} {\mathrel}{\M@extsymbols@id}{"2260}
5167 \M@sym@{\nl} {\mathrel}{\M@extsymbols@id}{"226E}
5168 \M@sym@{\nleq} {\mathrel}{\M@extsymbols@id}{"2270}
5169 \M@sym@{\ngeq} {\mathrel}{\M@extsymbols@id}{"2271}
5170 \M@sym@{\lneq} {\mathrel}{\M@extsymbols@id}{"2A87}
5171 \M@sym@{\gneq} {\mathrel}{\M@extsymbols@id}{"2A88}
5172 \M@sym@{\lneqq} {\mathrel}{\M@extsymbols@id}{"2268}
5173 \M@sym@{\gneqq} {\mathrel}{\M@extsymbols@id}{"2269}
5174 \M@sym@{\ntriangleleft} {\mathrel}{\M@extsymbols@id}{"22EA}
5175 \M@sym@{\ntriangleright} {\mathrel}{\M@extsymbols@id}{"22EB}
5176 \M@sym@{\ntrianglelefteq} {\mathrel}{\M@extsymbols@id}{"22EC}
5177 \M@sym@{\ntrianglerighteq}{\mathrel}{\M@extsymbols@id}{"22ED}
5178 \M@sym@{\nsim} {\mathrel}{\M@extsymbols@id}{"2241}
5179 \M@sym@{\napprox} {\mathrel}{\M@extsymbols@id}{"2249}
5180 \M@sym@{\nsimeq} {\mathrel}{\M@extsymbols@id}{"2244}
5181 \M@sym@{\nsimeqq} {\mathrel}{\M@extsymbols@id}{"2247}
5182 \M@sym@{\simneqq} {\mathrel}{\M@extsymbols@id}{"2246}
5183 \M@sym@{\nlsim} {\mathrel}{\M@extsymbols@id}{"2274}
5184 \M@sym@{\ngsim} {\mathrel}{\M@extsymbols@id}{"2275}
5185 \M@sym@{\lnsim} {\mathrel}{\M@extsymbols@id}{"22E6}
5186 \M@sym@{\gnsim} {\mathrel}{\M@extsymbols@id}{"22E7}
5187 \M@sym@{\lnapprox} {\mathrel}{\M@extsymbols@id}{"2A89}
5188 \M@sym@{\gnapprox} {\mathrel}{\M@extsymbols@id}{"2A8A}
5189 \M@sym@{\nprec} {\mathrel}{\M@extsymbols@id}{"2280}
5190 \M@sym@{\nsucc} {\mathrel}{\M@extsymbols@id}{"2281}
5191 \M@sym@{\npreceq} {\mathrel}{\M@extsymbols@id}{"22E0}
5192 \M@sym@{\nsucceq} {\mathrel}{\M@extsymbols@id}{"22E1}
5193 \M@sym@{\precneq} {\mathrel}{\M@extsymbols@id}{"2AB1}
5194 \M@sym@{\succneq} {\mathrel}{\M@extsymbols@id}{"2AB2}
5195 \M@sym@{\precneqq} {\mathrel}{\M@extsymbols@id}{"2AB5}
5196 \M@sym@{\succneqq} {\mathrel}{\M@extsymbols@id}{"2AB6}
5197 \M@sym@{\precnsim} {\mathrel}{\M@extsymbols@id}{"22E8}
5198 \M@sym@{\succnsim} {\mathrel}{\M@extsymbols@id}{"22E9}
5199 \M@sym@{\precnapprox} {\mathrel}{\M@extsymbols@id}{"2AB9}
5200 \M@sym@{\succnapprox} {\mathrel}{\M@extsymbols@id}{"2ABA}
5201 \M@sym@{\nequiv} {\mathrel}{\M@extsymbols@id}{"2262}
5202 % \end{macrocode}
5203 % The \textsf{math-operator} package renames |\Re| and |\Im| to |\varRe| and |\varIm|. To make \textsf{mathfont} compatible with that package, we test whether these macros contain |mathchar| in their definitions before redefining. First |\Re|.
5204 % \begin{macrocode}
5205 \expanded{\noexpand\in@{\expandafter\@gobble\string\mathchar}
5206 {\meaning\Re}}
5207 \ifin@
5208 \M@sym@{\Re}{\mathord}{\M@extsymbols@id}{"211C}
5209 \else
5210 \expanded{\noexpand\in@{\expandafter\@gobble\string\mathchar}
5211 {\meaning\varRe}}
5212 \ifin@
5213 \M@sym@{\varRe}{\mathord}{\M@extsymbols@id}{"211C}
5214 \fi
5215 \fi
5216 % \end{macrocode}
5217 % And |\Im|.
5218 % \begin{macrocode}
5219 \expanded{\noexpand\in@{\expandafter\@gobble\string\mathchar}
5220 {\meaning\Im}}
5221 \ifin@
5222 \M@sym@{\Im}{\mathord}{\M@extsymbols@id}{"2111}
5223 \else
5224 \expanded{\noexpand\in@{\expandafter\@gobble\string\mathchar}
5225 {\meaning\varIm}}
5226 \ifin@
5227 \M@sym@{\varIm}{\mathord}{\M@extsymbols@id}{"2111}
5228 \fi
5229 \fi
5230 % \end{macrocode}
5231 % We handle |\ng| specially. The \LaTeX\ kernel defines |\ng| as a text symbol, so we define |\mathng| like for |\$|, etc.
5232 % \begin{macrocode}
5233 \let\textng\ng
5234 \M@sym@{\mathng}{\mathrel}{\M@extsymbols@id}{"226F}
5235 \protected\def\ng{\ifmmode\mathng\else\textng\fi}
5236 % \end{macrocode}
5237 % If we're not adjusting the font, we declare |\nabla| here.
5238 % \begin{macrocode}
5239 \ifM@adjust@font\else
5240 \M@sym@{\nabla}{\mathord}{\M@extsymbols@id}{"2207}
5241 \fi}
5242 % \end{macrocode}
5243 % Set arrows.
5244 % \begin{macrocode}
5245 \def\M@arrows@set{
5246 \edef\M@arrows@id{M\@tempc-\M@arrowsshape}
5247 \let\uparrow\@undefined
5248 \let\Uparrow\@undefined
5249 \let\downarrow\@undefined
5250 \let\Downarrow\@undefined
5251 \let\updownarrow\@undefined
5252 \let\Updownarrow\@undefined
5253 \let\longrightarrow\@undefined
5254 \let\longleftarrow\@undefined
5255 \let\longleftrightarrow\@undefined
5256 \let\hookrightarrow\@undefined
5257 \let\hookleftarrow\@undefined
5258 \let\Longrightarrow\@undefined
5259 \let\Longleftarrow\@undefined
5260 \let\Longleftrightarrow\@undefined
5261 \let\rightleftharpoons\@undefined
5262 \M@sym@{\rightarrow} {\mathrel}{\M@arrows@id}{"2192}
5263 \let\to\rightarrow
5264 \M@sym@{\nrightarrow} {\mathrel}{\M@arrows@id}{"219B}
5265 \M@sym@{\Rightarrow} {\mathrel}{\M@arrows@id}{"21D2}
5266 \M@sym@{\nRightarrow} {\mathrel}{\M@arrows@id}{"21CF}
5267 \M@sym@{\Rrightarrow} {\mathrel}{\M@arrows@id}{"21DB}
5268 \M@sym@{\longrightarrow} {\mathrel}{\M@arrows@id}{"27F6}
5269 \M@sym@{\Longrightarrow} {\mathrel}{\M@arrows@id}{"27F9}
5270 \M@sym@{\rightbararrow} {\mathrel}{\M@arrows@id}{"21A6}
5271 \let\mapsto\rightbararrow
5272 \M@sym@{\Rightbararrow} {\mathrel}{\M@arrows@id}{"2907}
5273 \M@sym@{\longrightbararrow} {\mathrel}{\M@arrows@id}{"27FC}
5274 \let\longmapsto\longrightbararrow
5275 \M@sym@{\Longrightbararrow} {\mathrel}{\M@arrows@id}{"27FE}
5276 \M@sym@{\hookrightarrow} {\mathrel}{\M@arrows@id}{"21AA}
5277 \M@sym@{\rightdasharrow} {\mathrel}{\M@arrows@id}{"21E2}
5278 \M@sym@{\rightharpoonup} {\mathrel}{\M@arrows@id}{"21C0}
5279 \M@sym@{\rightharpoondown} {\mathrel}{\M@arrows@id}{"21C1}
5280 \M@sym@{\rightarrowtail} {\mathrel}{\M@arrows@id}{"21A3}
5281 \M@sym@{\rightoplusarrow} {\mathrel}{\M@arrows@id}{"27F4}
5282 \M@sym@{\rightwavearrow} {\mathrel}{\M@arrows@id}{"219D}
5283 \M@sym@{\rightsquigarrow} {\mathrel}{\M@arrows@id}{"21DD}
5284 \M@sym@{\longrightsquigarrow} {\mathrel}{\M@arrows@id}{"27FF}
5285 \M@sym@{\looparrowright} {\mathrel}{\M@arrows@id}{"21AC}
5286 \M@sym@{\curvearrowright} {\mathrel}{\M@arrows@id}{"293B}
5287 \M@sym@{\circlearrowright} {\mathrel}{\M@arrows@id}{"21BB}
5288 \M@sym@{\twoheadrightarrow} {\mathrel}{\M@arrows@id}{"21A0}
5289 \M@sym@{\rightarrowtobar} {\mathrel}{\M@arrows@id}{"21E5}
5290 \M@sym@{\rightwhitearrow} {\mathrel}{\M@arrows@id}{"21E8}
5291 \M@sym@{\rightrightarrows} {\mathrel}{\M@arrows@id}{"21C9}
5292 \M@sym@{\rightrightrightarrows}{\mathrel}{\M@arrows@id}{"21F6}
5293 \M@sym@{\leftarrow} {\mathrel}{\M@arrows@id}{"2190}
5294 \let\from\leftarrow
5295 \M@sym@{\nleftarrow} {\mathrel}{\M@arrows@id}{"219A}
5296 \M@sym@{\Leftarrow} {\mathrel}{\M@arrows@id}{"21D0}
5297 \M@sym@{\nLeftarrow} {\mathrel}{\M@arrows@id}{"21CD}
5298 \M@sym@{\Lleftarrow} {\mathrel}{\M@arrows@id}{"21DA}
5299 \M@sym@{\longleftarrow} {\mathrel}{\M@arrows@id}{"27F5}
5300 \M@sym@{\Longleftarrow} {\mathrel}{\M@arrows@id}{"27F8}
5301 \M@sym@{\leftbararrow} {\mathrel}{\M@arrows@id}{"21A4}
5302 \let\mapsfrom\leftbararrow
5303 \M@sym@{\Leftbararrow} {\mathrel}{\M@arrows@id}{"2906}
5304 \M@sym@{\longleftbararrow} {\mathrel}{\M@arrows@id}{"27FB}
5305 \let\longmapsfrom\longleftbararrow
5306 \M@sym@{\Longleftbararrow} {\mathrel}{\M@arrows@id}{"27FD}
5307 \M@sym@{\hookleftarrow} {\mathrel}{\M@arrows@id}{"21A9}
5308 \M@sym@{\leftdasharrow} {\mathrel}{\M@arrows@id}{"21E0}
5309 \M@sym@{\leftharpoonup} {\mathrel}{\M@arrows@id}{"21BC}
5310 \M@sym@{\leftharpoondown} {\mathrel}{\M@arrows@id}{"21BD}
5311 \M@sym@{\leftarrowtail} {\mathrel}{\M@arrows@id}{"21A2}
5312 \M@sym@{\leftoplusarrow} {\mathrel}{\M@arrows@id}{"2B32}
5313 \M@sym@{\leftwavearrow} {\mathrel}{\M@arrows@id}{"219C}
5314 \M@sym@{\leftsquigarrow} {\mathrel}{\M@arrows@id}{"21DC}
5315 \M@sym@{\longleftsquigarrow} {\mathrel}{\M@arrows@id}{"2B33}
5316 \M@sym@{\looparrowleft} {\mathrel}{\M@arrows@id}{"21AB}
5317 \M@sym@{\curvearrowleft} {\mathrel}{\M@arrows@id}{"293A}
5318 \M@sym@{\circlearrowleft} {\mathrel}{\M@arrows@id}{"21BA}
5319 \M@sym@{\twoheadleftarrow} {\mathrel}{\M@arrows@id}{"219E}
5320 \M@sym@{\leftarrowtobar} {\mathrel}{\M@arrows@id}{"21E4}
5321 \M@sym@{\leftwhitearrow} {\mathrel}{\M@arrows@id}{"21E6}
5322 \M@sym@{\leftleftarrows} {\mathrel}{\M@arrows@id}{"21C7}
5323 \M@sym@{\leftleftleftarrows} {\mathrel}{\M@arrows@id}{"2B31}
5324 \M@sym@{\leftrightarrow} {\mathrel}{\M@arrows@id}{"2194}
5325 \M@sym@{\Leftrightarrow} {\mathrel}{\M@arrows@id}{"21D4}
5326 \M@sym@{\nLeftrightarrow} {\mathrel}{\M@arrows@id}{"21CE}
5327 \M@sym@{\longleftrightarrow} {\mathrel}{\M@arrows@id}{"27F7}
5328 \M@sym@{\Longleftrightarrow} {\mathrel}{\M@arrows@id}{"27FA}
5329 \M@sym@{\leftrightwavearrow} {\mathrel}{\M@arrows@id}{"21AD}
5330 \M@sym@{\leftrightarrows} {\mathrel}{\M@arrows@id}{"21C6}
5331 \M@sym@{\leftrightharpoons} {\mathrel}{\M@arrows@id}{"21CB}
5332 \M@sym@{\leftrightarrowstobar} {\mathrel}{\M@arrows@id}{"21B9}
5333 \M@sym@{\rightleftarrows} {\mathrel}{\M@arrows@id}{"21C4}
5334 \M@sym@{\rightleftharpoons} {\mathrel}{\M@arrows@id}{"21CC}
5335 \M@sym@{\uparrow} {\mathrel}{\M@arrows@id}{"2191}
5336 \M@sym@{\Uparrow} {\mathrel}{\M@arrows@id}{"21D1}
5337 \M@sym@{\Uuparrow} {\mathrel}{\M@arrows@id}{"290A}
5338 \M@sym@{\upbararrow} {\mathrel}{\M@arrows@id}{"21A5}
5339 \M@sym@{\updasharrow} {\mathrel}{\M@arrows@id}{"21E1}
5340 \M@sym@{\upharpoonleft} {\mathrel}{\M@arrows@id}{"21BF}
5341 \M@sym@{\upharpoonright} {\mathrel}{\M@arrows@id}{"21BE}
5342 \M@sym@{\twoheaduparrow} {\mathrel}{\M@arrows@id}{"219F}
5343 \M@sym@{\uparrowtobar} {\mathrel}{\M@arrows@id}{"2912}
5344 \M@sym@{\upwhitearrow} {\mathrel}{\M@arrows@id}{"21E7}
5345 \M@sym@{\upwhitebararrow} {\mathrel}{\M@arrows@id}{"21EA}
5346 \M@sym@{\upuparrows} {\mathrel}{\M@arrows@id}{"21C8}
5347 \M@sym@{\downarrow} {\mathrel}{\M@arrows@id}{"2193}
5348 \M@sym@{\Downarrow} {\mathrel}{\M@arrows@id}{"21D3}
5349 \M@sym@{\Ddownarrow} {\mathrel}{\M@arrows@id}{"290B}
5350 \M@sym@{\downbararrow} {\mathrel}{\M@arrows@id}{"21A7}
5351 \M@sym@{\downdasharrow} {\mathrel}{\M@arrows@id}{"21E3}
5352 \M@sym@{\zigzagarrow} {\mathrel}{\M@arrows@id}{"21AF}
5353 \let\lightningboltarrow\zigzagarrow
5354 \M@sym@{\downharpoonleft} {\mathrel}{\M@arrows@id}{"21C3}
5355 \M@sym@{\downharpoonright} {\mathrel}{\M@arrows@id}{"21C2}
5356 \M@sym@{\twoheaddownarrow} {\mathrel}{\M@arrows@id}{"21A1}
5357 \M@sym@{\downarrowtobar} {\mathrel}{\M@arrows@id}{"2913}
5358 \M@sym@{\downwhitearrow} {\mathrel}{\M@arrows@id}{"21E9}
5359 \M@sym@{\downdownarrows} {\mathrel}{\M@arrows@id}{"21CA}
5360 \M@sym@{\updownarrow} {\mathrel}{\M@arrows@id}{"2195}
5361 \M@sym@{\Updownarrow} {\mathrel}{\M@arrows@id}{"21D5}
5362 \M@sym@{\updownarrows} {\mathrel}{\M@arrows@id}{"21C5}
5363 \M@sym@{\downuparrows} {\mathrel}{\M@arrows@id}{"21F5}
5364 \M@sym@{\updownharpoons} {\mathrel}{\M@arrows@id}{"296E}
5365 \M@sym@{\downupharpoons} {\mathrel}{\M@arrows@id}{"296F}
5366 \M@sym@{\nearrow} {\mathrel}{\M@arrows@id}{"2197}
5367 \M@sym@{\Nearrow} {\mathrel}{\M@arrows@id}{"21D7}
5368 \M@sym@{\nwarrow} {\mathrel}{\M@arrows@id}{"2196}
5369 \M@sym@{\Nwarrow} {\mathrel}{\M@arrows@id}{"21D6}
5370 \M@sym@{\searrow} {\mathrel}{\M@arrows@id}{"2198}
5371 \M@sym@{\Searrow} {\mathrel}{\M@arrows@id}{"21D8}
5372 \M@sym@{\swarrow} {\mathrel}{\M@arrows@id}{"2199}
5373 \M@sym@{\Swarrow} {\mathrel}{\M@arrows@id}{"21D9}
5374 \M@sym@{\nwsearrow} {\mathrel}{\M@arrows@id}{"2921}
5375 \M@sym@{\neswarrow} {\mathrel}{\M@arrows@id}{"2922}
5376 \M@sym@{\lcirclearrow} {\mathrel}{\M@arrows@id}{"27F2}
5377 \M@sym@{\rcirclearrow} {\mathrel}{\M@arrows@id}{"27F3}
5378 % \end{macrocode}
5379 % The commands |\relbar| and |\Relbar| produce a smashed minus and an equals sign respectively. They are helper control sequences that \LaTeX\ uses to create other arrows. We have a small issue with \textsf{amsmath} because in \XeTeX\ and Lua\TeX, \textsf{amsmath} defines |\relbar| and |\Relbar| in terms of the |\Umathcodes| of the minus and equals signs respectively. That is a good approach in general, but it doesn't work when a package like \textsf{mathfont} allows users to pick different fonts for symbols and arrows. We really want |\relbar| and |\Relbar| to come from the |arrows| font, so our approach is to define the control sequences now and then redefine |\AtBeginDocument| if needed.
5380 % \begin{macrocode}
5381 \let\@relbar\@undefined
5382 \let\@Relbar\@undefined
5383 \M@sym@{\@relbar}{\mathbin}{\M@arrows@id}{"2212}
5384 \M@sym@{\@Relbar}{\mathrel}{\M@arrows@id}{"3D}
5385 \protected\def\relbar{\mathrel{\mathpalette\mathsm@sh\@relbar}}
5386 \protected\def\Relbar{\@Relbar}
5387 % \end{macrocode}
5388 % We redefine stuff if \textsf{amsmath} gets loaded after \textsf{mathfont}.
5389 % \begin{macrocode}
5390 \@ifpackageloaded{amsmath}
5391 {\relax}{
5392 \let\@@relbar\relbar
5393 \let\@@Relbar\Relbar
5394 \AtBeginDocument{\@ifpackageloaded{amsmath}{
5395 \let\relbar\@@relbar
5396 \let\Relbar\@@Relbar}
5397 {\relax}}}}
5398 % \end{macrocode}
5399 % Set blackboard bold letters and numbers. The alphanumeric keywords work a bit differently from the other font-setting commands. We define |\mathbb| here, which takes a single argument and is essentially a wrapper around |\M@bb@mathcodes|. That command changes the |\Umathcode|s of letters to the Unicode hex values of corresponding blackboard-bold characters, and throughout, |\M@bb@num| stores the family number of the sumbol font for the |bb| character class. In the definition of |\mathbb|, we use |\begingroup| and |\endgroup| to avoid creating unexpected atoms. The other alphanumeric keywords work similarly.
5400 % \begin{macrocode}
5401 \def\M@bb@set{
5402 \protected\def\mathbb##1{\relax
5403 \ifmmode\else
5404 \M@HModeError\mathbb
5405 $
5406 \fi
5407 \begingroup
5408 \M@bb@mathcodes
5409 ##1
5410 \endgroup}
5411 \edef\M@bb@num{\number
5412 \csname symM\@tempc-\M@bbshape\endcsname}
5413 \protected\edef\M@bb@mathcodes{
5414 \Umathcode`A=0+\M@bb@num"1D538\relax
5415 \Umathcode`B=0+\M@bb@num"1D539\relax
5416 \Umathcode`C=0+\M@bb@num"2102\relax
5417 \Umathcode`D=0+\M@bb@num"1D53B\relax
5418 \Umathcode`E=0+\M@bb@num"1D53C\relax
5419 \Umathcode`F=0+\M@bb@num"1D53D\relax
5420 \Umathcode`G=0+\M@bb@num"1D53E\relax
5421 \Umathcode`H=0+\M@bb@num"210D\relax
5422 \Umathcode`I=0+\M@bb@num"1D540\relax
5423 \Umathcode`J=0+\M@bb@num"1D541\relax
5424 \Umathcode`K=0+\M@bb@num"1D542\relax
5425 \Umathcode`L=0+\M@bb@num"1D543\relax
5426 \Umathcode`M=0+\M@bb@num"1D544\relax
5427 \Umathcode`N=0+\M@bb@num"2115\relax
5428 \Umathcode`O=0+\M@bb@num"1D546\relax
5429 \Umathcode`P=0+\M@bb@num"2119\relax
5430 \Umathcode`Q=0+\M@bb@num"211A\relax
5431 \Umathcode`R=0+\M@bb@num"211D\relax
5432 \Umathcode`S=0+\M@bb@num"1D54A\relax
5433 \Umathcode`T=0+\M@bb@num"1D54B\relax
5434 \Umathcode`U=0+\M@bb@num"1D54C\relax
5435 \Umathcode`V=0+\M@bb@num"1D54D\relax
5436 \Umathcode`W=0+\M@bb@num"1D54E\relax
5437 \Umathcode`X=0+\M@bb@num"1D54F\relax
5438 \Umathcode`Y=0+\M@bb@num"1D550\relax
5439 \Umathcode`Z=0+\M@bb@num"2124\relax
5440 \Umathcode`a=0+\M@bb@num"1D552\relax
5441 \Umathcode`b=0+\M@bb@num"1D553\relax
5442 \Umathcode`c=0+\M@bb@num"1D554\relax
5443 \Umathcode`d=0+\M@bb@num"1D555\relax
5444 \Umathcode`e=0+\M@bb@num"1D556\relax
5445 \Umathcode`f=0+\M@bb@num"1D557\relax
5446 \Umathcode`g=0+\M@bb@num"1D558\relax
5447 \Umathcode`h=0+\M@bb@num"1D559\relax
5448 \Umathcode`i=0+\M@bb@num"1D55A\relax
5449 \Umathcode`j=0+\M@bb@num"1D55B\relax
5450 \Umathcode`k=0+\M@bb@num"1D55C\relax
5451 \Umathcode`l=0+\M@bb@num"1D55D\relax
5452 \Umathcode`m=0+\M@bb@num"1D55E\relax
5453 \Umathcode`n=0+\M@bb@num"1D55F\relax
5454 \Umathcode`o=0+\M@bb@num"1D560\relax
5455 \Umathcode`p=0+\M@bb@num"1D561\relax
5456 \Umathcode`q=0+\M@bb@num"1D562\relax
5457 \Umathcode`r=0+\M@bb@num"1D563\relax
5458 \Umathcode`s=0+\M@bb@num"1D564\relax
5459 \Umathcode`t=0+\M@bb@num"1D565\relax
5460 \Umathcode`u=0+\M@bb@num"1D566\relax
5461 \Umathcode`v=0+\M@bb@num"1D567\relax
5462 \Umathcode`w=0+\M@bb@num"1D568\relax
5463 \Umathcode`x=0+\M@bb@num"1D569\relax
5464 \Umathcode`y=0+\M@bb@num"1D56A\relax
5465 \Umathcode`z=0+\M@bb@num"1D56B\relax
5466 \Umathcode`0=0+\M@bb@num"1D7D8\relax
5467 \Umathcode`1=0+\M@bb@num"1D7D9\relax
5468 \Umathcode`2=0+\M@bb@num"1D7DA\relax
5469 \Umathcode`3=0+\M@bb@num"1D7DB\relax
5470 \Umathcode`4=0+\M@bb@num"1D7DC\relax
5471 \Umathcode`5=0+\M@bb@num"1D7DD\relax
5472 \Umathcode`6=0+\M@bb@num"1D7DE\relax
5473 \Umathcode`7=0+\M@bb@num"1D7DF\relax
5474 \Umathcode`8=0+\M@bb@num"1D7E0\relax
5475 \Umathcode`9=0+\M@bb@num"1D7E1\relax}}
5476 % \end{macrocode}
5477 % Set caligraphic letters.
5478 % \begin{macrocode}
5479 \def\M@cal@set{
5480 \protected\def\mathcal##1{\relax
5481 \ifmmode\else
5482 \M@HModeError\mathcal
5483 $
5484 \fi
5485 \begingroup
5486 \M@cal@mathcodes
5487 ##1
5488 \endgroup}
5489 \edef\M@cal@num{\number
5490 \csname symM\@tempc-\M@calshape\endcsname}
5491 \protected\edef\M@cal@mathcodes{
5492 \Umathcode`A=0+\M@cal@num"1D49C\relax
5493 \Umathcode`B=0+\M@cal@num"212C\relax
5494 \Umathcode`C=0+\M@cal@num"1D49E\relax
5495 \Umathcode`D=0+\M@cal@num"1D49F\relax
5496 \Umathcode`E=0+\M@cal@num"2130\relax
5497 \Umathcode`F=0+\M@cal@num"2131\relax
5498 \Umathcode`G=0+\M@cal@num"1D4A2\relax
5499 \Umathcode`H=0+\M@cal@num"210B\relax
5500 \Umathcode`I=0+\M@cal@num"2110\relax
5501 \Umathcode`J=0+\M@cal@num"1D4A5\relax
5502 \Umathcode`K=0+\M@cal@num"1D4A6\relax
5503 \Umathcode`L=0+\M@cal@num"2112\relax
5504 \Umathcode`M=0+\M@cal@num"2133\relax
5505 \Umathcode`N=0+\M@cal@num"1D4A9\relax
5506 \Umathcode`O=0+\M@cal@num"1D4AA\relax
5507 \Umathcode`P=0+\M@cal@num"1D4AB\relax
5508 \Umathcode`Q=0+\M@cal@num"1D4AC\relax
5509 \Umathcode`R=0+\M@cal@num"211B\relax
5510 \Umathcode`S=0+\M@cal@num"1D4AE\relax
5511 \Umathcode`T=0+\M@cal@num"1D4AF\relax
5512 \Umathcode`U=0+\M@cal@num"1D4B0\relax
5513 \Umathcode`V=0+\M@cal@num"1D4B1\relax
5514 \Umathcode`W=0+\M@cal@num"1D4B2\relax
5515 \Umathcode`X=0+\M@cal@num"1D4B3\relax
5516 \Umathcode`Y=0+\M@cal@num"1D4B4\relax
5517 \Umathcode`Z=0+\M@cal@num"1D4B5\relax
5518 \Umathcode`a=0+\M@cal@num"1D4B6\relax
5519 \Umathcode`b=0+\M@cal@num"1D4B7\relax
5520 \Umathcode`c=0+\M@cal@num"1D4B8\relax
5521 \Umathcode`d=0+\M@cal@num"1D4B9\relax
5522 \Umathcode`e=0+\M@cal@num"212F\relax
5523 \Umathcode`f=0+\M@cal@num"1D4BB\relax
5524 \Umathcode`g=0+\M@cal@num"210A\relax
5525 \Umathcode`h=0+\M@cal@num"1D4BD\relax
5526 \Umathcode`i=0+\M@cal@num"1D4BE\relax
5527 \Umathcode`j=0+\M@cal@num"1D4BF\relax
5528 \Umathcode`k=0+\M@cal@num"1D4C0\relax
5529 \Umathcode`l=0+\M@cal@num"1D4C1\relax
5530 \Umathcode`m=0+\M@cal@num"1D4C2\relax
5531 \Umathcode`n=0+\M@cal@num"1D4C3\relax
5532 \Umathcode`o=0+\M@cal@num"2134\relax
5533 \Umathcode`p=0+\M@cal@num"1D4C5\relax
5534 \Umathcode`q=0+\M@cal@num"1D4C6\relax
5535 \Umathcode`r=0+\M@cal@num"1D4C7\relax
5536 \Umathcode`s=0+\M@cal@num"1D4C8\relax
5537 \Umathcode`t=0+\M@cal@num"1D4C9\relax
5538 \Umathcode`u=0+\M@cal@num"1D4CA\relax
5539 \Umathcode`v=0+\M@cal@num"1D4CB\relax
5540 \Umathcode`w=0+\M@cal@num"1D4CC\relax
5541 \Umathcode`x=0+\M@cal@num"1D4CD\relax
5542 \Umathcode`y=0+\M@cal@num"1D4CE\relax
5543 \Umathcode`z=0+\M@cal@num"1D4CF\relax}}
5544 % \end{macrocode}
5545 % Set fraktur letters.
5546 % \begin{macrocode}
5547 \def\M@frak@set{
5548 \protected\def\mathfrak##1{\relax
5549 \ifmmode\else
5550 \M@HModeError\mathfrak
5551 $
5552 \fi
5553 \begingroup
5554 \M@frak@mathcodes
5555 ##1
5556 \endgroup}
5557 \edef\M@frak@num{\number
5558 \csname symM\@tempc-\M@frakshape\endcsname}
5559 \protected\edef\M@frak@mathcodes{
5560 \Umathcode`A=0+\M@frak@num"1D504\relax
5561 \Umathcode`B=0+\M@frak@num"1D505\relax
5562 \Umathcode`C=0+\M@frak@num"212D\relax
5563 \Umathcode`D=0+\M@frak@num"1D507\relax
5564 \Umathcode`E=0+\M@frak@num"1D508\relax
5565 \Umathcode`F=0+\M@frak@num"1D509\relax
5566 \Umathcode`G=0+\M@frak@num"1D50A\relax
5567 \Umathcode`H=0+\M@frak@num"210C\relax
5568 \Umathcode`I=0+\M@frak@num"2111\relax
5569 \Umathcode`J=0+\M@frak@num"1D50D\relax
5570 \Umathcode`K=0+\M@frak@num"1D50E\relax
5571 \Umathcode`L=0+\M@frak@num"1D50F\relax
5572 \Umathcode`M=0+\M@frak@num"1D510\relax
5573 \Umathcode`N=0+\M@frak@num"1D511\relax
5574 \Umathcode`O=0+\M@frak@num"1D512\relax
5575 \Umathcode`P=0+\M@frak@num"1D513\relax
5576 \Umathcode`Q=0+\M@frak@num"1D514\relax
5577 \Umathcode`R=0+\M@frak@num"211C\relax
5578 \Umathcode`S=0+\M@frak@num"1D516\relax
5579 \Umathcode`T=0+\M@frak@num"1D517\relax
5580 \Umathcode`U=0+\M@frak@num"1D518\relax
5581 \Umathcode`V=0+\M@frak@num"1D519\relax
5582 \Umathcode`W=0+\M@frak@num"1D51A\relax
5583 \Umathcode`X=0+\M@frak@num"1D51B\relax
5584 \Umathcode`Y=0+\M@frak@num"1D51C\relax
5585 \Umathcode`Z=0+\M@frak@num"2128\relax
5586 \Umathcode`a=0+\M@frak@num"1D51E\relax
5587 \Umathcode`b=0+\M@frak@num"1D51F\relax
5588 \Umathcode`c=0+\M@frak@num"1D520\relax
5589 \Umathcode`d=0+\M@frak@num"1D521\relax
5590 \Umathcode`e=0+\M@frak@num"1D522\relax
5591 \Umathcode`f=0+\M@frak@num"1D523\relax
5592 \Umathcode`g=0+\M@frak@num"1D524\relax
5593 \Umathcode`h=0+\M@frak@num"1D525\relax
5594 \Umathcode`i=0+\M@frak@num"1D526\relax
5595 \Umathcode`j=0+\M@frak@num"1D527\relax
5596 \Umathcode`k=0+\M@frak@num"1D528\relax
5597 \Umathcode`l=0+\M@frak@num"1D529\relax
5598 \Umathcode`m=0+\M@frak@num"1D52A\relax
5599 \Umathcode`n=0+\M@frak@num"1D52B\relax
5600 \Umathcode`o=0+\M@frak@num"1D52C\relax
5601 \Umathcode`p=0+\M@frak@num"1D52D\relax
5602 \Umathcode`q=0+\M@frak@num"1D52E\relax
5603 \Umathcode`r=0+\M@frak@num"1D52F\relax
5604 \Umathcode`s=0+\M@frak@num"1D530\relax
5605 \Umathcode`t=0+\M@frak@num"1D531\relax
5606 \Umathcode`u=0+\M@frak@num"1D532\relax
5607 \Umathcode`v=0+\M@frak@num"1D533\relax
5608 \Umathcode`w=0+\M@frak@num"1D534\relax
5609 \Umathcode`x=0+\M@frak@num"1D535\relax
5610 \Umathcode`y=0+\M@frak@num"1D536\relax
5611 \Umathcode`z=0+\M@frak@num"1D537\relax}}
5612 % \end{macrocode}
5613 % Set bold caligraphic letters.
5614 % \begin{macrocode}
5615 \def\M@bcal@set{
5616 \protected\def\mathbcal##1{\relax
5617 \ifmmode\else
5618 \M@HModeError\mathbcal
5619 $
5620 \fi
5621 \begingroup
5622 \M@bcal@mathcodes
5623 ##1
5624 \endgroup}
5625 \edef\M@bcal@num{\number
5626 \csname symM\@tempc-\M@bcalshape\endcsname}
5627 \protected\edef\M@bcal@mathcodes{
5628 \Umathcode`A=0+\M@bcal@num"1D4D0\relax
5629 \Umathcode`B=0+\M@bcal@num"1D4D1\relax
5630 \Umathcode`C=0+\M@bcal@num"1D4D2\relax
5631 \Umathcode`D=0+\M@bcal@num"1D4D3\relax
5632 \Umathcode`E=0+\M@bcal@num"1D4D4\relax
5633 \Umathcode`F=0+\M@bcal@num"1D4D5\relax
5634 \Umathcode`G=0+\M@bcal@num"1D4D6\relax
5635 \Umathcode`H=0+\M@bcal@num"1D4D7\relax
5636 \Umathcode`I=0+\M@bcal@num"1D4D8\relax
5637 \Umathcode`J=0+\M@bcal@num"1D4D9\relax
5638 \Umathcode`K=0+\M@bcal@num"1D4DA\relax
5639 \Umathcode`L=0+\M@bcal@num"1D4DB\relax
5640 \Umathcode`M=0+\M@bcal@num"1D4DC\relax
5641 \Umathcode`N=0+\M@bcal@num"1D4DD\relax
5642 \Umathcode`O=0+\M@bcal@num"1D4DE\relax
5643 \Umathcode`P=0+\M@bcal@num"1D4DF\relax
5644 \Umathcode`Q=0+\M@bcal@num"1D4E0\relax
5645 \Umathcode`R=0+\M@bcal@num"1D4E1\relax
5646 \Umathcode`S=0+\M@bcal@num"1D4E2\relax
5647 \Umathcode`T=0+\M@bcal@num"1D4E3\relax
5648 \Umathcode`U=0+\M@bcal@num"1D4E4\relax
5649 \Umathcode`V=0+\M@bcal@num"1D4E5\relax
5650 \Umathcode`W=0+\M@bcal@num"1D4E6\relax
5651 \Umathcode`X=0+\M@bcal@num"1D4E7\relax
5652 \Umathcode`Y=0+\M@bcal@num"1D4E8\relax
5653 \Umathcode`Z=0+\M@bcal@num"1D4E9\relax
5654 \Umathcode`a=0+\M@bcal@num"1D4EA\relax
5655 \Umathcode`b=0+\M@bcal@num"1D4EB\relax
5656 \Umathcode`c=0+\M@bcal@num"1D4EC\relax
5657 \Umathcode`d=0+\M@bcal@num"1D4ED\relax
5658 \Umathcode`e=0+\M@bcal@num"1D4EE\relax
5659 \Umathcode`f=0+\M@bcal@num"1D4EF\relax
5660 \Umathcode`g=0+\M@bcal@num"1D4F0\relax
5661 \Umathcode`h=0+\M@bcal@num"1D4F1\relax
5662 \Umathcode`i=0+\M@bcal@num"1D4F2\relax
5663 \Umathcode`j=0+\M@bcal@num"1D4F3\relax
5664 \Umathcode`k=0+\M@bcal@num"1D4F4\relax
5665 \Umathcode`l=0+\M@bcal@num"1D4F5\relax
5666 \Umathcode`m=0+\M@bcal@num"1D4F6\relax
5667 \Umathcode`n=0+\M@bcal@num"1D4F7\relax
5668 \Umathcode`o=0+\M@bcal@num"1D4F8\relax
5669 \Umathcode`p=0+\M@bcal@num"1D4F9\relax
5670 \Umathcode`q=0+\M@bcal@num"1D4FA\relax
5671 \Umathcode`r=0+\M@bcal@num"1D4FB\relax
5672 \Umathcode`s=0+\M@bcal@num"1D4FC\relax
5673 \Umathcode`t=0+\M@bcal@num"1D4FD\relax
5674 \Umathcode`u=0+\M@bcal@num"1D4FE\relax
5675 \Umathcode`v=0+\M@bcal@num"1D4FF\relax
5676 \Umathcode`w=0+\M@bcal@num"1D500\relax
5677 \Umathcode`x=0+\M@bcal@num"1D501\relax
5678 \Umathcode`y=0+\M@bcal@num"1D502\relax
5679 \Umathcode`z=0+\M@bcal@num"1D503\relax}}
5680 % \end{macrocode}
5681 % Set bold fraktur letters.
5682 % \begin{macrocode}
5683 \def\M@bfrak@set{
5684 \protected\def\mathbfrak##1{\relax
5685 \ifmmode\else
5686 \M@HModeError\mathbfrak
5687 $
5688 \fi
5689 \begingroup
5690 \M@bfrak@mathcodes
5691 ##1
5692 \endgroup}
5693 \edef\M@bfrak@num{\number
5694 \csname symM\@tempc-\M@bfrakshape\endcsname}
5695 \protected\edef\M@bfrak@mathcodes{
5696 \Umathcode`A=0+\M@bfrak@num"1D56C\relax
5697 \Umathcode`B=0+\M@bfrak@num"1D56D\relax
5698 \Umathcode`C=0+\M@bfrak@num"1D56E\relax
5699 \Umathcode`D=0+\M@bfrak@num"1D56F\relax
5700 \Umathcode`E=0+\M@bfrak@num"1D570\relax
5701 \Umathcode`F=0+\M@bfrak@num"1D571\relax
5702 \Umathcode`G=0+\M@bfrak@num"1D572\relax
5703 \Umathcode`H=0+\M@bfrak@num"1D573\relax
5704 \Umathcode`I=0+\M@bfrak@num"1D574\relax
5705 \Umathcode`J=0+\M@bfrak@num"1D575\relax
5706 \Umathcode`K=0+\M@bfrak@num"1D576\relax
5707 \Umathcode`L=0+\M@bfrak@num"1D577\relax
5708 \Umathcode`M=0+\M@bfrak@num"1D578\relax
5709 \Umathcode`N=0+\M@bfrak@num"1D579\relax
5710 \Umathcode`O=0+\M@bfrak@num"1D57A\relax
5711 \Umathcode`P=0+\M@bfrak@num"1D57B\relax
5712 \Umathcode`Q=0+\M@bfrak@num"1D57C\relax
5713 \Umathcode`R=0+\M@bfrak@num"1D57D\relax
5714 \Umathcode`S=0+\M@bfrak@num"1D57E\relax
5715 \Umathcode`T=0+\M@bfrak@num"1D57F\relax
5716 \Umathcode`U=0+\M@bfrak@num"1D580\relax
5717 \Umathcode`V=0+\M@bfrak@num"1D581\relax
5718 \Umathcode`W=0+\M@bfrak@num"1D582\relax
5719 \Umathcode`X=0+\M@bfrak@num"1D583\relax
5720 \Umathcode`Y=0+\M@bfrak@num"1D584\relax
5721 \Umathcode`Z=0+\M@bfrak@num"1D585\relax
5722 \Umathcode`a=0+\M@bfrak@num"1D586\relax
5723 \Umathcode`b=0+\M@bfrak@num"1D587\relax
5724 \Umathcode`c=0+\M@bfrak@num"1D588\relax
5725 \Umathcode`d=0+\M@bfrak@num"1D589\relax
5726 \Umathcode`e=0+\M@bfrak@num"1D58A\relax
5727 \Umathcode`f=0+\M@bfrak@num"1D58B\relax
5728 \Umathcode`g=0+\M@bfrak@num"1D58C\relax
5729 \Umathcode`h=0+\M@bfrak@num"1D58D\relax
5730 \Umathcode`i=0+\M@bfrak@num"1D58E\relax
5731 \Umathcode`j=0+\M@bfrak@num"1D58F\relax
5732 \Umathcode`k=0+\M@bfrak@num"1D590\relax
5733 \Umathcode`l=0+\M@bfrak@num"1D591\relax
5734 \Umathcode`m=0+\M@bfrak@num"1D592\relax
5735 \Umathcode`n=0+\M@bfrak@num"1D593\relax
5736 \Umathcode`o=0+\M@bfrak@num"1D594\relax
5737 \Umathcode`p=0+\M@bfrak@num"1D595\relax
5738 \Umathcode`q=0+\M@bfrak@num"1D596\relax
5739 \Umathcode`r=0+\M@bfrak@num"1D597\relax
5740 \Umathcode`s=0+\M@bfrak@num"1D598\relax
5741 \Umathcode`t=0+\M@bfrak@num"1D599\relax
5742 \Umathcode`u=0+\M@bfrak@num"1D59A\relax
5743 \Umathcode`v=0+\M@bfrak@num"1D59B\relax
5744 \Umathcode`w=0+\M@bfrak@num"1D59C\relax
5745 \Umathcode`x=0+\M@bfrak@num"1D59D\relax
5746 \Umathcode`y=0+\M@bfrak@num"1D59E\relax
5747 \Umathcode`z=0+\M@bfrak@num"1D59F\relax}}
5748 % \end{macrocode}
5749 % Reset |\endlinechar|.
5750 % \begin{macrocode}
5751 \endlinechar\count@
5752 % \end{macrocode}
5753 % And that's everything!
5754 %
5755 % \vfill\eject
5756 %
5757 % \section*{Version History}
5758 %
5759 % New features and updates with each version. Listed in no particular order.
5760 %
5761 % \begin{multicols*}{2}
5762 % \bgroup\raggedright\parskip\z@\parindent\z@\leftskip1em\obeylines
5763 % \setbox0\hbox{\hskip 1pt.\hskip 1pt}
5764 % \def\version#1#2{\par\bigskip
5765 % \hbox to \hsize{\textbf{#1}\kern2pt%
5766 % \cleaders\copy0\hfill\kern2pt#2\strut}\par}
5767 % \def\item{\leavevmode\raise0.5ex\hbox{\vrule height 1pt width 0.5em}\kern1pt}
5768 % \def\item{---\kern0.2ex\relax}^^A I like the em dash better than a vrule
5769 %
5770 % \version{1.1b}{July 2018}
5771 % \item initial release
5772 %
5773 % \version{1.2}{August 2018}
5774 % \item minor bug fix for |\mathfrak|
5775 % \item eliminated redundant batchfile
5776 %
5777 % \version{1.3}{January 2019}
5778 % \item added |symbols| keyword\par
5779 % \item created |mathfont_example.pdf|
5780 % \item corrected the description of the \textsf{mathastext} package
5781 % \item font-change |\message| added to |\mathfont|
5782 %
5783 % \version{1.4}{April 2019}
5784 % \item |\setfont| command added
5785 % \item |\mathfont| optional argument can parse spaces
5786 % \item |no-operators| now default package optional argument
5787 % \item added |\comma| command
5788 % \item new fancy fatal error message
5789 % \item improved messaging for |\mathfont|
5790 % \item internal command |\mathpound| changed to |\mathhash|
5791 % \item added a missing |#1| after |\char`\"| in the example code redefining |"| in the user guide
5792 %
5793 % \version{1.5}{April 2019}
5794 % \item separated |\increment| and |\Delta|
5795 % \item version history added
5796 % \item initial off-the-shelf use insert added
5797 %
5798 % \version{1.6}{December 2019}
5799 % \item separated implementation and user documentation
5800 % \item created |mathfont_heading.tex|
5801 % \item created |mathfont_doc_patch.tex| for use with the index
5802 % \item changed |mathfont_greek.pdf| to |mathfont_symbol_list.pdf|
5803 % \item eliminated |mathfont_example.pdf|
5804 % \item eliminated |operators| package option
5805 % \item eliminated |packages| package option
5806 % \item font name can be package option
5807 % \item added Hebrew and Cyrillic characters
5808 % \item separated ancient Greek from modern Greek characters
5809 % \item created new keywords: |extsymbols|, |delimiters|, |arrows|, |diacritics|, |bigops|, |extbigops|
5810 % \item improved messaging
5811 % \item improved internal code for local font-change commands
5812 % \item improved space parsing for the optional argument of |\mathfont|
5813 % \item bug fix for |\#|, etc.\ commands
5814 % \item bad input for |\mathbb|, etc.\ now gives a warning
5815 % \item improved error checking for |\newmathrm|, etc.\ commands
5816 % \item |\mathfont| now ignores bad options (on top of issuing an error)
5817 % \item iternal commands now begin with |\M@|\dots
5818 % \item added Easter Egg!
5819 % \item improved indexing
5820 % \item |mathfont.dtx| renamed as |mathfont_code.dtx|
5821 % \item |\newmathbold| renamed as |\newmathbf|
5822 % \item default local font changes now use |\updefault|, etc.
5823 % \item added fatal error for missing \textsf{fontspec}
5824 % \item fatal errors result in |\endinput| rather than |\@@end|
5825 %
5826 % \version{2.0}{December 2021}
5827 % {\smallskip\leftskip\z@
5828 % \fboxrule=1pt\relax
5829 % \dimen@\hsize
5830 % \advance\dimen@ by -2\fboxrule
5831 % \advance\dimen@ by -2\fboxsep
5832 % \fbox{\vbox{\hsize\dimen@
5833 % \strut\textbf{Big Change:} Font adjustments for Lua\TeX: new glyph boundaries for Latin letters in math mode, resizable delimiters, big operators, MathConstants table based on font metrics.\vphantom y}}\par\smallskip}
5834 % \item added |\charmline| and |\charmfile|
5835 % \item added |\mathconstantsfont|
5836 % \item certain dimensions in equations are now adjustable when typesetting with Lua\TeX
5837 % \item added |adjust| and |no-adjust| package options
5838 % \item automatic generation of |ind| file
5839 % \item fixed symbols for |\leftharpoonup|, |\leftharpoondown|, and fraktur R
5840 % \item cleaned up internal code and documentation
5841 % \item font names for |\mathfont| stored to avoid multiple symbol font declarations with the same font
5842 % \item more information about nfss family names stored and provided
5843 % \item added option |empty|
5844 % \item raised upper bound on |\DeclareSymbolFont| to 256
5845 % \item reintroduced |mathfont_example.tex| with different contents
5846 % \item changed several symbol-commands to |\protected| rather than robust macros
5847 % \item many user-level commands are now |\protected|
5848 % \item |\updefault| changed to |\shapedefault|
5849 % \item eliminated |\catcode| change for space characters when scanning optional argument of |\mathfont|
5850 % \item improved messaging for |\mathfont|
5851 % \item removed dependence on \textsf{fontspec} and added internal font-loader
5852 % \item switched |\epsilon| and |\varepsilon|
5853 % \item switched |\phi| and |\varphi|
5854 % \item changed |/| to produce a solidus in math mode and added |\fractionslash|
5855 % \item removed |\restoremathinternals| from the user guide
5856 % \item |\setfont| now sets |\mathrm|, etc.
5857 % \item added |\newmathsc|, other math alphabet commands for small caps
5858 %
5859 % \version{2.1}{November 2022}
5860 % \item |\mathbb|, etc.\ commands change |\Umathcode|s of letters instead of |\M@|\meta{bb,etc.}|@|\meta{letter} commands
5861 % \item removed warnings about non-letter contents of |\mathbb|, etc.
5862 % \item fonts loaded twice, once in unspecified mode (for text) and once in base mode (for math)
5863 % \item |mathconstantsfont| accepts ``upright'' or ``italic'' as optional argument
5864 %
5865 % \version{2.2}{December 2022}
5866 % \item changed the easter egg text
5867 % \item updated patch for |\DeclareSymbolFont| to work with changes to the kernel (fixed the |\M@p@tch@decl@re| error message)
5868 % \item calling Plain \TeX\ on \texttt{mathfont\_code.dtx} produces sty file and no pdf file
5869 %
5870 % \version{2.2a}{December 2022}
5871 % \item bug fix for |\mathconstantsfont|
5872 % \item bug fix for |\M@check@int|
5873 % \item added |doc2| option to |ltxdoc| in \texttt{mathfont\_code.dtx}
5874 %
5875 % \version{2.2b}{August 2023}
5876 % \item minor changes to code and documentation
5877 % \item |\ng| now works in math (as not greater than symbol) and text (as pronounciation symbol)
5878 %
5879 % \version{2.3}{September 2023}
5880 % \item solidus and |\fractionslash| are |\mathord| instead of |\mathbin|
5881 % \item removed |\mathfont{fontspec}| functionality
5882 % \item redesigned font-loader
5883 % \item added package options |default-loader| and |fontspec-loader|
5884 %
5885 % \version{2.4}{April 2025}
5886 % \item |\colon| is |\mathpunct| instead of |\mathord|
5887 % \item moved |\relbar| and |\Relbar| to |arrows|
5888 % \item reformatted |mathfont_code.pdf|
5889 % \item made compatible with |\mathbb|, etc.\ commands from other packages
5890 % \item renamed |set_nomath_true| to |set_nomath_false|
5891 % \item improved messaging |\AtBeginDocument|
5892 % \item removed deprecated package options, |\newmathbold|, |\restoremathinternals|
5893 % \item more Easter egg messages
5894 %
5895 % \version{2.4a}{June 2025}
5896 % \item bug fix involving nil value and |the_font|
5897 % \item changed underscores in file names to hyphens
5898 %
5899 % \version{3.0}{January 2026}
5900 % \item |\mathfont| and |\setfont| no longer restricted to preamble
5901 % \item effects of |\mathfont| are local instead of global
5902 % \item |\mathfont| now overrides previous calls to |\mathfont|
5903 % \item added |\mathfontshapes|
5904 % \item added |\mainfont|
5905 % \item changed |\setfont| to |\documentfont| (but kept old name for backwards compatibility)
5906 % \item changed |\setmathfontcommands| to |\mathfontcommands| and added documentation in the user guide
5907 % \item added support for arbitrary \textsc{nfss} series/shape codes in |\mathfont|
5908 % \item separated macros for default shapes from macros for shapes used in |\mathfont|
5909 % \item formalized language of keywords and shape identifiers
5910 % \item font-loader is better about using argument with spaces removed for checking \textsc{nfss} font family
5911 % \item font-loader now uses |\@tempshape| and |\@tempseries| when parsing argument
5912 % \item moved assignment of |\M@count| values into |\M@newfont|
5913 % \item changed |\CharmLine| to |\charmline| (but kept old name for backwards compatibility)
5914 % \item |\charmline| now uses |token.scan_string()| for scanning and expanding its argument
5915 % \item changed |\CharmFile| to |\charmfile| (but kept old name for backwards compatibility)
5916 % \item added |\charminfo|
5917 % \item added |\charmtype|
5918 % \item renamed counts for |\SurdHorizontalFactor|, etc.\ to be at user level
5919 % \item formalized language of user-friendly versions of Lua\TeX-only commands in the user guide
5920 % \item corrected axis height
5921 % \item font adjustments now happen only if |mode=base|
5922 % \item no more virtual Latin letters in extra encoding slots (package now modifies Latin letters in their regular encoding slots for base-mode fonts)
5923 % \item added |bold| and |bolditalic| shape identifiers
5924 % \item no more type |u| (became type |a|)
5925 % \item added separate charm information for upright and italic fonts (specified using |/| character)
5926 % \item reworked default charm values
5927 % \item possible to force type |a| and type |e| characters using |?| and |!| in |\charmline|
5928 % \item added extra field in type |e| for italic correction
5929 % \item clarified role of |bot_accent|, which does nothing, in the user guide
5930 % \item cleaned up Lua code
5931 % \item added |finishing_touches| callback
5932 % \item bug fix involving the handling of italic correction in Lua font adjustments
5933 % \item bug fix involving characters in operator font not displaying
5934 % \item corrected UTF-16BE information added to character subtables in the font
5935 % \item new definition for |\not|
5936 % \item added |\negslash|
5937 % \item added |script=math| to OpenType features for fonts if intended for math (so math fonts load with built-in math features)
5938 % \item added support for Unicode input
5939 % \item switched |\epsilon| and |\varepsilon| (so |\epsilon| is Unicode epsilon and |\varepsilon| is Unicode lunate epsilon)
5940 % \item surd is now an active character in math mode (|\mathcode"8000|)
5941 % \item cleaned up error messages
5942 % \item improved messaging |\AtBeginDocument|
5943 % \item better error checking in |\M@check@int|
5944 %
5945 % \version{3.0a}{February 2026}
5946 % \item removed spurious space in |\mainfont|
5947 % \item for base-mode version of fonts, replaced |script=math| with |-nomathparam|
5948 % \item added |script=latn| to default font features
5949 %
5950 %
5951 %
5952 %
5953 %
5954 %
5955 %
5956 % \egroup
5957 % \end{multicols*}
5958 %
5959 %
5960 %
5961 % \iffalse
5962 %
5963 %</package>
5964 %<*user>
5965 \documentclass[12pt]{article}
5966 \makeatletter
5967 \usepackage[margin=72.27pt]{geometry}
5968 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
5969 \usepackage[bottom]{footmisc}
5970 \usepackage{booktabs}
5971 \usepackage{graphicx}
5972 \usepackage{tabularx}
5973 \usepackage{multirow}
5974 \usepackage[implicit=false,colorlinks=true,allcolors=blue]{hyperref}
5975 \usepackage{enumitem}
5976 \SetEnumitemKey{special}{topsep=\smallskipamount,
5977 itemsep=\smallskipamount,
5978 parsep=\z@,partopsep=\z@}
5979 \setlist{special}
5980 \usepackage{doc}[=v2]
5981 \MakeShortVerb{|}
5982
5983 \protected\def\bigskip{\vskip\bigskipamount}
5984 \protected\def\medskip{\vskip\medskipamount}
5985 \protected\def\smallskip{\vskip\smallskipamount}
5986
5987 \def\link#1{\href{#1}{\nolinkurl{#1}}}
5988 \newcount\fig
5989 \fig=1\relax
5990 \c@topnumber\@ne
5991 % \skip\footins=7pt
5992
5993 % Our own label/ref scheme because the standard one isn't working
5994 \def\labelfig#1{\immediate\write\@auxout{\string\makelabel{#1}{\the\fig}}}
5995 \def\makelabel#1#2{\expandafter\gdef\csname fig@#1\endcsname{#2}}
5996
5997 \begin{document}
5998 \def\ref#1{\csname fig@#1\endcsname}
5999
6000
6001 \def\documentname{User Guide}
6002 \def\showabstract{1}
6003 \input mathfont-heading.tex
6004
6005 \baselineskip=\the\baselineskip minus 0.5pt
6006
6007
6008 \noindent Handling fonts in \TeX\ and \LaTeX\ is a notoriously difficult task because fonts are complicated.\footnote{The last few decades have seen huge advances in loading fonts with \TeX. Donald Knuth originally designed \TeX\ to load only fonts created with Metafont, and more recent engines such as Jonathan Kew's \XeTeX\ and Hans Hagen, et al.'s Lua\TeX\ have extended \TeX's font-loading capabilities to Unicode. \XeTeX\ supports OpenType and TrueType fonts natively, and Lua\TeX\ can load OpenType fonts through the \hbox{\textsf{luaotfload}} package. Information on \XeTeX\ is available at \link{https://tug.org/xetex/}, and information on Lua\TeX\ is available at the official website for Lua\TeX: \link{http://www.luatex.org/}. See also Ulrike Fischer, et al., ``\textsf{luaotfload}---OpenType `loader' for Plain \TeX\ and \LaTeX,'' \link{https://ctan.org/pkg/luaotfload}. For discussion of fonts generally, see Yannis Haralambous, \textit{Fonts \& Encodings} (Sebastopol: O'Reilly Media, Inc., 2007).} The \textsf{mathfont} package addresses this situation by providing tools to use TrueType and OpenType fonts in math mode and in the main text, and this user guide explains how to operate \textsf{mathfont}. For version history and code implementation, see |mathfont-code.pdf|, and for a list of all symbols accessible with \textsf{mathfont}, see |mathfont-symbol-list.pdf|. Those two pdf files, this user guide, and four example files are included in the \textsf{mathfont} installation and are available on \textsc{ctan}. Because Unicode text fonts are plentiful, I hope that this package expands the possibilities for typesetting math in \LaTeX.
6009
6010
6011 \section{Loading and Basic Functionality}
6012
6013 Loading\vadjust{\penalty-9999} fonts for math typesetting is more complicated than for regular text. First, selecting fonts for math mode, both in plain \TeX\ and in the \textsc{nfss}, involves additional macros above and beyond what we need to load text fonts. Second, \TeX\ expects fonts for math to contain extra information for formatting equations.\footnote{Specifically, this extra information is a set of large variants, math-specific parameter values associated with individual characters, and a MathConstants table. Also, math fonts often use slightly wider bounding boxes for letters in math mode---the Computer Modern $f$ is a well-known example. (Compare math-mode {\fboxsep=0pt\fbox{$f$}} and italic {\fboxsep=0pt\fbox{\textit f}}. Without italic correction, we have {\fboxsep=0pt\fbox{\itshape f}}.) For this reason, \textsf{mathfont} provides an interface to enlarge the bounding boxes of most Unicode characters when they appear in math mode. See section~5 for details.} Broadly speaking, we say that a \textit{math font} contains this extra information, whereas a \textit{text font} does not, and typesetting math with glyphs from one or more text fonts may yield messier equations than using a properly prepared math font. The functionality of \textsf{mathfont} then is twofold: (1) provide a wrapper around the \textsc{nfss} commands for math typesetting that serves as a high-level interface; and (2) implement Lua\TeX\ callbacks that artificially convert text fonts into math fonts at loading.\footnote{Values for MathConstants table are different from but inspired by Ulrik Vieth, ``Understanding the \AE sthetics of Math Typesetting,'' (Bacho\TeX\ Conference, 2008) and Ulrik Vieth ``OpenType Math Illuminated,'' \textit{TUGboat} 30 (2009): 22--31. See also Bogus\l aw Jackowski, ``Appendix G Illuminated,'' \textit{TUGboat} 27 (2006): 83--90.} Although \textsf{mathfont} tries its best to get your fonts right, it may run into trouble when picking fonts to load. If this happens, you should declare your font family and shapes in the \textsc{nfss} before setting any fonts with \textsf{mathfont}.
6014
6015
6016 \begin{figure}[t]\labelfig{packages}
6017 \centerline{\bfseries Table \the\fig: Comparison of General Font-Loading Packages\strut}
6018 \global\advance\fig\@ne
6019 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}\toprule
6020 & Text font & Math font\\\cmidrule{2-3}
6021 Traditional \TeX\ font & \textsf{mathastext} & No general package\\
6022 Unicode font (for math typesetting) & \textsf{mathfont} or \textsf{mathspec} & (\textsf{lua-})\textsf{unicode-math}\\
6023 Unicode font (for text only) & \textsf{fontspec} & \textsf{fontspec} \\\bottomrule
6024 \end{tabular*}
6025 \end{figure}
6026
6027
6028 You must use one of \XeLaTeX\ or Lua\LaTeX\ to typeset a document with \textsf{mathfont}. You can load \textsf{mathfont} with the standard |\usepackage| syntax, and the package accepts five optional arguments. If you use Lua\TeX, the options |adjust| or |no-adjust| will manually specify whether \textsf{mathfont} should adapt text fonts for math mode, and \textsf{mathfont} selects |adjust| by default. If you use \XeTeX, \textsf{mathfont} cannot adjust any font objects with Lua callbacks, and either of these package options will cause an error.\footnote{With \XeLaTeX, \textsf{mathfont} does not add big operators or resizable delimiters to the font. This means you will have to use the Computer Modern defaults, load a separate math font for resizable characters, or end up with a document where large operators and delimiters do not scale like they do normally.} For this reason, using Lua\TeX\ with \textsf{mathfont} is recommended as of version 2.0. The options |default-loader| and |fontspec-loader| determine which font-loading code \textsf{mathfont} uses. If you load the package with the |default-loader| option, \textsf{mathfont} uses a built-in font-loader, and if you load the package with |fontspec-loader|, \textsf{mathfont} uses the font-loader from \textsf{fontspec}. If you load \textsf{mathfont} with any other optional argument, the package will interpret it as a font name and call |\documentfont| (described in the next section) on your argument. Doing so selects that font for the text of your document and for the character classes in the upper portion of Table~\ref{Keywords}.
6029
6030
6031 \begin{figure}[t]\labelfig{commands}
6032 \centerline{\bfseries Table \the\fig: Main User-Level Control Sequences Provided by \textsf{mathfont}\strut}
6033 \global\advance\fig\@ne
6034 \tabcolsep\z@
6035 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}llp{1in}<{\raggedright\arraybackslash}}\toprule
6036 Control Sequence & Use & Engine\\\midrule
6037 \vrb\documentfont & Set font for text and math & \multirow{6}{*}{\vbox{\XeTeX\ and Lua\TeX}}\\
6038 \vrb\mainfont & Set font for text &\\
6039 \vrb\mathfont & Set font for math &\\
6040 \vrb\mathfontshapes & Declare font shapes in the preamble &\\
6041 \vrb\newmath\meta{specifier} & Create local font-change command for math &\\
6042 \vrb\mathfontcommands & Create several local font-change commands &\\\midrule
6043 \vrb\mathconstantsfont & Select MathConstants table for use &\multirow{8}{*}{Lua\TeX\ only}\\
6044 \vrb\charmline & Enlarge bounding box; change size of extensibles &\\
6045 \vrb\charmfile & Call \vrb\charmline\ on each line from a file &\\
6046 \vrb\charminfo & Print charm information of a character &\\
6047 \vrb\charmtype & Print type of a character for charm purposes &\\
6048 \vrb\hsurdfactor & Move overline for square root horizontally &\\
6049 \vrb\vsurdfactor & Move overline for square root vertically &\\
6050 \vrb\rulethicknessfactor & Set rule thickness for square root, fractions &\\
6051 \bottomrule
6052 \end{tabular*}
6053 \end{figure}
6054
6055
6056
6057 \begin{figure}[t]\labelfig{Keywords}
6058 \centerline{\bfseries Table \the\fig: Character Classes\strut}
6059 \global\advance\fig by 1\relax
6060 \tabcolsep\z@
6061 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lllc}\toprule
6062 Keyword & Meaning & Default Shape Identifier & Alphabetic?\\\midrule
6063 |upper| & Upper-Case Latin & |italic| & Yes\\
6064 |lower| & Lower-Case Latin & |italic| & Yes\\
6065 |diacritics| & Diacritics & |upright| & Yes\\
6066 |greekupper| & Upper-Case Greek & |upright| & Yes\\
6067 |greeklower| & Lower-Case Greek & |italic| & Yes\\
6068 |digits| & Arabic Numerals & |upright| & Yes\\
6069 |operator| & Operator Font & |upright*| & N/A\rlap{\textsuperscript\dag}\\
6070 |delimiters| & Delimiter & |upright| & No\\
6071 |radical| & Square Root Symbol & |upright| & No\\
6072 |symbols| & Basic Math Symbols & |upright| & No\\
6073 |bigops| & Big Operators & |upright| & No\\\midrule
6074 |agreekupper| & Upper-Case Ancient Greek & |upright| & Yes\\
6075 |agreeklower| & Lower-Case Ancient Greek & |italic| & Yes\\
6076 |cyrillicupper| & Upper-Case Cyrillic & |upright| & Yes\\
6077 |cyrilliclower| & Lower-Case Cyrillic & |italic| & Yes\\
6078 |hebrew| & Hebrew & |upright| & Yes\\
6079 |extsymbols| & Extended Math Symbols & |upright| & No\\
6080 |arrows| & Arrows & |upright| & No\\
6081 |extbigops| & Extended Big Operators & |upright| & No\\
6082 |bb| & Blackboard Bold (double-struck) & |upright| & No\\
6083 |cal| & Caligraphic & |upright| & No\\
6084 |frak| & Fraktur & |upright| & No\\
6085 |bcal| & Bold Caligraphic & |upright| & No\\
6086 |bfrak| & Bold Fraktur & |upright| & No\\
6087 \bottomrule
6088 \end{tabular*}
6089 \smallskip\footnotesize
6090 \noindent\strut\textsuperscript\dag Technically |opererator| is not a class of symbols but rather is a local font-change instruction similar to what is described in section~3 of this user guide.
6091 \end{figure}
6092
6093
6094
6095 \begin{figure}[t]\labelfig{Shape-Identifiers}
6096 \centerline{\bfseries Table \the\fig: Shape Identifiers\strut}
6097 \global\advance\fig by 1\relax
6098 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lllll}\toprule
6099 Identifier & Series & Uses \textsc{nfss} Series & Shape & Uses \textsc{nfss} Shape\\\midrule
6100 |upright| & medium & \vrb\mddefault & upright & \vrb\shapedefault\\
6101 |italic| & medium & \vrb\mddefault & italic & \vrb\itdefault\\
6102 |bold| & bold & \vrb\bfdefault & upright & \vrb\shapedefault\\
6103 |bolditalic| & bold & \vrb\bfdefault & italic & \vrb\itdefault\\
6104 \meta{series}|/|\meta{shape} && \meta{series} && \meta{shape}\\
6105 \bottomrule
6106 \end{tabular*}
6107 \end{figure}
6108
6109
6110
6111 The \textsf{mathfont} package is closely related to several other \LaTeX\ packages. The functionality is closest to that of \textsf{mathspec} by Andrew Gilbert Moschou.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,'' \link{https://ctan.org/pkg/mathspec}.} That package is compatible with \XeTeX\ only and loads text fonts for use in math. The \textsf{unicode-math} package is a main \LaTeX\ package for loading actual Unicode math fonts, and \textsf{lua-unicode-math} is a Lua\TeX-specific adaptation.\footnote{Marcel Krueger, ``\textsf{lua-unicode-math}---OpenType Math font support for LuaLaTeX,'' \link{https://ctan.org/pkg/lua-unicode-math}; Will Robertson, et al., ``\textsf{unicode-math}---Unicode mathematics support for XeTeX and LuaTeX,'' \link{https://ctan.org/pkg/unicode-math}.} If you have a Unicode font with proper math support, rather than a text font that you want to use for equations, consider using those packages instead of \textsf{mathfont}. Users who want a text font for math with pdf\LaTeX\ should consider Jean-Fran\c cois Burnol's \textsf{mathastext} because \textsf{mathfont} is incompatible with pdf\TeX.\footnote{Jean-Fran\c cois Burnol, ``\textsf{mathastext}---Use the text font in maths mode,'' \link{https://ctan.org/pkg/mathastext}. In several previous versions of this documentation, I mischaracterized the approach of \textsf{mathastext} to \TeX's internal mathematics spacing. In fact, \textsf{mathastext} preserves and in some cases extends rules for space between various math-mode characters.} Finally, you may be better off using \textsf{fontspec} if your document does not contain any math.\footnote{Will Robertson and Khaled Hosny, ``\textsf{fontspec}---Advanced font selection in \XeLaTeX\ and Lua\LaTeX,'' \link{https://ctan.org/pkg/fontspec}.} The \textsf{fontspec} package is designed to load TrueType and OpenType fonts for text and provides a high-level interface for selecting OpenType font features. Table~\ref{packages} summarizes this information.
6112
6113
6114
6115 \section{Setting the Default Font}
6116
6117
6118 The \textsf{mathfont} package provides three commands for setting fonts in your document. The |\mathfont| command sets the font for various classes of characters when they appear in math mode, and after you call |\mathfont| on any class of characters, you can use Unicode input for that class of characters in math mode. The |\mainfont| command sets the font outside of equations. The control sequence |\documentfont| calls both |\mainfont| and |\mathfont|, calls |\mathconstantsfont| if the engine is Lua\TeX, and calls |\mathfontcommands| if in the document preamble. Each of these three commands accepts one optional argument and one mandatory argument, so the full syntax is
6119 \begin{code}
6120 |\documentfont[|\meta{\textup{\ttfamily rm}, \textup{\ttfamily sf}, \textup{\ttfamily tt}, or empty}|]{|\meta{font name}|}|\\
6121 |\mainfont[|\meta{\textup{\ttfamily rm}, \textup{\ttfamily sf}, \textup{\ttfamily tt}, or empty}|]{|\meta{font name}|}|\\
6122 |\mathfont[|\meta{keywords}|]{|\meta{font name}|}|
6123 \end{code}
6124 More recent calls to any of these commands will override previous instructions, and all font changes through these macros are local. \textit{This is a backwards-incompatible change in version 3.0.} For context, \LaTeX\ classifies fonts into family (what most users typically think of as a ``font''), series (the weight, usually medium or bold), and shape (the appearance, usually upright or italic). The mandatory argument of these three commands specifies a font family, and the optional argument of |\mathfont| specifies font series and shape. To choose a series and shape outside of math mode, you should use the standard commands from the kernel.\footnote{Specifically,\vadjust{\penalty-1000} \vrb\fontseries\ and \vrb\fontshape\ locally select arbitrary series and shapes from the \textsc{nfss}, and the kernel provides macros that reformat their argument such as \vrb\textbf\ and \vrb\textit.}
6125
6126 The optional argument for |\mainfont| and |\documentfont| determines how \textsf{mathfont} stores the font information. Using |rm|, |sf|, or |tt| will prompt \textsf{mathfont} to set both |\familydefault| and one of |\rmdefault|, |\sfdefault|, or |\ttdefault| respectively to the requested \textsc{nfss} family. The corresponding |\rmfamily|, |\sffamily|, or |\ttfamily| command will switch to the font family thereafter. Providing an empty optional argument instructs \textsf{mathfont} to switch to the font family without saving the font name, and in this case, you will see no change in the effects of |\rmfamily| and friends. If you do not provide an optional argument, \textsf{mathfont} uses |rm|.
6127
6128 The optional argument for |\mathfont| should be a comma-separated list of keywords from Table~\ref{Keywords}, and it determines which math-mode characters will undergo a font change. When you use this command, \textsf{mathfont} sets the font family for every character in those keywords when in math mode to the mandatory argument. For a list of characters associated with the different keywords, see |mathfont_symbol_list.pdf|. If you do not specify an optional argument, |\mathfont| uses all keywords from the upper half of Table~\ref{Keywords} (but not including |delimiters|, |radical|, or |bigops| characters in \XeTeX), so calling |\mathfont| with no optional argument is a fast way to change the font for most common math characters.
6129
6130 Characters in math mode often appear in different series or shapes from the same font family, and \textsf{mathfont} allows users to request particular series and shape combinations by using the shape identifiers in Table~\ref{Shape-Identifiers}. By default, the characters in a \meta{keyword} will follow the shape identifier stored in |\|\meta{keyword}|default|, so for example, |\upperdefault| is initially defined to be the character string |italic|. Table~\ref{Keywords} contains the initial value of each default setting. To change the series and shape, you can redefine any |\|\meta{keyword}|default| macro to a different shape identifier, or you can request a different shape identifier in the optional argument of |\mathfont|. If you say |=|\meta{shape identifier} immediately after a keyword and before the following comma, the package will apply your requested \meta{shape identifier} to that keyword. For example, if you say
6131 \begin{code}
6132 |\mathfont[upper=upright, lower=upright]{Baskerville}|
6133 \end{code}
6134 you will see Latin letters appear in upright Baskerville in your equations.
6135
6136 You may include |*| character immediately after the shape identifier if you want \textsf{mathfont} to use unmodified characters from the font. This option is most appropriate for situations such as math operators where you want to use regular text in your equations and do not need enlarged bounding boxes. For example, the command
6137 \begin{code}
6138 |\mathfont[upper, lower, operator=italic*]{Times New Roman}|
6139 \end{code}
6140 changes all Latin letters to italic Times New Roman and switches math operators to the same italic text that you would see if you use Times New Roman outside of math. This feature does not do anything in \XeTeX.
6141
6142 The mandatory argument of all three font-setting commands should be a system font name or an \textsc{nfss} font family name. If you use a system font, you can select OpenType features by putting a colon after the font name and following it with the appropriate tags.\footnote{By default, \textsf{mathfont} enables standard ligatures, traditional \TeX\ ligatures, and lining numbers. The package sets |smcp| to |true| or |false| depending on whether it is attempting to load a small-caps font. For the full list of OpenType features, see \link{https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist}.} The syntax for specifying features depends on the font-loader: with the built-in font-loader, you should use the standard ``|+|\meta{tag}'' or ``|-|\meta{tag}'' syntax, and when using \textsf{fontspec} as the font-loader, you should use that package's high-level interface, as described in the \textsf{fontspec} documentation. For example, suppose you want math with oldstyle numbers. With the built-in font-loader, you should add ``|+onum|,'' or if using \textsf{fontspec}, you should add |Numbers=OldStyle| to your |\mathfont| command. So to load Adobe Garamond Pro with oldstyle numbering, you would say
6143 \begin{code}
6144 |\mathfont{Adobe Garamond Pro:+onum}|
6145 \end{code}
6146 with the built-in font-loader or
6147 \begin{code}
6148 |\mathfont{Adobe Garamond Pro: Numbers=OldStyle}|
6149 \end{code}
6150 if using \textsf{fontspec}. With the built-in font-loader, you should separate OpenType tags with semi-colons, and for \textsf{fontspec}, you should use commas.
6151
6152
6153 When the mandatory argument of a font-changing command is an \textsc{nfss} family name, \textsf{mathfont} uses that font family. When the engine is \XeTeX, you don't have to do anything special and can ignore the rest of this paragraph. When the engine is Lua\TeX, \textsf{mathfont} expects the \textsc{nfss} to contain a second entry for the same font family that uses base mode for loading.\footnote{The \textsf{luaotfload} package supports three modes for loading fonts: |node|, |base|, and |harf|. The default setting is |node| mode. It supports full OpenType features in text but none for math, whereas |base| mode supports fewer OpenType features, but they work in both text and math. Loading a font with |harf| mode engages HarfBuzz, a font shaper that arranges characters in potentially complicated layouts but also provides no access to OpenType features in math.} If \meta{name} is the mandatory argument, you should tell \textsf{mathfont} the family name for the base-mode version by storing it in the control sequence |\|\meta{name}|-base|. If you do not do this, you will see an error message. My intention is that the first font family is for text, and the base-mode font family is for math---using two different loading options provides the greatest access to OpenType font features throughout your document.
6154
6155
6156 You can access blackboard-bold, calligraphic, or fraktur letters in three ways. First, the Unicode standard contains encoding slots for these types of letters, and the last five keywords in Table~\ref{Keywords} access this portion of the Unicode table.\footnote{The Math Alphanumeric Symbols block is U+1D400--U+1D7FF. Most blackboard-bold, calligraphic, and fraktur letters live in this portion of the Unicode table, although a few live in other places.} If you call |\mathfont| on one of these \meta{keyword}s, the package defines the macro
6157 \begin{code}
6158 |\math|\meta{keyword}|{|\meta{text}|}|
6159 \end{code}
6160 which behaves like a local font-change command from the next section and converts Latin letters into \meta{keyword} style. For example,
6161 \begin{code}
6162 |\mathfont[bb]{STIXGeneral}|
6163 \end{code}
6164 defines |\mathbb| to typeset blackboard-bold letters using the glyphs from STIXGeneral. Second, you may have a Unicode font where the normal Latin letters are themselves double struck, calligraphic, or fraktur, and in that case, you should declare a local font-change command using the tools in the next section. Third, \textsf{mathfont} should play nicely with (local) font-changing macros from other packages, so you should have no problem using, for example, \textsf{amssymb} with \textsf{mathfont}.\footnote{American Mathematical Society, ``\textsf{amssymb}.'' See also American Mathematical Society, ``\textsf{amsfonts}---\TeX\ fonts from the American Mathematical Society,'' \link{https://ctan.org/pkg/amsfonts}.}
6165
6166
6167 \begin{figure}[t]
6168 \labelfig{MathAlpha}
6169 \centerline{\bfseries Table \the\fig: Macros to Create Local Font-Change Commands with Preset Shapes\strut}
6170 \global\advance\fig by 1\relax
6171 \tabcolsep\z@
6172 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lllll}\toprule
6173 Command & Series & Uses \textsc{nfss} Series & Shape & Uses \textsc{nfss} Shape\\\midrule
6174 |\newmathrm| & Medium & |\mddefault| & Upright & |\shapedefault|\\
6175 |\newmathit| & Medium & |\mddefault| & Italic & |\itdefault|\\
6176 |\newmathbf| & Bold & |\bfdefault| & Upright & |\shapedefault|\\
6177 |\newmathbfit| & Bold & |\bfdefault| & Italic & |\itdefault|\\
6178 |\newmathsc| & Medium & |\mddefault| & Small Caps & |\scdefault|\\
6179 |\newmathscit| & Medium & |\mddefault| & Italic Small Caps & |\scdefault\itdefault|\\
6180 |\newmathbfsc| & Bold & |\bfdefault| & Small Caps & |\scdefault|\\
6181 |\newmathbfscit| & Bold & |\bfdefault| & Italic Small Caps & |\scdefault\itdefault|\\\bottomrule
6182 \end{tabular*}
6183 \end{figure}
6184
6185
6186 \section{Local Font Changes}
6187
6188 With \textsf{mathfont}, it is possible to create commands that locally change the font for math alphabet characters, i.e.\ those marked as alphabetic in Table~\ref{Keywords}. (I am slightly abusing notation. In this section, I mean local as in acting on a small portion of the document, not local with respect to grouping. All font-change commands from \textsf{mathfont} are local in that regard.) The commands from this section should appear only in the preamble. The eight commands in Table~\ref{MathAlpha} accept a \meta{control sequence} as their first mandatory argument and a \meta{font name} as the second, so for example, the macro |\newmathrm| looks like
6189 \begin{code}
6190 |\newmathrm{|\meta{control sequence}|}{|\meta{font name}|}|
6191 \end{code}
6192 You can specify OpenType features as part of the \meta{font name} the same way as in the previous section. The macros in Table~\ref{MathAlpha} define the control sequence in their first argument to accept a string of characters and convert it to the font family in the second argument. The series and shape information depend on the command used. For example, writing
6193 \begin{code}
6194 |\newmathrm{\matharial}{Arial}|
6195 \end{code}
6196 creates the macro
6197 \begin{code}
6198 |\matharial{|\meta{argument}|}|
6199 \end{code}
6200 which can be used only in math mode and which converts the math alphabet characters in its \meta{argument} into the Arial font with upright shape and medium weight.
6201
6202
6203
6204 The macro |\mathfontcommands| accepts a single font name as its argument. It calls each |\newmath|\meta{specifier} command from Table~\ref{MathAlpha} to define |\math|\meta{specifier} using the font family from its argument. For example,
6205 \begin{code}
6206 |\mathfontcommands{Helvetica}|
6207 \end{code}
6208 makes the standard font-changing commands such as |\mathrm| and |\mathit| use Helvetica instead of Computer Modern.
6209
6210 In traditional \LaTeX, |\mathrm| and friends do not change the font for Greek characters. That remains the case until you call |\mathfont| for |greeklower| or |greekupper| characters, and then any local font-change commands from this section will work on lower-case or upper-case Greek letters respectively. Similarly, the local font-change commands will affect Cyrillic and Hebrew characters after you call |\mathfont| for those keywords.
6211
6212 These nine control sequences provide tools for most local font changes, but they won't be able to address everything. Accordingly, \textsf{mathfont} provides general |\newmathfontcommand| macro. Its argument structure is
6213 \begin{code}
6214 |\newmathfontcommand{|\meta{control sequence}|}{|\meta{font name}|}{|\meta{series}|}{|\meta{shape}|}|
6215 \end{code}
6216 where the \meta{control sequence} in the first argument again becomes the macro that changes characters to the \meta{font name}. You are welcome to use a system font name when you call |\newmathfontcommand|, but my intention behind this command is that you can use an \textsc{nfss} family name for the \meta{font name}. Then the series and shape values can correspond to more obscure font faces from the \textsc{nfss} family that you would be otherwise unable to access. As with |\mathfont|, if you are using Lua\TeX\ and the \meta{font name} is an \textsc{nfss} family, you should make sure that you defined |\|\meta{font name}|-base|, or you will see an error.
6217
6218
6219 \section{Default Math Parameters}
6220
6221 Lua\TeX\ uses the MathConstants table from the most recent font assigned for use in math mode, and this means that in a document with multiple math fonts, the choice of MathConstants table can depend on the order of font declaration and be unpredictable. To avoid potential problems from using the wrong MathConstants table, \textsf{mathfont} provides
6222 \begin{code}
6223 |\mathconstantsfont[|\meta{shape identifier}|]{|\meta{font name}|}|
6224 \end{code}
6225 where \meta{shape identifier} is a shape identifier from Table~\ref{Shape-Identifiers} and \meta{font name} is a font name as in the previous two sections. By default, |\mathconstantsfont| uses |upright| for the optional argument. This macro forces Lua\TeX\ to use the MathConstants table from the requested font face, and once again, if you use an \textsc{nfss} family name for \meta{font name} with Lua\TeX, make sure to define |\|\meta{font name}|-base| appropriately. You don't need to set the MathConstants table when you use |\documentfont| or pass a font name to \textsf{mathfont} at loading because the package calls |\mathconstantsfont| automatically in this case. This command does not do anything in \XeTeX.
6226
6227
6228 \section{Declaring Font Shapes}
6229
6230 You\vadjust{\penalty-9999} are welcome to use the commands from sections~2 and 4 after |\begin{document}|, but you are limited in what fonts you can use. \LaTeX\ prohibits new font declarations after the preamble, and at that point, \textsf{mathfont} will only use font faces that already exist in the \textsc{nfss} or that it used for any purpose previously. What this means in practical terms: if you want to use |\mathfont| or |\mainfont| after |\begin{document}|, you probably have to use a font that \textsf{mathfont} handled in some capacity in the preamble. This makes it nonobvious how to use a font after the preamble if you do not want to set that font for any characters in the preamble.
6231
6232 To address this situation, \textsf{mathfont} provides the command |\mathfontshapes|. The purpose of this macro is to declare font shapes before |\begin{document}| without using them for anything. It accepts one optional argument and one mandatory argument, so the syntax is
6233 \begin{code}
6234 |\mathfontshapes[|\meta{shape identifiers}|]{|\meta{font name}|}|
6235 \end{code}
6236 The optional argument should be a comma-separated list of shape identifiers, and by default, the macro uses |upright|, |upright*|, |italic|, and |bold|. The mandatory argument should be a font name like in the previous sections.
6237
6238 After you use |\mathfontshapes|, you should have no problem using the same font family for |\mainfont|. You will also be able to use the font family for |\mathfont| or |\mathconstantsfont| provided that you stick to shape identifiers that appeared in the optional argument of |\mathfontshapes|. For example, if you say
6239 \begin{code}
6240 |\mathfontshapes{Didot}|
6241 \end{code}
6242 in your preamble, you can include
6243 \begin{code}
6244 |\mathfont{Didot}|
6245 \end{code}
6246 after the preamble (even if you didn't have it in the preamble), but if you type
6247 \begin{code}
6248 |\mathfont[operator=italic*]{Didot}|
6249 \end{code}
6250 you will run into problems because |\mathfontshapes| does not normally use the shape identifier |italic*|. You should instead say
6251 \begin{code}
6252 |\mathfontshapes[italic*]{Didot}|
6253 \end{code}
6254 in your preamble to avoid any issues.
6255
6256
6257 \section{Lua Font Adjustments}
6258
6259
6260 When Lua\TeX\ reads in a font file, \textsf{mathfont} makes the font object in memory appear to be a math font rather than a text font. Most of this process happen behind the scenes, but \textsf{mathfont} provides control sequences that allow you to customize some modifications. With the exception of the read-only control sequences |\charminfo| and |\charmtype|, their wrapped equivalents, and the count variables, all macros from this section should appear in the preamble only.
6261
6262 The main macro for doing so is |\charmline|. (Charm stands for ``character metric.'') It accepts one mandatory argument, so the syntax is
6263 \begin{code}
6264 |\charmline{|\meta{charm information}|}|
6265 \end{code}
6266 The \meta{charm information} should be a sequence of entries separated by a comma and/or space, where entry means one or two numbers or asterisks. If an entry is two numbers, two asterisks, or one of each, you must separate them with a slash, and the first entry in \meta{charm information} should be a single integer between 0 and 1,114,111. The command fully expands its argument, and you may see strange errors if \meta{charm information} contains unexpandable control sequences. Processing uses |tonumber()| from Lua, so your input can include anything that Lua recognizes as a number. In particular, you can specify hexadecimal numbers by prefixing them with |0x|.
6267
6268 This macro controls how \textsf{mathfont} adjusts bounding boxes, accent placement, and large variants. The first entry in \meta{charm information} corresponds to an entry in the Unicode table, and \textsf{mathfont} references the remaining entries when it alters properties of the character in that encoding slot during font loading. For purposes of charm information, a character can have one of two types: |a| for ``alphabetic'' or |e| for ``extensible.''\footnote{Alphabetic is something of a misnomer that I kept for historical reasons.} Any character that resizes, such as delimiters, big operators, and the surd character has type |e|, and you should specify 33 additional entries after the encoding slot. All other characters have type |a|, and you should specify 4 additional entries after the encoding slot. If you specify too few charm values, \textsf{mathfont} will raise an error, and if you provide too many, \textsf{mathfont} ignores the extras and prints a warning on the terminal. Version 3.0 eliminates type |u| and requires an extra entry for type |e| characters, and \textit{these are backwards-incompatible changes.} If you call |\charmline| for an encoding slot that does not have any charm information, \textsf{mathfont} assumes that character should be type |a|. You can change a character to type |e| by including an |!| symbol immediately after the first entry, and you can change a character to type |a| by including a |?| symbol immediately after the first entry.
6269
6270
6271 \begin{figure}[t]
6272 \labelfig{Charm}
6273 \centerline{\bfseries Table \the\fig: Number of Entries Required in \vrb\charmline\strut}
6274 \global\advance\fig by 1\relax
6275 \begin{tabularx}\textwidth{Xcl}\toprule
6276 Character & Type & \hfil Total Number of Entries\\\midrule
6277 Everything Else & |a| & \hfil5\\
6278 Delimiters, Radical (Surd Character), Big Operators & |e| & \hfil34\\
6279 \bottomrule
6280 \end{tabularx}
6281 \end{figure}
6282
6283
6284
6285 When \textsf{mathfont} parses \meta{charm information}, the order of the entries determines their purpose. As is standard in \TeX, \textsf{mathfont} divides all numbers in |\charmline| by 1000 to form floats before using them in calculations. For type |a| characters, the second and third entries tell Lua\TeX\ how much to stretch the left and right sides of the glyph's bounding box when it appears in math mode, and the third entry determines horizontal placement of top math accents. The final entry determines the |bot_accent| attribute for that character in the font object, although Lua\TeX\ does not use this piece of information for formatting equations.\footnote{See Hans Hagen and Mikael P. Sundqvist, ``On Bottom Accents in OpenType Math,'' \textit{TUGBoat} 44 (2023): 207--208. See also two threads from the Lua\TeX\ developer mailing list from 2012, available at
6286 \edef\temp{http://mailman.ntg.nl/archives/list/[email protected]/thread/3SDPLVHQYLVHHOBUA3DWROTWLMUBUQI5/\string#WX432F6M52MUIK4WE5I3W7YSJOWDIA4G}%
6287 \edef\tempurl{http:\break//mailman.ntg.nl/archives/list/[email protected]/thread/3SDPLVHQYLVHHOBUA3DWROTWLMUBUQI5/\hfil\break\string#WX432F6M52MUIK4WE5I3W7YSJOWDIA4G}%
6288 \@onelevel@sanitize\temp
6289 \href{\temp}{\texttt{\tempurl}} and
6290 \edef\temp{https://mailman.ntg.nl/archives/list/[email protected]/thread/PU2VYNG7XBWVBBUY4VIPJOS75NNZM7UE/\string#PU2VYNG7XBWVBBUY4VIPJOS75NNZM7UE}%
6291 \@onelevel@sanitize\temp\expandafter\link\expandafter{\temp}.}
6292 If the Unicode value corresponds to a type |e| character, \textsf{mathfont} interprets the first 30 entries after the encoding slot as 15 successive pairs of horizontal and vertical scale factors that determine the size of large variants. For example, the second and third entries in \meta{charm information} are the horizontal and vertical scale factors for the first large variant. The last three entries determine, respectively,\vadjust{\penalty-1000} horizontal placement of top accents, the |bot_accent| attribute, and the character's italic correction.
6293
6294 Asterisks and subentries affect how \textsf{mathfont} uses charm information in memory. Writing an asterisk tells \textsf{mathfont} to use whatever value it has saved in memory, either the default value or the value from the most recent call to |\charmline| or |\charmfile|. When an entry contains two subentries, \textsf{mathfont} uses the first subentry for unslanted fonts and the second subentry for slanted or italic fonts. If an entry is a single number or asterisk, \textsf{mathfont} uses that input for both slanted and unslanted fonts.
6295
6296 If you want to store charm information in a file instead of your document preamble, you should use the control sequence |\charmfile|. This command accepts one mandatory argument, so the syntax is
6297 \begin{code}
6298 |\charmfile{|\meta{file name}|}|
6299 \end{code}
6300 It reads in a file and calls |\charmline| individually on each line from the file.
6301
6302 The default settings are decent, so for most applications, you can probably ignore charm information altogether. However, if you find bounding boxes or accent placement to be off slightly in your equations or if you want to change the scaling for a delimiter or big operator, you should try calling |\charmline| with different values to see what works. For a given character, the scale for changes is the width of that character's unmodified bounding box.\footnote{For type |a|, it's technically the unmodified bounding box width plus italic correction because \textsf{mathfont} incorporates the italic correction into the character width.} For example,
6303 \begin{code}
6304 |\charmline{0x61, 200, -100, *, 50}|
6305 \end{code}
6306 tells \textsf{mathfont} to take the lower-case ``a'' (U+61, i.e.\ encoding slot number 97), increase the bounding box on the left side by 20\% of the character width, decrease the bounding box on the right side by 10\% of the character width, do nothing to the top accent, and shift the |bot_accent| attribute right by 5\% of the character width. There is no general formula for what charm values to use for a given font! Rather, you will need to make a design choice based on what looks best, and if you regularly use a specific font, consider making a custom set of charm values and uploading it to \textsc{ctan}.
6307
6308
6309 The package provides two commands to query charm information in memory, namely |\charminfo| and |\charmtype|. These macros are weird in that they don't take an argument. Rather, they scan (and remove) the next integer from the input stream in the same manner as a |\count| variable, so the syntax is
6310 \begin{code}
6311 |\charminfo|\meta{integer}\\
6312 |\charmtype|\meta{integer}
6313 \end{code}
6314 Both macros are fully expandable and work outside the document preamble. If \textsf{mathfont} has charm information in memory for the Unicode encoding slot \meta{integer}, |\charmtype| expands to |a| or |e| depending on the type of that character, and |\charminfo| expands to a space-separated lists of charm entries. The results of |\charminfo| look exactly like the input of |\charmline|, so typing
6315 \begin{code}
6316 |\charmline{|\meta{encoding slot}|,\charminfo|\meta{encoding slot}|}|
6317 \end{code}
6318 is valid syntax and reassigns the charm information for \meta{encoding slot} to itself. If \meta{integer} is not the encoding slot for a character with charm information, both macros expand to |none|.
6319
6320
6321 Three count variables affect equation formatting with \textsf{mathfont}. Their default value is 1000, and \textsf{mathfont} divides\vadjust{\penalty-1000} their value by 1000 to convert them to floats before using them. The first two, |\hsurdfactor| and |\vsurdvactor|, affect the positioning of the overline in square root expressions. Specifically, changing either count scales the bounding box for the surd (square root) character by the corresponding float value. Larger values of |\hsurdvactor| therefore shift the overline to the right, and smaller values do the opposite. Larger values of |\vsurdfactor| raise the overline. The third count, |\rulethicknessfactor|, determines the thickness of horizontal rules such as the overline in square root expressions or the fraction bar. You will probably want to increase |\rulethicknessfactor| for fonts with heavier weight and decrease it for fonts with lighter weight. Please be aware that \textsf{mathfont} uses the value of each count only once per font when \TeX\ loads the font for math typesetting. This typically happens the first time the user enters math mode.
6322
6323 The package provides user-friendly versions of each control sequence in this section. The macros |\CharmInfo| and |\CharmType| accept an integer as a single mandatory argument and print the results of |\charminfo| and |\charmtype| to the terminal. The macros |\SurdHorizontalFactor|, |\SurdVerticalFactor|, and |\RuleThicknessFactor| similarly accept a single integer as a mandatory argument and set the corresponding count variable to that value. Additionally, |\IntegralItalicFactor| accepts an integer as its argument and divides the argument by 1000 to form a float. When \TeX\ loads a font, it increases the italic correction of the integral symbol by that fraction of the symbol's width, which affects positioning of limits. For parity in macro names and backwards compatibility, |\CharmLine| and |\CharmFile| are defined to do the same thing as their lower-case counterparts.
6324
6325
6326
6327
6328 \begin{figure}[t]
6329 \labelfig{Callbacks}
6330 \centerline{\bfseries Table \the\fig: Lua Callbacks Created by \textsf{mathfont}\strut}
6331 \global\advance\fig by 1\relax
6332 \newbox\mybox
6333 \setbox\mybox\vbox{\raggedright
6334 \hsize0.9in\relax If base mode\break and |nomath|}
6335 \begin{tabularx}\textwidth{lXl}\toprule
6336 Callback Name & What It Does By Default & Called?\\\midrule
6337 |"mathfont.inspect_font"| & Nothing & Always\\\midrule
6338 |"mathfont.pre_adjust"| & Nothing & \multirow{7}{*}{\copy\mybox}\\
6339 |"mathfont.disable_nomath"| & Set font attribute |nomath| to false &\\
6340 |"mathfont.add_math_constants"| & Create a MathConstants table &\\
6341 |"mathfont.fix_character_metrics"|& \raggedright\arraybackslash Adjust bounding boxes, add character-specific math fields, create large variants &\\
6342 |"mathfont.post_adjust"| & Nothing &\\\midrule
6343 |"mathfont.finishing_touches"| & Nothing & Always\\
6344 \bottomrule
6345 \end{tabularx}
6346 \end{figure}
6347
6348
6349
6350 Advanced users who want to interact with the font adjustment process directly should use the seven callbacks in Table~\ref{Callbacks}. When \textsf{luaotfload} loads a font, \textsf{mathfont} (1) always calls |mathfont.inspect_font|; (2) calls the middle five callbacks in the order that they appear in Table~\ref{Callbacks} if the font object contains |nomath=true| and was loaded with |base| mode; and (3) always calls |mathfont.finishing_touches|. Functions added to these callbacks should accept a font object as a single argument and return nothing. Further, please be careful when loading functions in |disable_nomath|, |add_math_constants|, and |fix_character_metrics|. If you add a function there, Lua\TeX\ will not carry out the default behavior associated with the callback, so do not mess with these three callbacks unless you are duplicating the default behavior or you really know what you're doing. Otherwise, you risk breaking the package. See |mathfont-code.pdf| for more information.
6351
6352
6353 \end{document}
6354 %</user>
6355 %<*chars>
6356 \documentclass[12pt]{article}
6357 \makeatletter
6358 \usepackage[margin=72.27pt]{geometry}
6359 \usepackage{tabularx}
6360 \usepackage{booktabs}
6361 \usepackage{multicol}
6362 \multicolsep=\bigskipamount
6363 \premulticols=\z@
6364 \postmulticols=4\bigskipamount
6365 \usepackage{graphicx}
6366 \usepackage{mathfont}
6367 \mathfont[\M@keys]{STIXGeneral}
6368 \mathfont[agreeklower=upright,agreekupper]{Crimson}
6369 \mathfont[hebrew]{Coelacanth}
6370 \usepackage{shortvrb}
6371 \MakeShortVerb{|}
6372 \def\meta#1{\ensuremath{\langle\textit{#1}\rangle}}
6373 \raggedcolumns
6374 \parskip=0pt
6375 \fboxrule=1pt
6376 \charmline{8747 1200 1700 * * * * * * * *
6377 * * * * * * * * * *
6378 * * * * * * * * * *
6379 * * *}
6380 \charmline{8748 1200 1700 * * * * * * * *
6381 * * * * * * * * * *
6382 * * * * * * * * * *
6383 * * *}
6384 \charmline{8749 1200 1700 * * * * * * * *
6385 * * * * * * * * * *
6386 * * * * * * * * * *
6387 * * *}
6388 \charmline{8750 1200 1700 * * * * * * * *
6389 * * * * * * * * * *
6390 * * * * * * * * * *
6391 * * *}
6392 \charmline{8751 1200 1700 * * * * * * * *
6393 * * * * * * * * * *
6394 * * * * * * * * * *
6395 * * *}
6396 \charmline{8752 1200 1700 * * * * * * * *
6397 * * * * * * * * * *
6398 * * * * * * * * * *
6399 * * *}
6400 \begin{document}
6401
6402 \def\documentname{Symbol List}
6403 \def\showabstract{1}
6404 \input mathfont-heading.tex
6405
6406 \noindent The \textsf{mathfont} package provides tools to access several hundred characters for math typesetting, and this document lists these symbols along with the control sequences to access them. To get access to the symbols from a section of this document, call |\mathfont| with the keyword-option for that section and the name of a font that contains those symbols. The package does not define any math symbols until you call |\mathfont| or |\setfont| (or load \textsf{mathfont} with a font name as package option), and if you see a symbol or control sequence here that is not part of standard \LaTeX, you will not be able to access it until you call |\mathfont| on the corresponding keyword. Further, \textsf{mathfont} does not come with or load any fonts by itself, so you are responsible for the fonts. Not all fonts contain all math symbols, so choose your font wisely!\footnote{Besides letters and digits, most Unicode text fonts should contain diacritics, delimiters, and the basic math characters in the keyword |symbols|. Text fonts will often contain square root and basic operator symbols, but they may not be suitable for math typesetting. Greek characters are hit or miss, and it is unusual for English text fonts to contain Cyrillic, Hebrew, ancient Greek, arrows, letterlike characters, or any extended (keywords |extbigops| and |extsymbols|) set of symbols. After you load \textsf{mathfont}, \TeX\ will print a message to the terminal if you try to typeset a missing character from some font.} This document shows ancient Greek in Crimson, Hebrew in Coelacanth, and all other math characters in STIXGeneral.
6407
6408 \begin{figure}[t]
6409 \centerline{\bfseries Table 1: Characters Defined by Multiple Keywords\strut}
6410 \begin{tabularx}\textwidth{XXX}\toprule
6411 Character & Keywords & Default Font\\\midrule
6412 \vrb\increment & \texttt{greekupper} & \texttt{symbols}\\
6413 & \texttt{symbols} & \\\midrule
6414 \vrb\nabla & \texttt{greekupper} & \texttt{(ext)symbols}\\
6415 & \texttt{symbols} with Lua\TeX & \\
6416 & \texttt{extsymbols} with \XeTeX & \\\midrule
6417 \expandafter\vrb\string| & \texttt{symbols} & \texttt{symbols} normally\\
6418 & \texttt{delimiters} with Lua\TeX & \texttt{delimiters} after |\left|, \hfil\penalty0|\right|, etc.\\\midrule
6419 \vrb\simeq\ and \vrb\cong & \texttt{symbols} & \texttt{extsymbols} \\
6420 & \texttt{extsymbols} & \\\bottomrule
6421 \end{tabularx}
6422 \end{figure}
6423
6424 As of version 2.0, \textsf{mathfont} artificially adds resizable delimiters and big operator characters to text fonts when you compile with Lua\LaTeX. In this case, square root symbols will automatically resize, big operators will appear larger in |\displaystyle|, and you can use |\left|, |\right|, and |\big|, etc.\ with characters from the keyword |delimiters|. If you use \XeTeX, \textsf{mathfont} will not create large variants of characters, and your Unicode math symbols will all be the same size as they appear in the font. In this case, you may be best off sticking with the Computer Modern defaults for resizable characters provided they don't clash with the rest of your document. Throughout this document, anything labeled ``Lua\TeX\ only'' means that \textsf{mathfont} provides this functionality only if you enable Lua-based font adjustments. If you load \textsf{mathfont} in Lua\TeX\ with the |no-adjust| option, you will not be able to access these features the same as if you typeset with \XeTeX.
6425
6426
6427 A few characters appear multiple times in this list. When that happens, it means that \textsf{mathfont} defines the control sequence for multiple keywords. If you call |\mathfont| for only one of those keywords, your symbol will appear in the font associated with that keyword. If you call |\mathfont| on multiple keywords, the package uses the font associated with the default keyword/font for that character. Table~1 lists the default keyword for each command that appears multiple times in this document. If you need Unicode encoding slot numbers for character metric adjustments, each symbol corresponds to its standard Unicode encoding value, with the exception of the fake angle brackets. When you typeset with Lua\TeX, \textsf{mathfont} artificially adds |\fakelangle|, |\fakerangle|, |\fakellangle|, and |\fakerrangle| to the font in encoding slots 1,044,508--1,044,511 respectively.
6428
6429 \bigskip\bigskip
6430 \nointerlineskip\centerline{\vrule height 0.5pt width 2.5in}
6431 \bigskip\bigskip
6432
6433 \catcode`\|=12
6434
6435 \blockheader{lower}{Lower-Case Latin}
6436
6437 \begin{multicols}{3}
6438 \charexample a
6439 \charexample b
6440 \charexample c
6441 \charexample d
6442 \charexample e
6443 \charexample f
6444 \charexample g
6445 \charexample h
6446 \charexample i
6447 \charexample j
6448 \charexample k
6449 \charexample l
6450 \charexample m
6451 \charexample n
6452 \charexample o
6453 \charexample p
6454 \charexample q
6455 \charexample r
6456 \charexample s
6457 \charexample t
6458 \charexample u
6459 \charexample v
6460 \charexample w
6461 \charexample x
6462 \charexample y
6463 \charexample z
6464 \charexample\hbar
6465 \charexample\imath
6466 \charexample\jmath
6467 \end{multicols}
6468
6469 \blockheader{upper}{Upper-Case Latin}
6470
6471 \begin{multicols}{3}
6472 \charexample A
6473 \charexample B
6474 \charexample C
6475 \charexample D
6476 \charexample E
6477 \charexample F
6478 \charexample G
6479 \charexample H
6480 \charexample I
6481 \charexample J
6482 \charexample K
6483 \charexample L
6484 \charexample M
6485 \charexample N
6486 \charexample O
6487 \charexample P
6488 \charexample Q
6489 \charexample R
6490 \charexample S
6491 \charexample T
6492 \charexample U
6493 \charexample V
6494 \charexample W
6495 \charexample X
6496 \charexample Y
6497 \charexample Z
6498 \end{multicols}
6499
6500 \blockheader{diacritics}{Accent}
6501
6502 \begin{multicols}{3}
6503 \def\hook{\footnote{You will run into trouble if you load \textsf{amsmath} after calling \vrb\mathfont\ with the \texttt{accent} keyword. This is a known bug.}}
6504 \accentexample\acute
6505 \let\hook\relax
6506 \accentexample\aacute
6507 \accentexample\dot
6508 \accentexample\ddot
6509 \accentexample\grave
6510 \accentexample\breve
6511 \accentexample\hat
6512 \accentexample\check
6513 \accentexample\bar
6514 \accentexample\mathring
6515 \accentexample\tilde
6516 \end{multicols}
6517
6518 \blockheader{digits}{Arabic Numeral}
6519
6520 \begin{multicols}{3}
6521 \charexample0
6522 \charexample1
6523 \charexample2
6524 \charexample3
6525 \charexample4
6526 \charexample5
6527 \charexample6
6528 \charexample7
6529 \charexample8
6530 \charexample9
6531 \end{multicols}
6532
6533 \blockheader{greekupper}{Upper-Case Greek}
6534
6535 \begin{multicols}{3}
6536 \charexample\Alpha
6537 \charexample\Beta
6538 \charexample\Gamma
6539 \charexample\Delta
6540 \charexample\Epsilon
6541 \charexample\Zeta
6542 \charexample\Eta
6543 \charexample\Theta
6544 \charexample\Iota
6545 \charexample\Kappa
6546 \charexample\Lambda
6547 \charexample\Mu
6548 \charexample\Nu
6549 \charexample\Xi
6550 \charexample\Omicron
6551 \charexample\Pi
6552 \charexample\Rho
6553 \charexample\Sigma
6554 \charexample\Tau
6555 \charexample\Upsilon
6556 \charexample\Phi
6557 \charexample\Chi
6558 \charexample\Psi
6559 \charexample\Omega
6560 \charexample\varTheta
6561 \charexample\increment
6562 \charexample\nabla
6563 \end{multicols}
6564
6565 \blockheader{greeklower}{Lower-Case Greek}
6566
6567 \begin{multicols}{3}
6568 \charexample\alpha
6569 \charexample\beta
6570 \charexample\gamma
6571 \charexample\delta
6572 \charexample\epsilon
6573 \charexample\zeta
6574 \charexample\eta
6575 \charexample\theta
6576 \charexample\iota
6577 \charexample\kappa
6578 \charexample\lambda
6579 \charexample\mu
6580 \charexample\nu
6581 \charexample\xi
6582 \charexample\omicron
6583 \charexample\pi
6584 \charexample\rho
6585 \charexample\sigma
6586 \charexample\tau
6587 \charexample\upsilon
6588 \charexample\phi
6589 \charexample\chi
6590 \charexample\psi
6591 \charexample\omega
6592 \charexample\varbeta
6593 \charexample\varepsilon
6594 \charexample\varkappa
6595 \charexample\vartheta
6596 \charexample\varrho
6597 \charexample\varsigma
6598 \charexample\varphi
6599 \end{multicols}
6600
6601 \blockheader{agreekupper}{Upper-Case Ancient Greek}
6602
6603 \begin{multicols}{3}
6604 \charexample\Heta
6605 \charexample\Sampi
6606 \charexample\Digamma
6607 \charexample\Koppa
6608 \charexample\Stigma
6609 \charexample\Sho
6610 \charexample\San
6611 \charexample\varSampi
6612 \charexample\varDigamma
6613 \charexample\varKoppa
6614 \end{multicols}
6615
6616 \blockheader{agreeklower}{Lower-Case Ancient Greek}
6617
6618 \begin{multicols}{3}
6619 \charexample\heta
6620 \charexample\sampi
6621 \charexample\digamma
6622 \charexample\koppa
6623 \charexample\stigma
6624 \charexample\sho
6625 \charexample\san
6626 \charexample\varsampi
6627 \charexample\vardigamma
6628 \charexample\varkoppa
6629 \end{multicols}
6630
6631 \blockheader{cyrillicupper}{Upper-Case Cyrillic}
6632
6633 \begin{multicols}{3}
6634 \charexample\cyrA
6635 \charexample\cyrBe
6636 \charexample\cyrVe
6637 \charexample\cyrGhe
6638 \charexample\cyrDe
6639 \charexample\cyrIe
6640 \charexample\cyrZhe
6641 \charexample\cyrZe
6642 \charexample\cyrI
6643 \charexample\cyrKa
6644 \charexample\cyrEl
6645 \charexample\cyrEm
6646 \charexample\cyrEn
6647 \charexample\cyrO
6648 \charexample\cyrPe
6649 \charexample\cyrEr
6650 \charexample\cyrEs
6651 \charexample\cyrTe
6652 \charexample\cyrU
6653 \charexample\cyrEf
6654 \charexample\cyrHa
6655 \charexample\cyrTse
6656 \charexample\cyrChe
6657 \charexample\cyrSha
6658 \charexample\cyrShcha
6659 \charexample\cyrHard
6660 \charexample\cyrYeru
6661 \charexample\cyrSoft
6662 \charexample\cyrE
6663 \charexample\cyrYu
6664 \charexample\cyrYa
6665 \charexample\cyrvarI
6666 \end{multicols}
6667
6668 \blockheader{cyrilliclower}{Lower-Case Cyrillic}
6669
6670 \begin{multicols}{3}
6671 \charexample\cyra
6672 \charexample\cyrbe
6673 \charexample\cyrve
6674 \charexample\cyrghe
6675 \charexample\cyrde
6676 \charexample\cyrie
6677 \charexample\cyrzhe
6678 \charexample\cyrze
6679 \charexample\cyri
6680 \charexample\cyrka
6681 \charexample\cyrel
6682 \charexample\cyrem
6683 \charexample\cyren
6684 \charexample\cyro
6685 \charexample\cyrpe
6686 \charexample\cyrer
6687 \charexample\cyres
6688 \charexample\cyrte
6689 \charexample\cyru
6690 \charexample\cyref
6691 \charexample\cyrha
6692 \charexample\cyrtse
6693 \charexample\cyrche
6694 \charexample\cyrsha
6695 \charexample\cyrshcha
6696 \charexample\cyrhard
6697 \charexample\cyryeru
6698 \charexample\cyrsoft
6699 \charexample\cyre
6700 \charexample\cyryu
6701 \charexample\cyrya
6702 \charexample\cyrvari
6703 \end{multicols}
6704
6705 \blockheader{hebrew}{Hebrew}
6706
6707 \begin{multicols}{3}
6708 \charexample\aleph
6709 \charexample\beth
6710 \charexample\gimel
6711 \charexample\daleth
6712 \charexample\he
6713 \charexample\vav
6714 \charexample\zayin
6715 \charexample\het
6716 \charexample\tet
6717 \charexample\yod
6718 \charexample\kaf
6719 \charexample\lamed
6720 \charexample\mem
6721 \charexample\nun
6722 \charexample\samekh
6723 \charexample\ayin
6724 \charexample\pe
6725 \charexample\tsadi
6726 \charexample\qof
6727 \charexample\resh
6728 \charexample\shin
6729 \charexample\tav
6730 \charexample\varkaf
6731 \charexample\varmem
6732 \charexample\varnun
6733 \charexample\varpe
6734 \charexample\vartsadi
6735 \end{multicols}
6736
6737 \medskip
6738 \def\temp{; shown in \texttt{\vrb\big}, etc.\ sizes}
6739 \blockheader{delimiters\aftergroup\temp}{Delimiter}
6740 \medskip
6741 \begin{multicols}{3}
6742 \delimexample(
6743 \delimexample)
6744 \delimexample[
6745 \delimexample]
6746 \delimexample{\{\ifmmode\else\space(Lua\TeX\ only)\fi}
6747 \delimexample{\}\ifmmode\else\space(Lua\TeX\ only)\fi}
6748 \delimexample{|\,\ifmmode\else\space(Lua\TeX\ only)\fi}
6749 \delimexample\lguil
6750 \delimexample\rguil
6751 \delimexample\llguil
6752 \delimexample\rrguil
6753 \luadelimexample\fakelangle
6754 \luadelimexample\fakerangle
6755 \luadelimexample\fakellangle
6756 \luadelimexample\fakerrangle
6757 \hbox to \hsize{\hbox to 0.8in{$\leftbrace$\hfil}\vrb\leftbrace\hfil}
6758 \hbox to \hsize{\hbox to 0.8in{$\rightbrace$\hfil}\vrb\rightbrace\hfil}
6759 \end{multicols}
6760 \medskip
6761
6762 \blockheader{radical}{Square Root}
6763 \smallskip
6764 \begin{multicols}{2}
6765 \charexample\surd
6766 \def\temp{ (Lua\TeX\ only)\hfill}
6767 \charexample{\sqrt{\ifmmode\mkern 12mu\vphantom{1}\else\temp\fi}}
6768 \end{multicols}
6769
6770 \blockheader{bigops}{Big Operator}
6771 \smallskip
6772 \begin{multicols}{2}
6773 \operatorexample\sum
6774 \operatorexample\prod
6775 \operatorexample\intop
6776 \end{multicols}
6777 \medskip
6778
6779 \blockheader{extbigops}{Extended Big Operators}
6780 \smallskip
6781 \begin{multicols}{3}
6782 \operatorexample\coprod
6783 \operatorexample\bigvee
6784 \operatorexample\bigwedge
6785 \operatorexample\bigcap
6786 \operatorexample\bigcup
6787 \operatorexample\bigoplus
6788 \operatorexample\bigotimes
6789 \operatorexample\bigodot
6790 \operatorexample\bigsqcap
6791 \operatorexample\bigsqcup
6792 \operatorexample\iint
6793 \operatorexample\iiint
6794 \operatorexample\oint
6795 \operatorexample\oiint
6796 \operatorexample\oiiint
6797 \end{multicols}
6798
6799 \medskip
6800
6801 \blockheader{symbols}{Basic Math}
6802 \begin{multicols}{3}
6803 \charexample.
6804 \charexample @
6805 \let\par\relax
6806 \charexample\#
6807 \charexample\$
6808 \charexample\%
6809 \charexample\&
6810 \charexample\P
6811 \charexample\S
6812 \charexample\pounds
6813 \charexample|
6814 \charexample\neg
6815 \charexample\infty
6816 \charexample\partial
6817 \charexample\mathbackslash
6818 \charexample\degree
6819 \charexample\increment
6820 \def\temp{ (Lua\TeX\ only)}
6821 \charexample{\nabla\ifmmode\else\temp\fi}
6822 \charexample'
6823 \charexample\prime
6824 \charexample"
6825 \charexample+
6826 \charexample-
6827 \charexample*
6828 \charexample\times
6829 \charexample/
6830 \charexample\fractionslash
6831 \charexample\div
6832 \charexample\pm
6833 \charexample\bullet
6834 \charexample\dag
6835 \charexample\ddag
6836 \charexample\cdot
6837 \charexample\setminus
6838 \charexample=
6839 \charexample<
6840 \charexample>
6841 \charexample\leq
6842 \charexample\geq
6843 \charexample\sim
6844 \charexample\approx
6845 \charexample\simeq
6846 \charexample\equiv
6847 \charexample\cong
6848 \charexample\mid
6849 \charexample\parallel
6850 \charexample!
6851 \charexample?
6852 \charexample{,\ifmmode\else\phantom{\texttt{comma}} \rlap{(as \vrb\mathpunct)}\fi}
6853 \charexample{\comma\ifmmode\else\space(as \vrb\mathord)\fi}
6854 \charexample{:\ifmmode\else\phantom{\texttt{colon}} (as \vrb\mathrel)\fi}
6855 \charexample{\colon\ifmmode\else\space\rlap{(as \vrb\mathpunct)}\fi}\charexample;
6856 \charexample\mathellipsis
6857 \end{multicols}
6858 \blockheader{symbols}{Lua\TeX-only (!) Operator}
6859 \begin{multicols}{3}
6860 \operatorexample\bigat
6861 \operatorexample\bighash
6862 \operatorexample\bigdollar
6863 \operatorexample\bigpercent
6864 \operatorexample\bigand
6865 \operatorexample\bigplus
6866 \operatorexample\bigp
6867 \operatorexample\bigq
6868 \operatorexample\bigS
6869 \operatorexample\bigtimes
6870 \operatorexample\bigdiv
6871 \end{multicols}
6872
6873
6874
6875
6876 \blockheader{extsymbols}{Extended Math}
6877 \begin{multicols}{3}
6878 \charexample\wp
6879 \charexample\Re
6880 \charexample\Im
6881 \charexample\ell
6882 \charexample\forall
6883 \charexample\exists
6884 \charexample\emptyset
6885 \charexample{\nabla\ifmmode\else\space(\XeTeX\ only)\fi}
6886 \charexample\in
6887 \charexample\ni
6888 \charexample\mp
6889 \charexample\angle
6890 \charexample\top
6891 \charexample\bot
6892 \charexample\vdash
6893 \charexample\dashv
6894 \charexample\flat
6895 \charexample\natural
6896 \charexample\sharp
6897 \charexample\clubsuit
6898 \charexample\spadesuit
6899 \charexample\diamondsuit
6900 \charexample\heartsuit
6901 \charexample\bclubsuit
6902 \charexample\bdiamondsuit
6903 \charexample\bheartsuit
6904 \charexample\bspadesuit
6905 \charexample\wclubsuit
6906 \charexample\wdiamondsuit
6907 \charexample\wheartsuit
6908 \charexample\wspadesuit
6909 \charexample\wedge
6910 \charexample\vee
6911 \charexample\cap
6912 \charexample\cup
6913 \charexample\sqcap
6914 \charexample\sqcup
6915 \charexample\amalg
6916 \charexample\wr
6917 \charexample\ast
6918 \charexample\star
6919 \charexample\diamond
6920 \charexample\varcdot
6921 \charexample\varsetminus
6922 \charexample\oplus
6923 \charexample\otimes
6924 \charexample\ominus
6925 \charexample\odiv
6926 \charexample\oslash
6927 \charexample\odot
6928 \charexample\sqplus
6929 \charexample\sqtimes
6930 \charexample\sqminus
6931 \charexample\sqdot
6932 \charexample\in
6933 \charexample\ni
6934 \charexample\subset
6935 \charexample\supset
6936 \charexample\subseteq
6937 \charexample\supseteq
6938 \charexample\sqsubset
6939 \charexample\sqsupset
6940 \charexample\sqsubseteq
6941 \charexample\sqsupseteq
6942 \charexample\triangleleft
6943 \charexample\triangleright
6944 \charexample\trianglelefteq
6945 \charexample\trianglerighteq
6946 \charexample\propto
6947 \charexample\bowtie
6948 \charexample\hourglass
6949 \charexample\therefore
6950 \charexample\because
6951 \charexample\ratio
6952 \charexample\proportion
6953 \charexample\ll
6954 \charexample\gg
6955 \charexample\lll
6956 \charexample\ggg
6957 \charexample\leqq
6958 \charexample\geqq
6959 \charexample\lapprox
6960 \charexample\gapprox
6961 \charexample\simeq
6962 \charexample\eqsim
6963 \charexample\simeqq
6964 \charexample\cong
6965 \charexample\approxeq
6966 \charexample\sssim
6967 \charexample\seq
6968 \charexample\doteq
6969 \charexample\coloneq
6970 \charexample\eqcolon
6971 \charexample\ringeq
6972 \charexample\arceq
6973 \charexample\wedgeeq
6974 \charexample\veeeq
6975 \charexample\stareq
6976 \charexample\triangleeq
6977 \charexample\defeq
6978 \charexample\qeq
6979 \charexample\lsim
6980 \charexample\gsim
6981 \charexample\prec
6982 \charexample\succ
6983 \charexample\preceq
6984 \charexample\succeq
6985 \charexample\preceqq
6986 \charexample\succeqq
6987 \charexample\precsim
6988 \charexample\succsim
6989 \charexample\precapprox
6990 \charexample\succapprox
6991 \charexample\precprec
6992 \charexample\succsucc
6993 \charexample\asymp
6994 \charexample\nin
6995 \charexample\nni
6996 \charexample\nsubset
6997 \charexample\nsupset
6998 \charexample\nsubseteq
6999 \charexample\nsupseteq
7000 \charexample\subsetneq
7001 \charexample\supsetneq
7002 \charexample\nsqsubseteq
7003 \charexample\nsqsupseteq
7004 \charexample\sqsubsetneq
7005 \charexample\sqsupsetneq
7006 \charexample\neq
7007 \charexample\nl
7008 \def\hook{\footnote{In text mode, \vrb\ng\ produces \ng---as of version 2.2b, \textsf{mathfont} redefines the math-mode version only and leaves the text-mode version alone. If you are using the \textsf{hyperref} package, you should type \vrb\mathng\ instead of \vrb\ng.}}
7009 \charexample\ng
7010 \let\hook\relax
7011 \charexample\nleq
7012 \charexample\ngeq
7013 \charexample\lneq
7014 \charexample\gneq
7015 \charexample\lneqq
7016 \charexample\gneqq
7017 \charexample\ntriangleleft
7018 \charexample\ntriangleright
7019 \charexample\ntrianglelefteq
7020 \charexample\ntrianglerighteq
7021 \charexample\nsim
7022 \charexample\napprox
7023 \charexample\nsimeq
7024 \charexample\nsimeqq
7025 \charexample\simneqq
7026 \charexample\nlsim
7027 \charexample\ngsim
7028 \charexample\lnsim
7029 \charexample\gnsim
7030 \charexample\lnapprox
7031 \charexample\gnapprox
7032 \charexample\nprec
7033 \charexample\nsucc
7034 \charexample\npreceq
7035 \charexample\nsucceq
7036 \charexample\precneq
7037 \charexample\succneq
7038 \charexample\precneqq
7039 \charexample\succneqq
7040 \charexample\precnsim
7041 \charexample\succnsim
7042 \charexample\precnapprox
7043 \charexample\succnapprox
7044 \charexample\nequiv
7045 \end{multicols}
7046
7047
7048 \blockheader{arrows}{Arrow}
7049 \begin{multicols}{2}
7050 \def\hook{\footnote{Both \vrb\relbar\space and \vrb\Relbar\space are helper macros that certain packages use to elongate various horizontal arrows.}}
7051 \charexample\relbar
7052 \let\hook\relax
7053 \charexample\Relbar
7054 \charexample\rightarrow
7055 \charexample\to
7056 \charexample\nrightarrow
7057 \charexample\Rightarrow
7058 \charexample\nRightarrow
7059 \charexample\Rrightarrow
7060 \charexample\longrightarrow
7061 \charexample\Longrightarrow
7062 \charexample\rightbararrow
7063 \charexample\mapsto
7064 \charexample\Rightbararrow
7065 \charexample\longrightbararrow
7066 \charexample\longmapsto
7067 \charexample\Longrightbararrow
7068 \charexample\hookrightarrow
7069 \charexample\rightdasharrow
7070 \charexample\rightharpoonup
7071 \charexample\rightharpoondown
7072 \charexample\rightarrowtail
7073 \charexample\rightoplusarrow
7074 \charexample\rightwavearrow
7075 \charexample\rightsquigarrow
7076 \charexample\longrightsquigarrow
7077 \charexample\looparrowright
7078 \charexample\curvearrowright
7079 \charexample\circlearrowright
7080 \charexample\twoheadrightarrow
7081 \charexample\rightarrowtobar
7082 \charexample\rightwhitearrow
7083 \charexample\rightrightarrows
7084 \charexample\rightrightrightarrows
7085 \charexample\leftarrow
7086 \charexample\from
7087 \charexample\nleftarrow
7088 \charexample\Leftarrow
7089 \charexample\nLeftarrow
7090 \charexample\Lleftarrow
7091 \charexample\longleftarrow
7092 \charexample\Longleftarrow
7093 \charexample\leftbararrow
7094 \charexample\mapsfrom
7095 \charexample\Leftbararrow
7096 \charexample\longleftbararrow
7097 \charexample\longmapsfrom
7098 \charexample\Longleftbararrow
7099 \charexample\hookleftarrow
7100 \charexample\leftdasharrow
7101 \charexample\leftharpoonup
7102 \charexample\leftharpoondown
7103 \charexample\leftarrowtail
7104 \charexample\leftoplusarrow
7105 \charexample\leftwavearrow
7106 \charexample\leftsquigarrow
7107 \charexample\longleftsquigarrow
7108 \charexample\looparrowleft
7109 \charexample\curvearrowleft
7110 \charexample\circlearrowleft
7111 \charexample\twoheadleftarrow
7112 \charexample\leftarrowtobar
7113 \charexample\leftwhitearrow
7114 \charexample\leftleftarrows
7115 \charexample\leftleftleftarrows
7116 \charexample\leftrightarrow
7117 \charexample\Leftrightarrow
7118 \charexample\nLeftrightarrow
7119 \charexample\longleftrightarrow
7120 \charexample\Longleftrightarrow
7121 \charexample\leftrightwavearrow
7122 \charexample\leftrightarrows
7123 \charexample\leftrightharpoons
7124 \charexample\leftrightarrowstobar
7125 \charexample\rightleftarrows
7126 \charexample\rightleftharpoons
7127 \charexample\uparrow
7128 \charexample\Uparrow
7129 \charexample\Uuparrow
7130 \charexample\upbararrow
7131 \charexample\updasharrow
7132 \charexample\upharpoonleft
7133 \charexample\upharpoonright
7134 \charexample\twoheaduparrow
7135 \charexample\uparrowtobar
7136 \charexample\upwhitearrow
7137 \charexample\upwhitebararrow
7138 \charexample\upuparrows
7139 \charexample\downarrow
7140 \charexample\Downarrow
7141 \charexample\Ddownarrow
7142 \charexample\downbararrow
7143 \charexample\downdasharrow
7144 \charexample\zigzagarrow
7145 \charexample\lightningboltarrow
7146 \charexample\downharpoonleft
7147 \charexample\downharpoonright
7148 \charexample\twoheaddownarrow
7149 \charexample\downarrowtobar
7150 \charexample\downwhitearrow
7151 \charexample\downdownarrows
7152 \charexample\updownarrow
7153 \charexample\Updownarrow
7154 \charexample\updownarrows
7155 \charexample\downuparrows
7156 \charexample\updownharpoons
7157 \charexample\downupharpoons
7158 \charexample\nearrow
7159 \charexample\Nearrow
7160 \charexample\nwarrow
7161 \charexample\Nwarrow
7162 \charexample\searrow
7163 \charexample\Searrow
7164 \charexample\swarrow
7165 \charexample\Swarrow
7166 \charexample\nwsearrow
7167 \charexample\neswarrow
7168 \charexample\lcirclearrow
7169 \charexample\rcirclearrow
7170 \end{multicols}
7171
7172
7173 \blockheader{bb}{Blackboard Bold}
7174
7175 \vskip\multicolsep
7176 \letterlikechars\mathbb
7177 \hbox to \hsize{\printchars\digits\hfil}
7178 \vskip\multicolsep
7179
7180 \blockheader{cal}{Caligraphic}
7181
7182 \vskip\multicolsep
7183 \letterlikechars\mathcal
7184 \vskip\multicolsep
7185
7186 \blockheader{frak}{Fraktur}
7187
7188 \vskip\multicolsep
7189 \letterlikechars\mathfrak
7190 \vskip\multicolsep
7191
7192 \blockheader{bcal}{Bold Calligraphic}
7193
7194 \vskip\multicolsep
7195 \letterlikechars\mathbcal
7196 \vskip\multicolsep
7197
7198 \blockheader{bfrak}{Bold Fraktur}
7199
7200 \vskip\multicolsep
7201 \letterlikechars\mathbfrak
7202
7203 \end{document}
7204 %</chars>
7205 %<*equations>
7206 \multicolsep=0pt\relax
7207 \bigskip
7208 \begin{multicols*}{2}
7209
7210 Black-Scholes Equation
7211 \[
7212 \frac{\partial V}{\partial t}+
7213 \frac12\sigma^2S^2\frac{\partial^2V}{\partial S^2}
7214 =rV-rS\frac{\partial V}{\partial X}
7215 \]
7216
7217 \vfill
7218
7219 Cardano's Formula/Cubic Formula
7220 \begin{align*}
7221 t_i&=\omega_i\sqrt[3]{-\frac q2+\sqrt{\frac{q^2}4+\frac{p^3}{27}}}\\
7222 &\qquad\qquad{}+\omega_i^2\sqrt[3]{-\frac q2-\sqrt{\frac{q^2}4+\frac{p^3}{27}}}
7223 \end{align*}
7224
7225 \vfill
7226
7227 Einstein's Field Equation (General Relativity)
7228 \[
7229 R_{\mu\nu}-\frac12Rg_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}
7230 \]
7231
7232 \vfill
7233
7234 First Isomorphism Theorem
7235 \[
7236 \phi(X)\cong X/\ker(\phi)
7237 \]
7238
7239 \vfill
7240
7241 Gauss-Bonnet Formula
7242 \[
7243 \int_MK\ dA+\int_{\partial M}k_g\ ds=2\pi\chi(M)
7244 \]
7245
7246 \vfill
7247
7248 Maxwell's Equations
7249 \begin{align*}
7250 \nabla\bullet\mathbf E&=\frac\rho{\epsilon_0}&
7251 \nabla\bullet\mathbf B&=0\\
7252 \nabla\times\mathbf E&=-\frac{\partial\mathbf B}{\partial t}&
7253 \nabla\times\mathbf B&=\mu_0\left(\mathbf J+
7254 \epsilon_0\frac{\partial\mathbf E}{\partial t}\right)
7255 \end{align*}
7256
7257 \vfill
7258
7259 Michaelis-Menten Model
7260 \bgroup
7261 \belowdisplayskip=0pt\relax
7262 \belowdisplayshortskip=0pt\relax
7263 \[
7264 v=\frac{d[P]}{dt}=V\frac{[S]}{K_M+[S]}
7265 \]
7266 \par\egroup
7267 \hrule height 0pt
7268 \columnbreak
7269 %% next column begins here
7270
7271
7272 Navier-Stokes Equation
7273 \begin{align*}
7274 \frac{\partial}{\partial t}(\rho\mathbf{u})+\nabla\bullet
7275 (\rho \mathbf{u}\otimes \mathbf{u})={}
7276 &{-}\nabla\bar p+\mu\nabla^2\mathbf{u}\\
7277 &+\frac13\mu\nabla(\nabla\bullet u)+
7278 \rho\mathbf{g}
7279 \end{align*}
7280
7281 \vfill
7282
7283 Quadratic Formula
7284 \[
7285 x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
7286 \]
7287
7288 \vfill
7289
7290 Ramanujan's Approximation for $\Gamma$
7291 \[
7292 \Gamma(1+x)\approx\sqrt\pi\,x^xe^{-x}\,\sqrt[6]{8x^3+4x^2+x+\frac1{30}}
7293 \]
7294
7295 \vfill
7296
7297 Residue Theorem
7298 \[
7299 \frac1{2i\pi}\int_{\gamma}f(z)\ dz=\sum_{k=1}^n\Res_{a_k}(f)
7300 \]
7301
7302
7303 \vfill
7304
7305 Riemann Zeta Function
7306 \begin{align*}
7307 \zeta(z)&=\sum_{i=1}^\infty\frac1{z^i}
7308 =\frac1{\Gamma(z)}\int_0^\infty\frac{x^{z-1}}{e^x-1}\ dx\\
7309 &=2^z\pi^{z-1}\sin\left(\frac{\pi z}2\right)\,\Gamma(1-z)\,\zeta(1-z)
7310 \end{align*}
7311
7312
7313 \vfill
7314
7315 Schrodinger Equation
7316 \[
7317 i\hbar\frac d{dt}|\Psi(t)\fakerangle=\hat H|\Psi(t)\fakerangle
7318 \]
7319
7320 \vfill
7321
7322
7323 Lorentz Transformation (Special Relativity)
7324 \belowdisplayskip=0pt\relax
7325 \belowdisplayshortskip=0pt\relax
7326 \[
7327 t'=\left(t-\frac{vx}{c^2}\right)\frac1{\sqrt{1-\frac{v^2}{c^2}}}
7328 \]
7329 \hrule height 0pt
7330
7331 \end{multicols*}
7332 %</equations>
7333 %<*cormorant>
7334 \ifx\directlua\undefined
7335 \PackageError{mathfont}
7336 {\MessageBreak
7337 LuaLaTeX is recommended for\MessageBreak
7338 mathfont-example-cormorant.tex}
7339 {It's recommended that you typeset this file\MessageBreak
7340 with LuaTeX. You can use XeLaTeX if you want,\MessageBreak
7341 but things will turn out weird. To resolve\MessageBreak
7342 this error, typeset the file with LuaLaTeX.}
7343 \fi
7344 \documentclass[12pt]{article}
7345 \usepackage[margin=1in]{geometry}
7346 \usepackage{innerscript}
7347 \usepackage{multicol}
7348 \usepackage{amsmath}
7349 \DeclareMathOperator{\Res}{Res}
7350 \usepackage{mathfont}
7351 \documentfont{Cormorant:-liga}
7352 \mathfont[greeklower=upright,greekupper]{Crimson}
7353 \mathfont[diacritics]{Bona Nova}
7354 \RuleThicknessFactor{800}
7355 \parindent=0pt\relax
7356 \begin{document}
7357
7358 \def\footnote#1{}
7359 \def\showabstract{0}
7360 \let\textsf\relax
7361 \let\ttfamily\relax
7362 \def\documentname{Example---Cormorant}
7363
7364 \input mathfont-heading.tex
7365
7366 This is Cormorant with Crimson for Greek characters and Bona Nova for diacritics. ``Testing. Testing.'' Brown foxes quickly jump over dazzling does and harts. This document shows an example of mathfont in action. Unfortunately, there are many more equations in the world than I have space for here. Nevertheless, I hope I hit some of the highlights. Happy \TeX ing!
7367
7368
7369 \input{mathfont-equations.tex}
7370
7371 \end{document}
7372 %</cormorant>
7373 %<*kelvinch>
7374 \ifx\directlua\undefined
7375 \PackageError{mathfont}
7376 {\MessageBreak
7377 LuaLaTeX is recommended for\MessageBreak
7378 mathfont-example-kelvinch.tex}
7379 {It's recommended that you typeset this file\MessageBreak
7380 with LuaTeX. You can use XeLaTeX if you want,\MessageBreak
7381 but things will turn out weird. To resolve\MessageBreak
7382 this error, typeset the file with LuaLaTeX.}
7383 \fi
7384 \documentclass[12pt]{article}
7385 \usepackage[margin=1in]{geometry}
7386 \usepackage{innerscript}
7387 \usepackage{multicol}
7388 \usepackage{amsmath}
7389 \DeclareMathOperator{\Res}{Res}
7390 \usepackage{mathfont}
7391 \documentfont{Kelvinch:-clig}
7392 \mathfont[radical]{Crimson}
7393 \IntegralItalicFactor{500}
7394 \hsurdfactor=900
7395 \rulethicknessfactor=1300
7396 \parindent=0pt\relax
7397 \begin{document}
7398
7399 \def\footnote#1{}
7400 \def\showabstract{0}
7401 \let\textsf\relax
7402 \let\ttfamily\relax
7403 \def\documentname{Example---Kelvinch}
7404
7405 \input mathfont-heading.tex
7406
7407 This is Kelvinch with Crimson for the radical signs. ``Testing. Testing.'' Brown foxes quickly jump over dazzling does and harts. This document shows an example of mathfont in action. Unfortunately, there are many more equations in the world than I have space for here. Nevertheless, I hope I hit some of the highlights. Happy \TeX ing!
7408
7409 \input{mathfont-equations.tex}
7410
7411 \end{document}
7412 %</kelvinch>
7413 %<*roboto>
7414 \ifx\directlua\undefined
7415 \PackageError{mathfont}
7416 {\MessageBreak
7417 LuaLaTeX is recommended for\MessageBreak
7418 mathfont-example-roboto.tex}
7419 {It's recommended that you typeset this file\MessageBreak
7420 with LuaTeX. You can use XeLaTeX if you want,\MessageBreak
7421 but things will turn out weird. To resolve\MessageBreak
7422 this error, typeset the file with LuaLaTeX.}
7423 \fi
7424 \documentclass[12pt]{article}
7425 \usepackage[margin=1in]{geometry}
7426 \usepackage{innerscript}
7427 \usepackage{multicol}
7428 \usepackage{amsmath}
7429 \DeclareMathOperator{\Res}{Res}
7430 \usepackage[Roboto]{mathfont}
7431 \mathfont[radical]{Overpass}
7432 \mathfontshapes{STIXGeneral}
7433 \DeclareMathSymbol{\otimes}{\mathbin}{M5-m/n}{"2297}
7434 \rulethicknessfactor=1600
7435 \IntegralItalicFactor{500}
7436 \hsurdfactor=800
7437 \parindent=0pt\relax
7438 \begin{document}
7439
7440 \def\footnote#1{}
7441 \def\showabstract{0}
7442 \let\textsf\relax
7443 \let\ttfamily\relax
7444 \def\documentname{Example---Roboto}
7445
7446 \input mathfont-heading.tex
7447
7448 This is Roboto with Overpass for the radical signs and STIXGeneral for the tensor product. ``Testing. Testing.'' Brown foxes quickly jump over dazzling does and harts. This document shows an example of mathfont in action. Unfortunately, there are many more equations in the world than I have space for here. Nevertheless, I hope I hit some of the highlights. Happy \TeX ing!
7449
7450
7451 \input{mathfont-equations.tex}
7452
7453 \end{document}
7454 %</roboto>
7455 %<*typey>
7456 \ifx\directlua\undefined
7457 \PackageError{mathfont}
7458 {\MessageBreak
7459 LuaLaTeX is recommended for\MessageBreak
7460 mathfont-example-typey.tex}
7461 {It's recommended that you typeset this file\MessageBreak
7462 with LuaTeX. You can use XeLaTeX if you want,\MessageBreak
7463 but things will turn out weird. To resolve\MessageBreak
7464 this error, typeset the file with LuaLaTeX.}
7465 \fi
7466 \documentclass[12pt]{article}
7467 \usepackage[margin=1in]{geometry}
7468 \usepackage{innerscript}
7469 \usepackage{multicol}
7470 \usepackage{amsmath}
7471 \DeclareMathOperator{\Res}{Res}
7472 \usepackage{mathfont}
7473
7474 %% We have to declare Typey McTypeface manually because
7475 %% it has no bold fontface---we use embolden from luaotflaod
7476 %% to make a fake bold
7477
7478 \makeatletter
7479 \DeclareFontFamily{TU}{Typey}{}
7480 \DeclareFontShape{TU}{Typey}{m}{n}
7481 {<->"Typey McTypeface:\M@otf@features"}{}
7482 \DeclareFontShape{TU}{Typey}{m}{it}
7483 {<->"Typey McTypeface/I:\M@otf@features"}{}
7484 \DeclareFontShape{TU}{Typey}{b}{n}
7485 {<->"Typey McTypeface:\M@otf@features;embolden=6"}{}
7486 \DeclareFontShape{TU}{Typey}{b}{it}
7487 {<->"Typey McTypeface/I:\M@otf@features;embolden=6"}{}
7488
7489 %% We also need to declare Typey-base family for math mode
7490
7491 \DeclareFontFamily{TU}{Typey-base}{}
7492 \DeclareFontShape{TU}{Typey-base}{\mddefault}{\shapedefault}
7493 {<->"Typey McTypeface:\M@otf@features;mode=base"}{}
7494 \DeclareFontShape{TU}{Typey-base}{\mddefault}{\itdefault}
7495 {<->"Typey McTypeface/I:\M@otf@features;mode=base"}{}
7496 \DeclareFontShape{TU}{Typey-base}{\bfdefault}{\shapedefault}
7497 {<->"Typey McTypeface:\M@otf@features;embolden=6;mode=base"}{}
7498 \DeclareFontShape{TU}{Typey-base}{\bfdefault}{\itdefault}
7499 {<->"Typey McTypeface/I:\M@otf@features;embolden=6;mode=base"}{}
7500
7501 %% And link the Typey-base font family to the Typey family
7502 \expandafter\def\csname Typey-base\endcsname{Typey-base}
7503 \makeatother
7504
7505 \documentfont{Typey}
7506 \mathfont[radical]{Crimson}
7507 \mathfontshapes{STIXGeneral}
7508 \DeclareMathSymbol{\otimes}{\mathbin}{M5-m/n}{"2297}
7509 \RuleThicknessFactor{1300}
7510 \hsurdfactor850
7511 \parindent=0pt\relax
7512 \begin{document}
7513
7514 \def\footnote#1{}
7515 \def\showabstract{0}
7516 \let\textsf\relax
7517 \let\ttfamily\relax
7518 \def\documentname{Example---Typey McTypeface}
7519
7520 \input mathfont-heading.tex
7521
7522 This is Typey McTypeface with Crimson for the radical signs and STIXGeneral for the tensor product. ``Testing. Testing.'' Brown foxes quickly jump over dazzling does and harts. This document shows mathfont in action. Unfortunately, there are many more equations in the world than I have space for here. Nevertheless, I hope I hit some of the highlights. Happy \TeX ing!
7523
7524 \let\bullet\cdot
7525 \input{mathfont-equations.tex}
7526
7527 \end{document}
7528 %</typey>
7529 %<*heading>
7530
7531 \csname count@\endcsname\catcode`\@
7532 \makeatletter
7533
7534 % package date and edition
7535 \def\packagedate{February 2026}
7536 \def\packageversion{3.0a}
7537
7538 % header and footer commands
7539 \let\@@section\section
7540 \def\section{\par
7541 \penalty\z@
7542 \vskip0.7in\relax
7543 \penalty\z@
7544 \vskip-0.7in\relax
7545 \vskip\z@
7546 \@ifstar\star@sect\no@star@sect}
7547 \def\star@sect#1{\@@section*{#1}\section@name{#1}}
7548 \def\no@star@sect#1{\@@section{#1}\section@name{#1}}
7549 \def\section@name#1{\expandafter
7550 \def\csname section@\thesection\endcsname{#1}}
7551 \def\sectionname{\csname section@\thesection\endcsname}
7552
7553 \def\@oddhead{\ifnum\c@page>\@ne
7554 \ifodd\c@page
7555 \rlap{\textit{\sectionname}}\hfil
7556 \hbox to 0pt{\hss\documentname\hss}\hfil
7557 \llap{\the\c@page}\relax
7558 \else
7559 \rlap{\the\c@page}\hfil
7560 \hb@xt@\z@{\hss\documentname\hss}\hfil
7561 \llap{\textit{\sectionname}}\relax
7562 \fi
7563 \else
7564 \hfil
7565 \fi}
7566 \def\@oddfoot{\hfil\ifnum\count0=1\relax1\fi\hfil}
7567 \let\@evenfoot\@empty
7568
7569 % penalties
7570 \pretolerance=20
7571 \hyphenpenalty=10
7572 \exhyphenpenalty=5
7573 \brokenpenalty=0
7574 \clubpenalty=5
7575 \widowpenalty=5
7576 \finalhyphendemerits=300
7577 \doublehyphendemerits=500
7578
7579 \flushbottom
7580
7581 % general macros
7582 \protected\def\XeTeX{X\kern-0.125em
7583 \raise-0.5ex\hbox{\reflectbox{E}}\kern-0.1667em
7584 \TeX}
7585 \protected\def\XeLaTeX{X\kern-0.125em
7586 \raise-0.5ex\hbox{\reflectbox{E}}\kern-0.125em
7587 \LaTeX}
7588 \bgroup
7589 \catcode`\_=12
7590 \protected\gdef
7591 \fontspeccommand{\texttt{\string\fontspec_set_family:Nnn}}
7592 \protected\gdef
7593 \fontspecbool{\texttt{\string\g__fontspec_math_bool}}
7594 \egroup
7595 \def\topfraction{1}
7596 \def\bottomfraction{1}
7597 \let\code\@undefined
7598 \newenvironment{code}
7599 {\strut\vadjust\bgroup\vskip 5pt plus 1pt minus 3pt\relax
7600 \parindent\z@\leftskip2em\relax
7601 \noindent\strut\ignorespaces}
7602 {\strut\par\vskip 5pt plus 1pt minus 3pt\relax
7603 \egroup\hfill\break\strut\ignorespacesafterend}
7604 \def\vrb#1{\expandafter\texttt\expandafter{\string#1}}
7605 \parskip=0pt
7606
7607 % symbol list macros
7608 \def\charexample#1{\hbox to \hsize{\hbox to 0.4in{$#1$\hfil}\vrb#1\hook\hfil}}
7609 \def\accentexample#1{\hbox to \hsize{\hbox to 0.4in{$#1 a$\hfil}\vrb#1\hook\hfil}}
7610 \let\hook\relax
7611 \def\delimexample#1{\hbox to \hsize{%
7612 \hbox to 0.8in{$#1\big#1\Big#1\bigg#1\Bigg#1$\hfil}\vrb#1\hfil}}
7613 \def\luadelimexample#1{\hbox{\vbox{\hbox to 0.8in{%
7614 $#1\big#1\Big#1\bigg#1\Bigg#1$\hfil}\hrule width 0pt height 0pt\relax}%
7615 \hbox to \dimexpr\hsize-0.8in{\vbox{\vss
7616 \hbox{\vrb#1}
7617 \hbox{\quad(Lua\TeX only)}
7618 \vss}\hfil}}}
7619 \def\operatorexample#1{\hbox to \hsize{%
7620 \hbox to 0.4in{$#1$\hfil}%
7621 \hbox to 0.4in{$\displaystyle#1$\hfil}\vrb#1\hfil}\smallskip}
7622 \def\blockheader#1#2{%
7623 \hbox{\fbox{\hbox to \dimexpr\hsize-2\fboxrule-2\fboxsep\relax{%
7624 \hfil#2 Characters (Keyword \texttt{#1})\strut\hfil}}}}
7625 \def\upperalphabet{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
7626 \def\loweralphabet{abcdefghijklmnopqrstuvwxyz}
7627 \def\digits{0123456789}
7628 \def\printchars#1{%
7629 \expandafter\@tfor\expandafter\letter\expandafter:\expandafter=#1\do{%
7630 \hbox to \dimexpr\hsize/26{$\@tempstyle{\letter}$\hfil}}}
7631 \def\letterlikechars#1{\smallskip\let\@tempstyle#1
7632 \noindent\printchars\upperalphabet\par
7633 \noindent\printchars\loweralphabet\par}
7634
7635 % title information
7636 {\large\parindent=0pt\leftskip=0pt plus 1 fil\rightskip=0pt plus 1fil\parfillskip=0pt
7637 {\global\setbox0\hbox{\strut\Large
7638 Package \textsf{mathfont} v.\ \packageversion\ \documentname}%
7639 \unhcopy0\let\thefootnote\relax\footnote{Acknowledgements: Thanks to Lyric Bingham for her work checking my Unicode hex values. Thanks to Matthew Braham, Sergio Callegari, Daniel Flipo, Nikos Platis, Shyam Sundar, Adrian Vollmer, Herbert Voss, and Andreas Zidak for pointing out bugs in previous versions of \textsf{mathfont}. Thanks to Jean-Fran\c cois Burnol for pointing out an error in the documentation in reference to his \textsf{mathastext} package.}\global\advance\c@footnote\m@ne}\par
7640 {\strut Conrad Kosowsky}\par
7641 {\strut\packagedate}\par
7642 {\strut\ttfamily [email protected]}\par}
7643
7644 \medskip
7645
7646 \ifnum\showabstract=1\relax
7647
7648 % off-the-shelf insert
7649 {% add margin
7650 \leftskip 0.5in
7651 \rightskip 0.5in
7652 % margin changes for user guide and symbol list
7653 \ifdim\hsize>6in
7654 \advance\leftskip 0.5in
7655 \advance\rightskip -0.5in
7656 \fi
7657 % set \hsize
7658 \hsize\dimexpr\paperwidth - 3in\relax
7659 % no \parindent
7660 \parindent\z@
7661 % now make the insert
7662 \leavevmode\hb@xt@\dimexpr\hsize - \leftskip - \rightskip\relax{%
7663 \vrule width \p@
7664 \kern-\p@\relax
7665 \vbox{\hsize\dimexpr\hsize - \leftskip - \rightskip\relax
7666 \parindent\z@
7667 \leftskip\medskipamount
7668 \rightskip\medskipamount
7669 \hrule height \p@
7670 \smallskip
7671 \strut For easy, off-the-shelf use, type the
7672 following in your preamble and compile with
7673 \XeLaTeX\ or Lua\LaTeX:\par
7674 \medskip
7675 \hfil|\usepackage[|\meta{font name}|]{mathfont}|\par
7676 \medskip
7677 As of version 2.0, using Lua\LaTeX\ is recommended.
7678 Minor backwards incompatible changes in version 3.0.\strut\par
7679 \smallskip
7680 \hrule height \p@}%
7681 \kern-\p@
7682 \vrule width \p@}
7683
7684 \medskip
7685
7686 % abstract
7687 {\small
7688 {\hfil\bfseries Overview\strut\par}
7689 The \textsf{mathfont} package adapts Unicode text fonts for math mode. The package allows the user to specify a default font for different classes of math symbols, and it enables Unicode input in math mode. The package provides tools to change the font locally for math alphabet characters. When typesetting with Lua\TeX, \textsf{mathfont} adds resizable delimiters, big operators, and a MathConstants table to text fonts.\par}}
7690
7691 \bigskip\bigskip\nointerlineskip
7692 \centerline{\vrule height 0.5pt width 2.5in}\bigskip\bigskip
7693 \nointerlineskip
7694 \fi
7695
7696
7697 \catcode`\@\count@
7698
7699 %</heading>
7700 %<*doc>
7701
7702 % definitions and a new toks
7703 \let\?\SpecialUsageIndex
7704 \expandafter\newif\csname if@def\endcsname
7705 \newtoks\index@nomainlist
7706 \index@nomainlist{}
7707 \MacrocodeTopsep=2.5pt plus 3pt minus 1pt
7708 \def\@defname{def}
7709 \def\@edefname{edef}
7710 \def\@gdefname{gdef}
7711 \def\@xdefname{xdef}
7712 \def\@letname{let}
7713 \let\main\textbf
7714
7715 % choose macros not to index by definition
7716 \def\DoNotIndexMain{\bgroup
7717 \catcode`\\=12\relax
7718 \do@not@index@main}
7719 \def\do@not@index@main#1{\egroup
7720 \index@nomainlist\expandafter{\the\index@nomainlist#1,}}
7721
7722 % the patch
7723 \reversemarginpar
7724 \@mparswitchfalse
7725 \marginparsep=0.5em
7726 \newbox\@tempboxb
7727 \newbox\macrobox
7728 \marginparwidth=\dimexpr1.5in-2\marginparsep\relax
7729
7730 % macro to put macros in the margin
7731 % we need to \let\par\relax because \marginpar
7732 % contains a transition to h mode and back to v
7733 % mode that will mess up our code line numbering
7734 \def\marginmacro#1\@nil{\begingroup\footnotesize
7735 \setbox\macrobox\vbox{}\relax
7736 \setbox\@tempboxa\hbox{\@backslashchar}\relax
7737 \@tfor\@i:=#1\do
7738 {\setbox\@tempboxb\hbox{\@i}\relax
7739 \ifdim\dimexpr\wd\@tempboxa+\wd\@tempboxb\relax
7740 <\marginparwidth
7741 \setbox\@tempboxa\hbox{\unhbox\@tempboxa\unhbox\@tempboxb}\else
7742 \@break@tfor\fi}\relax
7743 \let\par\relax
7744 \marginpar{\hb@xt@\marginparwidth{\hfil\unhbox\@tempboxa}}\endgroup}
7745
7746 \def\macro@finish{\macro@namepart
7747 \if@def
7748 \@deffalse
7749 \@expandtwoargs\in@{\macro@namepart}{\the\index@excludelist}\relax
7750 \ifin@
7751 \else
7752 \@expandtwoargs\in@{\macro@namepart}{\the\index@nomainlist}\relax
7753 \ifin@
7754 \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}\relax
7755 \@tempa
7756 \else
7757 \edef\@tempa{\noexpand\SpecialMainIndex{\bslash\macro@namepart}}\relax
7758 \expandafter\marginmacro\macro@namepart\@nil
7759 \@tempa
7760 \fi
7761 \fi
7762 \else
7763 \ifx\macro@namepart\@defname
7764 \@deftrue
7765 \else
7766 \ifx\macro@namepart\@edefname
7767 \@deftrue
7768 \else
7769 \ifx\macro@namepart\@letname
7770 \@deftrue
7771 \else
7772 \ifx\macro@namepart\@gdefname
7773 \@deftrue
7774 \else
7775 \ifx\macro@namepart\@xdefname
7776 \@deftrue
7777 \fi
7778 \fi
7779 \fi
7780 \fi
7781 \fi
7782 \@expandtwoargs\in@{\macro@namepart}{\the\index@excludelist}\relax
7783 \ifin@
7784 \else
7785 \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}\relax
7786 \@tempa
7787 \fi
7788 \fi}
7789
7790 % the other patch (just one change: \parskip\z@ to \parskip 0pt plus 0.2pt)
7791 \def\macro@code{%
7792 \topsep \MacrocodeTopsep
7793 \@beginparpenalty0% \predisplaypenalty
7794 \if@inlabel\leavevmode\fi
7795 \trivlist \parskip 0pt plus 0.2pt \item[]%
7796 \macro@font
7797 \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
7798 \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
7799 \blank@linefalse \def\par{\ifblank@line
7800 \leavevmode\fi
7801 \blank@linetrue\@@par
7802 \penalty\interlinepenalty}
7803 \obeylines
7804 \let\do\do@noligs \verbatim@nolig@list
7805 \let\do\@makeother \dospecials
7806 \global\@newlistfalse
7807 \global\@minipagefalse
7808 \ifcodeline@index
7809 \everypar{\global\advance\c@CodelineNo\@ne
7810 \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
7811 \check@module}%
7812 \else \everypar{\check@module}%
7813 \fi
7814 \init@crossref}
7815 %</doc>
7816 %
7817 % \fi
7818 %
7819 % \check@checksum
7820 %
7821 \endinput