summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mathfont
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-09-12 03:01:04 +0000
committerNorbert Preining <norbert@preining.info>2023-09-12 03:01:04 +0000
commitbecf79ac9bbdddd15ef9d66a35c6d64252a2cd46 (patch)
tree8d5a60061f6aef780c147dcc82674a5652be9b75 /macros/latex/contrib/mathfont
parentf2abd8392e16d9b51a73c3c09b322ddde8b9be9e (diff)
CTAN sync 202309120301
Diffstat (limited to 'macros/latex/contrib/mathfont')
-rw-r--r--macros/latex/contrib/mathfont/README.txt13
-rw-r--r--macros/latex/contrib/mathfont/mathfont_code.dtx917
-rw-r--r--macros/latex/contrib/mathfont/mathfont_code.pdfbin371600 -> 377615 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_example_cormorant.pdfbin51345 -> 51361 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_example_kelvinch.pdfbin85079 -> 84682 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_example_roboto.pdfbin54420 -> 54396 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_example_typey.pdfbin47470 -> 47469 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_symbol_list.pdfbin180972 -> 181157 bytes
-rw-r--r--macros/latex/contrib/mathfont/mathfont_user_guide.pdfbin116189 -> 118518 bytes
9 files changed, 515 insertions, 415 deletions
diff --git a/macros/latex/contrib/mathfont/README.txt b/macros/latex/contrib/mathfont/README.txt
index 497feab233..de934e84c4 100644
--- a/macros/latex/contrib/mathfont/README.txt
+++ b/macros/latex/contrib/mathfont/README.txt
@@ -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.
*********************************************************
diff --git a/macros/latex/contrib/mathfont/mathfont_code.dtx b/macros/latex/contrib/mathfont/mathfont_code.dtx
index c2e87863dd..a3acd6fecf 100644
--- a/macros/latex/contrib/mathfont/mathfont_code.dtx
+++ b/macros/latex/contrib/mathfont/mathfont_code.dtx
@@ -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 @@ For more information, see mathfont_code.dtx. Happy TeXing!
\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 @@ For more information, see mathfont_code.dtx. Happy TeXing!
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{enumitem}
+\usepackage{soul}
+\setlist{itemsep=\smallskipamount,topsep=\smallskipamount,
+ parsep=\z@,partopsep=\z@}
\c@IndexColumns=2
\c@topnumber\@ne
\columnsep=20pt
@@ -285,7 +288,7 @@ For more information, see mathfont_code.dtx. Happy TeXing!
% \fi
%
%
-% \CheckSum{6631}
+% \CheckSum{6640}
% \init@checksum
%
%
@@ -330,7 +333,7 @@ For more information, see mathfont_code.dtx. Happy TeXing!
% \mathgroup,\nolimits,\on@line,\PackageWarningNoLine,\RequirePackage,%
% \thr@@,\M@toks,\inputlineno,\mathchar@type,\DeclareMathAccent,%
% \ifM@EasterEgg@declare,\M@EasterEgg@declaretrue,\M@EasterEgg@declarefalse,%
-% \IfFileExists,\E@sterEggHook,\@gobblefour,\@gobbletwo@brackets,%
+% \IfFileExists,\E@sterEggHook,\@gobblefour,\@gobble@brackets,%
% \protected,\@eha,\@cclv,\new@mathgroup,\new@symbolfont,\@latex@error,%
% \ifcase,\or,\thr@@,\gdef,\rmdefault,\openin,\closein,\immediate,%
% \M@Decl@reF@milytrue,\M@Decl@reF@milyfalse,\itdefault,\shapedefault,%
@@ -394,52 +397,74 @@ For more information, see mathfont_code.dtx. Happy TeXing!
% 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@XeTeXLuaTeX % is engine one of xetex or luatex?
\newif\ifM@Noluaotfload % cannot find luaotfload.sty?
\newif\ifM@adjust@font % should adjust fonts with lua script?
\newif\ifM@font@loaded % load mathfont with font specified?
\newif\ifE@sterEggDecl@red % already did easter egg?
+\newcount\M@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@brackets[#1]#2{}
+\long\def\@gobble@brackets[#1]{}
\def\M@NoMathfontError#1{\PackageError{mathfont}
{\MessageBreak Invalid command\MessageBreak
\string#1 on line \the\inputlineno}
{Your command was ignored. I couldn't\MessageBreak
load mathfont, so I never defined this\MessageBreak
control sequence.}}
-\protected\def\mathfont{\M@NoMathfontError\mathfont
- \@ifnextchar[\@gobbletwo@brackets\@gobble}
-\protected\def\setfont{\M@NoMathfontError\setfont\@gobble}
-\protected\def\mathconstantsfont{\M@NoMathfontError\mathconstantsfont
- \@ifnextchar[\@gobbletwo@brackets\@gobble}
-\protected\def\newmathrm{\M@NoMathfontError\newmathrm\@gobbletwo}
-\protected\def\newmathit{\M@NoMathfontError\newmathit\@gobbletwo}
-\protected\def\newmathbf{\M@NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbfit{\M@NoMathfontError\newmathbf\@gobbletwo}
-\protected\def\newmathbold{\M@NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathboldit{\M@NoMathfontError\newmathbold\@gobbletwo}
-\protected\def\newmathsc{\M@NoMathfontError\newmathsc\@gobbletwo}
-\protected\def\newmathscit{\M@NoMathfontError\newmathscit\@gobbletwo}
-\protected\def\newmathbfsc{\M@NoMathfontError\newmathbfsc\@gobbletwo}
-\protected\def\newmathbfscit{\M@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@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@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@NoMathfontError
+ \expandafter\noexpand\@i
+ \noexpand\@ifnextchar[{\noexpand\expandafter
+ \noexpand\@gobble\noexpand\@gobble@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@NoMathfontError\newmathfontcommand\@gobblefour}
-\protected\def\RuleThicknessFactor{%
- \M@NoMathfontError\RuleThicknessFactor\@gobble}
-\protected\def\IntegralItalicFactor{%
- \M@NoMathfontError\IntegralItalicFactor\@gobble}
-\protected\def\SurdVerticalFactor{%
- \M@NoMathfontError\SurdVerticalFactor\@gobble}
-\protected\def\SurdHorizontalFactor{%
- \M@NoMathfontError\SurdHorizontalFactor\@gobble}
-\protected\def\CharmLine{\M@NoMathfontError\CharmLine\@gobble}
-\protected\def\CharmFile{\M@NoMathfontError\CharmFile\@gobble}
% \end{macrocode}
% Check that the engine is \XeTeX\ or Lua\TeX. If yes, set |\ifM@XeTeXLuaTeX| to true. (Otherwise the conditional will be false by default.)
% \begin{macrocode}
@@ -450,7 +475,7 @@ For more information, see mathfont_code.dtx. Happy TeXing!
\M@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@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@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@XeTeXLuaTeX\else
\begingroup
@@ -489,12 +514,12 @@ document with one of those two engines.^^J}}%
\IfFileExists{luaotfload.sty}
{\M@Noluaotfloadfalse\RequirePackage{luaotfload}}{\M@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,7 +619,12 @@ by TeX or compile with XeLaTeX.^^J}}%
\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@loader\z@}
+\DeclareOption{fontspec-loader}{\M@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@adjust@fonttrue}
\DeclareOption{no-adjust}{\M@adjust@fontfalse}
@@ -604,32 +634,91 @@ by TeX or compile with XeLaTeX.^^J}}%
\DeclareOption*{\M@font@loadedtrue\edef\M@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@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@loader\z@}}
+\fi
+% \end{macrocode}
+% We print an informational message specifying the font-loader in use. We store default OpenType features in |\M@otf@features|. The contents depend on the font-loader because we use \XeTeX/\textsf{luaotfload} syntax versus \textsf{fontspec} syntax. By default, \textsf{mathfont} loads fonts with Latin script, default language, \TeX\ and common ligatures, and lining numbers.
+% \begin{macrocode}
+\ifcase\M@loader
+ \wlog{Package mathfont Info: Using default font-loader.}
+ \AtEndOfPackage{\typeout{:: mathfont :: Using default font-loader.}}
+ \def\M@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@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@adjust@font|.
% \begin{macrocode}
\ifdefined\directlua
\ifM@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@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@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 @@ by TeX or compile with XeLaTeX.^^J}}%
% \begin{tabularx}\textwidth{lX}
% \toprule
% Command & Use\\\midrule
-% \vrb\M@FontChangeInfo & Use a symbol font for some characters\\
+% \vrb\M@FontChangeInfo & Use a symbol font inside \vrb\mathfont\\
% \vrb\M@NewFontCommandInfo & Declare new alphanumeric font-change command\\
% \vrb\M@SymbolFontInfo & Declare new symbol font\\\midrule
% \vrb\M@CharsSetWarning & Warning when calling \vrb\mathfont\ multiple times for same keyword\\
-% \vrb\M@InternalsRestoredError & User called \vrb\mathfont\ after restoring kernel\\
+% \vrb\M@InternalsRestoredError & User called \vrb\mathfont\ after restoring kernel\\\midrule
+% \vrb\M@MissingNFSSShapesWarning & Warning if font is missing shapes\\
+% \vrb\M@NoBaseModeDetectedWarning & Warning if no base-mode version of a font\\\midrule
% \vrb\M@InvalidOptionError & Bad option for \vrb\mathfont\\
% \vrb\M@InvalidSupoptionError & Bad suboption for \vrb\mathfont\\
% \vrb\M@MissingOptionError & Missing an option for \vrb\mathfont\\
@@ -659,9 +750,7 @@ by TeX or compile with XeLaTeX.^^J}}%
% \vrb\M@DeprecatedWarning & Warning for certain deprecated macros\\
% \vrb\M@DoubleArgError & Gave multiple tokens to be the font-change macro\\
% \vrb\M@HModeError & Font-change command used outside math mode\\
-% \vrb\M@MissingControlSequenceError & No macro provided to be font-change command\\
-% \vrb\M@NoFontspecFamilyError & Improper option \texttt{fontspec} for \vrb\mathfont\\
-% \vrb\M@NoFontspecError & Option \texttt{fontspec} for \vrb\mathfont\ declared without having loaded \textsf{fontspec}\\\midrule
+% \vrb\M@MissingControlSequenceError & No macro provided to be font-change command\\\midrule
% \vrb\M@BadIntegerError & Font metric adjustment value was not an integer\\
% \vrb\M@ForbiddenCharmFile & Charm file contains a bad character\\
% \vrb\M@ForbiddenCharmLine & Charm line contains a bad character\\
@@ -687,6 +776,18 @@ by TeX or compile with XeLaTeX.^^J}}%
#1 chars, so I'm ignoring\MessageBreak
this option for \string\mathfont\space
on line \the\inputlineno\@gobble}}
+\def\M@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@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 @@ by TeX or compile with XeLaTeX.^^J}}%
\def\M@MissingSuboptionError{\PackageError{mathfont}
{Missing^^Jsuboption for \string\mathfont\on@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@InternalsRestoredError{\PackageError{mathfont}
{Internal^^Jcommands restored}
{This package slightly changes two LaTeX\MessageBreak
@@ -746,35 +847,15 @@ by TeX or compile with XeLaTeX.^^J}}%
Try typesetting this document with all\MessageBreak
\string\mathfont\space commands placed before you call\MessageBreak
\string\restoremathinternals.^^J}}
-\def\M@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@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}
% \indexpage{your mathconstants on line=Your \texttt{\char`\\mathconstants} on line}
% \begin{macrocode}
\def\M@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 @@ by TeX or compile with XeLaTeX.^^J}}%
{The optional argument of \string\mathconstantsfont\MessageBreak
should be "upright" or "italic." Right now,\MessageBreak
it's "#1."^^J}}
-\def\M@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@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 @@ by TeX or compile with XeLaTeX.^^J}}%
%
% \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@mathchar\set@mathchar
@@ -910,9 +981,9 @@ by TeX or compile with XeLaTeX.^^J}}%
\protected\xdef#2{%
\Umathaccent\mathchar@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@mathgroup@top|, where |\e@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@prefix|, implement the patch by expanding |\M@p@tch@decl@re|, and retokenize the whole thing. A simpler approach, such as calling |\M@p@tch@decl@re| directly on the expansion of |\DeclareSymbolFont|, won't work because of 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@mathgroup@top|, where |\e@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@prefix|, implement the patch by expanding |\M@p@tch@decl@re|, and retokenize the whole thing. A simpler approach, such as calling |\M@p@tch@decl@re| directly on the expansion of |\DeclareSymbolFont|, won't work because of how \TeX\ stores and expands parameter symbols inside macros.
%
-% As of November 2022, the \LaTeX\ kernel has redefined |\DeclareSymbolFont@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@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@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@m@dropped| is defined, we should patch that macro, and otherwise, we should patch |\DeclareSymbolFont|.
% \begin{macrocode}
\ifx\DeclareSymbolFont@m@dropped\@undefined
\edef\@tempa{\expandafter\strip@prefix\meaning\DeclareSymbolFont}
@@ -948,18 +1019,18 @@ by TeX or compile with XeLaTeX.^^J}}%
% \begin{macrocode}
\newbox\surdbox
\newcount\M@count
-\newcount\M@rule@thickness@factor
-\newcount\M@integral@italic@factor
-\newcount\M@surd@vertical@factor
-\newcount\M@surd@horizontal@factor
+\newcount\M@RuleThicknessFactor
+\newcount\M@IntegralItalicFactor
+\newcount\M@SurdVerticalFactor
+\newcount\M@SurdHorizontalFactor
\newmuskip\radicandoffset
\newread\M@Charm
\newtoks\M@toks
\M@count\z@
-\M@rule@thickness@factor\@m
-\M@integral@italic@factor=400\relax
-\M@surd@horizontal@factor\@m
-\M@surd@vertical@factor\@m
+\M@RuleThicknessFactor\@m
+\M@IntegralItalicFactor=400\relax
+\M@SurdHorizontalFactor\@m
+\M@SurdVerticalFactor\@m
\radicandoffset=3mu\relax
% \end{macrocode}
% Necessary booleans and default math font shapes.
@@ -992,7 +1063,6 @@ by TeX or compile with XeLaTeX.^^J}}%
\newif\if@suboptionpresent
\newif\ifM@arg@good
\newif\ifM@Decl@reF@mily
-\newif\ifM@Decl@reF@milyB@se
\newif\ifM@fromCharmFile
% \end{macrocode}
% Default shapes.
@@ -1040,179 +1110,183 @@ by TeX or compile with XeLaTeX.^^J}}%
\edef\M@defaultkeys{\M@defaultkeys,delimiters,radical,bigops}
\fi
% \end{macrocode}
-% Default OpenType features for loading fonts.
-% \begin{macrocode}
-\def\M@otf@features{script=latin;language=DFLT;%
- tlig=true;liga=true;smcp=false;lnum=true}
-\def\M@otf@features@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@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@newfont| directly because it may change without warning. Instead call |\mathfont| with the |empty| keyword and extract the \textsc{nfss} family name from |\M@f@ntn@me| or |\M@f@ntn@meb@se|. Our general approach is to feed the mandatory argument of |\mathfont| to |\M@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@f@ntn@me| and |\M@f@nt@n@me@base|.
+% We come to the fontloader. The main font-loading macro is |\M@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@f@ntn@me| and |\M@f@nt@n@me@base|. (Advanced users: please do not call |\M@newfont| directly because its implementation may change. Instead call |\mathfont| with the |empty| keyword and extract the \textsc{nfss} family name from |\M@f@ntn@me| or |\M@f@ntn@meb@se|.) Our general approach is to feed the mandatory argument of |\mathfont| to |\M@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@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@f@ntn@me|, and |\M@f@nt@n@me@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@f@ntn@me|, it is possible to find the corresponding base-mode family name by calling |\csname|\penalty0|\M@f@ntn@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@split@colon| and |\M@strip@colon| for parsing the argument of |\mathfont|. If the user calls |\mathfont{|\meta{name}|:|\meta{features}|}|, we store the name in |\@tempbase| and the features in |\@tempfeatures|. If the user specifies a name only, then |\@tempfeatures| will be empty. Syntactically, we use |\M@strip@colon| to remove a final |:| the same way we removed a final |=| when we parsed the optional argument in the previous section.
-% \?\@tempfeatures\?\@tempbase
-% \begin{macrocode}
-\def\M@split@colon#1:#2\@nil{\def\@tempbase{#1}
- \def\@tempfeatures{#2}}
-\def\M@strip@colon#1:{#1}
-% \end{macrocode}
-% The macro |\M@fill@nfss@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|.
-% \begin{macrocode}
-\def\M@fill@nfss@shapes#1#2{%
-% \end{macrocode}
-% Upright shape.
-% \begin{macrocode}
- \ifcsname TU/#1/\mddefault/\shapedefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\mddefault}{\shapedefault}
- {<->"\@tempbase:\M@otf@features;#2"}{}
- \fi
-% \end{macrocode}
-% Italic shape.
+% We begin with commands to add series and shape information to the \textsc{nfss} for a given font family. The |\M@declare@shape| macro takes several arguments. It checks whether the series/shape pair exists in the \textsc{nfss}, and if not, it adds it using |\DeclareFontShape|. The argument structure is
+% \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}
- \ifcsname TU/#1/\mddefault/\itdefault\endcsname
+\def\M@declare@shape#1#2#3#4#5#6{%
+ \ifcsname TU/#1/#5/#6\endcsname
\else
- \DeclareFontShape{TU}{#1}{\mddefault}{\itdefault}
- {<->"\@tempbase/I:\M@otf@features;#2"}{}
- \fi
+ \DeclareFontShape{TU}{#1}{#5}{#6}{<->"\@tempbase#2:#3;#4"}{}
+ \fi}
% \end{macrocode}
-% Bold series with upright shape.
-% \begin{macrocode}
- \ifcsname TU/#1/\bfdefault/\shapedefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\bfdefault}{\shapedefault}
- {<->"\@tempbase/B:\M@otf@features;#2"}{}
- \fi
+% The |\M@fill@nfss@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@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@fill@nfss@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}
+% 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}
+ {#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@declare@shape\@i}}
+% \end{macrocode}
+% The |\M@check@nfss@shapes| macro checks if a font family has shapes declared in upright, italic, bold, and bold italic. If any of those shapes are missing, we issue a warning. We store the missing series/shape pairs in |\@tempb| to print them as part of the warning message.
+% \begin{macrocode}
+\def\M@check@nfss@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@MissingNFSSShapesWarning{#1}}
+ \edef\@tempb{\@tempb, \@i}
+ \fi}
% \end{macrocode}
-% Bold series with italic 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/\itdefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\bfdefault}{\itdefault}
- {<->"\@tempbase/BI:\M@otf@features;#2"}{}
- \fi
+ \@tempwarning{\expandafter\@gobble\@tempb}}
% \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.
+% We use |\M@split@colon| and |\M@strip@colon| for parsing the argument of |\mathfont|. If the user calls |\mathfont{|\meta{name}|:|\meta{features}|}|, we store the name in |\@tempbase| and the features in |\@tempfeatures|. If the user specifies a name only, then |\@tempfeatures| will be empty. Syntactically, we use |\M@strip@colon| to remove a final |:| the same way we remove\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/\mddefault/\scdefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault}
- {<->"\@tempbase:\M@otf@features@sc;#2"}{}
- \fi
- \ifcsname TU/#1/\mddefault/\scdefault\itdefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\mddefault}{\scdefault\itdefault}
- {<->"\@tempbase/I:\M@otf@features@sc;#2"}{}
- \fi
- \ifcsname TU/#1/\bfdefault/\scdefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault}
- {<->"\@tempbase/B:\M@otf@features@sc;#2"}{}
- \fi
- \ifcsname TU/#1/\bfdefault/\scdefault\itdefault\endcsname
- \else
- \DeclareFontShape{TU}{#1}{\bfdefault}{\scdefault\itdefault}
- {<->"\@tempbase/BI:\M@otf@features@sc;#2"}{}
- \fi}
+\def\M@split@colon#1:#2\@nil{\def\@tempbase{#1}
+ \def\@tempfeatures{#2}}
+\def\M@strip@colon#1:{#1}
% \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@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|.
+% 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}
\def\M@newfont#1{%
\edef\@tempa{#1}
\expandafter\M@split@colon\@tempa:\@nil
- \def\@tempb{fontspec}
+ \ifx\@tempfeatures\@empty\else
+ \edef\@tempfeatures{\expandafter\M@strip@colon\@tempfeatures}
+ \fi
+% \end{macrocode}
+% First we check if the argument is an entry in the \textsc{nfss}. If yes, we check if the shapes are present using |\M@check@nfss@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}
+ \ifcsname TU+\@tempbase\endcsname % is font family already in nfss?
+ \let\M@f@ntn@me\@tempbase
+ \M@check@nfss@shapes\M@f@ntn@me
+ \ifx\directlua\@undefined % if XeTeX
+ \expandafter\edef\csname\M@f@ntn@me-base\endcsname{\M@f@ntn@me}
+ \let\M@f@ntn@meb@se\M@f@ntn@me
+ \else % if LuaTeX
% \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@f@ntn@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.
+% 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}
- \ifx\@tempa\@tempb
- \@ifpackageloaded{fontspec}{%
- \expandafter\ifx\csname l_fontspec_family_tl\endcsname\@empty
- \M@NoFontspecFamilyError
+ \ifcsname\M@f@ntn@me-base\endcsname % if base-mode version is known
+ \edef\M@f@ntn@meb@se{\csname\M@f@ntn@me-base\endcsname}
+ \M@check@nfss@shapes\M@f@ntn@meb@se
\else
- \expandafter
- \let\expandafter\M@f@ntn@me\csname l_fontspec_family_tl\encsname
- \def\@tempbase{\M@f@ntn@me\space(from fontspec)}
- \let\M@f@ntn@meb@se\M@f@ntn@me % no separate font in base mode
- \fi}{\M@NoFontspecError}
+ \M@NoBaseModeDetectedWarning{\M@f@ntn@me}
+ \edef\M@f@ntn@meb@se{\M@f@ntn@me}
+ \expandafter\edef\csname\M@f@ntn@me-base\endcsname{\M@f@ntn@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@f@ntn@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@fontfamily@\@tempbase\endcsname
+ {\M@f@ntn@me}
+ \expandafter\edef\csname M@fontfamily@base@\@tempbase\endcsname
+ {\M@f@ntn@meb@se}
\else
- \@ifpackageloaded{fontspec}
- {\csname fontspec_set_family:Nnn\endcsname\M@f@ntn@me{}{\@tempa}
- % no separate font in base mode
- \let\M@f@ntn@meb@se\M@f@ntn@me}
% \end{macrocode}
-% If the user has not loaded \textsf{fontspec}, we split the argument into a name and features using |\M@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@fontfamily@|\meta{arg}, and we use the font family name from the previous call to |\M@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@Decl@reF@milytrue
- \M@Decl@reF@milyB@setrue
- \ifx\@tempfeatures\@empty
- \ifdefined\directlua
- \edef\@basefeatures{mode=base}
- \else
- \let\@basefeatures\@tempfeatures
- \fi
- \else
- \edef\@tempfeatures{\expandafter\M@strip@colon\@tempfeatures}
- \ifdefined\directlua
- \edef\@basefeatures{\@tempfeatures;mode=base}
- \else
- \let\@basefeatures\@tempfeatures
- \fi
- \fi
+ \edef@nospace\@tempa{\@tempa}
+ \ifcsname M@fontfamily@\@tempa\endcsname
+ \edef\M@f@ntn@me{\csname M@fontfamily@\@tempa\endcsname}
+ \edef\M@f@ntn@meb@se{\csname M@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@fill@nfss@shapes| to ensure that we have declared all the shapes. In this case, we set |\ifM@Decl@reF@mily| to false and break out of the |\@tfor| loop.
-% \begin{macrocode}
- \edef@nospace\@tempa{\@tempa}
- \edef@nospace\@tempb{\@tempbase}
- \M@Decl@reF@milytrue
- \@tfor\@i:=\@tempa\@tempb\@tempbase\do{%
- \ifcsname TU+\@i\endcsname
- \expandafter\let\expandafter\M@f@ntn@me\@i
- \M@Decl@reF@milyfalse
- \M@fill@nfss@shapes\M@f@ntn@me\@tempfeatures
- \@break@tfor
- \fi}
-% \end{macrocode}
-% If |\M@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|.
+% If |\M@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@f@ntn@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@fill@nfss@shapes| to declare all the shapes.
% \indexpage{log file=\texttt{log} file}
% \begin{macrocode}
- \ifM@Decl@reF@mily
+ \edef@nospace\@tempa{\@tempa}
+ \ifcase\M@loader % are we using default font-loader?
\let\M@f@ntn@me\@tempa
- \wlog{Package mathfont Info: Adding \M@f@ntn@me\space to the nfss!}
+ \wlog{Package mathfont Info: Adding \@tempbase\space to the nfss!}
+ \wlog{Family name: \M@f@ntn@me}
\DeclareFontFamily{TU}{\M@f@ntn@me}{}
+ \M@fill@nfss@shapes{\M@f@ntn@me}{\M@otf@features}{\@tempfeatures}
% \end{macrocode}
-% Now load the four most common font faces with |\M@fill@nfss@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@fill@nfss@shapes\M@f@ntn@me\@tempfeatures
- \fi
+ \ifdefined\directlua
+ \edef\M@f@ntn@meb@se{\M@f@ntn@me-base}
+ \wlog{Package mathfont Info: Adding \@tempbase with mode=base
+ to the nfss!}
+ \wlog{Family name: \M@f@ntn@meb@se}
+ \DeclareFontFamily{TU}{\M@f@ntn@meb@se}{}
+ \M@fill@nfss@shapes
+ {\M@f@ntn@meb@se}{\M@otf@features}{\@tempfeatures;mode=base}
+ \else
+ \edef\M@f@ntn@meb@se{\M@f@ntn@me}
+ \fi
+ \or % are we using fontspec as font-loader?
% \end{macrocode}
-% At this point, there is an entry for the font in the \textsc{nfss}, and we stored the family name in |\M@f@ntn@me|. Now we check if the \textsc{nfss} contains a base-mode version with the family name ending in |-base|.
+% If the user requested \textsf{fontspec} as the font-loader, we pass the font name and features to |\fontspec_set_family:Nnn| for loading and store the \textsc{nfss} family name in |\M@f@ntn@me|. In Lua\TeX, we request a separate base-mode version by specifying |Renderer=Base|.
% \begin{macrocode}
- \ifdefined\directlua
- \edef\M@f@ntn@meb@se{\M@f@ntn@me-base}
- \else
- \let\M@f@ntn@meb@se\M@f@ntn@me
- \fi
- \ifcsname TU+\M@f@ntn@meb@se\endcsname\else
- \wlog{Package mathfont Info: Adding \M@f@ntn@meb@se\space
- to the nfss!}
- \DeclareFontFamily{TU}{\M@f@ntn@meb@se}{}
+ \wlog{Package mathfont Info: Passing \@tempbase\space to fontspec
+ for handling!}
+ \csname fontspec_set_family:Nnn\endcsname\M@f@ntn@me
+ {\M@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@f@ntn@meb@se
+ {\M@otf@features,\@tempfeatures,Renderer=Base}{\@tempbase}
+ \else
+ \edef\M@f@ntn@meb@se{\M@f@ntn@me}
+ \fi
\fi
- \M@fill@nfss@shapes\M@f@ntn@meb@se\@basefeatures}
+% \end{macrocode}
+% Now link the base-mode family name and store the family names for future reference.
+% \begin{macrocode}
+ \expandafter\edef\csname\M@f@ntn@me-base\endcsname{\M@f@ntn@meb@se}
+ \expandafter\edef\csname M@fontfamily@\@tempa\endcsname
+ {\M@f@ntn@me}
+ \expandafter\edef\csname M@fontfamily@base@\@tempa\endcsname
+ {\M@f@ntn@meb@se}
+ \fi
\fi}
% \end{macrocode}
% Finally, the font-loading commands should appear only in the preamble.
% \begin{macrocode}
+\@onlypreamble\M@declare@shape
\@onlypreamble\M@fill@nfss@shapes
\@onlypreamble\M@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 @@ by TeX or compile with XeLaTeX.^^J}}%
\else
\M@toks{}
% \end{macrocode}
-% We immediately call |\M@newfont| on the mandatory argument of |\mathfont|. We store the \textsc{nfss} family name in |\M@fontfamily@|\meta{argument} and |M@fontfamily@base@|\meta{argument}. If we need a new value of |\M@count|, we store it in |\M@fontid@|\meta{\textsc{nfss} family name}. We will not need a new value of |\M@count| if the user asks for the same \textsc{nfss} font family twice. Throughout the definition of |\mathfont|, |\@tempa| stores the value of |\M@count| that corresponds to the current font.
+% We call |\M@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@f@ntn@me| and |\M@f@ntn@meb@se|. If we need a new value of |\M@count|, we store it in |\M@fontid@|\meta{\textsc{nfss} family name}. We will not need a new value of |\M@count| if the user asks for the same \textsc{nfss} font family twice. Throughout the definition of |\mathfont|, |\@tempa| stores the value of |\M@count| that corresponds to the current font.
% \indexpage{keyword options=keyword options for \texttt{\char`\\mathfont}}
% \begin{macrocode}
\M@newfont{#2}
- \expandafter\edef\csname M@fontfamily@#2\endcsname{\M@f@ntn@me}
- \expandafter\edef\csname M@fontfamily@base@#2\endcsname{\M@f@ntn@meb@se}
\ifcsname M@fontid@\M@f@ntn@me\endcsname\else % need new \M@count value?
- \expandafter\edef\csname M@fontid@\M@f@ntn@me\endcsname{\the\M@count}
- \expandafter\let\csname M@fontid@\M@f@ntn@meb@se\expandafter\endcsname
- \csname M@fontid@\M@f@ntn@me\endcsname
+ \expandafter\edef\csname M@fontid@\M@f@ntn@me\endcsname{\the
+ \M@count}
+ \expandafter\edef\csname M@fontid@\M@f@ntn@meb@se\endcsname{\the
+ \M@count}
\advance\M@count\@ne
\fi
\edef\@tempa{\csname M@fontid@\M@f@ntn@me\endcsname}
@@ -1452,67 +1525,66 @@ by TeX or compile with XeLaTeX.^^J}}%
\let\rmdefault\M@f@ntn@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@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@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@SetMathConstants\relax
- \protected\def\mathconstantsfont{%
- \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
- \def\@mathconstantsfont[#1]#2{%
- \edef\@tempa{\csname M@fontfamily@base@#2\endcsname}
- \expandafter\ifx\@tempa\relax
- \M@BadMathConstantsFontError{#2}
- \else
+\let\M@SetMathConstants\relax
+\protected\def\mathconstantsfont{%
+ \@ifnextchar[{\@mathconstantsfont}{\@mathconstantsfont[upright]}}
+\def\@mathconstantsfont[#1]#2{%
+ \edef@nospace\@tempa{#2}
+ \edef\@tempa{\csname M@fontfamily@base@\@tempa\endcsname}
+ \expandafter\ifx\@tempa\relax
+ \M@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@SetMathConstants| if necessary, we store the \textsc{nfss} family name in |\m@th@const@nts@font|.
% \begin{macrocode}
- \def\@tempb{#1}
- \def\@tempc{upright}
+ \def\@tempb{#1}
+ \def\@tempc{upright}
+ \ifx\@tempb\@tempc
+ \let\m@th@const@nts@font@sh@pe\shapedefault
+ \else
+ \def\@tempc{italic}
\ifx\@tempb\@tempc
- \let\m@th@const@nts@font@sh@pe\shapedefault
+ \let\m@th@const@nts@font@sh@pe\itdefault
\else
- \def\@tempc{italic}
- \ifx\@tempb\@tempc
- \let\m@th@const@nts@font@sh@pe\itdefault
- \else
- \M@BadMathConstantsFontTypeError{#1}
- \fi
- \fi
- \ifcsname symM#1\csname M@fontid@\@tempa\endcsname\endcsname\else
- \DeclareSymbolFont{M#1\csname M@fontid@\@tempa\endcsname}
- {TU}{\@tempa}{\mddefault}{\m@th@const@nts@font@sh@pe}
+ \M@BadMathConstantsFontTypeError{#1}
\fi
- \let\m@th@const@nts@font\@tempa
+ \fi
+ \ifcsname symM#1\csname M@fontid@\@tempa\endcsname\endcsname\else
+ \DeclareSymbolFont{M#1\csname M@fontid@\@tempa\endcsname}
+ {TU}{\@tempa}{\mddefault}{\m@th@const@nts@font@sh@pe}
+ \fi
+ \let\m@th@const@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@fonts| repeatedly to append |\textfont|, etc.\ assignments onto the macro |\math@fonts|. Usually |\math@fonts| is empty because this process always happens inside a group, so we can hook into the code by defining |\math@font| to be |\aftergroup|\meta{extra code}. In this case, the \textit{extra code} will be another call to |\getanddefine@fonts|.
%
% We initialize |\M@SetMathConstants| to be |\relax|, so we define it the first time the user calls |\mathconstantsfont|. The command calls |\getanddefine@fonts| inside a group and uses as arguments the upright face of the font corresponding to |#1|. Then we call |\math@fonts|, and to avoid an infinite loop, we gobble the |\aftergroup||\M@SetMathConstants| macros that \textsf{mathfont} has inserted at the start of |\math@fonts|. Setting |\globaldefs| to 1 makes the |\textfont|, etc.\ assignments from |\getanddefine@fonts| global when we call |\math@fonts|.\indexpage{LaTeX kernel=\LaTeX\ kernel}^^A
% \begin{macrocode}
- \protected\def\M@SetMathConstants{%
- \begingroup
- \escapechar\m@ne
- \expandafter\getanddefine@fonts
- \csname symM#1\csname M@fontid@\m@th@const@nts@font\endcsname
- \expandafter
- \endcsname % expands to \symMupright<id>
- \csname TU/\m@th@const@nts@font
- /\seriesdefault
- /\m@th@const@nts@font@sh@pe
- \endcsname % expands to \TU/<nfss family name>/m/<shape>
- \globaldefs\@ne
- \expandafter\@gobbletwo\math@fonts % gobble to avoid infinite loop
- \endgroup}
- \fi}
- \def\math@fonts{\aftergroup\M@SetMathConstants}
-\else
- \protected\def\mathconstantsfont{\M@LuaTeXOnlyWarning
- \@ifnextchar[\@gobbletwo@brackets\@gobble}
-\fi
+ \protected\def\M@SetMathConstants{%
+ \begingroup
+ \escapechar\m@ne
+ \expandafter\getanddefine@fonts
+ \csname symM#1\csname M@fontid@\m@th@const@nts@font\endcsname
+ \expandafter
+ \endcsname % expands to \symMupright<id>
+ \csname TU/\m@th@const@nts@font
+ /\seriesdefault
+ /\m@th@const@nts@font@sh@pe
+ \endcsname % expands to \TU/<nfss family name>/m/<shape>
+ \globaldefs\@ne
+ \expandafter\@gobbletwo\math@fonts % gobble to avoid infinite loop
+ \endgroup}
+ \fi
+ \ifM@adjust@font\else
+ \M@MathConstantsNoFontAdjustWarning
+ \fi}
+\def\math@fonts{\aftergroup\M@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}
%
@@ -1543,7 +1615,7 @@ by TeX or compile with XeLaTeX.^^J}}%
\@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@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,45 +1711,24 @@ by TeX or compile with XeLaTeX.^^J}}%
\fi
\fi}
% \end{macrocode}
-% Define |\RuleThicknessFactor|.
-% \begin{macrocode}
- \protected\def\RuleThicknessFactor#1{%
- \M@check@int{#1}
- \ifM@arg@good
- \global\M@rule@thickness@factor=#1\relax
- \else
- \M@BadIntegerError\RuleThicknessFactor{#1}
- \fi}
-% \end{macrocode}
-% Define |\IntegralItalicFactor|.
-% \begin{macrocode}
- \protected\def\IntegralItalicFactor#1{%
- \M@check@int{#1}
- \ifM@arg@good
- \global\M@integral@italic@factor=#1\relax
- \else
- \M@BadIntegerError\IntegralItalicFactor{#1}
- \fi}
-% \end{macrocode}
-% Define |\SurdHorizontalFactor|.
-% \begin{macrocode}
- \protected\def\SurdHorizontalFactor#1{%
- \M@check@int{#1}
- \ifM@arg@good
- \global\M@surd@horizontal@factor=#1\relax
- \else
- \M@BadIntegerError\SurdHorizontalFactor{#1}
- \fi}
-% \end{macrocode}
-% Define |\SurdVerticalFactor|.
-% \begin{macrocode}
- \protected\def\SurdVerticalFactor#1{%
- \M@check@int{#1}
- \ifM@arg@good
- \global\M@surd@vertical@factor=#1\relax
- \else
- \M@BadIntegerError\SurdVerticalFactor{#1}
- \fi}
+% 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}
+ \let\@tempa~
+ \let~\noexpand
+ \count@\escapechar
+ \escapechar\m@ne
+ \@tfor\@i:=\RuleThicknessFactor\IntegralItalicFactor
+ \SurdHorizontalFactor\SurdVerticalFactor\do{%
+ \protected\expandafter\edef\@i#1{%
+ ~\M@check@int{#1}%
+ ~\ifM@arg@good
+ ~\global
+ \expandafter~\csname M@\expandafter\string\@i\endcsname=#1\relax
+ ~\else
+ ~\M@BadIntegerError\expandafter~\@i{#1}%
+ ~\fi}}
+ \let~\@tempa
+ \escapechar\count@
% \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@NoFontAdjustError| and gobble its argument.
% \begin{macrocode}
@@ -1741,22 +1792,6 @@ by TeX or compile with XeLaTeX.^^J}}%
\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@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@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@info@begindocument#1:#2\@nil{%
@@ -1802,6 +1837,22 @@ by TeX or compile with XeLaTeX.^^J}}%
\expandafter\keyword@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@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@font@loaded
@@ -1822,28 +1873,24 @@ by TeX or compile with XeLaTeX.^^J}}%
\@onlypreamble\M@hebrew@set
\@onlypreamble\M@digits@set
\@onlypreamble\M@operator@set
-\@onlypreamble\M@symbols@set
-\@onlypreamble\M@extsymbols@set
\@onlypreamble\M@delimiters@set
-\@onlypreamble\M@arrows@set
+\@onlypreamble\M@radical@set
\@onlypreamble\M@bigops@set
\@onlypreamble\M@extbigops@set
+\@onlypreamble\M@symbols@set
+\@onlypreamble\M@extsymbols@set
+\@onlypreamble\M@arrows@set
\@onlypreamble\M@bb@set
\@onlypreamble\M@cal@set
\@onlypreamble\M@frak@set
\@onlypreamble\M@bcal@set
\@onlypreamble\M@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 @@ function mathfont:modify_e_base(index, fontdata)
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@surd@horizontal@factor| and |\M@surd@vertical@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@SurdHorizontalFactor| and |\M@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@surd@horizontal@factor") / 1000
- local vertical_scale = tex.getcount("M@surd@vertical@factor") / 1000
+ local horizontal_scale = tex.getcount("M@SurdHorizontalFactor") / 1000
+ local vertical_scale = tex.getcount("M@SurdVerticalFactor") / 1000
char.width = horizontal_scale * char.width
char.height = vertical_scale * height
end
@@ -2370,7 +2417,7 @@ function mathfont:modify_e_base(index, fontdata)
% 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@integral@italic@factor") / 1000
+ local scale_factor = tex.getcount("M@IntegralItalicFactor") / 1000
char.italic = scale_factor * width
end
end
@@ -2609,11 +2656,11 @@ function mathfont.math_constants(fontdata)
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@rule@thickness@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@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@rule@thickness@factor") / 1000
+ local scale_factor = tex.getcount("M@RuleThicknessFactor") / 1000
rule_thickness = (size / 18) * scale_factor
fontdata.MathConstants[dim] = rule_thickness
else
@@ -3019,32 +3066,32 @@ mathfont:new_type_a(567, 1044507, {700, 50, -150, 0}) % \jmath
% \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 @@ mathfont:add_extensible_variants(smash, int_glyphs, int_scale)
\DeclareMathSymbol{-}{\mathbin}{\M@symbols@font}{"2212}
\DeclareMathSymbol{*}{\mathbin}{\M@symbols@font}{"2A}
\DeclareMathSymbol{\times}{\mathbin}{\M@symbols@font}{"D7}
- \DeclareMathSymbol{/}{\mathbin}{\M@symbols@font}{"2F}
- \DeclareMathSymbol{\fractionslash}{\mathbin}{\M@symbols@font}{"2215}
+ \DeclareMathSymbol{/}{\mathord}{\M@symbols@font}{"2F}
+ \DeclareMathSymbol{\fractionslash}{\mathord}{\M@symbols@font}{"2215}
\DeclareMathSymbol{\div}{\mathbin}{\M@symbols@font}{"F7}
\DeclareMathSymbol{\pm}{\mathbin}{\M@symbols@font}{"B1}
\DeclareMathSymbol{\bullet}{\mathbin}{\M@symbols@font}{"2022}
@@ -4678,7 +4725,7 @@ mathfont:add_extensible_variants(smash, int_glyphs, int_scale)
% \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,7 +4770,13 @@ mathfont:add_extensible_variants(smash, int_glyphs, int_scale)
%
% \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 @@ mathfont:add_extensible_variants(smash, int_glyphs, int_scale)
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 @@ Handling fonts in \TeX\ and \LaTeX\ is a notoriously difficult task because font
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 @@ and \textsf{mathfont} sets the default font face for every character in those ke
\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 @@ If you want to change the font for both text and math, you should use |\setfont|
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 @@ Command & Series & Shape\\\midrule
\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 @@ Together these eight commands will provide tools for most local font changes, bu
\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 @@ The \textsf{mathfont} package provides six user-level commands to change boundin
\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,12 +5024,6 @@ For most applications, you can probably ignore charm information altogether, but
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}
@@ -4985,6 +5040,14 @@ Callback Name & What It Does By Default\\\midrule
\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 @@ A few characters appear multiple times in this list. When that happens, it means
\end{document}
%</chars>
%<*equations>
-\begin{multicols}{2}
+\multicolsep=0pt\relax
+\bigskip
+\begin{multicols*}{2}
Black-Scholes Equation
\[
@@ -5835,27 +5900,37 @@ Black-Scholes Equation
=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}}}\\
&\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 @@ Maxwell's Equations
\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,17 +5964,21 @@ Navier-Stokes Equation
\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
\[
@@ -5901,6 +5986,8 @@ Residue Theorem
\]
+\vfill
+
Riemann Zeta Function
\begin{align*}
\zeta(z)&=\sum_{i=1}^\infty\frac1{z^i}
@@ -5908,17 +5995,26 @@ Riemann Zeta Function
&=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 @@ This is Cormorant with Crimson for Greek characters and Bona Nova for diacritics
\DeclareMathOperator{\Res}{Res}
\usepackage{mathfont}
\mathfont[radical]{Crimson}
-\setfont{Kelvinch}
+\setfont{Kelvinch:-clig}
\IntegralItalicFactor{500}
\SurdHorizontalFactor{900}
\parindent=0pt\relax
@@ -6091,6 +6187,9 @@ This is Roboto with Overpass for the radical signs and STIXGeneral for the tenso
{<->"Typey McTypeface:\M@otf@features;embolden=6;mode=base"}{}
\DeclareFontShape{TU}{Typey-base}{\bfdefault}{\itdefault}
{<->"Typey McTypeface/I:\M@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 @@ This is Typey McTypeface with Crimson for the radical signs and STIXGeneral for
\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
diff --git a/macros/latex/contrib/mathfont/mathfont_code.pdf b/macros/latex/contrib/mathfont/mathfont_code.pdf
index 37c581a0cc..fb3a867c4d 100644
--- a/macros/latex/contrib/mathfont/mathfont_code.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_code.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_example_cormorant.pdf b/macros/latex/contrib/mathfont/mathfont_example_cormorant.pdf
index 3809731b4b..894f83bab1 100644
--- a/macros/latex/contrib/mathfont/mathfont_example_cormorant.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_example_cormorant.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_example_kelvinch.pdf b/macros/latex/contrib/mathfont/mathfont_example_kelvinch.pdf
index f8aa3e4af3..68f3336d17 100644
--- a/macros/latex/contrib/mathfont/mathfont_example_kelvinch.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_example_kelvinch.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_example_roboto.pdf b/macros/latex/contrib/mathfont/mathfont_example_roboto.pdf
index 28dd9a4b25..a72b4d9bc1 100644
--- a/macros/latex/contrib/mathfont/mathfont_example_roboto.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_example_roboto.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_example_typey.pdf b/macros/latex/contrib/mathfont/mathfont_example_typey.pdf
index 2cdcdf05c1..7d7f86da75 100644
--- a/macros/latex/contrib/mathfont/mathfont_example_typey.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_example_typey.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_symbol_list.pdf b/macros/latex/contrib/mathfont/mathfont_symbol_list.pdf
index e643cb1624..4eff1c516f 100644
--- a/macros/latex/contrib/mathfont/mathfont_symbol_list.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_symbol_list.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathfont/mathfont_user_guide.pdf b/macros/latex/contrib/mathfont/mathfont_user_guide.pdf
index 43787de754..9700a1faef 100644
--- a/macros/latex/contrib/mathfont/mathfont_user_guide.pdf
+++ b/macros/latex/contrib/mathfont/mathfont_user_guide.pdf
Binary files differ