A new font selection scheme for TEX macro packages (Initialisation)^{∗}

Frank Mittelbach  Rainer Schöpf

March 27, 1996

This file contains the top level L^{A}TEX interface to the font selection scheme commands. See other parts of the L^{A}TEX distribution, or The L^{A}TEX Companion for higher level documentation of these commands.

1 NFSS Initialisation

Finally, there are six commands that are to be used in L^{A}TEX and that we will therefore protect against expansion at the wrong point: \fontfamily, \fontseries,

\fontshape, \fontsize, \selectfont, and \mathversion.

1.1 Providing math versions

L^{A}TEX provides two versions. We call them normal and bold, respectively.

 1 \DeclareMathVersion{normal}
 2 \DeclareMathVersion{bold}

Now we define the standard font change commands. We don’t allow the use of \rmfamily etc. in math mode.

First the changes to another family:

 3 \DeclareRobustCommand\rmfamily
 4  {\not@math@alphabet\rmfamily\mathrm
 5  \fontfamily\rmdefault\selectfont}
 6 \DeclareRobustCommand\sffamily
 7  {\not@math@alphabet\sffamily\mathsf
 8  \fontfamily\sfdefault\selectfont}
 9 \DeclareRobustCommand\ttfamily
10  {\not@math@alphabet\ttfamily\mathtt
11  \fontfamily\ttdefault\selectfont}

∗This file has version number v3.0g dated 1995/11/01

Then the commands changing the series:

12 \DeclareRobustCommand\bfseries
13  {\not@math@alphabet\bfseries\mathbf
14  \fontseries\bfdefault\selectfont}
15 \DeclareRobustCommand\mdseries
16  {\not@math@alphabet\mdseries\relax
17  \fontseries\mddefault\selectfont}
18 \DeclareRobustCommand\upshape
19  {\not@math@alphabet\upshape\relax
20  \fontshape\updefault\selectfont}

Then the commands changing the shape:

21 \DeclareRobustCommand\slshape
22  {\not@math@alphabet\slshape\relax
23  \fontshape\sldefault\selectfont}
24 \DeclareRobustCommand\scshape
25  {\not@math@alphabet\scshape\relax
26  \fontshape\scdefault\selectfont}
27 \DeclareRobustCommand\itshape
28  {\not@math@alphabet\itshape\mathit
29  \fontshape\itdefault\selectfont}

We also have to define the emphasize font change command (i.e. \em). This command will look is the current font is sloped (i.e. has a positive \fontdimen1) and will then select either \upshape or \itshape.

30 \DeclareRobustCommand\em
31  {\@nomath\em \ifdim \fontdimen\@ne\font >\z@
32  \upshape \else \itshape \fi}

\not@math@alphabet This function generates an error message when it is called in math mode. The same function should be defined in newlfont.sty.

33 \def\not@math@alphabet#1#2{%
34 \relax
35 \ifmmode
36  \@latex@error{Command \noexpand#1invalid in math mode}%
37  {%
38  Please
39  \ifx#2\relax
40  define a new math alphabet^^J%
41  if you want to use a special font in math mode%
42  \else

We have to a \noexpand below to prevent expansion of #2. In case of #1 we can omit this (due to the current definition of robust commands since they do come out right there :-).

43  use the math alphabet \noexpand#2instead of
44  the #1command%
45  \fi

46 .

47  }%
48 \fi}

Finally we provide two abbreviations to switch to the L^{A}TEX versions.

49 \def\boldmath{\@nomath\boldmath
50  \mathversion{bold}}
51 \def\unboldmath{\@nomath\unboldmath
52  \mathversion{normal}}

Here we switch to the default math version by defining the internal macro \math@version. We dare not to call \mathversion at this place because this

would call \glb@settings.
53 \def\math@version{normal}

1.2 Miscellaneous

\newfont \symbol We start by defining a few macros that are part of standard L^{A}TEX’s user interface. The use of these functions is not encouraged, but they will allow to process older documents without changes to the source.

54 \def\newfont#1#2{\@ifdefinable#1{\font#1=#2\relax}}
55 \def\symbol#1{\char #1\relax}

\@setfontsize \@setsize This abbreviation is used by L^{A}TEX’s user level size changing commands, such as

\large.
56 \def\@setfontsize#1#2#3{\@nomath#1%

For the benefit of people relying on keeping the name of the current font command saved in \@currsize we define it. To ensure that \@setfontsize keeps being robust we omit this assignment during times where \protect differs from

\@typeset@protect.
57  \ifx\protect\@typeset@protect
58  \let\@currsize#1%
59  \fi
60  \fontsize{#2}{#3}\selectfont}

For compatibility we also define \@setsize the 209 command

61 ⟨∗compat⟩

62 \def\@setsize#1#2#3#4{\@setfontsize#1{#4}{#2}}

63 ⟨/compat⟩

\oldstylenums This macro implements old style numerals but only works if we assume that the standard math fonts are used. Thus it needs changing in case other math encodings are used.

64 \def\oldstylenums#1{%
65 \begingroup

Provide spacing using the interword space of the current font.

66  \spaceskip\fontdimen\tw@\font

Then switch to the math italic font. We don’t change the current value of \f@series which means that you can use bold numerals if \bfseries is in force (For this there must be a substitution of OML/cmm/bx/it into OML/cmm/b/it in the corresponding .fd files.

67  \usefont{OML}{cmm}{\f@series}{it}%
68  \mathgroup\symletters #1%
69 \endgroup

70 }

\hexnumber@ To set up L^{A}TEX’s special math character definitions we first provide a macro to generate hexadecimal numbers. It is a rather simple \ifcase.

71 \def\hexnumber@#1{\ifcase\number#1
72 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or
73 9\or A\or B\or C\or D\or E\or F\fi}

