texlive[68241] Master/texmf-dist: mathfont (11sep23)

commits+karl at tug.org commits+karl at tug.org
Mon Sep 11 23:17:53 CEST 2023


Revision: 68241
          http://tug.org/svn/texlive?view=revision&revision=68241
Author:   karl
Date:     2023-09-11 23:17:53 +0200 (Mon, 11 Sep 2023)
Log Message:
-----------
mathfont (11sep23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/mathfont/README.txt
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_code.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_doc_patch.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_equations.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_heading.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.tex
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.pdf
    trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.tex
    trunk/Master/texmf-dist/source/latex/mathfont/mathfont_code.dtx
    trunk/Master/texmf-dist/tex/latex/mathfont/mathfont.sty

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/README.txt	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/README.txt	2023-09-11 21:17:53 UTC (rev 68241)
@@ -1,12 +1,13 @@
-LaTeX package mathfont version 2.2b installation information,
-released August 2023.
+              LaTeX Package mathfont v. 2.3
+                Installation Guide/README
+                     Conrad Kosowsky
 
-This file is README.txt from version 2.2b of the free and
+
+This file is README.txt from version 2.3 of the free and
 open-source LaTeX package "mathfont," to be used with the
 XeTeX or LuaTeX engines. The package is designed to adapt
-text fonts for use in math mode, and if you typeset your
-document with LuaLaTeX, mathfont adds resizable delimiters,
-big operators, and a MathConstants table to your font.
+text fonts for use in math mode. See the user guide for
+more information. See below for installation instructions.
 
 *********************************************************
 

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_doc_patch.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_doc_patch.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_doc_patch.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `doc')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_equations.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_equations.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_equations.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `equations')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -59,7 +59,9 @@
 %% 
 %% For more information, see mathfont_code.dtx. Happy TeXing!
 %% 
-\begin{multicols}{2}
+\multicolsep=0pt\relax
+\bigskip
+\begin{multicols*}{2}
 
 Black-Scholes Equation
 \[
@@ -68,6 +70,8 @@
   =rV-rS\frac{\partial V}{\partial X}
 \]
 
+\vfill
+
 Cardano's Formula/Cubic Formula
 \begin{align*}
 t_i&=\omega_i\sqrt[3]{-\frac q2+\sqrt{\frac{q^2}4+\frac{p^3}{27}}}\\
@@ -74,21 +78,29 @@
   &\qquad\qquad{}+\omega_i^2\sqrt[3]{-\frac q2-\sqrt{\frac{q^2}4+\frac{p^3}{27}}}
 \end{align*}
 
+\vfill
+
 Einstein's Field Equation (General Relativity)
 \[
 R_{\mu\nu}-\frac12Rg_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}
 \]
 
+\vfill
+
 First Isomorphism Theorem
 \[
 \phi(X)\cong X/\ker(\phi)
 \]
 
+\vfill
+
 Gauss-Bonnet Formula
 \[
 \int_MK\ dA+\int_{\partial M}k_g\ ds=2\pi\chi(M)
 \]
 
+\vfill
+
 Maxwell's Equations
 \begin{align*}
 \nabla\bullet\mathbf E&=\frac\rho{\epsilon_0}&
@@ -98,11 +110,18 @@
   \epsilon_0\frac{\partial\mathbf E}{\partial t}\right)
 \end{align*}
 
+\vfill
+
 Michaelis-Menten Model
+\bgroup
+\belowdisplayskip=0pt\relax
+\belowdisplayshortskip=0pt\relax
 \[
 v=\frac{d[P]}{dt}=V\frac{[S]}{K_M+[S]}
 \]
-
+\par\egroup
+\hrule height 0pt
+\columnbreak
 %% next column begins here
 
 Navier-Stokes Equation
@@ -114,21 +133,29 @@
   \rho\mathbf{g}
 \end{align*}
 
+\vfill
+
 Quadratic Formula
 \[
 x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
 \]
 
+\vfill
+
 Ramanujan's Approximation for $\Gamma$
 \[
 \Gamma(1+x)\approx\sqrt\pi\,x^xe^{-x}\,\sqrt[6]{8x^3+4x^2+x+\frac1{30}}
 \]
 
+\vfill
+
 Residue Theorem
 \[
 \frac1{2i\pi}\int_{\gamma}f(z)\ dz=\sum_{k=1}^n\Res_{a_k}(f)
 \]
 
+\vfill
+
 Riemann Zeta Function
 \begin{align*}
 \zeta(z)&=\sum_{i=1}^\infty\frac1{z^i}
@@ -136,17 +163,24 @@
   &=2^z\pi^{z-1}\sin\left(\frac{\pi z}2\right)\,\Gamma(1-z)\,\zeta(1-z)
 \end{align*}
 
+\vfill
+
 Schrodinger Equation
 \[
 i\hbar\frac d{dt}|\Psi(t)\fakerangle=\hat H|\Psi(t)\fakerangle
 \]
 
+\vfill
+
 Lorentz Transformation (Special Relativity)
+\belowdisplayskip=0pt\relax
+\belowdisplayshortskip=0pt\relax
 \[
 t'=\left(t-\frac{vx}{c^2}\right)\frac1{\sqrt{1-\frac{v^2}{c^2}}}
 \]
+\hrule height 0pt
 
-\end{multicols}
+\end{multicols*}
 \endinput
 %%
 %% End of file `mathfont_equations.tex'.

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_cormorant.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `cormorant')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_kelvinch.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `kelvinch')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -77,7 +77,7 @@
 \DeclareMathOperator{\Res}{Res}
 \usepackage{mathfont}
 \mathfont[radical]{Crimson}
-\setfont{Kelvinch}
+\setfont{Kelvinch:-clig}
 \IntegralItalicFactor{500}
 \SurdHorizontalFactor{900}
 \parindent=0pt\relax

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_roboto.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `roboto')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_example_typey.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `typey')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -104,6 +104,9 @@
   {<->"Typey McTypeface:\M at otf@features;embolden=6;mode=base"}{}
 \DeclareFontShape{TU}{Typey-base}{\bfdefault}{\itdefault}
   {<->"Typey McTypeface/I:\M at otf@features;embolden=6;mode=base"}{}
+
+%% And link the Typey-base font family to the Typey family
+\expandafter\def\csname Typey-base\endcsname{Typey-base}
 \makeatother
 
 \setfont{Typey}

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_heading.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_heading.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_heading.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `heading')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -63,8 +63,8 @@
 \csname count@\endcsname\catcode`\@
 \makeatletter
 
-\def\packagedate{August 2023}
-\def\packageversion{2.2b}
+\def\packagedate{September 2023}
+\def\packageversion{2.3}
 
 
 \let\@@section\section

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_symbol_list.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `chars')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.tex	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/doc/latex/mathfont/mathfont_user_guide.tex	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `user')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -74,7 +74,7 @@
   itemsep=\smallskipamount,
   parsep=\z@,partopsep=\z@}
 \setlist{special}
-\usepackage{doc}
+\usepackage{doc}[=v2]
 \MakeShortVerb{|}
 \def\link#1{\href{#1}{\nolinkurl{#1}}}
 \newcount\fig
@@ -97,7 +97,7 @@
 
 Loading 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}}}.) For this reason, \textsf{mathfont} also provides an interface to enlarge the bounding boxes of Latin letters 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 usually results in 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}.
 
-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{mathfont}| syntax, and the package accepts three 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. 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. If you load \textsf{mathfont} with any other optional argument, the package will interpret it as a font name and call |\setfont| (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 section of Table~1.
+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{mathfont}| 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. 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 |\setfont| (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 section of Table~1.
 
 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, which is compatible with \XeTeX\ only and selects characters from text fonts for math.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,'' \link{https://ctan.org/pkg/mathspec}.} The \textsf{unicode-math} package is the standard \LaTeX\ package for loading actual unicode math fonts, and if you have a unicode font with proper math support, rather than a text font that you want to use for equations, consider using this package instead of \textsf{mathfont}.\footnote{Will Robertson, et al., ``\textsf{unicode-math}---Unicode mathematics support for XeTeX and LuaTeX,'' \link{https://ctan.org/pkg/unicode-math}.} 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 will probably 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.
 
@@ -144,7 +144,7 @@
 \begin{code}
 |\mathfont[lower=upright, upper=upright]{Times New Roman}|
 \end{code}
-changes all Latin letters to upright Times New Roman. Once \textsf{mathfont} has set the default font for a keyword in Table~1, it will ignore any future instructions to do so and prints a warning to the terminal instead.
+changes all Latin letters to upright Times New Roman. Once \textsf{mathfont} has set the default font for a keyword in Table~1, it will ignore any future instructions to change the font for that keyword again, and instead the package prints a warning message.
 
 \begin{figure}[t]
 \labelfig{SetFont}
@@ -169,9 +169,17 @@
 \end{code}
 It calls |\mathfont| without an optional argument---i.e.\ for the default keywords---on your \meta{font name} and sets your document's default text font to be the \meta{font name}. The command also defines the eight commands in Table~\ref{SetFont} using the \meta{font name} and the |\new| macros in the next section. Both |\mathfont| and |\setfont| should appear in the preamble only.
 
-To select OpenType features, you should put a colon after the font name and follow it with appropriate OpenType 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}.} For example adding ``|onum=true|'' tells \TeX\ to load your font with oldstyle numbering, assuming that feature is present in the font. You should separate different OpenType feature tags with a semi-colon.
+To select OpenType features, you should put a colon after the font name and follow it with appropriate OpenType 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 can use that package's high-level interface.\footnote{See the \textsf{fontspec} documentation for instructions on selecting OpenType features with \textsf{fontspec}.} 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
+\begin{code}
+|\mathfont{Adobe Garamond Pro:+onum}|
+\end{code}
+for the built-in font-loader or
+\begin{code}
+|\mathfont{Adobe Garamond Pro:Numbers=OldStyle}|
+\end{code}
+if using \textsf{fontspec}. With the built-in font-loader, you should separate OpenType tags with semi-colons, and \textsf{fontspec} allows you to use commas.
 
-Whenever you select a font, \textsf{mathfont} first checks whether you previously loaded \textsf{fontspec}, and if so, the package feeds your entire \meta{font name} argument to \textsf{fontspec}. (You can also say ``|fontspec|'' as the \meta{font name} to select the most recent font used by \textsf{fontspec}.) If you have not loaded \textsf{fontspec}, the package uses its own fontloader. I recommend letting \textsf{mathfont} handle font-loading because when using Lua\TeX, \textsf{mathfont} takes care to load fonts in such a way that full OpenType features are accessible in text and limited OpenType features are accessible in math.\footnote{The \textsf{luaotfload} package supports two main modes for loading fonts: |node| mode is the default setting, and it supports full OpenType features in text but no OpenType features in math. The |base| mode supports limited OpenType features, but the features will work for both text and math. When \textsf{mathfont} loads a font, it does so twice, once in |node| mode, which is primarily for setting the text font with \vrb\setfont, and once in |base| mode, which is for the package's other font declarations. This way you will be able to use OpenType features throughout your document. The package does not currently load fonts with HarfBuzz.} While it is also possible to do this in \textsf{fontspec}, it takes some doing.
+Whenever you select a font, \textsf{mathfont} first checks whether your argument corresponds to a font family identifier in the \textsc{nfss}, and if it does, \textsf{mathfont} uses that font. Otherwise, the package uses loads the font, either through the built-in font-loader or with \textsf{fontspec}. Advanced users should know that when the engine is Lua\TeX, \textsf{mathfont} loads fonts twice. During the first loading, \textsf{mathfont} makes no specifications for the renderer, so the first version of the font will typically use node mode. During the second loading, \textsf{mathfont} specifies base mode. My intention is that the font face with unspecified renderer is for text and the font face with base-mode renderer is for math---using different loading options for text and math provides the greatest access to OpenType font features throughout your document.\footnote{The \textsf{luaotfload} package supports two main modes for loading fonts: |node| mode is the default setting, and it supports full OpenType features in text but no OpenType features in math. The |base| mode supports fewer OpenType features, but the font features work in both text and math. Other loading options such as HarfBuzz are similarly useful for text but provide no access to OpenType features in math.}
 
 The last five keywords in Table~\ref{Keywords} are a bit different. If you call |\mathfont| on a \meta{keyword} from the last five rows in Table~\ref{Keywords}, the package defines the macro
 \begin{code}
@@ -202,7 +210,7 @@
 
 \section{Local Font Changes}
 
-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}. 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, and they define the \meta{control sequence} to typeset any math alphabet characters in their argument into the \meta{font name}. For example, the macro |\newmathrm| looks like
+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}. 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, and they define the \meta{control sequence} to typeset any math alphabet characters in their argument into the \meta{font name}. You can specify OpenType features as part of the \meta{font name} the same way as for |\mathfont|, described in the previous section.  For example, the macro |\newmathrm| looks like
 \begin{code}
 |\newmathrm{|\meta{control sequence}|}{|\meta{font name}|}|.
 \end{code}
@@ -220,7 +228,7 @@
 \begin{code}
 |\newmathfontcommand{|\meta{control sequence}|}{|\meta{font name}|}{|\meta{series}|}{|\meta{shape}|}|,
 \end{code}
-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 with |\newmathfontcommand|, but the 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. The commands from this section should appear in the preamble only.
+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 the 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. The commands from this section should appear in the preamble only.
 
 \section{Default Math Parameters}
 
@@ -252,7 +260,7 @@
 \end{itemize}
 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|. If you specify too few charm values, \textsf{mathfont} will raise an error, and if you provide too many, \textsf{mathfont} will silently ignore the extras.
 
-\begin{figure}[b]
+\begin{figure}[tb]
 \labelfig{Factors}
 \centerline{\bfseries Table \the\fig: Commands to Adjust Individual Characters\strut}
 \global\advance\fig by 1\relax
@@ -271,12 +279,6 @@
 \end{code}
 tells \textsf{mathfont} to take the lower-case ``a'' (unicode encoding value of 97), increase the bounding box on the left side by 20\% of the glyph width, decrease the bounding box on the right side by 20\% of the glyph width, do nothing to the top accent, and shift the bottom accent right by 5\% of the glyph 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 particular font, consider making a custom set of charm values and uploading it to \textsc{ctan}. Additionally, if you store your charm information in a file, you can read it in with |\CharmFile|. The argument of this command should be a file name, and \textsf{mathfont} reads the file and feeds each line individually to |\CharmLine|.
 
-The commands in Table~\ref{Factors} adjust other aspects of the font as indicated. Each command accepts a single integer as an argument, and \textsf{mathfont} divides the input by 1000. With each macro, \textsf{mathfont} multiplies the quotient by some default length, so values greater than or less than 1000 mean ``scale up'' or ``scale down'' respectively. For example,
-\begin{code}
-|\RuleThicknessFactor{2000}|
-\end{code}
-doubles the thickness of the fraction rule and radical overbar relative to the default, which varies between fonts. Changing the |\RuleThicknessFactor| is useful for fonts with particularly heavy or light weight. The |\IntegralItalicFactor| is important for making limits better fit integral signs, and the |\SurdVerticalFactor| and |\SurdHorizontalFactor| commands are essential when the top of the surd glyph differs from the top of its bounding box. The six control sequences from this section should appear in the preamble only.
-
 \begin{figure}[tb]
 \labelfig{Callbacks}
 \centerline{\bfseries Table \the\fig: Lua Callbacks Created by \textsf{mathfont}\strut}
@@ -292,6 +294,12 @@
 \end{tabularx}
 \end{figure}
 
+The commands in Table~\ref{Factors} adjust other aspects of the font as indicated. Each command accepts a single integer as an argument, and \textsf{mathfont} divides the input by 1000. With each macro, \textsf{mathfont} multiplies the quotient by some default length, so values greater than or less than 1000 mean ``scale up'' or ``scale down'' respectively. For example,
+\begin{code}
+|\RuleThicknessFactor{2000}|
+\end{code}
+doubles the thickness of the fraction rule and radical overbar relative to the default, which varies between fonts. Changing the |\RuleThicknessFactor| is useful for fonts with particularly heavy or light weight. The |\IntegralItalicFactor| is important for making limits better fit integral signs, and the |\SurdVerticalFactor| and |\SurdHorizontalFactor| commands are essential when the top of the surd glyph differs from the top of its bounding box. The six control sequences from this section should appear in the preamble only.
+
 Finally, advanced users who want to interact with the font adjustment process directly should use the six callbacks in Table~\ref{Callbacks}. When \textsf{luaotfload} loads a font, \textsf{mathfont} (1) always calls |mathfont.inspect_font| and (2) calls the other five callbacks in the order that they appear in Table~\ref{Callbacks} if the font object contains |nomath=true|. 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 the |disable_nomath|, |add_math_constants|, and |fix_character_metrics| callbacks. 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.
 
 \end{document}

Modified: trunk/Master/texmf-dist/source/latex/mathfont/mathfont_code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/mathfont/mathfont_code.dtx	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/source/latex/mathfont/mathfont_code.dtx	2023-09-11 21:17:53 UTC (rev 68241)
@@ -1,9 +1,9 @@
 % \iffalse     ---!!! FIRST META-COMMENT !!!---
 % 
 % 
-% This file is mathfont_code.dtx from version 2.2b of the
+% This file is mathfont_code.dtx from version 2.3 of the
 % free and open-source LaTeX package "mathfont," released
-% August 2023, to be used with the XeTeX or LuaTeX engines.
+% September 2023, to be used with the XeTeX or LuaTeX engines.
 % 
 % Running Plain TeX on mathfont_code.dtx will produce the
 % following files:
@@ -43,8 +43,8 @@
 % \iffalse     ---!!! SECOND META-COMMENT !!!---
 % 
 % 
-% This file is from version 2.2b of the free and open-source
-% LaTeX package "mathfont," released August 2023, to be used
+% This file is from version 2.3 of the free and open-source
+% LaTeX package "mathfont," released September 2023, to be used
 % with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 % is recommended.)
 % 
@@ -154,8 +154,8 @@
 \askforoverwritefalse
 \preamble
 
-This file is from version 2.2b of the free and open-source
-LaTeX package "mathfont," released August 2023, to be used
+This file is from version 2.3 of the free and open-source
+LaTeX package "mathfont," released September 2023, to be used
 with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 is recommended.)
 
@@ -238,7 +238,7 @@
 \fi
 %</batchfile>
 %<*driver>
-\documentclass[12pt,doc2,letterpaper]{ltxdoc}
+\documentclass[12pt,doc2,letterpaper,twoside]{ltxdoc}
 \makeatletter
 \usepackage[margin=1in]{geometry}
 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
@@ -247,6 +247,9 @@
 \usepackage{booktabs}
 \usepackage{multirow}
 \usepackage{enumitem}
+\usepackage{soul}
+\setlist{itemsep=\smallskipamount,topsep=\smallskipamount,
+  parsep=\z@,partopsep=\z@}
 \c at IndexColumns=2
 \c at topnumber\@ne
 \columnsep=20pt
@@ -285,7 +288,7 @@
 % \fi
 % 
 % 
-% \CheckSum{6631}
+% \CheckSum{6640}
 % \init at checksum
 % 
 % 
@@ -330,7 +333,7 @@
 %   \mathgroup,\nolimits,\on at line,\PackageWarningNoLine,\RequirePackage,%
 %   \thr@@,\M at toks,\inputlineno,\mathchar at type,\DeclareMathAccent,%
 %   \ifM at EasterEgg@declare,\M at EasterEgg@declaretrue,\M at EasterEgg@declarefalse,%
-%   \IfFileExists,\E at sterEggHook,\@gobblefour,\@gobbletwo at brackets,%
+%   \IfFileExists,\E at sterEggHook,\@gobblefour,\@gobble at brackets,%
 %   \protected,\@eha,\@cclv,\new at mathgroup,\new at symbolfont,\@latex at error,%
 %   \ifcase,\or,\thr@@,\gdef,\rmdefault,\openin,\closein,\immediate,%
 %   \M at Decl@reF at milytrue,\M at Decl@reF at milyfalse,\itdefault,\shapedefault,%
@@ -394,9 +397,9 @@
 % First and foremost, the package needs to declare itself.
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{mathfont}[2023/08/21 v. 2.2b Package mathfont]
+\ProvidesPackage{mathfont}[2023/09/09 v. 2.3 Package mathfont]
 %    \end{macrocode}
-% We specify conditionals that we will use later in handling options and setup.
+% We specify conditionals and one count variable that we use later in handling options and setup.
 %    \begin{macrocode}
 \newif\ifM at XeTeXLuaTeX     % is engine one of xetex or luatex?
 \newif\ifM at Noluaotfload    % cannot find luaotfload.sty?
@@ -403,10 +406,11 @@
 \newif\ifM at adjust@font     % should adjust fonts with lua script?
 \newif\ifM at font@loaded     % load mathfont with font specified?
 \newif\ifE at sterEggDecl@red % already did easter egg?
+\newcount\M at loader         % specifies which font-loader to use
 %    \end{macrocode}
-% 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.\indexpage{invalid command}
+% 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. We do so in three batches: those that |\@gobble| their argument, those that |\@gobbletwo| their argument, and those that accept an optional argument.\indexpage{invalid command}
 %    \begin{macrocode}