\nfss@text In it simplest form \nfss@text is an \mbox. This will produce unbreakable text outside math and inside math you will get text with the same fonts as outside. The only drawback is that such item won’t change sizes in subscripts. But this behavior can be easily changed. With the amstex style option one will get a sub style called amstext which will redefine the \nfss@text macro to produce correct text in all sizes.

We have to use \def instead of the shorter \let since \mbox is undefined when we reach this point.

74 \def\nfss@text#1{{\mbox{#1}}}

\copyright The definition of \copyright was changed so that it works in other type styles, and to make it robust. We leave the family untouched so that the copyright notice will come out differently if a different font family is in use. This command is commented out, since it is now defined in ltoutenc.dtx.

75 %\DeclareRobustCommand\copyright
76 %    {{\ooalign{\hfil
77 %     \raise.07ex\hbox{\mdseries\upshape c}\hfil\crcr
78 %     \mathhexbox20D}}}

\normalfont \reset@font \p@reset@font The macro \reset@font is used in L^{A}TEX to switch to a standard font, in order to initialize the current font in situations where typesetting is done in a new visual context (e.g. in a footnote). We define it here to allow the test for the new L^{A}TEX version above but nevertheless are able to run all kind of mixtures.

The user interface name for \reset@font is \normalfont:

79 \DeclareRobustCommand\normalfont
80  {\usefont\encodingdefault
81  \familydefault
82  \seriesdefault
83  \shapedefault
84  \relax}
85 \let\reset@font\normalfont

We left out the special L^{A}TEX fonts which are not automatically included in the base version of the font selection since these fonts contain only a few characters which are also included in the AMS fonts so anybody who is using these fonts doesn’t need them. But for compatibility reasons we will define these symbols.

 86 \def\not@base#1{\@latex@error
 87 {Command \noexpand#1not provided in base LaTeX2e}%
 88 {Load the latexsym or the amsfonts package to
 89 define this symbol}}
 90 \def\mho{\not@base\mho}
 91 \def\Join{\not@base\Join}
 92 \def\Box{\not@base\Box}
 93 \def\Diamond{\not@base\Diamond}
 94 \def\leadsto{\not@base\leadsto}
 95 \def\sqsubset{\not@base\sqsubset}
 96 \def\sqsupset{\not@base\sqsupset}
 97 \def\lhd{\not@base\lhd}
 98 \def\unlhd{\not@base\unlhd}
 99 \def\rhd{\not@base\rhd}
100 \def\unrhd{\not@base\unrhd}

We now initialize all variables set by \DeclareErrorFont. These values are not really important since they will be overwritten later on by the definition in

 fontdef.ltx.

However, if fontdef.cfg is corrupted then at least a hopefully suitable error font is present.

101 \DeclareErrorFont{OT1}{cmr}{m}{n}{10}  %%% don't modify this setting
102  %%% overwrite it in fontdef.cfg
103  %%% if necessary

We now load the customizable parts of NFSS.

104 \ifnum\inputlineno=\m@ne

Still using TEX2. need a configuration file to avoid setting the 8bit characters.

105 \InputIfFileExists{fonttext.cfg}
106  {\typeout{*************************************^^J%
107  *^^J%
108  * Local config file fonttext.cfg used^^J%
109  *^^J%
110  *************************************}%
111  \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%

112 }

113  {\typeout{*************************************^^J%
114  *^^J%
115  * You MUST use a fonttext.cfg file!^^J%
116  * As you are still using TeX2!!!!!^^J%
117  *^^J%
118  * See the documentation file tex2.txt^^J%
119  *^^J%
120  *************************************}%
121  \batchmode \@@end}
122 \else

With TEX3 can use the standard ltx file if no configuration file exists.

123 \InputIfFileExists{fonttext.cfg}

124  {\typeout{*************************************^^J%
125  *^^J%
126  * Local config file fonttext.cfg used^^J%
127  *^^J%
128  *************************************}%
129  \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%

130 }

131  {\input{fonttext.ltx}}
132 \fi
133 \let\@addtofilelist\@gobble

Ditto for math although I don’t that we will get a lot of customisation :-)

134 \InputIfFileExists{fontmath.cfg}
135  {\typeout{*************************************^^J%
136  *^^J%
137  * Local config file fontmath.cfg used^^J%
138  *^^J%
139  *************************************}%
140  \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%

141 }

142  {\input{fontmath.ltx}}
143 \let\@addtofilelist\@gobble

Then we preload several fonts. This file might be customized without changing the behavior of the format (i.e. necessary font definitions will be loaded at runtime if they are not preloaded). This is done in the file preload.ltx.

144 \InputIfFileExists{preload.cfg}
145  {\typeout{*************************************^^J%
146  *^^J%
147  * Local config file preload.cfg used^^J%
148  *^^J%
149  *************************************}%
150  \def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}%

151 }

152  {\input{preload.ltx}}
153 \let\@addtofilelist\@gobble

\@acci \@accii \@acciii We also save the values of some accents in \@acci, \@accii and \@acciii so they can be restored by a minipage inside a tabbing environment.

154 \let\@acci\' \let\@accii\` \let\@acciii\=

{\cal \atop \mit} Here were the two old ⟨alphabet identifiers⟩.