-\long\def\@gobbletwo at brackets[#1]#2{}
+\long\def\@gobble at brackets[#1]{}
 \def\M at NoMathfontError#1{\PackageError{mathfont}
   {\MessageBreak Invalid command\MessageBreak
   \string#1 on line \the\inputlineno}
@@ -413,33 +417,54 @@
   {Your command was ignored. I couldn't\MessageBreak
   load mathfont, so I never defined this\MessageBreak
   control sequence.}}
-\protected\def\mathfont{\M at NoMathfontError\mathfont
-  \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\protected\def\setfont{\M at NoMathfontError\setfont\@gobble}
-\protected\def\mathconstantsfont{\M at NoMathfontError\mathconstantsfont
-  \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\protected\def\newmathrm{\M at NoMathfontError\newmathrm\@gobbletwo}
-\protected\def\newmathit{\M at NoMathfontError\newmathit\@gobbletwo}
-\protected\def\newmathbf{\M at NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbfit{\M at NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbold{\M at NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathboldit{\M at NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathsc{\M at NoMathfontError\newmathsc\@gobbletwo}
-\protected\def\newmathscit{\M at NoMathfontError\newmathscit\@gobbletwo}
-\protected\def\newmathbfsc{\M at NoMathfontError\newmathbfsc\@gobbletwo}
-\protected\def\newmathbfscit{\M at NoMathfontError\newmathbfscit\@gobbletwo}
+%    \end{macrocode}
+% First the commands that normally accept a single argument---the ``bad'' versions |\@gobble| the argument. To keep the syntax straightforward, we put the |\def| declaration inside |\@tempa| and the definition itself inside |\@tempb|. 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|.
+%    \begin{macrocode}
+\@tfor\@i:=\setfont
+  \RuleThicknessFactor
+  \IntegralItalicFactor
+  \SurdVerticalFactor
+  \SurdHorizontalFactor
+  \CharmLine
+  \CharmFile\do{%
+    \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+    \edef\@tempb{\noexpand\M at NoMathfontError
+      \expandafter\noexpand\@i
+      \noexpand\@gobble}%
+    \expandafter\@tempa\expandafter{\@tempb}}
+%    \end{macrocode}
+% Now for the macros that |\@gobbletwo| their argument. The code is essentially the same.
+%    \begin{macrocode}
+\@tfor\@i:=\newmathrm
+  \newmathit
+  \newmathbf
+  \newmathbfit
+  \newmathbold
+  \newmathboldit
+  \newmathsc
+  \newmathscit
+  \newmathbfsc
+  \newmathbfscit\do{%
+    \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+    \edef\@tempb{\noexpand\M at NoMathfontError
+      \expandafter\noexpand\@i
+      \noexpand\@gobbletwo}%
+    \expandafter\@tempa\expandafter{\@tempb}}
+%    \end{macrocode}
+% 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.
+%    \begin{macrocode}
+\@tfor\@i:=\mathfont\mathconstantsfont\do{%
+  \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+  \edef\@tempb{\noexpand\M at NoMathfontError
+    \expandafter\noexpand\@i
+    \noexpand\@ifnextchar[{\noexpand\expandafter
+      \noexpand\@gobble\noexpand\@gobble at brackets}{\noexpand\@gobble}}
+  \expandafter\@tempa\expandafter{\@tempb}}
+%    \end{macrocode}
+% We code |\newmathfontcommand| by hand because it is the only command with four arguments.
+%    \begin{macrocode}
 \protected\def\newmathfontcommand{%
   \M at NoMathfontError\newmathfontcommand\@gobblefour}
-\protected\def\RuleThicknessFactor{%
-  \M at NoMathfontError\RuleThicknessFactor\@gobble}
-\protected\def\IntegralItalicFactor{%
-  \M at NoMathfontError\IntegralItalicFactor\@gobble}
-\protected\def\SurdVerticalFactor{%
-  \M at NoMathfontError\SurdVerticalFactor\@gobble}
-\protected\def\SurdHorizontalFactor{%
-  \M at NoMathfontError\SurdHorizontalFactor\@gobble}
-\protected\def\CharmLine{\M at NoMathfontError\CharmLine\@gobble}
-\protected\def\CharmFile{\M at NoMathfontError\CharmFile\@gobble}
 %    \end{macrocode}
 % Check that the engine is \XeTeX\ or Lua\TeX. If yes, set |\ifM at XeTeXLuaTeX| to true. (Otherwise the conditional will be false by default.)
 %    \begin{macrocode}
@@ -450,7 +475,7 @@
   \M at XeTeXLuaTeXtrue
 \fi
 %    \end{macrocode}
-% 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.\indexpage{catcode changes} 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 at NoFontspecError| 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.\indexpage{unable to load}\indexpage{missing xetex or luatex=missing \XeTeX\ or Lua\TeX}
+% 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.\indexpage{catcode changes} 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 at 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.\indexpage{unable to load}\indexpage{missing xetex or luatex=missing \XeTeX\ or Lua\TeX}
 %    \begin{macrocode}
 \ifM at XeTeXLuaTeX\else
 \begingroup
@@ -489,12 +514,12 @@
   \IfFileExists{luaotfload.sty}
     {\M at Noluaotfloadfalse\RequirePackage{luaotfload}}{\M at Noluaotfloadtrue}
 \else
-  \PackageWarningNoLine{mathfont}{%
+  \AtEndOfPackage{\PackageWarningNoLine{mathfont}{%
     The current engine is XeTeX, but as\MessageBreak
     of mathfont version 2.0, LuaTeX is\MessageBreak
     recommended. Consider compiling with\MessageBreak
     LuaLaTeX. Certain features will not\MessageBreak
-    work with XeTeX}
+    work with XeTeX}}
 \fi
 %    \end{macrocode}
 % If the engine is Lua\TeX, we absolutely 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.\indexpage{unable to load}\indexpage{cannot not find the file luaotfloadsty=cannot find the file \texttt{luaotfload}}
@@ -594,8 +619,13 @@
       \let\EasterEggUpdate\relax}
   \fi}% my easter egg :)
 %    \end{macrocode}
-% The three real package options. The options |adjust| and |no-adjust| overwrite \textsf{mathfont}'s default decision about whether to apply Lua-based font adjustments to all future fonts loaded.
+% The five real package options. The |default-loader| and |fontspec-loader| tell \textsf{mathfont} what to use as a backend for loading fonts.
 %    \begin{macrocode}
+\DeclareOption{default-loader}{\M at loader\z@}
+\DeclareOption{fontspec-loader}{\M at loader\@ne}
+%    \end{macrocode}
+% The options |adjust| and |no-adjust| overwrite \textsf{mathfont}'s default decision about whether to apply Lua-based font adjustments to all future fonts loaded.
+%    \begin{macrocode}
 \DeclareOption{adjust}{\M at adjust@fonttrue}
 \DeclareOption{no-adjust}{\M at adjust@fontfalse}
 %    \end{macrocode}
@@ -604,32 +634,91 @@
 \DeclareOption*{\M at font@loadedtrue\edef\M at font@load{\CurrentOption}}
 \ProcessOptions*
 %    \end{macrocode}
+% 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.
+%    \begin{macrocode}
+\ifcase\M at loader
+  \wlog{Package mathfont Info: Default font-loader was
+    requested for font loading.}
+\or
+  \wlog{Package mathfont Info: Package fontspec was
+    requested for font loading.}
+%    \end{macrocode}
+% If \textsf{fontspec} was already loaded, check whether |\g__fontspec_math_bool| is true or not. If it is, change it to false.
+%    \begin{macrocode}
+  \@ifpackageloaded{fontspec}
+    {\wlog{Package mathfont Info: Package fontspec detected.}
+      \csname bool_if:NTF\expandafter\endcsname
+        \csname g__fontspec_math_bool\endcsname
+        {\wlog{Package mathfont Info: Setting
+          \string\g__fontspec_math_bool to false.}
+          \csname bool_set_false:N\expandafter\endcsname
+          \csname g__fontspec_math_bool\endcsname}{\relax}}
+%    \end{macrocode}
+% If \textsf{fontspec} was not loaded, check that the package file exists. 
+%    \begin{macrocode}
+    {\wlog{Package mathfont Info: Package fontspec not detected.}
+      \IfFileExists{fontspec.sty}
+        {\wlog{Package mathfont Info: File fontspec.sty was found.}
+          \wlog{Package mathfont Info: Loading fontspec.}
+          \RequirePackage[no-math]{fontspec}}
+        {\PackageError{mathfont}{Missing package fontspec;\MessageBreak
+          using default font-loader instead}
+          {You requested fontspec as the font-loader for\MessageBreak
+          mathfont. However, I can't find the fontspec\MessageBreak
+          package file, so I'm going to use the default\MessageBreak
+          font-loader instead. (This likely means that\MessageBreak
+          something is wrong with your TeX installation.)\MessageBreak
+          Check your TeX distribution for a list of the\MessageBreak
+          packages installed on your system. To resolve\MessageBreak
+          this error, make sure fontspec is installed in\MessageBreak
+          a directory searchable by TeX or load mathfont\MessageBreak
+          with the default-loader option.^^J}
+          \M at loader\z@}}
+\fi
+%    \end{macrocode}
+% We print an informational message specifying the font-loader in use. We store default OpenType features in |\M at 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.
+%    \begin{macrocode}
+\ifcase\M at loader
+  \wlog{Package mathfont Info: Using default font-loader.}
+  \AtEndOfPackage{\typeout{:: mathfont :: Using default font-loader.}}
+  \def\M at otf@features{script=latin;language=DFLT;+tlig;+liga;+lnum}
+\or
+  \wlog{Package mathfont Info: Using fontspec as font-loader.}
+  \AtEndOfPackage{\typeout{:: mathfont :: Using fontspec as font-loader.}}
+  \def\M at otf@features{Script=Latin,
+    Language=Default,
+    Ligatures={TeX,Common},
+    Numbers=Lining}
+\fi
+%    \end{macrocode}
 % 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 at adjust@font|.
 %    \begin{macrocode}
 \ifdefined\directlua
   \ifM at adjust@font
+    \wlog{Package mathfont Info: Enabling Lua-based font adjustments.}
     \AtEndOfPackage{%
       \typeout{:: mathfont :: Lua-based font adjustments enabled.}}
   \else
+    \wlog{Package mathfont Info: Disabling Lua-based font adjustments.}
     \AtEndOfPackage{%
       \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
   \fi
 \else
 %    \end{macrocode}
-% If |\directlua| is undefined, we say that Lua-based font adjustments are disabled, and we issue an error if the user tried to manually enable them.
+% 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.
 %    \begin{macrocode}
-  \AtEndOfPackage{%
-    \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
   \ifM at adjust@font
-    \AtEndOfPackage{%
     \PackageError{mathfont}{Option^^J"adjust" ignored with XeTeX}
     {Your package option "adjust" was ignored.\MessageBreak
     This option works only with LuaTeX, and it\MessageBreak
     looks like the current engine is XeTeX. To\MessageBreak
     enable Lua-based font adjustments, typeset\MessageBreak
-    with LuaLaTeX.^^J}}
+    with LuaLaTeX.^^J}
     \M at adjust@fontfalse
   \fi
+  \wlog{Package mathfont Info: Disabling Lua-based font adjustments.}
+  \AtEndOfPackage{%
+    \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
 \fi
 %    \end{macrocode}
 % 
@@ -644,11 +733,13 @@
 % \begin{tabularx}\textwidth{lX}
 % \toprule
 % Command & Use\\\midrule
-% \vrb\M at FontChangeInfo & Use a symbol font for some characters\\
+% \vrb\M at FontChangeInfo & Use a symbol font inside \vrb\mathfont\\
 % \vrb\M at NewFontCommandInfo & Declare new alphanumeric font-change command\\
 % \vrb\M at SymbolFontInfo & Declare new symbol font\\\midrule
 % \vrb\M at CharsSetWarning & Warning when calling \vrb\mathfont\ multiple times for same keyword\\
-% \vrb\M at InternalsRestoredError & User called \vrb\mathfont\ after restoring kernel\\
+% \vrb\M at InternalsRestoredError & User called \vrb\mathfont\ after restoring kernel\\\midrule
+% \vrb\M at MissingNFSSShapesWarning & Warning if font is missing shapes\\
+% \vrb\M at NoBaseModeDetectedWarning & Warning if no base-mode version of a font\\\midrule
 % \vrb\M at InvalidOptionError & Bad option for \vrb\mathfont\\
 % \vrb\M at InvalidSupoptionError & Bad suboption for \vrb\mathfont\\
 % \vrb\M at MissingOptionError & Missing an option for \vrb\mathfont\\
@@ -659,9 +750,7 @@
 % \vrb\M at DeprecatedWarning & Warning for certain deprecated macros\\
 % \vrb\M at DoubleArgError & Gave multiple tokens to be the font-change macro\\
 % \vrb\M at HModeError & Font-change command used outside math mode\\
-% \vrb\M at MissingControlSequenceError & No macro provided to be font-change command\\
-% \vrb\M at NoFontspecFamilyError & Improper option \texttt{fontspec} for \vrb\mathfont\\
-% \vrb\M at NoFontspecError & Option \texttt{fontspec} for \vrb\mathfont\ declared without having loaded \textsf{fontspec}\\\midrule
+% \vrb\M at MissingControlSequenceError & No macro provided to be font-change command\\\midrule
 % \vrb\M at BadIntegerError & Font metric adjustment value was not an integer\\
 % \vrb\M at ForbiddenCharmFile & Charm file contains a bad character\\
 % \vrb\M at ForbiddenCharmLine & Charm line contains a bad character\\
@@ -687,6 +776,18 @@
   #1 chars, so I'm ignoring\MessageBreak
   this option for \string\mathfont\space
   on line \the\inputlineno\@gobble}}
+\def\M at MissingNFSSShapesWarning#1#2{\PackageWarning{mathfont}
+  {The nfss family "#1"\MessageBreak
+  from line \the\inputlineno\space is missing shapes. You\MessageBreak
+  may see some substitutions or errors.\MessageBreak
+  Missing shape(s):#2\@gobble}}
+\def\M at NoBaseModeDetectedWarning#1{\PackageWarning{mathfont}
+  {I couldn't find a base-mode version of\MessageBreak
+  the nfss family "#1"\MessageBreak
+  from line \the\inputlineno, so I'm using the family\MessageBreak
+  you specified for the math font. Some\MessageBreak
+  font features may not work in math\MessageBreak
+  mode\@gobble}}
 %    \end{macrocode}
 % \indexpage{I already set the font}
 % Warnings for the |\mathbb|, etc.\ commands.
@@ -729,9 +830,9 @@
 \def\M at MissingSuboptionError{\PackageError{mathfont}
   {Missing^^Jsuboption for \string\mathfont\on at line}
   {It looks like you included an = somewhere\MessageBreak
-  but didn't put the suboption after it. Either\MessageBreak
-  that or you typed == instead of = in the\MessageBreak
-  optional argument of \string\mathfont.^^J}}
+  in the optional argument of \string\mathfont\space but\MessageBreak
+  didn't put the suboption after it. Either\MessageBreak
+  that or you typed == instead of =.^^J}}
 \def\M at InternalsRestoredError{\PackageError{mathfont}
   {Internal^^Jcommands restored}
   {This package slightly changes two LaTeX\MessageBreak
@@ -746,27 +847,6 @@
   Try typesetting this document with all\MessageBreak
   \string\mathfont\space commands placed before you call\MessageBreak
   \string\restoremathinternals.^^J}}
-\def\M at NoFontspecFamilyError{\PackageError{mathfont}
-  {No previous^^Jfont loaded by fontspec}
-  {You called \string\mathfont\space
-  with the argument "fontspec" \MessageBreak
-  on line \the\inputlineno,
-  and that tells me to use the previous \MessageBreak
-  font loaded by the fontspec package. However, it \MessageBreak
-  looks like you haven't loaded any fonts yet with \MessageBreak
-  fontspec. To resolve this error, try using for \MessageBreak
-  example \string\setmainfont\space
-  before calling \string\mathfont.^^J}}
-\def\M at NoFontspecError{\PackageError{mathfont}
-  {Missing^^Jpackage fontspec}
-  {You called \string\mathfont\space
-  with the argument "fontspec" \MessageBreak
-  on line \the\inputlineno,
-  and that tells me to use the previous \MessageBreak
-  font loaded by the fontspec package. However, you\MessageBreak
-  haven't loaded fontspec, so some things are about\MessageBreak
-  to get messed up. To resolve this error, load\MessageBreak
-  fontspec before calling \string\mathfont.^^J}}
 %    \end{macrocode}
 % Error messages for |\mathconstantsfont|.
 % \indexpage{Invalid font specifier}
@@ -773,8 +853,9 @@
 % \indexpage{your mathconstants on line=Your \texttt{\char`\\mathconstants} on line}
 %    \begin{macrocode}
 \def\M at BadMathConstantsFontError#1{\PackageError{mathfont}
-  {Invalid\MessageBreak font specifier for
-  \string\mathconstantsfont:\MessageBreak"#1"}
+  {Invalid font specifier\MessageBreak
+  for \string\mathconstantsfont:\MessageBreak
+  "#1"}
   {Your command was ignored--I can't parse your argument.\MessageBreak
   Please make sure to use text that you have previously\MessageBreak
   fed to \string\mathfont\space for the argument of 
@@ -785,10 +866,13 @@
   {The optional argument of \string\mathconstantsfont\MessageBreak
   should be "upright" or "italic." Right now,\MessageBreak
   it's "#1."^^J}}
-\def\M at LuaTeXOnlyWarning{\PackageWarning{mathfont}
-    {Your \string\mathconstantsfont\space
-    on line \the\inputlineno\space is\MessageBreak
-    for LuaTeX only, and I'm ignoring it\@gobble}}
+\def\M at MathConstantsNoFontAdjustWarning{\PackageWarning{mathfont}
+  {Your \string\mathconstantsfont\space
+  on line \the\inputlineno\MessageBreak
+  is mainly for use in LuaTeX with font\MessageBreak
+  adjustments enabled. In the current\MessageBreak
+  situation, it is probably not doing\MessageBreak
+  anything\@gobble}}
 %    \end{macrocode}
 % Error messages for the |\newmathrm|, etc.\ commands.
 % \indexpage{Missing control sequence}
@@ -859,19 +943,6 @@
 % 
 % \section{Default Settings}
 % 
-% We do not want \textsf{fontspec} making changes to mathematics. If the user has loaded the package, we set |\g__fontspec_math_bool| to false. Otherwise, we pass the |no-math| option to the package in case the user loads it later.
-%    \begin{macrocode}
-\@ifpackageloaded{fontspec}
-  {\wlog{Package mathfont Info: Package fontspec detected.}
-    \wlog{Package mathfont Info: Setting \string\g__fontspec_math_bool
-      to false.}
-    \csname bool_set_false:N\expandafter\endcsname
-    \csname g__fontspec_math_bool\endcsname}
-  {\wlog{Package mathfont Info: Package fontspec not detected.}
-    \wlog{Package mathfont Info: Will pass no-math option to fontspec
-      if it gets loaded.}
-    \PassOptionsToPackage{no-math}{fontspec}}
-%    \end{macrocode}
 % We save four macros from the \LaTeX\ kernel so we can change their definitions. To adapt the symbol declaration macros for use with unicode fonts, we reverse the conversion to hexadecimal in |\count0| and change the |\math| primitive to |\Umath|. Whereas the traditional primitives accept hexadecimal input, |\Umath| primitives accept decimal input with a |+| sign.\indexpage{LaTeX kernel=\LaTeX\ kernel}
 %    \begin{macrocode}
 \let\@@set at mathchar\set at mathchar
@@ -910,9 +981,9 @@
   \protected\xdef#2{%
     \Umathaccent\mathchar at type#3+\number#1+\the\count\z@\relax}}
 %    \end{macrocode}
-% 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<\e at mathgroup@top|, where |\e at mathgroup@top| is the number of math families and is 256 in \XeTeX\ and Lua\TeX. Because macro patching is complicated, the next few lines may seem somewhat esoteric. Our approach is to get a sanitized definition with |\meaning| and |\strip at prefix|, implement the patch by expanding |\M at p@tch at decl@re|, and retokenize the whole thing. A simpler approach, such as calling |\M at p@tch at decl@re| directly on the expansion of |\DeclareSymbolFont|, won't work because of the way \TeX\ stores and expands parameter symbols inside macros.
+% 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<\e at mathgroup@top|, where |\e at mathgroup@top| is the number of math families and is 256 in \XeTeX\ and Lua\TeX. Because macro patching is complicated, the next few lines may seem somewhat esoteric. Our approach is to get a sanitized definition with |\meaning| and |\strip at prefix|, implement the patch by expanding |\M at p@tch at decl@re|, and retokenize the whole thing. A simpler approach, such as calling |\M at p@tch at decl@re| directly on the expansion of |\DeclareSymbolFont|, won't work because of how \TeX\ stores and expands parameter symbols inside macros.
 % 
-% As of November 2022, the \LaTeX\ kernel has redefined |\DeclareSymbolFont at m@dropped| to have the same definition as the old |\DeclareSymbolFont|, and now |\DeclareSymbolFont| is a wrapper around this macro. This was done for error checking purposes to remove extra |m|'s from certain \textsc{nfss} family names. This means that if |\DeclareSymbolFont at m@dropped| is defined, we should patch that macro, and otherwise, we should patch |\DeclareSymbolFont|.
+% As of November 2022, the \LaTeX\ kernel team the name of |\DeclareSymbolFont| to |\DeclareSymbolFont at m@dropped|, and now |\DeclareSymbolFont| is a wrapper around the renamed macro. This was done for error checking purposes to remove extra |m|'s from certain \textsc{nfss} family names. This means that if |\DeclareSymbolFont at m@dropped| is defined, we should patch that macro, and otherwise, we should patch |\DeclareSymbolFont|.
 %    \begin{macrocode}
 \ifx\DeclareSymbolFont at m@dropped\@undefined
   \edef\@tempa{\expandafter\strip at prefix\meaning\DeclareSymbolFont}
@@ -948,18 +1019,18 @@
 %    \begin{macrocode}
 \newbox\surdbox
 \newcount\M at count
-\newcount\M at rule@thickness at factor
-\newcount\M at integral@italic at factor
-\newcount\M at surd@vertical at factor
-\newcount\M at surd@horizontal at factor
+\newcount\M at RuleThicknessFactor
+\newcount\M at IntegralItalicFactor
+\newcount\M at SurdVerticalFactor
+\newcount\M at SurdHorizontalFactor
 \newmuskip\radicandoffset
 \newread\M at Charm
 \newtoks\M at toks
 \M at count\z@
-\M at rule@thickness at factor\@m
-\M at integral@italic at factor=400\relax
-\M at surd@horizontal at factor\@m
-\M at surd@vertical at factor\@m
+\M at RuleThicknessFactor\@m
+\M at IntegralItalicFactor=400\relax
+\M at SurdHorizontalFactor\@m
+\M at SurdVerticalFactor\@m
 \radicandoffset=3mu\relax
 %    \end{macrocode}
 % Necessary booleans and default math font shapes.
@@ -992,7 +1063,6 @@
 \newif\if at suboptionpresent
 \newif\ifM at arg@good
 \newif\ifM at Decl@reF at mily
-\newif\ifM at Decl@reF at milyB@se
 \newif\ifM at fromCharmFile
 %    \end{macrocode}
 % Default shapes.
@@ -1040,179 +1110,183 @@
   \edef\M at defaultkeys{\M at defaultkeys,delimiters,radical,bigops}
 \fi
 %    \end{macrocode}
-% Default OpenType features for loading fonts.
-%    \begin{macrocode}
-\def\M at otf@features{script=latin;language=DFLT;%
-  tlig=true;liga=true;smcp=false;lnum=true}
-\def\M at otf@features at sc{script=latin;language=DFLT;%
-  tlig=true;liga=true;smcp=true;lnum=true}
-%    \end{macrocode}
 % 
 % \section{Fontloader}
 % 
-% We come to the fontloader. The main font-loading macro is |\M at newfont|, and it is basically a wrapper around code we would expect to see in a typical |fd| file. Advanced users: please do not call |\M at newfont| directly because it may change without warning. Instead call |\mathfont| with the |empty| keyword and extract the \textsc{nfss} family name from |\M at f@ntn at me| or |\M at f@ntn at meb@se|. Our general approach is to feed the mandatory argument of |\mathfont| to |\M at newfont|, check if we have reason to believe that the font corresponds to a entry already in the \textsc{nfss}, and declare the font family and font shapes as necessary. If \textsf{fontspec} is loaded, we pass the entire argument to \textsf{fontspec}. If not, \textsf{mathfont} handles the font declaration internally. When \textsf{mathfont} declares a font family in the \textsc{nfss}, it does so twice, once using the information provided (which typically results in a font in node mode) and once using the information provided with |mode=base| (which results in a font in base mode). The first declaration uses the entire mandatory argument of |\mathfont| with spaces removed as the family name, and the second declaration uses this name with |-base| tacked onto the end. However the font gets loaded, we store the \textsc{nfss} family names in |\M at f@ntn at me| and |\M at f@nt at n@me at base|.
+% We come to the fontloader. The main font-loading macro is |\M at newfont|. It expects a font name and OpenType feature information in its argument, and it parses the information, adds fonts to the \textsc{nfss} if necessary, and stores \textsc{nfss} font family names in |\M at f@ntn at me| and |\M at f@nt at n@me at base|. (Advanced users: please do not call |\M at newfont| directly because its implementation may change. Instead call |\mathfont| with the |empty| keyword and extract the \textsc{nfss} family name from |\M at f@ntn at me| or |\M at f@ntn at meb@se|.) Our general approach is to feed the mandatory argument of |\mathfont| to |\M at newfont|, then proceed in one of three ways: (1) if the argument of |\mathfont| corresponds to a font family already in the \textsc{nfss}, including one that \textsf{mathfont} created through the built-in font-loader, check what shapes are present and issue a warning if we appear to be missing any important ones; (2) if the argument is not a family in the \textsc{nfss} and |\M at loader| is 0, we use the default font-loader, which is essentially a wrapper around code that we would expect to find in a typical |fd| file; or (3) otherwise, we feed the font name and feature information directly to \textsf{fontspec} and save the corresponding family name for reference later.
 % 
+% We use two control sequences for the family names because in Lua\TeX, we load the font twice. The first time uses a default or user-specified renderer (typically node mode), and the second time uses base mode. Node mode is better for text, but it has more limited capabilities in math mode. Accordingly, we use a node-mode version of the font for text and the base-mode version for math, and advanced users who want to manually switch to a given |\fontfamily| at some point in their document are probably better off using the family that \textsf{mathfont} loaded with the default renderer. The package stores the \textsc{nfss} family name for this version of the font in |\M at f@ntn at me|, and |\M at f@nt at n@me at base| contains the \textsc{nfss} family name of the base-mode version. In \XeTeX, these control sequences will be identical. Given a font family name from |\M at f@ntn at me|, it is possible to find the corresponding base-mode family name by calling |\csname|\penalty0|\M at f@ntn at me-base|\penalty0|\endcsname|. With \textsf{mathfont}'s built-in font-loader, the family name will be the mandatory argument of |\mathfont| with spaces removed, and the family name from using \textsf{fontspec} will be different.
 % 
-% We use |\M at split@colon| and |\M at 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 at strip@colon| to remove a final |:| the same way we removed a final |=| when we parsed the optional argument in the previous section.
-% \?\@tempfeatures\?\@tempbase
+% We begin with commands to add series and shape information to the \textsc{nfss} for a given font family. The |\M at 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
+%   \begin{itemize}
+%   \item |#1|---\textsc{nfss} font family name
+%   \item |#2|---optional |/B| or |/I| (or |/BI|) suffix on the font name
+%   \item |#3|---a list of (default) OpenType feature tags
+%   \item |#4|---a list of (the user's) OpenType feature tags
+%   \item |#5|---\textsc{nfss} series identifier
+%   \item |#6|---\textsc{nfss} shape identifier
+%   \end{itemize}
+% We assume that the font file reference has already been stored in |\@tempbase|.
 %    \begin{macrocode}
-\def\M at split@colon#1:#2\@nil{\def\@tempbase{#1}
-  \def\@tempfeatures{#2}}
-\def\M at strip@colon#1:{#1}
+\def\M at declare@shape#1#2#3#4#5#6{%
+  \ifcsname TU/#1/#5/#6\endcsname
+  \else
+    \DeclareFontShape{TU}{#1}{#5}{#6}{<->"\@tempbase#2:#3;#4"}{}
+  \fi}
 %    \end{macrocode}
-% The macro |\M at fill@nfss at shapes| accepts two arguments and does the actual work of ensuring that the \textsc{nfss} contains the appropriate series and shapes. The first argument should the name of a font family in the \textsc{nfss}, and the second should be a list of OpenType features. We check whether combinations of bold series and italic shape exist for that font in the \textsc{nfss}, and if not, we add them with |\DeclareFontShape|.
+% The |\M at fill@nfss at shapes| command does the work of populating the \textsc{nfss} with the correct shape information. The argument structure is:
+%   \begin{itemize}
+%   \item |#1|---\textsc{nfss} font family name
+%   \item |#2|---a list of (default) OpenType feature tags
+%   \item |#3|---a list of (the user's) OpenType feature tags
+%   \end{itemize}
+% We call |\M at 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.
 %    \begin{macrocode}
-\def\M at fill@nfss at shapes#1#2{%
+\def\M at fill@nfss at shapes#1#2#3{%
+  \@for\@i:={#1}{}{#2;-smcp}{#3}{\mddefault}{\shapedefault},%
+    {#1}{/I}{#2;-smcp}{#3}{\mddefault}{\itdefault},%
+    {#1}{/B}{#2;-smcp}{#3}{\bfdefault}{\shapedefault},%
+    {#1}{/BI}{#2;-smcp}{#3}{\bfdefault}{\itdefault},%
 %    \end{macrocode}
-% Upright shape.
+% 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.
 %    \begin{macrocode}
-  \ifcsname TU/#1/\mddefault/\shapedefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\shapedefault}
-      {<->"\@tempbase:\M at otf@features;#2"}{}
-  \fi
+    {#1}{}{#2;+smcp}{#3}{\mddefault}{\scdefault},%
+    {#1}{/I}{#2;+smcp}{#3}{\mddefault}{\scdefault\itdefault},%
+    {#1}{/B}{#2;+smcp}{#3}{\bfdefault}{\shapedefault},%
+    {#1}{/BI}{#2;+smcp}{#3}{\bfdefault}{\scdefault\itdefault}%
+      \do{\expandafter\M at declare@shape\@i}}
 %    \end{macrocode}
-% Italic shape.
+% The |\M at check@nfss at 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.
 %    \begin{macrocode}
-  \ifcsname TU/#1/\mddefault/\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\itdefault}
-      {<->"\@tempbase/I:\M at otf@features;#2"}{}
-  \fi
+\def\M at check@nfss at shapes#1{%
+  \let\@tempb\@empty
+  \let\@tempwarning\@gobble
+  \@for\@i:=\mddefault/\shapedefault,%
+    \mddefault/\itdefault,%
+    \bfdefault/\shapedefault,%
+    \bfdefault/\itdefault\do{%
+      \expandafter\ifx\csname TU/#1/\@i\endcsname\relax
+        \def\@tempwarning{\M at MissingNFSSShapesWarning{#1}}
+        \edef\@tempb{\@tempb, \@i}
+      \fi}
 %    \end{macrocode}
-% Bold series with upright shape.
+% 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|.
 %    \begin{macrocode}
-  \ifcsname TU/#1/\bfdefault/\shapedefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\shapedefault}
-      {<->"\@tempbase/B:\M at otf@features;#2"}{}
-  \fi
+  \@tempwarning{\expandafter\@gobble\@tempb}}
 %    \end{macrocode}
-% Bold series with italic shape.
+% We use |\M at split@colon| and |\M at 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 at strip@colon| to remove a final |:| the same way we remove\st{d} a final |=| when we parse\st{d} the optional argument in the \st{previous}next section.
+% \?\@tempfeatures\?\@tempbase
 %    \begin{macrocode}
-  \ifcsname TU/#1/\bfdefault/\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\itdefault}
-      {<->"\@tempbase/BI:\M at otf@features;#2"}{}
-  \fi
+\def\M at split@colon#1:#2\@nil{\def\@tempbase{#1}
+  \def\@tempfeatures{#2}}
+\def\M at strip@colon#1:{#1}
 %    \end{macrocode}
-% Now do the same thing for the small caps variants. I make no promises that this will work. 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.
+% The main font-loading macro. The command takes a single argument, which should have the form \meta{\textsc{nfss} family} or \meta{font name}|:|\meta{optional features}, and it begins by parsing the argument. It splits the argument at a |:| and stores each portion in |\@tempbase| and |\@tempfeatures|. If |\@tempfeatures| is not empty, it has an extra colon at the end. We remove it. Previous versions of \textsf{mathfont} allowed users to say |\mathfont{fontspec}|, but this functionality is no longer supported.
 %    \begin{macrocode}
-  \ifcsname TU/#1/\mddefault/\scdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault}
-      {<->"\@tempbase:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\mddefault/\scdefault\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault\itdefault}
-      {<->"\@tempbase/I:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\scdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault}
-      {<->"\@tempbase/B:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\scdefault\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault\itdefault}
-      {<->"\@tempbase/BI:\M at otf@features at sc;#2"}{}
-  \fi}
-%    \end{macrocode}
-% The main font-loading macro. This macro takes a single argument, which should have the form \meta{font name}|:|\meta{optional features}, and \textsf{mathfont} handles the information in one of three ways if all goes well: interface with \textsf{fontspec}, possibly declare a few extra shapes for a font already in the \textsc{nfss}, or declare and load the whole font. At a minimum, \textsf{mathfont} ensures that we have access to medium upright, medium italic, bold upright, and bold italic fonts after calling |\M at newfont|. If \textsf{mathfont} decides to declare a font itself, it will also try to load small caps versions. We begin by splitting the argument into |\@tempbase| and |\@tempfeatures|.
-%    \begin{macrocode}
 \def\M at newfont#1{%
   \edef\@tempa{#1}
   \expandafter\M at split@colon\@tempa:\@nil
-  \def\@tempb{fontspec}
+  \ifx\@tempfeatures\@empty\else
+    \edef\@tempfeatures{\expandafter\M at strip@colon\@tempfeatures}
+  \fi
 %    \end{macrocode}
-% If the argument is ``|fontspec|,'' we want to use the last font loaded by \textsf{fontspec}, which is stored in |\l_fontspec_family_tl|. If this macro is not empty, we store its contents in |\M at f@ntn at me| and skip loading entirely because \textsf{fontspec} already took care of it. We issue an error if |\l_fontspec_family_tl| is empty or if the user has not loaded \textsf{fontspec}. If we use \textsf{fontspec} to laod the font, we don't get a separate font in base mode.
+% First we check if the argument is an entry in the \textsc{nfss}. If yes, we check if the shapes are present using |\M at check@nfss at shapes|. We assume that if the user specifies a font family identifier here, they know what they are doing, and the font-loader makes no attempt to fill in missing shapes.
 %    \begin{macrocode}
-  \ifx\@tempa\@tempb
-    \@ifpackageloaded{fontspec}{%
-      \expandafter\ifx\csname l_fontspec_family_tl\endcsname\@empty
-        \M at NoFontspecFamilyError
+  \ifcsname TU+\@tempbase\endcsname % is font family already in nfss?
+    \let\M at f@ntn at me\@tempbase
+    \M at check@nfss at shapes\M at f@ntn at me
+    \ifx\directlua\@undefined % if XeTeX
+      \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at me}
+      \let\M at f@ntn at meb@se\M at f@ntn at me
+    \else % if LuaTeX
+%    \end{macrocode}
+% With Lua\TeX, we would like to have a proper base-mode version of the font. If the font declaration happened outside of \textsf{mathfont} and the engine is Lua\TeX, then \textsf{mathfont} expects to find another 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. Otherwise, we issue a warning if the engine is Lua\TeX.
+%    \begin{macrocode}
+      \ifcsname\M at f@ntn at me-base\endcsname % if base-mode version is known
+        \edef\M at f@ntn at meb@se{\csname\M at f@ntn at me-base\endcsname}
+        \M at check@nfss at shapes\M at f@ntn at meb@se
       \else
-        \expandafter
-          \let\expandafter\M at f@ntn at me\csname l_fontspec_family_tl\encsname
-        \def\@tempbase{\M at f@ntn at me\space(from fontspec)}
-        \let\M at f@ntn at meb@se\M at f@ntn at me % no separate font in base mode
-      \fi}{\M at NoFontspecError}
+        \M at NoBaseModeDetectedWarning{\M at f@ntn at me}
+        \edef\M at f@ntn at meb@se{\M at f@ntn at me}
+        \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at me}
+      \fi
+    \fi
 %    \end{macrocode}
-% If the argument is something other than ``|fontspec|,'' we need to parse it. If the user loaded \textsf{fontspec}, we pass the entire argument to |\fontspec_set_family:Nnn| for loading and store the \textsc{nfss} family name in |\M at f@ntn at me|. For Lua\TeX, this is not recommended\textemdash\textsf{fontspec} is designed to work with text, not math, fonts and typically loads fonts in |node| mode, which makes their OpenType features unusable in math mode.
+% Now save the font families for reference later.
 %    \begin{macrocode}
+    \expandafter\edef\csname M at fontfamily@\@tempbase\endcsname
+      {\M at f@ntn at me}
+    \expandafter\edef\csname M at fontfamily@base@\@tempbase\endcsname
+      {\M at f@ntn at meb@se}
   \else
-    \@ifpackageloaded{fontspec}
-    {\csname fontspec_set_family:Nnn\endcsname\M at f@ntn at me{}{\@tempa}
-      % no separate font in base mode
-      \let\M at f@ntn at meb@se\M at f@ntn at me}
 %    \end{macrocode}
-% If the user has not loaded \textsf{fontspec}, we split the argument into a name and features using |\M at split@colon|. The name goes in |\@tempbase|, and the features go in |\@tempfeatures|. We store the OpenType features for loading in base mode inside |\@basefeatures|. If we are typesetting in Lua\TeX, |\@basefeatures| will be the same as |\@tempfeatures| except with |mode=base| at the end, and if we are using \XeTeX, it will be exactly the same.
+% If the argument is not a font family identifier, then we check if \textsf{mathfont} has previously loaded a font using this argument. If yes, it will be stored in |\M at fontfamily@|\meta{arg}, and we use the font family name from the previous call to |\M at newfont|. We remove the spaces before using the argument because in general, we do not want \textsf{mathfont} to use space characters internally to distinguish font names.
 %    \begin{macrocode}
-    {\M at Decl@reF at milytrue
-      \M at Decl@reF at milyB@setrue
-      \ifx\@tempfeatures\@empty
-        \ifdefined\directlua
-          \edef\@basefeatures{mode=base}
-        \else
-          \let\@basefeatures\@tempfeatures
-        \fi
-      \else
-        \edef\@tempfeatures{\expandafter\M at strip@colon\@tempfeatures}
-        \ifdefined\directlua
-          \edef\@basefeatures{\@tempfeatures;mode=base}
-        \else
-          \let\@basefeatures\@tempfeatures
-        \fi
-      \fi
+    \edef at nospace\@tempa{\@tempa}
+    \ifcsname M at fontfamily@\@tempa\endcsname
+      \edef\M at f@ntn at me{\csname M at fontfamily@\@tempa\endcsname}
+      \edef\M at f@ntn at meb@se{\csname M at fontfamily@base@\@tempa\endcsname}
+    \else
 %    \end{macrocode}
-% We remove the spaces from |#1| and store it in |\@tempa| and from the human-readable font name contained in |#1| and store it in |\@tempb|. We check whether either already exists as a family name in the \textsc{nfss}, and if we do, we call |\M at fill@nfss at shapes| to ensure that we have declared all the shapes. In this case, we set |\ifM at Decl@reF at mily| to false and break out of the |\@tfor| loop.
+% If |\M at newfont| doesn't find anything previously that matches |#1|, we load the font. Under the built-in font-loader, the name for the font family will be |#1| with spaces removed, which we store in |\M at f@ntn at me|. (A properly declared \textsc{nfss} font family does not have spaces in its name because \LaTeX\ ignores spaces when scanning a font family declaration.) Then we call |\M at fill@nfss at shapes| to declare all the shapes.
+% \indexpage{log file=\texttt{log} file}
 %    \begin{macrocode}
       \edef at nospace\@tempa{\@tempa}
-      \edef at nospace\@tempb{\@tempbase}
-      \M at Decl@reF at milytrue
-      \@tfor\@i:=\@tempa\@tempb\@tempbase\do{%
-        \ifcsname TU+\@i\endcsname
-          \expandafter\let\expandafter\M at f@ntn at me\@i
-          \M at Decl@reF at milyfalse
-          \M at fill@nfss at shapes\M at f@ntn at me\@tempfeatures
-          \@break at tfor
-        \fi}
-%    \end{macrocode}
-% If |\M at newfont| didn't find anything in the \textsc{nfss}, we need to load the font. The name for the font family will be |#1| with spaces removed, which we previously stored in |\@tempa|.
-% \indexpage{log file=\texttt{log} file}
-%    \begin{macrocode}
-      \ifM at Decl@reF at mily
+      \ifcase\M at loader % are we using default font-loader?
         \let\M at f@ntn at me\@tempa
-        \wlog{Package mathfont Info: Adding \M at f@ntn at me\space to the nfss!}
+        \wlog{Package mathfont Info: Adding \@tempbase\space to the nfss!}
+        \wlog{Family name: \M at f@ntn at me}
         \DeclareFontFamily{TU}{\M at f@ntn at me}{}
+        \M at fill@nfss at shapes{\M at f@ntn at me}{\M at otf@features}{\@tempfeatures}
 %    \end{macrocode}
-% Now load the four most common font faces with |\M at fill@nfss at shapes|.
+% If the engine is Lua\TeX, we load a separate version of the font with |mode=base|. Then we link the base-mode and regular versions.
 %    \begin{macrocode}
-        \M at fill@nfss at shapes\M at f@ntn at me\@tempfeatures
+        \ifdefined\directlua
+          \edef\M at f@ntn at meb@se{\M at f@ntn at me-base}
+          \wlog{Package mathfont Info: Adding \@tempbase with mode=base
+            to the nfss!}
+          \wlog{Family name: \M at f@ntn at meb@se}
+          \DeclareFontFamily{TU}{\M at f@ntn at meb@se}{}
+          \M at fill@nfss at shapes
+            {\M at f@ntn at meb@se}{\M at otf@features}{\@tempfeatures;mode=base}
+        \else
+          \edef\M at f@ntn at meb@se{\M at f@ntn at me}
+        \fi
+      \or              % are we using fontspec as font-loader?
+%    \end{macrocode}
+% 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 at f@ntn at me|. In Lua\TeX, we request a separate base-mode version by specifying |Renderer=Base|.
+%    \begin{macrocode}
+        \wlog{Package mathfont Info: Passing \@tempbase\space to fontspec
+          for handling!}
+        \csname fontspec_set_family:Nnn\endcsname\M at f@ntn at me
+          {\M at otf@features,\@tempfeatures}{\@tempbase}
+        \ifdefined\directlua
+          \wlog{Package mathfont Info: Passing \@tempbase\space with
+            Renderer=Base to fontspec for handling!}
+          \csname fontspec_set_family:Nnn\endcsname\M at f@ntn at meb@se
+            {\M at otf@features,\@tempfeatures,Renderer=Base}{\@tempbase}
+        \else
+            \edef\M at f@ntn at meb@se{\M at f@ntn at me}
+        \fi
       \fi
 %    \end{macrocode}
-% At this point, there is an entry for the font in the \textsc{nfss}, and we stored the family name in |\M at f@ntn at me|. Now we check if the \textsc{nfss} contains a base-mode version with the family name ending in |-base|.
+% Now link the base-mode family name and store the family names for future reference.
 %    \begin{macrocode}
-      \ifdefined\directlua
-        \edef\M at f@ntn at meb@se{\M at f@ntn at me-base}
-      \else
-        \let\M at f@ntn at meb@se\M at f@ntn at me
-      \fi
-      \ifcsname TU+\M at f@ntn at meb@se\endcsname\else
-        \wlog{Package mathfont Info: Adding \M at f@ntn at meb@se\space
-          to the nfss!}
-        \DeclareFontFamily{TU}{\M at f@ntn at meb@se}{}
-      \fi
-      \M at fill@nfss at shapes\M at f@ntn at meb@se\@basefeatures}
+      \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at meb@se}
+      \expandafter\edef\csname M at fontfamily@\@tempa\endcsname
+        {\M at f@ntn at me}
+      \expandafter\edef\csname M at fontfamily@base@\@tempa\endcsname
+        {\M at f@ntn at meb@se}
+    \fi
   \fi}
 %    \end{macrocode}
 % Finally, the font-loading commands should appear only in the preamble.
 %    \begin{macrocode}
+\@onlypreamble\M at declare@shape
 \@onlypreamble\M at fill@nfss at shapes
 \@onlypreamble\M at newfont
 %    \end{macrocode}
-% At this point, the font information is stored in the \textsc{nfss}, but nothing has been loaded. For text fonts, that happens during a call to |\selectfont|, and for math fonts, that happens the first time entering math mode. I've played with the idea of forcing some fonts to load now, but I'm hesitant to change \LaTeX's standard font-loading behavior. I may address this issue further in future versions of \textsf{mathfont}.
+% At this point, the font information is stored in the \textsc{nfss}, but nothing has been loaded. For text fonts, that happens during a call to |\selectfont|, and for math fonts, that happens the first time entering math mode. I've considered forcing some fonts to load now, but I'm hesitant to change \LaTeX's standard font-loading behavior. On this issue, I plan to leave \textsf{mathfont} as is for the forseeable future.
 % 
 % 
 % 
@@ -1321,16 +1395,15 @@
   \else
     \M at toks{}
 %    \end{macrocode}
-% We immediately call |\M at newfont| on the mandatory argument of |\mathfont|. We store the \textsc{nfss} family name in |\M at fontfamily@|\meta{argument} and |M at fontfamily@base@|\meta{argument}. If we need a new value of |\M at count|, we store it in |\M at fontid@|\meta{\textsc{nfss} family name}. We will not need a new value of |\M at count| if the user asks for the same \textsc{nfss} font family twice. Throughout the definition of |\mathfont|, |\@tempa| stores the value of |\M at count| that corresponds to the current font.
+% We call |\M at newfont| on the mandatory argument of |\mathfont|, which stores the two \textsc{nfss} family names (one for default renderer and one for base-mode renderer if using Lua\TeX) in |\M at f@ntn at me| and |\M at f@ntn at meb@se|. If we need a new value of |\M at count|, we store it in |\M at fontid@|\meta{\textsc{nfss} family name}. We will not need a new value of |\M at count| if the user asks for the same \textsc{nfss} font family twice. Throughout the definition of |\mathfont|, |\@tempa| stores the value of |\M at count| that corresponds to the current font.
 % \indexpage{keyword options=keyword options for \texttt{\char`\\mathfont}}
 %    \begin{macrocode}
     \M at newfont{#2}
-    \expandafter\edef\csname M at fontfamily@#2\endcsname{\M at f@ntn at me}
-    \expandafter\edef\csname M at fontfamily@base@#2\endcsname{\M at f@ntn at meb@se}
     \ifcsname M at fontid@\M at f@ntn at me\endcsname\else % need new \M at count value?
-      \expandafter\edef\csname M at fontid@\M at f@ntn at me\endcsname{\the\M at count}
-      \expandafter\let\csname M at fontid@\M at f@ntn at meb@se\expandafter\endcsname
-        \csname M at fontid@\M at f@ntn at me\endcsname
+      \expandafter\edef\csname M at fontid@\M at f@ntn at me\endcsname{\the
+        \M at count}
+      \expandafter\edef\csname M at fontid@\M at f@ntn at meb@se\endcsname{\the
+        \M at count}
       \advance\M at count\@ne
     \fi
     \edef\@tempa{\csname M at fontid@\M at f@ntn at me\endcsname}
@@ -1452,68 +1525,67 @@
   \let\rmdefault\M at f@ntn at me}
 \@onlypreamble\setfont
 %    \end{macrocode}
-% The macro |\mathconstantsfont| handles choosing the font for setting math parameters in Lua\TeX. It issues a warning if called in \XeTeX. First, it checks if the argument was previously fed to |\mathfont| by seeing whether |\M at fontfamily@|\meta{|\string#1|} is equal to |\relax|. If yes, |#1| was never an argument of |\mathfont|, and we raise an error.
+% 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, it checks if the argument was previously fed to |\mathfont| by seeing whether |\M at fontfamily@|\meta{|\string#1|} is equal to |\relax|. If yes, |#1| was never an argument of |\mathfont|, and we raise an error.
 %    \begin{macrocode}
-\ifdefined\directlua
-  \let\M at SetMathConstants\relax
-  \protected\def\mathconstantsfont{%
-    \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
-  \def\@mathconstantsfont[#1]#2{%
-    \edef\@tempa{\csname M at fontfamily@base@#2\endcsname}
-    \expandafter\ifx\@tempa\relax
-      \M at BadMathConstantsFontError{#2}
-    \else
+\let\M at SetMathConstants\relax
+\protected\def\mathconstantsfont{%
+  \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
+\def\@mathconstantsfont[#1]#2{%
+  \edef at nospace\@tempa{#2}
+  \edef\@tempa{\csname M at fontfamily@base@\@tempa\endcsname}
+  \expandafter\ifx\@tempa\relax
+    \M at BadMathConstantsFontError{#2}
+  \else
 %    \end{macrocode}
 % Some error checking. If |#1| isn't ``upright'' or ``italic,'' we should raise an error. If the |\@tempa| font doesn't correspond to a symbol font, we declare it. Before defining |\M at SetMathConstants| if necessary, we store the \textsc{nfss} family name in |\m at th@const at nts@font|.
 %    \begin{macrocode}
-      \def\@tempb{#1}
-      \def\@tempc{upright}
+    \def\@tempb{#1}
+    \def\@tempc{upright}
+    \ifx\@tempb\@tempc
+      \let\m at th@const at nts@font at sh@pe\shapedefault
+    \else
+      \def\@tempc{italic}
       \ifx\@tempb\@tempc
-        \let\m at th@const at nts@font at sh@pe\shapedefault
+        \let\m at th@const at nts@font at sh@pe\itdefault
       \else
-        \def\@tempc{italic}
-        \ifx\@tempb\@tempc
-          \let\m at th@const at nts@font at sh@pe\itdefault
-        \else
-          \M at BadMathConstantsFontTypeError{#1}
-        \fi
+        \M at BadMathConstantsFontTypeError{#1}
       \fi
-      \ifcsname symM#1\csname M at fontid@\@tempa\endcsname\endcsname\else
-        \DeclareSymbolFont{M#1\csname M at fontid@\@tempa\endcsname}
-          {TU}{\@tempa}{\mddefault}{\m at th@const at nts@font at sh@pe}
-      \fi
-      \let\m at th@const at nts@font\@tempa
+    \fi
+    \ifcsname symM#1\csname M at fontid@\@tempa\endcsname\endcsname\else
+      \DeclareSymbolFont{M#1\csname M at fontid@\@tempa\endcsname}
+        {TU}{\@tempa}{\mddefault}{\m at th@const at nts@font at sh@pe}
+    \fi
+    \let\m at th@const at nts@font\@tempa
 %    \end{macrocode}
 % 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 default font we're using to the correct math family whenever we load new 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 at fonts| repeatedly to append |\textfont|, etc.\ assignments onto the macro |\math at fonts|. Usually |\math at fonts| is empty because this process always happens inside a group, so we can hook into the code by defining |\math at font| to be |\aftergroup|\meta{extra code}. In this case, the \textit{extra code} will be another call to |\getanddefine at fonts|.
 % 
 % We initialize |\M at SetMathConstants| to be |\relax|, so we define it the first time the user calls |\mathconstantsfont|. The command calls |\getanddefine at fonts| inside a group and uses as arguments the upright face of the font corresponding to |#1|. Then we call |\math at fonts|, and to avoid an infinite loop, we gobble the |\aftergroup||\M at SetMathConstants| macros that \textsf{mathfont} has inserted at the start of |\math at fonts|. Setting |\globaldefs| to 1 makes the |\textfont|, etc.\ assignments from |\getanddefine at fonts| global when we call |\math at fonts|.\indexpage{LaTeX kernel=\LaTeX\ kernel}^^A
 %    \begin{macrocode}
-      \protected\def\M at SetMathConstants{%
-        \begingroup
-        \escapechar\m at ne
-        \expandafter\getanddefine at fonts
-          \csname symM#1\csname M at fontid@\m at th@const at nts@font\endcsname
-            \expandafter
-          \endcsname % expands to \symMupright<id>
-          \csname TU/\m at th@const at nts@font
-                    /\seriesdefault
-                    /\m at th@const at nts@font at sh@pe
-          \endcsname % expands to \TU/<nfss family name>/m/<shape>
-        \globaldefs\@ne
-        \expandafter\@gobbletwo\math at fonts % gobble to avoid infinite loop
-        \endgroup}
-      \fi}
-  \def\math at fonts{\aftergroup\M at SetMathConstants}
-\else
-  \protected\def\mathconstantsfont{\M at LuaTeXOnlyWarning
-    \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\fi
+    \protected\def\M at SetMathConstants{%
+      \begingroup
+      \escapechar\m at ne
+      \expandafter\getanddefine at fonts
+        \csname symM#1\csname M at fontid@\m at th@const at nts@font\endcsname
+          \expandafter
+        \endcsname % expands to \symMupright<id>
+        \csname TU/\m at th@const at nts@font
+                  /\seriesdefault
+                  /\m at th@const at nts@font at sh@pe
+        \endcsname % expands to \TU/<nfss family name>/m/<shape>
+      \globaldefs\@ne
+      \expandafter\@gobbletwo\math at fonts % gobble to avoid infinite loop
+      \endgroup}
+    \fi
+  \ifM at adjust@font\else
+    \M at MathConstantsNoFontAdjustWarning
+  \fi}
+\def\math at fonts{\aftergroup\M at SetMathConstants}
 \@onlypreamble\mathconstantsfont
 %    \end{macrocode}
 % If the user has not enabled Lua font adjustments, then |\mathconstantsfont| will generate an error message and gobble its argument. This definition happens later in |mathfont.sty| when we define other Lua-related macros such as |\IntegralItalicFactor| to do the same thing absent font adjustments.
 % 
+% \vfill
 % 
-% 
 % \section{Local Font Changes}\indexpage{local font changes}
 % 
 % This section deals with local font changes. The |\newmathfontcommand| creates macros that change the font for math alphabet characters and is basically a wrapper around |\DeclareMathAlphabet|. First we code |\M at check@csarg|, which accepts two arguments. The |#1| argument is the user-level command that called |\M at check@csarg|, which we use for error messaging, and |#2| should be a single control sequence. The way |\M at check@csarg| scans the following tokens is a bit tricky: (1) check the length of the argument 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 at check@csarg| likes the input, it sets |\ifM at good@arg| to true, and otherwise, it sets |\ifM at arg@good| to false.
@@ -1543,7 +1615,7 @@
 \@onlypreamble\newmathfontcommand
 %    \end{macrocode}
 % Then define macros that create local font-changing commands with default series and shape information. Because they're all so similar, we metacode them. We define the commands themselves with |\define at newmath@cmd|. The argument structure is:
-%   \begin{itemize}[nosep]
+%   \begin{itemize}
 %   \item |#1|---|\newmath|\meta{key} macro name
 %   \item |#2|---font series
 %   \item |#3|---font shape
@@ -1639,46 +1711,25 @@
     \fi
   \fi}
 %    \end{macrocode}
-% Define |\RuleThicknessFactor|.
+% We meta-code the definitions of |\RuleThicknessFactor|, etc. To keep the syntax relatively clean, we temporarily eliminate the |\escapechar| and redefine |~| to |\noexpand|.
 %    \begin{macrocode}
-  \protected\def\RuleThicknessFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at rule@thickness at factor=#1\relax
-    \else
-      \M at BadIntegerError\RuleThicknessFactor{#1}
-    \fi}
+  \let\@tempa~
+  \let~\noexpand
+  \count@\escapechar
+  \escapechar\m at ne
+  \@tfor\@i:=\RuleThicknessFactor\IntegralItalicFactor
+    \SurdHorizontalFactor\SurdVerticalFactor\do{%
+      \protected\expandafter\edef\@i#1{%
+        ~\M at check@int{#1}%
+        ~\ifM at arg@good
+          ~\global
+            \expandafter~\csname M@\expandafter\string\@i\endcsname=#1\relax
+        ~\else
+          ~\M at BadIntegerError\expandafter~\@i{#1}%
+        ~\fi}}
+  \let~\@tempa
+  \escapechar\count@
 %    \end{macrocode}
-% Define |\IntegralItalicFactor|.
-%    \begin{macrocode}
-  \protected\def\IntegralItalicFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at integral@italic at factor=#1\relax
-    \else
-      \M at BadIntegerError\IntegralItalicFactor{#1}
-    \fi}
-%    \end{macrocode}
-% Define |\SurdHorizontalFactor|.
-%    \begin{macrocode}
-  \protected\def\SurdHorizontalFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at surd@horizontal at factor=#1\relax
-    \else
-      \M at BadIntegerError\SurdHorizontalFactor{#1}
-    \fi}
-%    \end{macrocode}
-% Define |\SurdVerticalFactor|.
-%    \begin{macrocode}
-  \protected\def\SurdVerticalFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at surd@vertical at factor=#1\relax
-    \else
-      \M at BadIntegerError\SurdVerticalFactor{#1}
-    \fi}
-%    \end{macrocode}
 % 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 at NoFontAdjustError| and gobble its argument.
 %    \begin{macrocode}
 \else
@@ -1741,22 +1792,6 @@
   \tracinglostchars\tw@
 \fi
 %    \end{macrocode}
-% Warn the user about possible problems with a multi-word optional package argument in \XeTeX.
-%    \begin{macrocode}
-\ifdefined\XeTeXrevision
-  \ifM at font@loaded
-    \AtEndOfPackage{%
-    \PackageWarningNoLine{mathfont}
-    {XeTeX detected. It looks like you\MessageBreak
-    specified a font when you loaded\MessageBreak
-    mathfont. If you run into problems\MessageBreak
-    with a font whose name is multiple\MessageBreak
-    words, try compiling with LuaLaTeX\MessageBreak
-    or call \string\setfont\space or \string\mathfont\MessageBreak
-    manually}}
-  \fi
-\fi
-%    \end{macrocode}
 % Write to the |log| file |\AtBeginDocument| all font changes carried out by \textsf{mathfont}. The command |\keyword at info@begindocument| accepts two arguments and is what acutally prints the informational message after the preamble. One argument is a keyword-argument from |\mathfont|, and the other is a number of spaces. The spaces make the messages line up with each other in the log file.\indexpage{log file=\texttt{log} file}
 %    \begin{macrocode}
 \def\keyword at info@begindocument#1:#2\@nil{%
@@ -1802,6 +1837,22 @@
     \expandafter\keyword at info@begindocument\@i\@nil}
   \wlog{}}
 %    \end{macrocode}
+% Warn the user about possible problems with a multi-word optional package argument in \XeTeX.
+%    \begin{macrocode}
+\ifdefined\XeTeXrevision
+  \ifM at font@loaded
+    \AtEndOfPackage{%
+    \PackageWarningNoLine{mathfont}
+    {XeTeX detected. It looks like you\MessageBreak
+    specified a font when you loaded\MessageBreak
+    mathfont. If you run into problems\MessageBreak
+    with a font whose name is multiple\MessageBreak
+    words, try compiling with LuaLaTeX\MessageBreak
+    or call \string\setfont\space or \string\mathfont\MessageBreak
+    manually}}
+  \fi
+\fi
+%    \end{macrocode}
 % If the user passed a font name to \textsf{mathfont}, we set it as the default |\AtEndOfPackage|.
 %    \begin{macrocode}
 \ifM at font@loaded
@@ -1822,12 +1873,13 @@
 \@onlypreamble\M at hebrew@set
 \@onlypreamble\M at digits@set
 \@onlypreamble\M at operator@set
+\@onlypreamble\M at delimiters@set
+\@onlypreamble\M at radical@set
+\@onlypreamble\M at bigops@set
+\@onlypreamble\M at extbigops@set
 \@onlypreamble\M at symbols@set
 \@onlypreamble\M at extsymbols@set
-\@onlypreamble\M at delimiters@set
 \@onlypreamble\M at arrows@set
-\@onlypreamble\M at bigops@set
-\@onlypreamble\M at extbigops@set
 \@onlypreamble\M at bb@set
 \@onlypreamble\M at cal@set
 \@onlypreamble\M at frak@set
@@ -1834,16 +1886,11 @@
 \@onlypreamble\M at bcal@set
 \@onlypreamble\M at bfrak@set
 %    \end{macrocode}
-%
 % 
 % 
-% 
-% 
-% 
 % \section{Adjust Fonts: Setup}
 % 
 % 
-% 
 % 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:
 % \begin{enumerate}\itemsep\z@
 % \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.
@@ -2355,14 +2402,14 @@
   local width, height, depth, italic = self.glyph_info(char)
   char.width = width + italic
 %    \end{macrocode}
-% 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 |\M at surd@horizontal at factor| and |\M at surd@vertical at factor|.
+% 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 |\M at SurdHorizontalFactor| and |\M at SurdVerticalFactor|.
 %    \begin{macrocode}
   if index == 8730 then
 %    \end{macrocode}
 % Now get the scale factors from the \TeX\ side of things and scale down (or up) the height and with of the surd.
 %    \begin{macrocode}
-    local horizontal_scale = tex.getcount("M at surd@horizontal at factor") / 1000
-    local vertical_scale = tex.getcount("M at surd@vertical at factor") / 1000
+    local horizontal_scale = tex.getcount("M at SurdHorizontalFactor") / 1000
+    local vertical_scale = tex.getcount("M at SurdVerticalFactor") / 1000
     char.width = horizontal_scale * char.width
     char.height = vertical_scale * height
   end
@@ -2370,7 +2417,7 @@
 % For the integral symbol, get the scale factor add the appropriate italic correction.
 %    \begin{macrocode}
   if index == 8747 then
-    local scale_factor = tex.getcount("M at integral@italic at factor") / 1000
+    local scale_factor = tex.getcount("M at IntegralItalicFactor") / 1000
     char.italic = scale_factor * width
   end
 end
@@ -2609,11 +2656,11 @@
   local axis = 0
   local rule_thickness = 0
 %    \end{macrocode}
-% 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 |\M at rule@thickness at factor|, which is the value of that |\count| divided by 1000. 
+% 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 |\M at RuleThicknessFactor|, which is the value of that |\count| divided by 1000. 
 %    \begin{macrocode}
   local dim = "FractionRuleThickness"
   if not fontdata.MathConstants[dim] then
-    local scale_factor = tex.getcount("M at rule@thickness at factor") / 1000
+    local scale_factor = tex.getcount("M at RuleThicknessFactor") / 1000
     rule_thickness = (size / 18) * scale_factor
     fontdata.MathConstants[dim] = rule_thickness
   else
@@ -3019,32 +3066,32 @@
 %    \end{macrocode}
 % Upper-case Latin letters will fill unicode slots U+FF020 through U+FF039.
 %    \begin{macrocode}
-mathfont:new_type_a(65, 1044512, {50, 0, 150, 0})  % A
-mathfont:new_type_a(66, 1044513, {50, 0, 0, 0})    % B
-mathfont:new_type_a(67, 1044514, {0, 0, 0, 0})     % C
-mathfont:new_type_a(68, 1044515, {50, 0, -50, 0})  % D
-mathfont:new_type_a(69, 1044516, {50, 0, 0, 0})    % E
-mathfont:new_type_a(70, 1044517, {50, 0, 0, 0})    % F
-mathfont:new_type_a(71, 1044518, {0, 0, 0, 0})     % G
-mathfont:new_type_a(72, 1044519, {50, 0, -50, 0})  % H
-mathfont:new_type_a(73, 1044520, {100, 0, 0, 0})   % I
-mathfont:new_type_a(74, 1044521, {50, 0, 100, 0})  % J
-mathfont:new_type_a(75, 1044522, {50, 0, 0, 0})    % K
-mathfont:new_type_a(76, 1044523, {50, 0, -180, 0}) % L
-mathfont:new_type_a(77, 1044524, {50, 0, -50, 0})  % M
-mathfont:new_type_a(78, 1044525, {50, 0, -50, 0})  % N
-mathfont:new_type_a(79, 1044526, {0, 0, 0, 0})     % O
-mathfont:new_type_a(80, 1044527, {0, 0, -50, 0})   % P
-mathfont:new_type_a(81, 1044528, {0, 50, 0, 0})    % Q
-mathfont:new_type_a(82, 1044529, {50, 0, -50, 0})  % R
-mathfont:new_type_a(83, 1044530, {0, 0, -50, 0})   % S
-mathfont:new_type_a(84, 1044531, {0, 0, -50, 0})   % T
-mathfont:new_type_a(85, 1044532, {0, 0, -50, 0})   % U
-mathfont:new_type_a(86, 1044533, {0, 50, 0, 0})    % V
-mathfont:new_type_a(87, 1044534, {0, 50, -50, 0})  % W
-mathfont:new_type_a(88, 1044535, {50, 0, 0, 0})    % X
-mathfont:new_type_a(89, 1044536, {0, 0, -50, 0})   % Y
-mathfont:new_type_a(90, 1044537, {50, 0, -50, 0})  % Z
+mathfont:new_type_a(65, 1044512, {50, 0, 150, 0})      % A
+mathfont:new_type_a(66, 1044513, {50, 0, 0, 0})        % B
+mathfont:new_type_a(67, 1044514, {0, 0, 0, 0})         % C
+mathfont:new_type_a(68, 1044515, {50, 0, -50, 0})      % D
+mathfont:new_type_a(69, 1044516, {50, 0, 0, 0})        % E
+mathfont:new_type_a(70, 1044517, {50, 0, 0, 0})        % F
+mathfont:new_type_a(71, 1044518, {0, 0, 0, 0})         % G
+mathfont:new_type_a(72, 1044519, {50, 0, -50, 0})      % H
+mathfont:new_type_a(73, 1044520, {100, 0, 0, 0})       % I
+mathfont:new_type_a(74, 1044521, {50, 0, 100, 0})      % J
+mathfont:new_type_a(75, 1044522, {50, 0, 0, 0})        % K
+mathfont:new_type_a(76, 1044523, {50, 0, -180, 0})     % L
+mathfont:new_type_a(77, 1044524, {50, 0, -50, 0})      % M
+mathfont:new_type_a(78, 1044525, {50, 0, -50, 0})      % N
+mathfont:new_type_a(79, 1044526, {0, 0, 0, 0})         % O
+mathfont:new_type_a(80, 1044527, {0, 0, -50, 0})       % P
+mathfont:new_type_a(81, 1044528, {0, 50, 0, 0})        % Q
+mathfont:new_type_a(82, 1044529, {50, 0, -50, 0})      % R
+mathfont:new_type_a(83, 1044530, {0, 0, -50, 0})       % S
+mathfont:new_type_a(84, 1044531, {0, 0, -50, 0})       % T
+mathfont:new_type_a(85, 1044532, {0, 0, -50, 0})       % U
+mathfont:new_type_a(86, 1044533, {0, 50, 0, 0})        % V
+mathfont:new_type_a(87, 1044534, {0, 50, -50, 0})      % W
+mathfont:new_type_a(88, 1044535, {50, 0, 0, 0})        % X
+mathfont:new_type_a(89, 1044536, {0, 0, -50, 0})       % Y
+mathfont:new_type_a(90, 1044537, {50, 0, -50, 0})      % Z
 %    \end{macrocode}
 % The Greek characters will be type |u|, so we don't need extra unicode slots for them. In future editions of \textsf{mathfont}, they may becoeme type |a| with adjusted bounding boxes, but I don't have immediate plans for such a change.
 %    \begin{macrocode}
@@ -3866,8 +3913,8 @@
   \DeclareMathSymbol{-}{\mathbin}{\M at symbols@font}{"2212}
   \DeclareMathSymbol{*}{\mathbin}{\M at symbols@font}{"2A}
   \DeclareMathSymbol{\times}{\mathbin}{\M at symbols@font}{"D7}
-  \DeclareMathSymbol{/}{\mathbin}{\M at symbols@font}{"2F}
-  \DeclareMathSymbol{\fractionslash}{\mathbin}{\M at symbols@font}{"2215}
+  \DeclareMathSymbol{/}{\mathord}{\M at symbols@font}{"2F}
+  \DeclareMathSymbol{\fractionslash}{\mathord}{\M at symbols@font}{"2215}
   \DeclareMathSymbol{\div}{\mathbin}{\M at symbols@font}{"F7}
   \DeclareMathSymbol{\pm}{\mathbin}{\M at symbols@font}{"B1}
   \DeclareMathSymbol{\bullet}{\mathbin}{\M at symbols@font}{"2022}
@@ -4678,7 +4725,7 @@
 %   \advance\dimen@ by -2\fboxrule
 %   \advance\dimen@ by -2\fboxsep
 %   \fbox{\vbox{\hsize\dimen@
-%     \strut\textbf{Big Change:} Font adjustments for Lua\TeX: new glyph boundaries for Latin letters in math mode, resizable delimiters, actual big operators, MathConstants table based on font metrics.\vphantom{y}}}
+%     \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}
 % \item added |\CharmLine| and |\CharmFile|
 % \item added |\mathconstantsfont|
@@ -4723,8 +4770,14 @@
 % 
 % \version{2.2b}{August 2023\strut}
 % \item minor changes to code and documentation
-% \item |\ng| now works in math (as not greater than) and text (as pronounciation symbol)
+% \item |\ng| now works in math (as not greater than symbol) and text (as pronounciation symbol)
 % 
+% \version{2.3}{September 2023\strut}
+% \item solidus and |\fractionslash| are |\mathord| instead of |\mathbin|
+% \item removed |\mathfont{fontspec}| functionality
+% \item redesigned font-loader
+% \item added package options |default-loader| and |fontspec-loader|
+% 
 % \egroup
 % \end{multicols*}
 % 
@@ -4749,7 +4802,7 @@
   itemsep=\smallskipamount,
   parsep=\z@,partopsep=\z@}
 \setlist{special}
-\usepackage{doc}
+\usepackage{doc}[=v2]
 \MakeShortVerb{|}
 \def\link#1{\href{#1}{\nolinkurl{#1}}}
 \newcount\fig
@@ -4777,7 +4830,7 @@
 
 Loading 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}}}.) For this reason, \textsf{mathfont} also provides an interface to enlarge the bounding boxes of Latin letters 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 usually results in 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}.
 
-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{mathfont}| syntax, and the package accepts three 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. 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. If you load \textsf{mathfont} with any other optional argument, the package will interpret it as a font name and call |\setfont| (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 section of Table~1.
+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{mathfont}| 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. 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 |\setfont| (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 section of Table~1.
 
 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, which is compatible with \XeTeX\ only and selects characters from text fonts for math.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,'' \link{https://ctan.org/pkg/mathspec}.} The \textsf{unicode-math} package is the standard \LaTeX\ package for loading actual unicode math fonts, and if you have a unicode font with proper math support, rather than a text font that you want to use for equations, consider using this package instead of \textsf{mathfont}.\footnote{Will Robertson, et al., ``\textsf{unicode-math}---Unicode mathematics support for XeTeX and LuaTeX,'' \link{https://ctan.org/pkg/unicode-math}.} 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 will probably 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.
 
@@ -4825,7 +4878,7 @@
 \begin{code}
 |\mathfont[lower=upright, upper=upright]{Times New Roman}|
 \end{code}
-changes all Latin letters to upright Times New Roman. Once \textsf{mathfont} has set the default font for a keyword in Table~1, it will ignore any future instructions to do so and prints a warning to the terminal instead.
+changes all Latin letters to upright Times New Roman. Once \textsf{mathfont} has set the default font for a keyword in Table~1, it will ignore any future instructions to change the font for that keyword again, and instead the package prints a warning message.
 
 
 \begin{figure}[t]
@@ -4853,9 +4906,17 @@
 It calls |\mathfont| without an optional argument---i.e.\ for the default keywords---on your \meta{font name} and sets your document's default text font to be the \meta{font name}. The command also defines the eight commands in Table~\ref{SetFont} using the \meta{font name} and the |\new| macros in the next section. Both |\mathfont| and |\setfont| should appear in the preamble only.
 
 
-To select OpenType features, you should put a colon after the font name and follow it with appropriate OpenType 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}.} For example adding ``|onum=true|'' tells \TeX\ to load your font with oldstyle numbering, assuming that feature is present in the font. You should separate different OpenType feature tags with a semi-colon.
+To select OpenType features, you should put a colon after the font name and follow it with appropriate OpenType 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 can use that package's high-level interface.\footnote{See the \textsf{fontspec} documentation for instructions on selecting OpenType features with \textsf{fontspec}.} 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
+\begin{code}
+|\mathfont{Adobe Garamond Pro:+onum}|
+\end{code}
+for the built-in font-loader or
+\begin{code}
+|\mathfont{Adobe Garamond Pro:Numbers=OldStyle}|
+\end{code}
+if using \textsf{fontspec}. With the built-in font-loader, you should separate OpenType tags with semi-colons, and \textsf{fontspec} allows you to use commas.
 
-Whenever you select a font, \textsf{mathfont} first checks whether you previously loaded \textsf{fontspec}, and if so, the package feeds your entire \meta{font name} argument to \textsf{fontspec}. (You can also say ``|fontspec|'' as the \meta{font name} to select the most recent font used by \textsf{fontspec}.) If you have not loaded \textsf{fontspec}, the package uses its own fontloader. I recommend letting \textsf{mathfont} handle font-loading because when using Lua\TeX, \textsf{mathfont} takes care to load fonts in such a way that full OpenType features are accessible in text and limited OpenType features are accessible in math.\footnote{The \textsf{luaotfload} package supports two main modes for loading fonts: |node| mode is the default setting, and it supports full OpenType features in text but no OpenType features in math. The |base| mode supports limited OpenType features, but the features will work for both text and math. When \textsf{mathfont} loads a font, it does so twice, once in |node| mode, which is primarily for setting the text font with \vrb\setfont, and once in |base| mode, which is for the package's other font declarations. This way you will be able to use OpenType features throughout your document. The package does not currently load fonts with HarfBuzz.} While it is also possible to do this in \textsf{fontspec}, it takes some doing.
+Whenever you select a font, \textsf{mathfont} first checks whether your argument corresponds to a font family identifier in the \textsc{nfss}, and if it does, \textsf{mathfont} uses that font. Otherwise, the package uses loads the font, either through the built-in font-loader or with \textsf{fontspec}. Advanced users should know that when the engine is Lua\TeX, \textsf{mathfont} loads fonts twice. During the first loading, \textsf{mathfont} makes no specifications for the renderer, so the first version of the font will typically use node mode. During the second loading, \textsf{mathfont} specifies base mode. My intention is that the font face with unspecified renderer is for text and the font face with base-mode renderer is for math---using different loading options for text and math provides the greatest access to OpenType font features throughout your document.\footnote{The \textsf{luaotfload} package supports two main modes for loading fonts: |node| mode is the default setting, and it supports full OpenType features in text but no OpenType features in math. The |base| mode supports fewer OpenType features, but the font features work in both text and math. Other loading options such as HarfBuzz are similarly useful for text but provide no access to OpenType features in math.}
 
 
 The last five keywords in Table~\ref{Keywords} are a bit different. If you call |\mathfont| on a \meta{keyword} from the last five rows in Table~\ref{Keywords}, the package defines the macro
@@ -4888,7 +4949,7 @@
 
 \section{Local Font Changes}
 
-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}. 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, and they define the \meta{control sequence} to typeset any math alphabet characters in their argument into the \meta{font name}. For example, the macro |\newmathrm| looks like
+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}. 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, and they define the \meta{control sequence} to typeset any math alphabet characters in their argument into the \meta{font name}. You can specify OpenType features as part of the \meta{font name} the same way as for |\mathfont|, described in the previous section.  For example, the macro |\newmathrm| looks like
 \begin{code}
 |\newmathrm{|\meta{control sequence}|}{|\meta{font name}|}|.
 \end{code}
@@ -4906,7 +4967,7 @@
 \begin{code}
 |\newmathfontcommand{|\meta{control sequence}|}{|\meta{font name}|}{|\meta{series}|}{|\meta{shape}|}|,
 \end{code}
-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 with |\newmathfontcommand|, but the 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. The commands from this section should appear in the preamble only.
+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 the 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. The commands from this section should appear in the preamble only.
 
 
 \section{Default Math Parameters}
@@ -4942,7 +5003,7 @@
 \end{itemize}
 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|. If you specify too few charm values, \textsf{mathfont} will raise an error, and if you provide too many, \textsf{mathfont} will silently ignore the extras.
 
-\begin{figure}[b]
+\begin{figure}[tb]
 \labelfig{Factors}
 \centerline{\bfseries Table \the\fig: Commands to Adjust Individual Characters\strut}
 \global\advance\fig by 1\relax
@@ -4963,13 +5024,7 @@
 tells \textsf{mathfont} to take the lower-case ``a'' (unicode encoding value of 97), increase the bounding box on the left side by 20\% of the glyph width, decrease the bounding box on the right side by 20\% of the glyph width, do nothing to the top accent, and shift the bottom accent right by 5\% of the glyph 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 particular font, consider making a custom set of charm values and uploading it to \textsc{ctan}. Additionally, if you store your charm information in a file, you can read it in with |\CharmFile|. The argument of this command should be a file name, and \textsf{mathfont} reads the file and feeds each line individually to |\CharmLine|.
 
 
-The commands in Table~\ref{Factors} adjust other aspects of the font as indicated. Each command accepts a single integer as an argument, and \textsf{mathfont} divides the input by 1000. With each macro, \textsf{mathfont} multiplies the quotient by some default length, so values greater than or less than 1000 mean ``scale up'' or ``scale down'' respectively. For example,
-\begin{code}
-|\RuleThicknessFactor{2000}|
-\end{code}
-doubles the thickness of the fraction rule and radical overbar relative to the default, which varies between fonts. Changing the |\RuleThicknessFactor| is useful for fonts with particularly heavy or light weight. The |\IntegralItalicFactor| is important for making limits better fit integral signs, and the |\SurdVerticalFactor| and |\SurdHorizontalFactor| commands are essential when the top of the surd glyph differs from the top of its bounding box. The six control sequences from this section should appear in the preamble only.
 
-
 \begin{figure}[tb]
 \labelfig{Callbacks}
 \centerline{\bfseries Table \the\fig: Lua Callbacks Created by \textsf{mathfont}\strut}
@@ -4985,6 +5040,14 @@
 \end{tabularx}
 \end{figure}
 
+
+The commands in Table~\ref{Factors} adjust other aspects of the font as indicated. Each command accepts a single integer as an argument, and \textsf{mathfont} divides the input by 1000. With each macro, \textsf{mathfont} multiplies the quotient by some default length, so values greater than or less than 1000 mean ``scale up'' or ``scale down'' respectively. For example,
+\begin{code}
+|\RuleThicknessFactor{2000}|
+\end{code}
+doubles the thickness of the fraction rule and radical overbar relative to the default, which varies between fonts. Changing the |\RuleThicknessFactor| is useful for fonts with particularly heavy or light weight. The |\IntegralItalicFactor| is important for making limits better fit integral signs, and the |\SurdVerticalFactor| and |\SurdHorizontalFactor| commands are essential when the top of the surd glyph differs from the top of its bounding box. The six control sequences from this section should appear in the preamble only.
+
+
 Finally, advanced users who want to interact with the font adjustment process directly should use the six callbacks in Table~\ref{Callbacks}. When \textsf{luaotfload} loads a font, \textsf{mathfont} (1) always calls |mathfont.inspect_font| and (2) calls the other five callbacks in the order that they appear in Table~\ref{Callbacks} if the font object contains |nomath=true|. 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 the |disable_nomath|, |add_math_constants|, and |fix_character_metrics| callbacks. 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.
 
 
@@ -5826,7 +5889,9 @@
 \end{document}
 %</chars>
 %<*equations>
-\begin{multicols}{2}
+\multicolsep=0pt\relax
+\bigskip
+\begin{multicols*}{2}
 
 Black-Scholes Equation
 \[
@@ -5835,6 +5900,8 @@
   =rV-rS\frac{\partial V}{\partial X}
 \]
 
+\vfill
+
 Cardano's Formula/Cubic Formula
 \begin{align*}
 t_i&=\omega_i\sqrt[3]{-\frac q2+\sqrt{\frac{q^2}4+\frac{p^3}{27}}}\\
@@ -5841,21 +5908,29 @@
   &\qquad\qquad{}+\omega_i^2\sqrt[3]{-\frac q2-\sqrt{\frac{q^2}4+\frac{p^3}{27}}}
 \end{align*}
 
+\vfill
+
 Einstein's Field Equation (General Relativity)
 \[
 R_{\mu\nu}-\frac12Rg_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}
 \]
 
+\vfill
+
 First Isomorphism Theorem
 \[
 \phi(X)\cong X/\ker(\phi)
 \]
 
+\vfill
+
 Gauss-Bonnet Formula
 \[
 \int_MK\ dA+\int_{\partial M}k_g\ ds=2\pi\chi(M)
 \]
 
+\vfill
+
 Maxwell's Equations
 \begin{align*}
 \nabla\bullet\mathbf E&=\frac\rho{\epsilon_0}&
@@ -5865,12 +5940,18 @@
   \epsilon_0\frac{\partial\mathbf E}{\partial t}\right)
 \end{align*}
 
+\vfill
+
 Michaelis-Menten Model
+\bgroup
+\belowdisplayskip=0pt\relax
+\belowdisplayshortskip=0pt\relax
 \[
 v=\frac{d[P]}{dt}=V\frac{[S]}{K_M+[S]}
 \]
-
-
+\par\egroup
+\hrule height 0pt
+\columnbreak
 %% next column begins here
 
 
@@ -5883,6 +5964,7 @@
   \rho\mathbf{g}
 \end{align*}
 
+\vfill
 
 Quadratic Formula
 \[
@@ -5889,11 +5971,14 @@
 x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
 \]
 
+\vfill
+
 Ramanujan's Approximation for $\Gamma$
 \[
 \Gamma(1+x)\approx\sqrt\pi\,x^xe^{-x}\,\sqrt[6]{8x^3+4x^2+x+\frac1{30}}
 \]
 
+\vfill
 
 Residue Theorem
 \[
@@ -5901,6 +5986,8 @@
 \]
 
 
+\vfill
+
 Riemann Zeta Function
 \begin{align*}
 \zeta(z)&=\sum_{i=1}^\infty\frac1{z^i}
@@ -5908,17 +5995,26 @@
   &=2^z\pi^{z-1}\sin\left(\frac{\pi z}2\right)\,\Gamma(1-z)\,\zeta(1-z)
 \end{align*}
 
+
+\vfill
+
 Schrodinger Equation
 \[
 i\hbar\frac d{dt}|\Psi(t)\fakerangle=\hat H|\Psi(t)\fakerangle
 \]
 
+\vfill
+
+
 Lorentz Transformation (Special Relativity)
+\belowdisplayskip=0pt\relax
+\belowdisplayshortskip=0pt\relax
 \[
 t'=\left(t-\frac{vx}{c^2}\right)\frac1{\sqrt{1-\frac{v^2}{c^2}}}
 \]
+\hrule height 0pt
 
-\end{multicols}
+\end{multicols*}
 %</equations>
 %<*cormorant>
 \ifx\directlua\undefined
@@ -5981,7 +6077,7 @@
 \DeclareMathOperator{\Res}{Res}
 \usepackage{mathfont}
 \mathfont[radical]{Crimson}
-\setfont{Kelvinch}
+\setfont{Kelvinch:-clig}
 \IntegralItalicFactor{500}
 \SurdHorizontalFactor{900}
 \parindent=0pt\relax
@@ -6091,6 +6187,9 @@
   {<->"Typey McTypeface:\M at otf@features;embolden=6;mode=base"}{}
 \DeclareFontShape{TU}{Typey-base}{\bfdefault}{\itdefault}
   {<->"Typey McTypeface/I:\M at otf@features;embolden=6;mode=base"}{}
+
+%% And link the Typey-base font family to the Typey family
+\expandafter\def\csname Typey-base\endcsname{Typey-base}
 \makeatother
 
 \setfont{Typey}
@@ -6123,8 +6222,8 @@
 \makeatletter
 
 % package date and edition
-\def\packagedate{August 2023}
-\def\packageversion{2.2b}
+\def\packagedate{September 2023}
+\def\packageversion{2.3}
 
 % header and footer commands
 

Modified: trunk/Master/texmf-dist/tex/latex/mathfont/mathfont.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/mathfont/mathfont.sty	2023-09-11 21:17:07 UTC (rev 68240)
+++ trunk/Master/texmf-dist/tex/latex/mathfont/mathfont.sty	2023-09-11 21:17:53 UTC (rev 68241)
@@ -6,8 +6,8 @@
 %%
 %% mathfont_code.dtx  (with options: `package')
 %% 
-%% This file is from version 2.2b of the free and open-source
-%% LaTeX package "mathfont," released August 2023, to be used
+%% This file is from version 2.3 of the free and open-source
+%% LaTeX package "mathfont," released September 2023, to be used
 %% with the XeTeX or LuaTeX engines. (As of version 2.0, LuaTeX
 %% is recommended.)
 %% 
@@ -60,13 +60,14 @@
 %% For more information, see mathfont_code.dtx. Happy TeXing!
 %% 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{mathfont}[2023/08/21 v. 2.2b Package mathfont]
+\ProvidesPackage{mathfont}[2023/09/09 v. 2.3 Package mathfont]
 \newif\ifM at XeTeXLuaTeX     % is engine one of xetex or luatex?
 \newif\ifM at Noluaotfload    % cannot find luaotfload.sty?
 \newif\ifM at adjust@font     % should adjust fonts with lua script?
 \newif\ifM at font@loaded     % load mathfont with font specified?
 \newif\ifE at sterEggDecl@red % already did easter egg?
-\long\def\@gobbletwo at brackets[#1]#2{}
+\newcount\M at loader         % specifies which font-loader to use
+\long\def\@gobble at brackets[#1]{}
 \def\M at NoMathfontError#1{\PackageError{mathfont}
   {\MessageBreak Invalid command\MessageBreak
   \string#1 on line \the\inputlineno}
@@ -73,33 +74,42 @@
   {Your command was ignored. I couldn't\MessageBreak
   load mathfont, so I never defined this\MessageBreak
   control sequence.}}
-\protected\def\mathfont{\M at NoMathfontError\mathfont
-  \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\protected\def\setfont{\M at NoMathfontError\setfont\@gobble}
-\protected\def\mathconstantsfont{\M at NoMathfontError\mathconstantsfont
-  \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\protected\def\newmathrm{\M at NoMathfontError\newmathrm\@gobbletwo}
-\protected\def\newmathit{\M at NoMathfontError\newmathit\@gobbletwo}
-\protected\def\newmathbf{\M at NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbfit{\M at NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbold{\M at NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathboldit{\M at NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathsc{\M at NoMathfontError\newmathsc\@gobbletwo}
-\protected\def\newmathscit{\M at NoMathfontError\newmathscit\@gobbletwo}
-\protected\def\newmathbfsc{\M at NoMathfontError\newmathbfsc\@gobbletwo}
-\protected\def\newmathbfscit{\M at NoMathfontError\newmathbfscit\@gobbletwo}
+\@tfor\@i:=\setfont
+  \RuleThicknessFactor
+  \IntegralItalicFactor
+  \SurdVerticalFactor
+  \SurdHorizontalFactor
+  \CharmLine
+  \CharmFile\do{%
+    \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+    \edef\@tempb{\noexpand\M at NoMathfontError
+      \expandafter\noexpand\@i
+      \noexpand\@gobble}%
+    \expandafter\@tempa\expandafter{\@tempb}}
+\@tfor\@i:=\newmathrm
+  \newmathit
+  \newmathbf
+  \newmathbfit
+  \newmathbold
+  \newmathboldit
+  \newmathsc
+  \newmathscit
+  \newmathbfsc
+  \newmathbfscit\do{%
+    \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+    \edef\@tempb{\noexpand\M at NoMathfontError
+      \expandafter\noexpand\@i
+      \noexpand\@gobbletwo}%
+    \expandafter\@tempa\expandafter{\@tempb}}
+\@tfor\@i:=\mathfont\mathconstantsfont\do{%
+  \edef\@tempa{\protected\def\expandafter\noexpand\@i}%
+  \edef\@tempb{\noexpand\M at NoMathfontError
+    \expandafter\noexpand\@i
+    \noexpand\@ifnextchar[{\noexpand\expandafter
+      \noexpand\@gobble\noexpand\@gobble at brackets}{\noexpand\@gobble}}
+  \expandafter\@tempa\expandafter{\@tempb}}
 \protected\def\newmathfontcommand{%
   \M at NoMathfontError\newmathfontcommand\@gobblefour}
-\protected\def\RuleThicknessFactor{%
-  \M at NoMathfontError\RuleThicknessFactor\@gobble}
-\protected\def\IntegralItalicFactor{%
-  \M at NoMathfontError\IntegralItalicFactor\@gobble}
-\protected\def\SurdVerticalFactor{%
-  \M at NoMathfontError\SurdVerticalFactor\@gobble}
-\protected\def\SurdHorizontalFactor{%
-  \M at NoMathfontError\SurdHorizontalFactor\@gobble}
-\protected\def\CharmLine{\M at NoMathfontError\CharmLine\@gobble}
-\protected\def\CharmFile{\M at NoMathfontError\CharmFile\@gobble}
 \ifdefined\directlua
   \M at XeTeXLuaTeXtrue
 \fi
@@ -140,12 +150,12 @@
   \IfFileExists{luaotfload.sty}
     {\M at Noluaotfloadfalse\RequirePackage{luaotfload}}{\M at Noluaotfloadtrue}
 \else
-  \PackageWarningNoLine{mathfont}{%
+  \AtEndOfPackage{\PackageWarningNoLine{mathfont}{%
     The current engine is XeTeX, but as\MessageBreak
     of mathfont version 2.0, LuaTeX is\MessageBreak
     recommended. Consider compiling with\MessageBreak
     LuaLaTeX. Certain features will not\MessageBreak
-    work with XeTeX}
+    work with XeTeX}}
 \fi
 \ifM at Noluaotfload % false by default; true if LuaTeX AND no luaotfload.sty
 \begingroup
@@ -232,31 +242,80 @@
       \let\E at sterEggUpd@te\relax
       \let\EasterEggUpdate\relax}
   \fi}% my easter egg :)
+\DeclareOption{default-loader}{\M at loader\z@}
+\DeclareOption{fontspec-loader}{\M at loader\@ne}
 \DeclareOption{adjust}{\M at adjust@fonttrue}
 \DeclareOption{no-adjust}{\M at adjust@fontfalse}
 \DeclareOption*{\M at font@loadedtrue\edef\M at font@load{\CurrentOption}}
 \ProcessOptions*
+\ifcase\M at loader
+  \wlog{Package mathfont Info: Default font-loader was
+    requested for font loading.}
+\or
+  \wlog{Package mathfont Info: Package fontspec was
+    requested for font loading.}
+  \@ifpackageloaded{fontspec}
+    {\wlog{Package mathfont Info: Package fontspec detected.}
+      \csname bool_if:NTF\expandafter\endcsname
+        \csname g__fontspec_math_bool\endcsname
+        {\wlog{Package mathfont Info: Setting
+          \string\g__fontspec_math_bool to false.}
+          \csname bool_set_false:N\expandafter\endcsname
+          \csname g__fontspec_math_bool\endcsname}{\relax}}
+    {\wlog{Package mathfont Info: Package fontspec not detected.}
+      \IfFileExists{fontspec.sty}
+        {\wlog{Package mathfont Info: File fontspec.sty was found.}
+          \wlog{Package mathfont Info: Loading fontspec.}
+          \RequirePackage[no-math]{fontspec}}
+        {\PackageError{mathfont}{Missing package fontspec;\MessageBreak
+          using default font-loader instead}
+          {You requested fontspec as the font-loader for\MessageBreak
+          mathfont. However, I can't find the fontspec\MessageBreak
+          package file, so I'm going to use the default\MessageBreak
+          font-loader instead. (This likely means that\MessageBreak
+          something is wrong with your TeX installation.)\MessageBreak
+          Check your TeX distribution for a list of the\MessageBreak
+          packages installed on your system. To resolve\MessageBreak
+          this error, make sure fontspec is installed in\MessageBreak
+          a directory searchable by TeX or load mathfont\MessageBreak
+          with the default-loader option.^^J}
+          \M at loader\z@}}
+\fi
+\ifcase\M at loader
+  \wlog{Package mathfont Info: Using default font-loader.}
+  \AtEndOfPackage{\typeout{:: mathfont :: Using default font-loader.}}
+  \def\M at otf@features{script=latin;language=DFLT;+tlig;+liga;+lnum}
+\or
+  \wlog{Package mathfont Info: Using fontspec as font-loader.}
+  \AtEndOfPackage{\typeout{:: mathfont :: Using fontspec as font-loader.}}
+  \def\M at otf@features{Script=Latin,
+    Language=Default,
+    Ligatures={TeX,Common},
+    Numbers=Lining}
+\fi
 \ifdefined\directlua
   \ifM at adjust@font
+    \wlog{Package mathfont Info: Enabling Lua-based font adjustments.}
     \AtEndOfPackage{%
       \typeout{:: mathfont :: Lua-based font adjustments enabled.}}
   \else
+    \wlog{Package mathfont Info: Disabling Lua-based font adjustments.}
     \AtEndOfPackage{%
       \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
   \fi
 \else
-  \AtEndOfPackage{%
-    \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
   \ifM at adjust@font
-    \AtEndOfPackage{%
     \PackageError{mathfont}{Option^^J"adjust" ignored with XeTeX}
     {Your package option "adjust" was ignored.\MessageBreak
     This option works only with LuaTeX, and it\MessageBreak
     looks like the current engine is XeTeX. To\MessageBreak
     enable Lua-based font adjustments, typeset\MessageBreak
-    with LuaLaTeX.^^J}}
+    with LuaLaTeX.^^J}
     \M at adjust@fontfalse
   \fi
+  \wlog{Package mathfont Info: Disabling Lua-based font adjustments.}
+  \AtEndOfPackage{%
+    \typeout{:: mathfont :: Lua-based font adjustments disabled.}}
 \fi
 \def\M at SymbolFontInfo#1#2#3#4{\wlog{^^JPackage mathfont Info:
   Declaring new symbol font from #1!^^J%
@@ -274,6 +333,18 @@
   #1 chars, so I'm ignoring\MessageBreak
   this option for \string\mathfont\space
   on line \the\inputlineno\@gobble}}
+\def\M at MissingNFSSShapesWarning#1#2{\PackageWarning{mathfont}
+  {The nfss family "#1"\MessageBreak
+  from line \the\inputlineno\space is missing shapes. You\MessageBreak
+  may see some substitutions or errors.\MessageBreak
+  Missing shape(s):#2\@gobble}}
+\def\M at NoBaseModeDetectedWarning#1{\PackageWarning{mathfont}
+  {I couldn't find a base-mode version of\MessageBreak
+  the nfss family "#1"\MessageBreak
+  from line \the\inputlineno, so I'm using the family\MessageBreak
+  you specified for the math font. Some\MessageBreak
+  font features may not work in math\MessageBreak
+  mode\@gobble}}
 \def\M at DeprecatedWarning#1#2{\PackageWarning{mathfont}
   {Your \string#1\space command on\MessageBreak
   line \the\inputlineno\space is deprecated, and I\MessageBreak
@@ -302,9 +373,9 @@
 \def\M at MissingSuboptionError{\PackageError{mathfont}
   {Missing^^Jsuboption for \string\mathfont\on at line}
   {It looks like you included an = somewhere\MessageBreak
-  but didn't put the suboption after it. Either\MessageBreak
-  that or you typed == instead of = in the\MessageBreak
-  optional argument of \string\mathfont.^^J}}
+  in the optional argument of \string\mathfont\space but\MessageBreak
+  didn't put the suboption after it. Either\MessageBreak
+  that or you typed == instead of =.^^J}}
 \def\M at InternalsRestoredError{\PackageError{mathfont}
   {Internal^^Jcommands restored}
   {This package slightly changes two LaTeX\MessageBreak
@@ -319,30 +390,10 @@
   Try typesetting this document with all\MessageBreak
   \string\mathfont\space commands placed before you call\MessageBreak
   \string\restoremathinternals.^^J}}
-\def\M at NoFontspecFamilyError{\PackageError{mathfont}
-  {No previous^^Jfont loaded by fontspec}
-  {You called \string\mathfont\space
-  with the argument "fontspec" \MessageBreak
-  on line \the\inputlineno,
-  and that tells me to use the previous \MessageBreak
-  font loaded by the fontspec package. However, it \MessageBreak
-  looks like you haven't loaded any fonts yet with \MessageBreak
-  fontspec. To resolve this error, try using for \MessageBreak
-  example \string\setmainfont\space
-  before calling \string\mathfont.^^J}}
-\def\M at NoFontspecError{\PackageError{mathfont}
-  {Missing^^Jpackage fontspec}
-  {You called \string\mathfont\space
-  with the argument "fontspec" \MessageBreak
-  on line \the\inputlineno,
-  and that tells me to use the previous \MessageBreak
-  font loaded by the fontspec package. However, you\MessageBreak
-  haven't loaded fontspec, so some things are about\MessageBreak
-  to get messed up. To resolve this error, load\MessageBreak
-  fontspec before calling \string\mathfont.^^J}}
 \def\M at BadMathConstantsFontError#1{\PackageError{mathfont}
-  {Invalid\MessageBreak font specifier for
-  \string\mathconstantsfont:\MessageBreak"#1"}
+  {Invalid font specifier\MessageBreak
+  for \string\mathconstantsfont:\MessageBreak
+  "#1"}
   {Your command was ignored--I can't parse your argument.\MessageBreak
   Please make sure to use text that you have previously\MessageBreak
   fed to \string\mathfont\space for the argument of
@@ -353,10 +404,13 @@
   {The optional argument of \string\mathconstantsfont\MessageBreak
   should be "upright" or "italic." Right now,\MessageBreak
   it's "#1."^^J}}
-\def\M at LuaTeXOnlyWarning{\PackageWarning{mathfont}
-    {Your \string\mathconstantsfont\space
-    on line \the\inputlineno\space is\MessageBreak
-    for LuaTeX only, and I'm ignoring it\@gobble}}
+\def\M at MathConstantsNoFontAdjustWarning{\PackageWarning{mathfont}
+  {Your \string\mathconstantsfont\space
+  on line \the\inputlineno\MessageBreak
+  is mainly for use in LuaTeX with font\MessageBreak
+  adjustments enabled. In the current\MessageBreak
+  situation, it is probably not doing\MessageBreak
+  anything\@gobble}}
 \def\M at MissingControlSequenceError#1#2{\PackageError{mathfont}
   {Missing control sequence\MessageBreak
   for\string#1\MessageBreak on input line \the\inputlineno}
@@ -411,16 +465,6 @@
   that your argument of \string#1\space\MessageBreak
   is a nonnegative integer. Right now it's\MessageBreak
   "#2".^^J}}
-\@ifpackageloaded{fontspec}
-  {\wlog{Package mathfont Info: Package fontspec detected.}
-    \wlog{Package mathfont Info: Setting \string\g__fontspec_math_bool
-      to false.}
-    \csname bool_set_false:N\expandafter\endcsname
-    \csname g__fontspec_math_bool\endcsname}
-  {\wlog{Package mathfont Info: Package fontspec not detected.}
-    \wlog{Package mathfont Info: Will pass no-math option to fontspec
-      if it gets loaded.}
-    \PassOptionsToPackage{no-math}{fontspec}}
 \let\@@set at mathchar\set at mathchar
 \let\@@set at mathsymbol\set at mathsymbol
 \let\@@set at mathaccent\set at mathaccent
@@ -469,18 +513,18 @@
 \fi
 \newbox\surdbox
 \newcount\M at count
-\newcount\M at rule@thickness at factor
-\newcount\M at integral@italic at factor
-\newcount\M at surd@vertical at factor
-\newcount\M at surd@horizontal at factor
+\newcount\M at RuleThicknessFactor
+\newcount\M at IntegralItalicFactor
+\newcount\M at SurdVerticalFactor
+\newcount\M at SurdHorizontalFactor
 \newmuskip\radicandoffset
 \newread\M at Charm
 \newtoks\M at toks
 \M at count\z@
-\M at rule@thickness at factor\@m
-\M at integral@italic at factor=400\relax
-\M at surd@horizontal at factor\@m
-\M at surd@vertical at factor\@m
+\M at RuleThicknessFactor\@m
+\M at IntegralItalicFactor=400\relax
+\M at SurdHorizontalFactor\@m
+\M at SurdVerticalFactor\@m
 \radicandoffset=3mu\relax
 \newif\ifM at upper
 \newif\ifM at lower
@@ -510,7 +554,6 @@
 \newif\if at suboptionpresent
 \newif\ifM at arg@good
 \newif\ifM at Decl@reF at mily
-\newif\ifM at Decl@reF at milyB@se
 \newif\ifM at fromCharmFile
 \def\M at uppershape{italic}          % latin upper
 \def\M at lowershape{italic}          % latin lower
@@ -546,117 +589,108 @@
 \ifM at adjust@font
   \edef\M at defaultkeys{\M at defaultkeys,delimiters,radical,bigops}
 \fi
-\def\M at otf@features{script=latin;language=DFLT;%
-  tlig=true;liga=true;smcp=false;lnum=true}
-\def\M at otf@features at sc{script=latin;language=DFLT;%
-  tlig=true;liga=true;smcp=true;lnum=true}
+\def\M at declare@shape#1#2#3#4#5#6{%
+  \ifcsname TU/#1/#5/#6\endcsname
+  \else
+    \DeclareFontShape{TU}{#1}{#5}{#6}{<->"\@tempbase#2:#3;#4"}{}
+  \fi}
+\def\M at fill@nfss at shapes#1#2#3{%
+  \@for\@i:={#1}{}{#2;-smcp}{#3}{\mddefault}{\shapedefault},%
+    {#1}{/I}{#2;-smcp}{#3}{\mddefault}{\itdefault},%
+    {#1}{/B}{#2;-smcp}{#3}{\bfdefault}{\shapedefault},%
+    {#1}{/BI}{#2;-smcp}{#3}{\bfdefault}{\itdefault},%
+    {#1}{}{#2;+smcp}{#3}{\mddefault}{\scdefault},%
+    {#1}{/I}{#2;+smcp}{#3}{\mddefault}{\scdefault\itdefault},%
+    {#1}{/B}{#2;+smcp}{#3}{\bfdefault}{\shapedefault},%
+    {#1}{/BI}{#2;+smcp}{#3}{\bfdefault}{\scdefault\itdefault}%
+      \do{\expandafter\M at declare@shape\@i}}
+\def\M at check@nfss at shapes#1{%
+  \let\@tempb\@empty
+  \let\@tempwarning\@gobble
+  \@for\@i:=\mddefault/\shapedefault,%
+    \mddefault/\itdefault,%
+    \bfdefault/\shapedefault,%
+    \bfdefault/\itdefault\do{%
+      \expandafter\ifx\csname TU/#1/\@i\endcsname\relax
+        \def\@tempwarning{\M at MissingNFSSShapesWarning{#1}}
+        \edef\@tempb{\@tempb, \@i}
+      \fi}
+  \@tempwarning{\expandafter\@gobble\@tempb}}
 \def\M at split@colon#1:#2\@nil{\def\@tempbase{#1}
   \def\@tempfeatures{#2}}
 \def\M at strip@colon#1:{#1}
-\def\M at fill@nfss at shapes#1#2{%
-  \ifcsname TU/#1/\mddefault/\shapedefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\shapedefault}
-      {<->"\@tempbase:\M at otf@features;#2"}{}
-  \fi
-  \ifcsname TU/#1/\mddefault/\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\itdefault}
-      {<->"\@tempbase/I:\M at otf@features;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\shapedefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\shapedefault}
-      {<->"\@tempbase/B:\M at otf@features;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\itdefault}
-      {<->"\@tempbase/BI:\M at otf@features;#2"}{}
-  \fi
-  \ifcsname TU/#1/\mddefault/\scdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault}
-      {<->"\@tempbase:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\mddefault/\scdefault\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault\itdefault}
-      {<->"\@tempbase/I:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\scdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault}
-      {<->"\@tempbase/B:\M at otf@features at sc;#2"}{}
-  \fi
-  \ifcsname TU/#1/\bfdefault/\scdefault\itdefault\endcsname
-  \else
-    \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault\itdefault}
-      {<->"\@tempbase/BI:\M at otf@features at sc;#2"}{}
-  \fi}
 \def\M at newfont#1{%
   \edef\@tempa{#1}
   \expandafter\M at split@colon\@tempa:\@nil
-  \def\@tempb{fontspec}
-  \ifx\@tempa\@tempb
-    \@ifpackageloaded{fontspec}{%
-      \expandafter\ifx\csname l_fontspec_family_tl\endcsname\@empty
-        \M at NoFontspecFamilyError
+  \ifx\@tempfeatures\@empty\else
+    \edef\@tempfeatures{\expandafter\M at strip@colon\@tempfeatures}
+  \fi
+  \ifcsname TU+\@tempbase\endcsname % is font family already in nfss?
+    \let\M at f@ntn at me\@tempbase
+    \M at check@nfss at shapes\M at f@ntn at me
+    \ifx\directlua\@undefined % if XeTeX
+      \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at me}
+      \let\M at f@ntn at meb@se\M at f@ntn at me
+    \else % if LuaTeX
+      \ifcsname\M at f@ntn at me-base\endcsname % if base-mode version is known
+        \edef\M at f@ntn at meb@se{\csname\M at f@ntn at me-base\endcsname}
+        \M at check@nfss at shapes\M at f@ntn at meb@se
       \else
-        \expandafter
-          \let\expandafter\M at f@ntn at me\csname l_fontspec_family_tl\encsname
-        \def\@tempbase{\M at f@ntn at me\space(from fontspec)}
-        \let\M at f@ntn at meb@se\M at f@ntn at me % no separate font in base mode
-      \fi}{\M at NoFontspecError}
+        \M at NoBaseModeDetectedWarning{\M at f@ntn at me}
+        \edef\M at f@ntn at meb@se{\M at f@ntn at me}
+        \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at me}
+      \fi
+    \fi
+    \expandafter\edef\csname M at fontfamily@\@tempbase\endcsname
+      {\M at f@ntn at me}
+    \expandafter\edef\csname M at fontfamily@base@\@tempbase\endcsname
+      {\M at f@ntn at meb@se}
   \else
-    \@ifpackageloaded{fontspec}
-    {\csname fontspec_set_family:Nnn\endcsname\M at f@ntn at me{}{\@tempa}
-      % no separate font in base mode
-      \let\M at f@ntn at meb@se\M at f@ntn at me}
-    {\M at Decl@reF at milytrue
-      \M at Decl@reF at milyB@setrue
-      \ifx\@tempfeatures\@empty
+    \edef at nospace\@tempa{\@tempa}
+    \ifcsname M at fontfamily@\@tempa\endcsname
+      \edef\M at f@ntn at me{\csname M at fontfamily@\@tempa\endcsname}
+      \edef\M at f@ntn at meb@se{\csname M at fontfamily@base@\@tempa\endcsname}
+    \else
+      \edef at nospace\@tempa{\@tempa}
+      \ifcase\M at loader % are we using default font-loader?
+        \let\M at f@ntn at me\@tempa
+        \wlog{Package mathfont Info: Adding \@tempbase\space to the nfss!}
+        \wlog{Family name: \M at f@ntn at me}
+        \DeclareFontFamily{TU}{\M at f@ntn at me}{}
+        \M at fill@nfss at shapes{\M at f@ntn at me}{\M at otf@features}{\@tempfeatures}
         \ifdefined\directlua
-          \edef\@basefeatures{mode=base}
+          \edef\M at f@ntn at meb@se{\M at f@ntn at me-base}
+          \wlog{Package mathfont Info: Adding \@tempbase with mode=base
+            to the nfss!}
+          \wlog{Family name: \M at f@ntn at meb@se}
+          \DeclareFontFamily{TU}{\M at f@ntn at meb@se}{}
+          \M at fill@nfss at shapes
+            {\M at f@ntn at meb@se}{\M at otf@features}{\@tempfeatures;mode=base}
         \else
-          \let\@basefeatures\@tempfeatures
+          \edef\M at f@ntn at meb@se{\M at f@ntn at me}
         \fi
-      \else
-        \edef\@tempfeatures{\expandafter\M at strip@colon\@tempfeatures}
+      \or              % are we using fontspec as font-loader?
+        \wlog{Package mathfont Info: Passing \@tempbase\space to fontspec
+          for handling!}
+        \csname fontspec_set_family:Nnn\endcsname\M at f@ntn at me
+          {\M at otf@features,\@tempfeatures}{\@tempbase}
         \ifdefined\directlua
-          \edef\@basefeatures{\@tempfeatures;mode=base}
+          \wlog{Package mathfont Info: Passing \@tempbase\space with
+            Renderer=Base to fontspec for handling!}
+          \csname fontspec_set_family:Nnn\endcsname\M at f@ntn at meb@se
+            {\M at otf@features,\@tempfeatures,Renderer=Base}{\@tempbase}
         \else
-          \let\@basefeatures\@tempfeatures
+            \edef\M at f@ntn at meb@se{\M at f@ntn at me}
         \fi
       \fi
-      \edef at nospace\@tempa{\@tempa}
-      \edef at nospace\@tempb{\@tempbase}
-      \M at Decl@reF at milytrue
-      \@tfor\@i:=\@tempa\@tempb\@tempbase\do{%
-        \ifcsname TU+\@i\endcsname
-          \expandafter\let\expandafter\M at f@ntn at me\@i
-          \M at Decl@reF at milyfalse
-          \M at fill@nfss at shapes\M at f@ntn at me\@tempfeatures
-          \@break at tfor
-        \fi}
-      \ifM at Decl@reF at mily
-        \let\M at f@ntn at me\@tempa
-        \wlog{Package mathfont Info: Adding \M at f@ntn at me\space to the nfss!}
-        \DeclareFontFamily{TU}{\M at f@ntn at me}{}
-        \M at fill@nfss at shapes\M at f@ntn at me\@tempfeatures
-      \fi
-      \ifdefined\directlua
-        \edef\M at f@ntn at meb@se{\M at f@ntn at me-base}
-      \else
-        \let\M at f@ntn at meb@se\M at f@ntn at me
-      \fi
-      \ifcsname TU+\M at f@ntn at meb@se\endcsname\else
-        \wlog{Package mathfont Info: Adding \M at f@ntn at meb@se\space
-          to the nfss!}
-        \DeclareFontFamily{TU}{\M at f@ntn at meb@se}{}
-      \fi
-      \M at fill@nfss at shapes\M at f@ntn at meb@se\@basefeatures}
+      \expandafter\edef\csname\M at f@ntn at me-base\endcsname{\M at f@ntn at meb@se}
+      \expandafter\edef\csname M at fontfamily@\@tempa\endcsname
+        {\M at f@ntn at me}
+      \expandafter\edef\csname M at fontfamily@base@\@tempa\endcsname
+        {\M at f@ntn at meb@se}
+    \fi
   \fi}
+\@onlypreamble\M at declare@shape
 \@onlypreamble\M at fill@nfss at shapes
 \@onlypreamble\M at newfont
 \def\M at check@option at valid#1{%
@@ -720,12 +754,11 @@
   \else
     \M at toks{}
     \M at newfont{#2}
-    \expandafter\edef\csname M at fontfamily@#2\endcsname{\M at f@ntn at me}
-    \expandafter\edef\csname M at fontfamily@base@#2\endcsname{\M at f@ntn at meb@se}
     \ifcsname M at fontid@\M at f@ntn at me\endcsname\else % need new \M at count value?
-      \expandafter\edef\csname M at fontid@\M at f@ntn at me\endcsname{\the\M at count}
-      \expandafter\let\csname M at fontid@\M at f@ntn at meb@se\expandafter\endcsname
-        \csname M at fontid@\M at f@ntn at me\endcsname
+      \expandafter\edef\csname M at fontid@\M at f@ntn at me\endcsname{\the
+        \M at count}
+      \expandafter\edef\csname M at fontid@\M at f@ntn at meb@se\endcsname{\the
+        \M at count}
       \advance\M at count\@ne
     \fi
     \edef\@tempa{\csname M at fontid@\M at f@ntn at me\endcsname}
@@ -784,52 +817,51 @@
   \setmathfontcommands{#1}
   \let\rmdefault\M at f@ntn at me}
 \@onlypreamble\setfont
-\ifdefined\directlua
-  \let\M at SetMathConstants\relax
-  \protected\def\mathconstantsfont{%
-    \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
-  \def\@mathconstantsfont[#1]#2{%
-    \edef\@tempa{\csname M at fontfamily@base@#2\endcsname}
-    \expandafter\ifx\@tempa\relax
-      \M at BadMathConstantsFontError{#2}
+\let\M at SetMathConstants\relax
+\protected\def\mathconstantsfont{%
+  \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
+\def\@mathconstantsfont[#1]#2{%
+  \edef at nospace\@tempa{#2}
+  \edef\@tempa{\csname M at fontfamily@base@\@tempa\endcsname}
+  \expandafter\ifx\@tempa\relax
+    \M at BadMathConstantsFontError{#2}
+  \else
+    \def\@tempb{#1}
+    \def\@tempc{upright}
+    \ifx\@tempb\@tempc
+      \let\m at th@const at nts@font at sh@pe\shapedefault
     \else
-      \def\@tempb{#1}
-      \def\@tempc{upright}
+      \def\@tempc{italic}
       \ifx\@tempb\@tempc
-        \let\m at th@const at nts@font at sh@pe\shapedefault
+        \let\m at th@const at nts@font at sh@pe\itdefault
       \else
-        \def\@tempc{italic}
-        \ifx\@tempb\@tempc
-          \let\m at th@const at nts@font at sh@pe\itdefault
-        \else
-          \M at BadMathConstantsFontTypeError{#1}
-        \fi
+        \M at BadMathConstantsFontTypeError{#1}
       \fi
-      \ifcsname symM#1\csname M at fontid@\@tempa\endcsname\endcsname\else
-        \DeclareSymbolFont{M#1\csname M at fontid@\@tempa\endcsname}
-          {TU}{\@tempa}{\mddefault}{\m at th@const at nts@font at sh@pe}
-      \fi
-      \let\m at th@const at nts@font\@tempa
-      \protected\def\M at SetMathConstants{%
-        \begingroup
-        \escapechar\m at ne
-        \expandafter\getanddefine at fonts
-          \csname symM#1\csname M at fontid@\m at th@const at nts@font\endcsname
-            \expandafter
-          \endcsname % expands to \symMupright<id>
-          \csname TU/\m at th@const at nts@font
-                    /\seriesdefault
-                    /\m at th@const at nts@font at sh@pe
-          \endcsname % expands to \TU/<nfss family name>/m/<shape>
-        \globaldefs\@ne
-        \expandafter\@gobbletwo\math at fonts % gobble to avoid infinite loop
-        \endgroup}
-      \fi}
-  \def\math at fonts{\aftergroup\M at SetMathConstants}
-\else
-  \protected\def\mathconstantsfont{\M at LuaTeXOnlyWarning
-    \@ifnextchar[\@gobbletwo at brackets\@gobble}
-\fi
+    \fi
+    \ifcsname symM#1\csname M at fontid@\@tempa\endcsname\endcsname\else
+      \DeclareSymbolFont{M#1\csname M at fontid@\@tempa\endcsname}
+        {TU}{\@tempa}{\mddefault}{\m at th@const at nts@font at sh@pe}
+    \fi
+    \let\m at th@const at nts@font\@tempa
+    \protected\def\M at SetMathConstants{%
+      \begingroup
+      \escapechar\m at ne
+      \expandafter\getanddefine at fonts
+        \csname symM#1\csname M at fontid@\m at th@const at nts@font\endcsname
+          \expandafter
+        \endcsname % expands to \symMupright<id>
+        \csname TU/\m at th@const at nts@font
+                  /\seriesdefault
+                  /\m at th@const at nts@font at sh@pe
+        \endcsname % expands to \TU/<nfss family name>/m/<shape>
+      \globaldefs\@ne
+      \expandafter\@gobbletwo\math at fonts % gobble to avoid infinite loop
+      \endgroup}
+    \fi
+  \ifM at adjust@font\else
+    \M at MathConstantsNoFontAdjustWarning
+  \fi}
+\def\math at fonts{\aftergroup\M at SetMathConstants}
 \@onlypreamble\mathconstantsfont
 \def\M at check@csarg#1#2{%
   \expandafter\ifx\expandafter\@nnil\@gobble#2\@nnil % good
@@ -920,34 +952,22 @@
       end}
     \fi
   \fi}
-  \protected\def\RuleThicknessFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at rule@thickness at factor=#1\relax
-    \else
-      \M at BadIntegerError\RuleThicknessFactor{#1}
-    \fi}
-  \protected\def\IntegralItalicFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at integral@italic at factor=#1\relax
-    \else
-      \M at BadIntegerError\IntegralItalicFactor{#1}
-    \fi}
-  \protected\def\SurdHorizontalFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at surd@horizontal at factor=#1\relax
-    \else
-      \M at BadIntegerError\SurdHorizontalFactor{#1}
-    \fi}
-  \protected\def\SurdVerticalFactor#1{%
-    \M at check@int{#1}
-    \ifM at arg@good
-      \global\M at surd@vertical at factor=#1\relax
-    \else
-      \M at BadIntegerError\SurdVerticalFactor{#1}
-    \fi}
+  \let\@tempa~
+  \let~\noexpand
+  \count@\escapechar
+  \escapechar\m at ne
+  \@tfor\@i:=\RuleThicknessFactor\IntegralItalicFactor
+    \SurdHorizontalFactor\SurdVerticalFactor\do{%
+      \protected\expandafter\edef\@i#1{%
+        ~\M at check@int{#1}%
+        ~\ifM at arg@good
+          ~\global
+            \expandafter~\csname M@\expandafter\string\@i\endcsname=#1\relax
+        ~\else
+          ~\M at BadIntegerError\expandafter~\@i{#1}%
+        ~\fi}}
+  \let~\@tempa
+  \escapechar\count@
 \else
   \@tfor\@i:=\RuleThicknessFactor\IntegralItalicFactor\SurdHorizontalFactor
     \SurdVerticalFactor\CharmLine\CharmFile
@@ -994,19 +1014,6 @@
 \ifnum\tracinglostchars<\tw@
   \tracinglostchars\tw@
 \fi
-\ifdefined\XeTeXrevision
-  \ifM at font@loaded
-    \AtEndOfPackage{%
-    \PackageWarningNoLine{mathfont}
-    {XeTeX detected. It looks like you\MessageBreak
-    specified a font when you loaded\MessageBreak
-    mathfont. If you run into problems\MessageBreak
-    with a font whose name is multiple\MessageBreak
-    words, try compiling with LuaLaTeX\MessageBreak
-    or call \string\setfont\space or \string\mathfont\MessageBreak
-    manually}}
-  \fi
-\fi
 \def\keyword at info@begindocument#1:#2\@nil{%
   \expandafter\ifx % next line is two cs to be compared
         \csname ifM@#1\expandafter\endcsname\csname iftrue\endcsname
@@ -1046,6 +1053,19 @@
   \@for\@i:=\@tempa\do{%
     \expandafter\keyword at info@begindocument\@i\@nil}
   \wlog{}}
+\ifdefined\XeTeXrevision
+  \ifM at font@loaded
+    \AtEndOfPackage{%
+    \PackageWarningNoLine{mathfont}
+    {XeTeX detected. It looks like you\MessageBreak
+    specified a font when you loaded\MessageBreak
+    mathfont. If you run into problems\MessageBreak
+    with a font whose name is multiple\MessageBreak
+    words, try compiling with LuaLaTeX\MessageBreak
+    or call \string\setfont\space or \string\mathfont\MessageBreak
+    manually}}
+  \fi
+\fi
 \ifM at font@loaded
   \AtEndOfPackage{\setfont\M at font@load}
 \fi
@@ -1061,12 +1081,13 @@
 \@onlypreamble\M at hebrew@set
 \@onlypreamble\M at digits@set
 \@onlypreamble\M at operator@set
+\@onlypreamble\M at delimiters@set
+\@onlypreamble\M at radical@set
+\@onlypreamble\M at bigops@set
+\@onlypreamble\M at extbigops@set
 \@onlypreamble\M at symbols@set
 \@onlypreamble\M at extsymbols@set
-\@onlypreamble\M at delimiters@set
 \@onlypreamble\M at arrows@set
-\@onlypreamble\M at bigops@set
-\@onlypreamble\M at extbigops@set
 \@onlypreamble\M at bb@set
 \@onlypreamble\M at cal@set
 \@onlypreamble\M at frak@set
@@ -1351,13 +1372,13 @@
   local width, height, depth, italic = self.glyph_info(char)
   char.width = width + italic
   if index == 8730 then
-    local horizontal_scale = tex.getcount("M at surd@horizontal at factor") / 1000
-    local vertical_scale = tex.getcount("M at surd@vertical at factor") / 1000
+    local horizontal_scale = tex.getcount("M at SurdHorizontalFactor") / 1000
+    local vertical_scale = tex.getcount("M at SurdVerticalFactor") / 1000
     char.width = horizontal_scale * char.width
     char.height = vertical_scale * height
   end
   if index == 8747 then
-    local scale_factor = tex.getcount("M at integral@italic at factor") / 1000
+    local scale_factor = tex.getcount("M at IntegralItalicFactor") / 1000
     char.italic = scale_factor * width
   end
 end
@@ -1519,7 +1540,7 @@
   local rule_thickness = 0
   local dim = "FractionRuleThickness"
   if not fontdata.MathConstants[dim] then
-    local scale_factor = tex.getcount("M at rule@thickness at factor") / 1000
+    local scale_factor = tex.getcount("M at RuleThicknessFactor") / 1000
     rule_thickness = (size / 18) * scale_factor
     fontdata.MathConstants[dim] = rule_thickness
   else
@@ -1825,32 +1846,32 @@
 mathfont:new_type_a(122, 1044505, {100, 50, -100, 0})  % z
 mathfont:new_type_a(305, 1044506, {100, 100, -150, 0}) % \imath
 mathfont:new_type_a(567, 1044507, {700, 50, -150, 0})  % \jmath
-mathfont:new_type_a(65, 1044512, {50, 0, 150, 0})  % A
-mathfont:new_type_a(66, 1044513, {50, 0, 0, 0})    % B
-mathfont:new_type_a(67, 1044514, {0, 0, 0, 0})     % C
-mathfont:new_type_a(68, 1044515, {50, 0, -50, 0})  % D
-mathfont:new_type_a(69, 1044516, {50, 0, 0, 0})    % E
-mathfont:new_type_a(70, 1044517, {50, 0, 0, 0})    % F
-mathfont:new_type_a(71, 1044518, {0, 0, 0, 0})     % G
-mathfont:new_type_a(72, 1044519, {50, 0, -50, 0})  % H
-mathfont:new_type_a(73, 1044520, {100, 0, 0, 0})   % I
-mathfont:new_type_a(74, 1044521, {50, 0, 100, 0})  % J
-mathfont:new_type_a(75, 1044522, {50, 0, 0, 0})    % K
-mathfont:new_type_a(76, 1044523, {50, 0, -180, 0}) % L
-mathfont:new_type_a(77, 1044524, {50, 0, -50, 0})  % M
-mathfont:new_type_a(78, 1044525, {50, 0, -50, 0})  % N
-mathfont:new_type_a(79, 1044526, {0, 0, 0, 0})     % O
-mathfont:new_type_a(80, 1044527, {0, 0, -50, 0})   % P
-mathfont:new_type_a(81, 1044528, {0, 50, 0, 0})    % Q
-mathfont:new_type_a(82, 1044529, {50, 0, -50, 0})  % R
-mathfont:new_type_a(83, 1044530, {0, 0, -50, 0})   % S
-mathfont:new_type_a(84, 1044531, {0, 0, -50, 0})   % T
-mathfont:new_type_a(85, 1044532, {0, 0, -50, 0})   % U
-mathfont:new_type_a(86, 1044533, {0, 50, 0, 0})    % V
-mathfont:new_type_a(87, 1044534, {0, 50, -50, 0})  % W
-mathfont:new_type_a(88, 1044535, {50, 0, 0, 0})    % X
-mathfont:new_type_a(89, 1044536, {0, 0, -50, 0})   % Y
-mathfont:new_type_a(90, 1044537, {50, 0, -50, 0})  % Z
+mathfont:new_type_a(65, 1044512, {50, 0, 150, 0})      % A
+mathfont:new_type_a(66, 1044513, {50, 0, 0, 0})        % B
+mathfont:new_type_a(67, 1044514, {0, 0, 0, 0})         % C
+mathfont:new_type_a(68, 1044515, {50, 0, -50, 0})      % D
+mathfont:new_type_a(69, 1044516, {50, 0, 0, 0})        % E
+mathfont:new_type_a(70, 1044517, {50, 0, 0, 0})        % F
+mathfont:new_type_a(71, 1044518, {0, 0, 0, 0})         % G
+mathfont:new_type_a(72, 1044519, {50, 0, -50, 0})      % H
+mathfont:new_type_a(73, 1044520, {100, 0, 0, 0})       % I
+mathfont:new_type_a(74, 1044521, {50, 0, 100, 0})      % J
+mathfont:new_type_a(75, 1044522, {50, 0, 0, 0})        % K
+mathfont:new_type_a(76, 1044523, {50, 0, -180, 0})     % L
+mathfont:new_type_a(77, 1044524, {50, 0, -50, 0})      % M
+mathfont:new_type_a(78, 1044525, {50, 0, -50, 0})      % N
+mathfont:new_type_a(79, 1044526, {0, 0, 0, 0})         % O
+mathfont:new_type_a(80, 1044527, {0, 0, -50, 0})       % P
+mathfont:new_type_a(81, 1044528, {0, 50, 0, 0})        % Q
+mathfont:new_type_a(82, 1044529, {50, 0, -50, 0})      % R
+mathfont:new_type_a(83, 1044530, {0, 0, -50, 0})       % S
+mathfont:new_type_a(84, 1044531, {0, 0, -50, 0})       % T
+mathfont:new_type_a(85, 1044532, {0, 0, -50, 0})       % U
+mathfont:new_type_a(86, 1044533, {0, 50, 0, 0})        % V
+mathfont:new_type_a(87, 1044534, {0, 50, -50, 0})      % W
+mathfont:new_type_a(88, 1044535, {50, 0, 0, 0})        % X
+mathfont:new_type_a(89, 1044536, {0, 0, -50, 0})       % Y
+mathfont:new_type_a(90, 1044537, {50, 0, -50, 0})      % Z
 mathfont:new_type_u(945, {0, 0})    % \alpha
 mathfont:new_type_u(946, {0, 0})    % \beta
 mathfont:new_type_u(947, {-50, 0})  % \gamma
@@ -2562,8 +2583,8 @@
   \DeclareMathSymbol{-}{\mathbin}{\M at symbols@font}{"2212}
   \DeclareMathSymbol{*}{\mathbin}{\M at symbols@font}{"2A}
   \DeclareMathSymbol{\times}{\mathbin}{\M at symbols@font}{"D7}
-  \DeclareMathSymbol{/}{\mathbin}{\M at symbols@font}{"2F}
-  \DeclareMathSymbol{\fractionslash}{\mathbin}{\M at symbols@font}{"2215}
+  \DeclareMathSymbol{/}{\mathord}{\M at symbols@font}{"2F}
+  \DeclareMathSymbol{\fractionslash}{\mathord}{\M at symbols@font}{"2215}
   \DeclareMathSymbol{\div}{\mathbin}{\M at symbols@font}{"F7}
   \DeclareMathSymbol{\pm}{\mathbin}{\M at symbols@font}{"B1}
   \DeclareMathSymbol{\bullet}{\mathbin}{\M at symbols@font}{"2022}



More information about the tex-live-commits mailing list.