| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% The LaTeX Project and any individual authors listed elsewhere |
| 5 |
% in this file. |
| 6 |
% |
| 7 |
% This file is part of the LaTeX base system. |
| 8 |
% ------------------------------------------- |
| 9 |
% |
| 10 |
% It may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 12 |
% of this license or (at your option) any later version. |
| 13 |
% The latest version of this license is in |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 16 |
% version 2008 or later. |
| 17 |
% |
| 18 |
% This file has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% The list of all files belonging to the LaTeX base distribution is |
| 21 |
% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 22 |
% information. |
| 23 |
% |
| 24 |
% The list of derived (unpacked) files belonging to the distribution |
| 25 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 26 |
% extension .ins) which are part of the distribution. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% \iffalse |
| 30 |
%%% From File: ltfssini.dtx |
| 31 |
%% Copyright (C) 1989-2001 Frank Mittelbach and Rainer Sch\"opf, |
| 32 |
%% all rights reserved. |
| 33 |
% |
| 34 |
%<*driver> |
| 35 |
% \fi |
| 36 |
% |
| 37 |
% |
| 38 |
\ProvidesFile{ltfssini.dtx} |
| 39 |
[2025/09/15 v3.2l LaTeX Kernel (NFSS Initialization)] |
| 40 |
% \iffalse |
| 41 |
\documentclass{ltxdoc} |
| 42 |
\begin{document} |
| 43 |
\DocInput{ltfssini.dtx} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \iffalse |
| 49 |
%<+checkmem>\def\CHECKMEM{\tracingstats=2 |
| 50 |
%<+checkmem> \newlinechar=`\^^J |
| 51 |
%<+checkmem> \message{^^JMemory usage: \filename}\shipout\hbox{}} |
| 52 |
%<+checkmem>\CHECKMEM |
| 53 |
% \fi |
| 54 |
% |
| 55 |
% |
| 56 |
% |
| 57 |
% \GetFileInfo{ltfssini.dtx} |
| 58 |
% \title{A new font selection scheme for \TeX{} macro packages\\ |
| 59 |
% (Initialization)\thanks |
| 60 |
% {This file has version number |
| 61 |
% \fileversion\ dated \filedate}} |
| 62 |
% |
| 63 |
% \author{Frank Mittelbach \and Rainer Sch\"opf} |
| 64 |
% |
| 65 |
% \MaintainedByLaTeXTeam{latex} |
| 66 |
% \maketitle |
| 67 |
% |
| 68 |
% This file contains the top level \LaTeX\ interface to the font |
| 69 |
% selection scheme commands. See other parts of the \LaTeX\ |
| 70 |
% distribution, or \emph{The \LaTeX\ Companion} for higher level |
| 71 |
% documentation of these commands. |
| 72 |
% |
| 73 |
% \MaybeStop{} |
| 74 |
% |
| 75 |
% |
| 76 |
% \changes{v3.0i}{1998/08/17}{(RmS) Minor documentation fixes.} |
| 77 |
% \changes{v3.0b}{1995/06/28} |
| 78 |
% {(DPC) Fix documentation typos} |
| 79 |
% \changes{v3.0a}{1995/05/24} |
| 80 |
% {(DPC) Make file from previous file, lfonts.dtx 1995/05/23 v2.2e} |
| 81 |
% \changes{v3.1b}{2016/10/15} |
| 82 |
% {Require e\TeX{}} |
| 83 |
% \changes{v3.1d}{2019/08/27}{Make various commands robust} |
| 84 |
% |
| 85 |
% |
| 86 |
% \section{NFSS Initialization} |
| 87 |
% |
| 88 |
% \iffalse |
| 89 |
%<+checkmem>\CHECKMEM |
| 90 |
% \fi |
| 91 |
% |
| 92 |
% |
| 93 |
% \changes{v2.2a}{1994/10/14}{New coding for cfg files} |
| 94 |
% \changes{v2.1a}{1993/12/03}{update for LaTeX2e} |
| 95 |
% \changes{v1.2c}{1992/01/06}{added slitex code} |
| 96 |
% \changes{v1.2d}{1992/03/21}{Renamed \cs{text} to \cs{nfss@text} |
| 97 |
% to make it internal.} |
| 98 |
% \changes{v1.2a}{1991/11/27}{All \cs{family}, \cs{shape} etc. renamed |
| 99 |
% to \cs{fontfamily} etc.} |
| 100 |
% \changes{v1.1i}{1990/04/02}{\cs{input} of files now handled |
| 101 |
% by docstrip.} |
| 102 |
% \changes{v1.1g}{1990/02/08}{Protected the commands |
| 103 |
% \cs{family}, \cs{series}, |
| 104 |
% \cs{shape}, \cs{size}, \cs{selectfont}, and \cs{mathversion}.} |
| 105 |
% \changes{v1.1c}{1989/12/03}{Some internal macros renamed to make them |
| 106 |
% inaccessible.} |
| 107 |
% \changes{v1.1b}{1989/12/02}{\cs{rmmath} renamed to \cs{mathrm}} |
| 108 |
% |
| 109 |
% \changes{v1.0i}{1989/11/07}{All family, series, and shape names |
| 110 |
% abbreviated.} |
| 111 |
% \changes{v1.0g}{1989/05/22}{Lines shortened to 72 characters} |
| 112 |
% \changes{v1.0f}{1989/04/29}{Corrections to \LaTeX\ tabular env. |
| 113 |
% added.} |
| 114 |
% \changes{v1.0e}{1989/04/27}{Definitions of \LaTeX\ symbols corrected.} |
| 115 |
% \changes{v1.0d}{1989/04/26}{\cs{xpt} added.} |
| 116 |
% \changes{v1.0c}{1989/04/21}{Changed to conform to fam.tex.} |
| 117 |
% \changes{v1.0b}{1989/04/15}{\cs{mathfontset} renamed to |
| 118 |
% \cs{mathversion.}} |
| 119 |
% \changes{v1.0a}{1989/04/10}{Starting with version numbers! |
| 120 |
% \cs{newif} for \cs{@tempswa} added since this switch is |
| 121 |
% unknown at the time when this file is read in. |
| 122 |
% (latex.tex is loaded later.) |
| 123 |
% \cs{math@famname} changed to \cs{math@version.}} |
| 124 |
% |
| 125 |
% |
| 126 |
% \changes{v2.1j}{1994/05/13}{Removed file identification typeout} |
| 127 |
% |
| 128 |
% Finally, there are six commands that are to be used in \LaTeX{} |
| 129 |
% and that we will therefore protect against expansion at the |
| 130 |
% wrong point: |
| 131 |
% |\fontfamily|, |\fontseries|, |\fontshape|, |\fontsize|, |
| 132 |
% |\selectfont|, and |\mathversion|. |
| 133 |
% |
| 134 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontfamily} to fam.dtx} |
| 135 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontencoding} to fam.dtx} |
| 136 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontseries} to fam.dtx} |
| 137 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontshape} to fam.dtx} |
| 138 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{fontsize} to fam.dtx} |
| 139 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{mathversion} to fam.dtx} |
| 140 |
% \changes{v2.1i}{1994/05/12}{Moved \cs{selectfont} to tracefnt.dtx} |
| 141 |
% |
| 142 |
% |
| 143 |
% \begin{macrocode} |
| 144 |
%<*2ekernel> |
| 145 |
\message{NFSS initialization,} |
| 146 |
% \end{macrocode} |
| 147 |
% |
| 148 |
% \subsection{Providing math \emph{versions}} |
| 149 |
% |
| 150 |
% \LaTeX{} provides two \emph{versions}. We call them |
| 151 |
% \textsf{normal} and \textsf{bold}, respectively. |
| 152 |
% \begin{macrocode} |
| 153 |
\DeclareMathVersion{normal} |
| 154 |
\DeclareMathVersion{bold} |
| 155 |
% \end{macrocode} |
| 156 |
% |
| 157 |
% |
| 158 |
% Now we define the standard font change commands. |
| 159 |
% We don't allow the use of |\rmfamily| etc.\ in math mode. |
| 160 |
% |
| 161 |
% (Actually most are now defined further down in the file.) |
| 162 |
% |
| 163 |
% First the changes to another \emph{family}: |
| 164 |
% \begin{macrocode} |
| 165 |
%\DeclareRobustCommand\rmfamily |
| 166 |
% {\not@math@alphabet\rmfamily\mathrm |
| 167 |
% \fontfamily\rmdefault\selectfont} |
| 168 |
%\DeclareRobustCommand\sffamily |
| 169 |
% {\not@math@alphabet\sffamily\mathsf |
| 170 |
% \fontfamily\sfdefault\selectfont} |
| 171 |
%\DeclareRobustCommand\ttfamily |
| 172 |
% {\not@math@alphabet\ttfamily\mathtt |
| 173 |
% \fontfamily\ttdefault\selectfont} |
| 174 |
% \end{macrocode} |
| 175 |
% Then the commands changing the \emph{series}: |
| 176 |
% \begin{macrocode} |
| 177 |
%\DeclareRobustCommand\bfseries |
| 178 |
% {\not@math@alphabet\bfseries\mathbf |
| 179 |
% \fontseries\bfdefault\selectfont} |
| 180 |
%\DeclareRobustCommand\mdseries |
| 181 |
% {\not@math@alphabet\mdseries\relax |
| 182 |
% \fontseries\mddefault\selectfont} |
| 183 |
\DeclareRobustCommand\upshape |
| 184 |
{\not@math@alphabet\upshape\relax |
| 185 |
\fontshape\updefault\selectfont} |
| 186 |
% \end{macrocode} |
| 187 |
% Then the commands changing the \emph{shape}: |
| 188 |
% \begin{macrocode} |
| 189 |
\DeclareRobustCommand\slshape |
| 190 |
{\not@math@alphabet\slshape\relax |
| 191 |
\fontshape\sldefault\selectfont} |
| 192 |
\DeclareRobustCommand\scshape |
| 193 |
{\not@math@alphabet\scshape\relax |
| 194 |
\fontshape\scdefault\selectfont} |
| 195 |
\DeclareRobustCommand\itshape |
| 196 |
{\not@math@alphabet\itshape\mathit |
| 197 |
\fontshape\itdefault\selectfont} |
| 198 |
% \end{macrocode} |
| 199 |
% |
| 200 |
% |
| 201 |
% |
| 202 |
% |
| 203 |
% \section{Custom series settings for main document families} |
| 204 |
% |
| 205 |
% This section was introduced 2020/02/02 and for now we support a |
| 206 |
% full rollback (may need splitting later). |
| 207 |
% \changes{v3.1e}{2019/12/17}{Provide custom series settings a la mweights} |
| 208 |
% \begin{macrocode} |
| 209 |
%</2ekernel> |
| 210 |
%<*2ekernel|latexrelease> |
| 211 |
%<latexrelease>\IncludeInRelease{2021/11/15}% |
| 212 |
%<latexrelease> {\DeclareFontSeriesDefault}{Custom series}% |
| 213 |
% \end{macrocode} |
| 214 |
% |
| 215 |
% One problem with the NFSS approach of handling the series axis |
| 216 |
% turned out to be that (especially with respect to ``boldness'') |
| 217 |
% different font families implemented different strategies. For |
| 218 |
% example, with Computer Modern fonts you normally only have |
| 219 |
% \texttt{bx} whereas most PostScript fonts offered only \texttt{b} |
| 220 |
% but not \texttt{bx}. As a result \LaTeX's standard setting for |
| 221 |
% \cs{bfdefault} didn't work with such fonts, but if it got changed |
| 222 |
% to produce \texttt{b}, then that didn't work with Computer Modern |
| 223 |
% if the fonts got combined (e.g., using Computer Modern Typewriter |
| 224 |
% with such fonts). |
| 225 |
% |
| 226 |
% The solution back then was to provide substitution rules in the |
| 227 |
% font \texttt{.fd} such that if a \texttt{bx} series got requested |
| 228 |
% the \texttt{b} series got used. While this works in that |
| 229 |
% particular case, it isn't a very |
| 230 |
% general solution. For example, if you happen to have a font family that |
| 231 |
% has several weights you may want to typeset the whole document |
| 232 |
% in a somewhat lighter or darker font but if you then modify |
| 233 |
% \cs{mddefault} to allow for this, then of course your change only |
| 234 |
% works with that particular family but not with the typewriter |
| 235 |
% or sans serif family you also want to use. |
| 236 |
% |
| 237 |
% A better solution was provided by the \texttt{mweights} package by |
| 238 |
% Bob Tennent that offers defaults on the level of the three main |
| 239 |
% font families in the document: for ``rm'', ``sf'' and ``tt'' so |
| 240 |
% that font packages could define defaults for the sans serif |
| 241 |
% document font by providing \cs{bfseries@sf} which then was used |
| 242 |
% when \cs{bfseries} got executed and the current family was the |
| 243 |
% \cs{sffamily}. |
| 244 |
% |
| 245 |
% \DescribeMacro\DeclareFontSeriesDefault |
| 246 |
% We now support this concept directly from within \LaTeX{} and for |
| 247 |
% use in font packages (or the document preamble) we offer |
| 248 |
% \cs{DeclareFontSeriesDefault}. This declaration takes three |
| 249 |
% arguments: |
| 250 |
% \begin{description} |
| 251 |
% \item[document family interface:] Can either be \texttt{rm}, |
| 252 |
% \texttt{sf} or \texttt{tt}. This is optional and if not given the |
| 253 |
% overall default. |
| 254 |
% \item[document series interface:] Can be \texttt{md} or |
| 255 |
% \texttt{bf}. |
| 256 |
% \item[series value:] This is the value that is going to be used |
| 257 |
% with the combination is requested. |
| 258 |
% \end{description} |
| 259 |
% |
| 260 |
% For example, \verb=\DeclareFontSeriesDefault[rm]{bf}{sb}= would |
| 261 |
% use \texttt{sb} (semi-bold) when \cs{rmfamily} \cs{bfseries} is |
| 262 |
% asked for. |
| 263 |
% |
| 264 |
% If used without the optional argument, e.g., |
| 265 |
% \verb=\DeclareFontSeriesDefault{bf}{b}= then this is like |
| 266 |
% redefining \cs{bfdefault} or \cs{mddefault}. |
| 267 |
% |
| 268 |
% If some family specify defaults aren't given, e.g. if there are |
| 269 |
% no declarations for, say, \texttt{tt} then the format defaults |
| 270 |
% of \cs{mddefault} and \cs{bfdefault} are assumed. If those are |
| 271 |
% later changed this is \emph{not} reflected!\footnote{I see no |
| 272 |
% easy way to achieve this without compromising compatibility with |
| 273 |
% existing packages that currently use \textsf{mweights} and directly |
| 274 |
% define (some) of the \cs{mdseries@..} commands but not others.} |
| 275 |
% |
| 276 |
% |
| 277 |
% |
| 278 |
% \begin{macro}{\DeclareFontSeriesDefault} |
| 279 |
% The command to declare font series defaults for the ``rm'', ``sf'' or |
| 280 |
% ``tt'' family. |
| 281 |
% \begin{macrocode} |
| 282 |
\let\DeclareFontSeriesDefault\@undefined % for rollback |
| 283 |
\newcommand\DeclareFontSeriesDefault[3][]{% |
| 284 |
% \end{macrocode} |
| 285 |
% |
| 286 |
% \changes{v3.2i}{2021/09/10}{Do delayed changes to \cs{bfdefault} or |
| 287 |
% \cs{mddefault} first (gh/663)} |
| 288 |
% \begin{macrocode} |
| 289 |
\expand@font@defaults |
| 290 |
\maybe@update@bfseries@defaults |
| 291 |
\maybe@update@mdseries@defaults |
| 292 |
% \end{macrocode} |
| 293 |
% |
| 294 |
% \begin{macrocode} |
| 295 |
\def\reserved@a{#1}% |
| 296 |
% \end{macrocode} |
| 297 |
% No optional argument: set up general default. |
| 298 |
% \changes{v3.1g}{2020/02/05}{Corrected misspelled csname (gh/264)} |
| 299 |
% \begin{macrocode} |
| 300 |
\ifx\reserved@a\@empty |
| 301 |
\ifcsname #2series\endcsname % supported are |
| 302 |
% \[md/bf]default |
| 303 |
% \end{macrocode} |
| 304 |
% Adding \cs{@empty} allows us to detect if the default gets |
| 305 |
% redefined with \cs{renewcommand} or \cs{def} by the user. |
| 306 |
% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault} |
| 307 |
% and \cs{mddefault} (gh/306)} |
| 308 |
% \begin{macrocode} |
| 309 |
\expandafter\def |
| 310 |
\csname #2default\endcsname{#3\@empty}% |
| 311 |
\expandafter\def |
| 312 |
\csname #2default@previous\endcsname{#3\@empty}% |
| 313 |
\else |
| 314 |
% \end{macrocode} |
| 315 |
% |
| 316 |
% \changes{v3.1g}{2020/02/05}{Clarified error text} |
| 317 |
% \begin{macrocode} |
| 318 |
\@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}% |
| 319 |
{Mandatory first argument must be 'md' or 'bf'.} |
| 320 |
\fi |
| 321 |
% \end{macrocode} |
| 322 |
% Optional argument given, set up specific default. |
| 323 |
% \begin{macrocode} |
| 324 |
\else |
| 325 |
\ifcsname #2series@#1\endcsname % supported are |
| 326 |
% \[md/bf]series@[rm/sf/tt] |
| 327 |
\expandafter\edef |
| 328 |
\csname #2series@#1\endcsname{#3}% |
| 329 |
% \end{macrocode} |
| 330 |
% |
| 331 |
% If the interface is used we remove the frozen kernel |
| 332 |
% default. This way, we know that something was explicitly set up |
| 333 |
% (even if the setup has the same value as the default). |
| 334 |
% \begin{macrocode} |
| 335 |
\expandafter\let |
| 336 |
\csname #2series@#1@kernel\endcsname\@undefined |
| 337 |
\else |
| 338 |
\@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}% |
| 339 |
{Optional argument must be 'rm', 'sf', or 'tt'. \MessageBreak |
| 340 |
Mandatory first argument must be 'md' or 'bf'.} |
| 341 |
\fi |
| 342 |
\fi |
| 343 |
} |
| 344 |
% \end{macrocode} |
| 345 |
% \end{macro} |
| 346 |
|
| 347 |
|
| 348 |
% \begin{macrocode} |
| 349 |
%</2ekernel|latexrelease> |
| 350 |
%<latexrelease>\EndIncludeInRelease |
| 351 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 352 |
%<latexrelease> {\DeclareFontSeriesDefault}{Custom series}% |
| 353 |
%<latexrelease> |
| 354 |
%<latexrelease>\let\DeclareFontSeriesDefault\@undefined % for rollback |
| 355 |
%<latexrelease>\newcommand\DeclareFontSeriesDefault[3][]{% |
| 356 |
%<latexrelease> \def\reserved@a{#1}% |
| 357 |
%<latexrelease> \ifx\reserved@a\@empty |
| 358 |
%<latexrelease> \ifcsname #2series\endcsname % supported are |
| 359 |
%<latexrelease> % \[md/bf]default |
| 360 |
%<latexrelease> \expandafter\def |
| 361 |
%<latexrelease> \csname #2default\endcsname{#3\@empty}% |
| 362 |
%<latexrelease> \expandafter\def |
| 363 |
%<latexrelease> \csname #2default@previous\endcsname{#3\@empty}% |
| 364 |
%<latexrelease> \else |
| 365 |
%<latexrelease> \@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}% |
| 366 |
%<latexrelease> {Mandatory first argument must be 'md' or 'bf'.} |
| 367 |
%<latexrelease> \fi |
| 368 |
%<latexrelease> \else |
| 369 |
%<latexrelease> \ifcsname #2series@#1\endcsname % supported are |
| 370 |
%<latexrelease> % \[md/bf]series@[rm/sf/tt] |
| 371 |
%<latexrelease> \expandafter\edef |
| 372 |
%<latexrelease> \csname #2series@#1\endcsname{#3}% |
| 373 |
%<latexrelease> \expandafter\let |
| 374 |
%<latexrelease> \csname #2series@#1@kernel\endcsname\@undefined |
| 375 |
%<latexrelease> \else |
| 376 |
%<latexrelease> \@latex@error{Wrong syntax for \string\DeclareFontSeriesDefault}% |
| 377 |
%<latexrelease> {Optional argument must be 'rm', 'sf', or 'tt'. \MessageBreak |
| 378 |
%<latexrelease> Mandatory first argument must be 'md' or 'bf'.} |
| 379 |
%<latexrelease> \fi |
| 380 |
%<latexrelease> \fi |
| 381 |
%<latexrelease>} |
| 382 |
%<latexrelease> |
| 383 |
%<latexrelease>\EndIncludeInRelease |
| 384 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 385 |
%<latexrelease> {\DeclareFontSeriesDefault}{Custom series}% |
| 386 |
%<latexrelease> |
| 387 |
%<latexrelease>\let\DeclareFontSeriesDefault\@undefined |
| 388 |
%<latexrelease>\let\bfseries@rm\@undefined |
| 389 |
%<latexrelease>\let\bfseries@sf\@undefined |
| 390 |
%<latexrelease>\let\bfseries@tt\@undefined |
| 391 |
%<latexrelease>\let\bfseries@rm@kernel\@undefined |
| 392 |
%<latexrelease>\let\bfseries@sf@kernel\@undefined |
| 393 |
%<latexrelease>\let\bfseries@tt@kernel\@undefined |
| 394 |
%<latexrelease>\let\mdseries@rm\@undefined |
| 395 |
%<latexrelease>\let\mdseries@sf\@undefined |
| 396 |
%<latexrelease>\let\mdseries@tt\@undefined |
| 397 |
%<latexrelease>\expandafter\let\csname [email protected]\endcsname\@undefined |
| 398 |
%<latexrelease> |
| 399 |
%<latexrelease>\let\@meta@family@list\@undefined |
| 400 |
%<latexrelease>\let\prepare@family@series@update\@undefined |
| 401 |
%<latexrelease>\let\update@series@target@value\@undefined |
| 402 |
%<latexrelease> |
| 403 |
% \end{macrocode} |
| 404 |
% This is always called in \cs{document} so don't make it undefined. |
| 405 |
% \begin{macrocode} |
| 406 |
%<latexrelease>\let\init@series@setup\relax |
| 407 |
%<latexrelease> |
| 408 |
%<latexrelease>\EndIncludeInRelease |
| 409 |
%<*2ekernel> |
| 410 |
% \end{macrocode} |
| 411 |
|
| 412 |
|
| 413 |
% \begin{macrocode} |
| 414 |
%</2ekernel> |
| 415 |
%<*2ekernel|latexrelease> |
| 416 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 417 |
%<latexrelease> {\mdseries@rm}{Custom series}% |
| 418 |
% \end{macrocode} |
| 419 |
|
| 420 |
% \begin{macro}{\mdseries@rm} |
| 421 |
% \begin{macro}{\mdseries@sf} |
| 422 |
% \begin{macro}{\mdseries@tt} |
| 423 |
% \begin{macro}{\bfseries@rm} |
| 424 |
% \begin{macro}{\bfseries@sf} |
| 425 |
% \begin{macro}{\bfseries@tt} |
| 426 |
% We initialize the family specific default at the end of the |
| 427 |
% format generation. Later on they may get overwritten in the |
| 428 |
% preamble or a package via \cs{DeclareFontSeriesDefault} (or |
| 429 |
% possibly directly). |
| 430 |
% |
| 431 |
% Conceptual change: The \cs{bfdefault} will be \texttt{b} not |
| 432 |
% \texttt{bx} because that is what it should be really for nearly |
| 433 |
% every font except Computer/Latin Modern. |
| 434 |
% |
| 435 |
% To account for the fact that by default we typeset in CM or LM we |
| 436 |
% set up the \cs{bfseries@..} defaults to use \texttt{bx} instead. |
| 437 |
% |
| 438 |
% This means that it behaves like before because if the default |
| 439 |
% fonts are used then \cs{bfseries@rm} etc kick in and make |
| 440 |
% \cs{textbf} use \texttt{bx}. However, if the font gets changed |
| 441 |
% then \cs{bfdefault} will get used. |
| 442 |
% |
| 443 |
% \begin{macrocode} |
| 444 |
\def\bfseries@rm{bx} |
| 445 |
\def\bfseries@sf{bx} |
| 446 |
\def\bfseries@tt{bx} |
| 447 |
% \end{macrocode} |
| 448 |
% |
| 449 |
% Frozen version of the kernel defaults so we can see if they have changed. |
| 450 |
% \begin{macrocode} |
| 451 |
\let\bfseries@rm@kernel\bfseries@rm |
| 452 |
\let\bfseries@sf@kernel\bfseries@sf |
| 453 |
\let\bfseries@tt@kernel\bfseries@tt |
| 454 |
% \end{macrocode} |
| 455 |
% |
| 456 |
% The default for the medium series is \texttt{m} and this will be |
| 457 |
% interpreted as resetting both weight and width. To reset only one |
| 458 |
% of them the virtual value \texttt{?m} and \texttt{m?} are available. |
| 459 |
% \begin{macrocode} |
| 460 |
\def\mdseries@rm{m} |
| 461 |
\def\mdseries@sf{m} |
| 462 |
\def\mdseries@tt{m} |
| 463 |
% \end{macrocode} |
| 464 |
% \end{macro} |
| 465 |
% \end{macro} |
| 466 |
% \end{macro} |
| 467 |
% \end{macro} |
| 468 |
% \end{macro} |
| 469 |
% \end{macro} |
| 470 |
% |
| 471 |
% |
| 472 |
% |
| 473 |
% \begin{macro}{\series@change@debug} |
| 474 |
% For debugging, but right now none of this code is extracted. The |
| 475 |
% idea is to have a separate package with debugging code |
| 476 |
% one day. |
| 477 |
% \begin{macrocode} |
| 478 |
%<*debug> |
| 479 |
\let\series@change@debug\typeout |
| 480 |
\let\series@change@debug\@gobble |
| 481 |
%</debug> |
| 482 |
% \end{macrocode} |
| 483 |
% \end{macro} |
| 484 |
% |
| 485 |
% \begin{macrocode} |
| 486 |
%</2ekernel|latexrelease> |
| 487 |
%<latexrelease>\EndIncludeInRelease |
| 488 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 489 |
%<latexrelease> {\mdseries@rm}{Custom series}% |
| 490 |
%<latexrelease> |
| 491 |
%<latexrelease>\let\bfseries@rm\@undefined |
| 492 |
%<latexrelease>\let\bfseries@sf\@undefined |
| 493 |
%<latexrelease>\let\bfseries@tt\@undefined |
| 494 |
%<latexrelease>\let\bfseries@rm@kernel\@undefined |
| 495 |
%<latexrelease>\let\bfseries@sf@kernel\@undefined |
| 496 |
%<latexrelease>\let\bfseries@tt@kernel\@undefined |
| 497 |
%<latexrelease>\let\mdseries@rm\@undefined |
| 498 |
%<latexrelease>\let\mdseries@sf\@undefined |
| 499 |
%<latexrelease>\let\mdseries@tt\@undefined |
| 500 |
%<latexrelease>\EndIncludeInRelease |
| 501 |
%<*2ekernel> |
| 502 |
% \end{macrocode} |
| 503 |
% |
| 504 |
% |
| 505 |
% |
| 506 |
% \begin{macrocode} |
| 507 |
%</2ekernel> |
| 508 |
%<*2ekernel|latexrelease> |
| 509 |
%<latexrelease>\IncludeInRelease{2025/11/01}% |
| 510 |
%<latexrelease> {\prepare@family@series@update}{Support meta family}% |
| 511 |
% \end{macrocode} |
| 512 |
% |
| 513 |
% \begin{macro}{\prepare@family@series@update} |
| 514 |
% |
| 515 |
% This is core command that prepares for the family update. The big |
| 516 |
% difference to the documented code above is that the nested |
| 517 |
% \cs{ifx} statements seem to be missing. Instead we loop through |
| 518 |
% an internal list that holds the names of the three meta |
| 519 |
% families. This approach allows us to extend the mechanism at a |
| 520 |
% later stage to allow for additional named meta families. |
| 521 |
% |
| 522 |
% \begin{macro}{\@meta@family@list} |
| 523 |
% Here is the current definition of that list: |
| 524 |
% \begin{macrocode} |
| 525 |
\def\@meta@family@list{\@elt{rm}\@elt{sf}\@elt{tt}} |
| 526 |
% \end{macrocode} |
| 527 |
% \end{macro} |
| 528 |
% |
| 529 |
% \begin{macro}{\@currentmetafamily} |
| 530 |
% \changes{v3.2l}{2025/09/15}{Macro added} |
| 531 |
% This macro holds the current \enquote{meta} family. At the moment |
| 532 |
% it is either \texttt{rm}, \texttt{sf}, \texttt{tt} or |
| 533 |
% \texttt{??}. The latter is used if the current font family does |
| 534 |
% not match any of the document meta families, defined through |
| 535 |
% \cs{rmdefault}, \cs{sfdefault} or \cs{ttdefault}, i.e., in the |
| 536 |
% case that yet another family was selected using \cs{fontfamily} |
| 537 |
% manually. |
| 538 |
% |
| 539 |
% The value gets updated by commands like \cs{rmfamily}, etc. |
| 540 |
% \begin{macrocode} |
| 541 |
\def\@currentmetafamily{??} |
| 542 |
% \end{macrocode} |
| 543 |
% \end{macro} |
| 544 |
% |
| 545 |
% \begin{macrocode} |
| 546 |
\def\prepare@family@series@update#1#2{% |
| 547 |
% \end{macrocode} |
| 548 |
% We start by updating the meta family. |
| 549 |
% \changes{v3.2l}{2025/09/15}{Always set \cs{@currentmetafamily}} |
| 550 |
% \begin{macrocode} |
| 551 |
\def\@currentmetafamily{#1}% |
| 552 |
% \end{macrocode} |
| 553 |
% |
| 554 |
% \changes{v3.1i}{2020/02/18}{No series auto-update when forced (gh/277)} |
| 555 |
% \begin{macrocode} |
| 556 |
\if@forced@series |
| 557 |
%<+debug> \series@change@debug{No series preparation (forced \f@series)\on@line}% |
| 558 |
\fontfamily#2% |
| 559 |
\else |
| 560 |
%<+debug> \series@change@debug{Preparing for switching to #1 (#2)\on@line}% |
| 561 |
\expand@font@defaults |
| 562 |
% \end{macrocode} |
| 563 |
% We prepare for changing the current series. We have to find it |
| 564 |
% before changing the family as discussed above. |
| 565 |
% \begin{macrocode} |
| 566 |
\let\target@series@value\@empty |
| 567 |
% \end{macrocode} |
| 568 |
% As the very last item in the meta family list we add |
| 569 |
% \verb=\@elt{??}= and define this pseudo meta family to be the |
| 570 |
% current font family. So if none of the real meta families matched then |
| 571 |
% this will match. This will cover the following case: |
| 572 |
% \begin{itemize} |
| 573 |
% \item \cs{bfseries} is called for a family using \texttt{bx} |
| 574 |
% (e.g., CMR) |
| 575 |
% \item Switch to a font family that is none of the meta |
| 576 |
% families, e.g., via \verb=\fontfamily{ptm}\allowbreak\verb=\selectfont= |
| 577 |
% \item Then none of the real meta families, match but the final |
| 578 |
% \verb=\@elt{??}= will. |
| 579 |
% \item Therefore if the current series is \cs{mddefault} or |
| 580 |
% \cs{bfdefault} it will be detected and the corresponding target |
| 581 |
% series selected. |
| 582 |
% \end{itemize} |
| 583 |
% \changes{v3.1i}{2020/02/18}{Recognize current family if it is not a |
| 584 |
% ``meta'' family and auto-update series using \cs{bfdefault} (gh/277)} |
| 585 |
% \begin{macrocode} |
| 586 |
\expandafter\edef\csname ??def@ult\endcsname{\f@family}% |
| 587 |
% \end{macrocode} |
| 588 |
% To find it we loop over the meta family list with a suitable |
| 589 |
% definition of \cs{@elt}. |
| 590 |
% \begin{macrocode} |
| 591 |
\let\@elt\update@series@target@value |
| 592 |
\@meta@family@list |
| 593 |
% \end{macrocode} |
| 594 |
% Last resort pseudo meta family. Will only be looked at if none of |
| 595 |
% the real ones have matched. |
| 596 |
% \begin{macrocode} |
| 597 |
\@elt{??}% |
| 598 |
\let\@elt\relax |
| 599 |
% \end{macrocode} |
| 600 |
% That will figure out the correct series value to use without updating |
| 601 |
% it. Now we can change the family. |
| 602 |
% \begin{macrocode} |
| 603 |
\fontfamily#2% |
| 604 |
% \end{macrocode} |
| 605 |
% After that we update the series. That code is again like the one |
| 606 |
% above. |
| 607 |
% \begin{macrocode} |
| 608 |
\ifx\target@series@value\@empty |
| 609 |
%<+debug> \series@change@debug{Target series still empty ...}% |
| 610 |
\else |
| 611 |
\ifx \f@series\target@series@value |
| 612 |
%<+debug> \series@change@debug{Target series unchanged: |
| 613 |
%<+debug> \f@series \space = \target@series@value}% |
| 614 |
\else |
| 615 |
\maybe@load@fontshape |
| 616 |
%<+debug> \series@change@debug{Target series: |
| 617 |
%<+debug> \f@series \space -> \target@series@value}% |
| 618 |
% \end{macrocode} |
| 619 |
% The \cs{target@series@value} may contain something like |
| 620 |
% \texttt{cm} (coming from a default) and so we can't directly |
| 621 |
% assign it to \cs{f@series} be have to drop any surplus \texttt{m} |
| 622 |
% first. |
| 623 |
% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from |
| 624 |
% \cs{target@series@value} (gh/291)} |
| 625 |
% \begin{macrocode} |
| 626 |
% \let\f@series\target@series@value |
| 627 |
\series@maybe@drop@one@m\target@series@value\f@series |
| 628 |
\fi |
| 629 |
\fi |
| 630 |
\fi |
| 631 |
} |
| 632 |
% \end{macrocode} |
| 633 |
% \end{macro} |
| 634 |
% |
| 635 |
% |
| 636 |
% |
| 637 |
% \begin{macro}{\update@series@target@value} |
| 638 |
% |
| 639 |
% In this macro you basically find the nested \cs{ifx}s from the |
| 640 |
% outline above. The only difference is that is it is parameterized |
| 641 |
% instead of being written out. And we have only for one block of tests |
| 642 |
% because the code is called repeatedly when looping over the meta |
| 643 |
% family list. From the \cs{@meta@family@list} list we get each |
| 644 |
% meta family name in turn. |
| 645 |
% \begin{macrocode} |
| 646 |
\def\update@series@target@value#1{% |
| 647 |
% \end{macrocode} |
| 648 |
% There is one additional test at the beginning, because the list |
| 649 |
% contains all meta families and we need to ignore the case where |
| 650 |
% current one from the list and target one are identical. |
| 651 |
% \changes{v3.2l}{2025/09/15}{Rename \cs{target@meta@family@value} to |
| 652 |
% \cs{@currentmetafamily} and set it always} |
| 653 |
% \begin{macrocode} |
| 654 |
\def\reserved@a{#1}% |
| 655 |
\ifx\@currentmetafamily\reserved@a % rm -> rm do nothing |
| 656 |
\else |
| 657 |
%<+debug> \series@change@debug{Trying to match #1: \csname#1def@ult\endcsname |
| 658 |
%<+debug> \space = \f@family\space ?}% |
| 659 |
% \end{macrocode} |
| 660 |
% We only ``do'' something if the current font family matches the |
| 661 |
% current meta family. |
| 662 |
% \begin{macrocode} |
| 663 |
\expandafter\ifx\csname#1def@ult\endcsname\f@family |
| 664 |
% \end{macrocode} |
| 665 |
% If that's the case we know that this is the block that applies |
| 666 |
% (only one meta family can match). So to speed things up we |
| 667 |
% change \cs{@elt} so that the rest of the loop gets gobbled. |
| 668 |
% \begin{macrocode} |
| 669 |
\let\@elt\@gobble |
| 670 |
% \end{macrocode} |
| 671 |
% Then we try to find the right new value for the series (as |
| 672 |
% explained above). The two macros defined first are only there |
| 673 |
% because we now need to use \cs{csname} and this way the code will |
| 674 |
% be a little faster. |
| 675 |
% \begin{macrocode} |
| 676 |
\expandafter\let\expandafter\reserved@b |
| 677 |
\csname mdseries@\@currentmetafamily\endcsname |
| 678 |
\expandafter\let\expandafter\reserved@c |
| 679 |
\csname bfseries@\@currentmetafamily\endcsname |
| 680 |
%<+debug>\series@change@debug{Targets for mdseries and bfseries: |
| 681 |
%<+debug> \reserved@b\space and \reserved@c}% |
| 682 |
% \end{macrocode} |
| 683 |
% This here is now identical to the nested \cs{ifx} block from the |
| 684 |
% outline, except that it there appeared twice in |
| 685 |
% \cs{rmfamily}. This is now covered by looping and stopping the |
| 686 |
% loop when a match was found. |
| 687 |
% \begin{macrocode} |
| 688 |
% \end{macrocode} |
| 689 |
% We have to sanitize the default value first because it may |
| 690 |
% contain something like \texttt{mc} and that would never match |
| 691 |
% \cs{f@series} because there it would be called \texttt{c} with |
| 692 |
% the \texttt{m} dropped. It would be probably better to do that |
| 693 |
% differently these days, but it is hard to adjust without causing |
| 694 |
% a lot of issues, so we do the dropping in various places instead. |
| 695 |
% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from \cs{reserved@d} |
| 696 |
% (gh/291)} |
| 697 |
% \begin{macrocode} |
| 698 |
\expandafter\series@maybe@drop@one@m |
| 699 |
\csname mdseries@#1\endcsname\reserved@d |
| 700 |
\ifx\reserved@d\f@series |
| 701 |
%<+debug> \series@change@debug{mdseries@#1 matched -> \reserved@b}% |
| 702 |
\let\target@series@value\reserved@b |
| 703 |
\else |
| 704 |
% \end{macrocode} |
| 705 |
% Again do some sanitizing. |
| 706 |
% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from \cs{reserved@d} |
| 707 |
% (gh/291)} |
| 708 |
% \begin{macrocode} |
| 709 |
\expandafter\series@maybe@drop@one@m |
| 710 |
\csname bfseries@#1\endcsname\reserved@d |
| 711 |
\ifx\reserved@d\f@series |
| 712 |
%<+debug> \series@change@debug{bfseries@#1 matched -> \reserved@c}% |
| 713 |
\let\target@series@value\reserved@c |
| 714 |
\else\ifx\f@series\mddef@ult \let\target@series@value\reserved@b |
| 715 |
%<+debug> \series@change@debug{mddef@ult matched -> \reserved@b}% |
| 716 |
\else\ifx\f@series\bfdef@ult \let\target@series@value\reserved@c |
| 717 |
%<+debug> \series@change@debug{bfdef@ult matched -> \reserved@c}% |
| 718 |
\fi\fi\fi\fi |
| 719 |
\fi |
| 720 |
\fi |
| 721 |
} |
| 722 |
% \end{macrocode} |
| 723 |
% \end{macro} |
| 724 |
% |
| 725 |
% |
| 726 |
% \begin{macro}{\@restoremetafamily} |
| 727 |
% In some situations it might be necessary to rerun the command |
| 728 |
% that sets the current meta family, e.g., rerun \cs{rmfamily} if |
| 729 |
% \texttt{rm} is the current meta family (for example, |
| 730 |
% if the hook \texttt{rmfamily} contains some conditional code and |
| 731 |
% the condition has changed at that point). The command |
| 732 |
% \cs{@restoremetafamily} offers a simply way to do this. |
| 733 |
% \begin{macrocode} |
| 734 |
\def\@restoremetafamily{% |
| 735 |
\csname \@currentmetafamily family\endcsname |
| 736 |
} |
| 737 |
% \end{macrocode} |
| 738 |
% \end{macro} |
| 739 |
% \begin{macrocode} |
| 740 |
%</2ekernel|latexrelease> |
| 741 |
%<latexrelease>\EndIncludeInRelease |
| 742 |
% \end{macrocode} |
| 743 |
% |
| 744 |
% \begin{macrocode} |
| 745 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 746 |
%<latexrelease> {\prepare@family@series@update}{Custom series}% |
| 747 |
%<latexrelease> |
| 748 |
%<latexrelease>\def\@meta@family@list{\@elt{rm}\@elt{sf}\@elt{tt}} |
| 749 |
%<latexrelease>\def\prepare@family@series@update#1#2{% |
| 750 |
%<latexrelease> \if@forced@series |
| 751 |
%<latexrelease> \fontfamily#2% |
| 752 |
%<latexrelease> \else |
| 753 |
%<latexrelease> \expand@font@defaults |
| 754 |
%<latexrelease> \let\target@series@value\@empty |
| 755 |
%<latexrelease> \def\target@meta@family@value{#1}% |
| 756 |
%<latexrelease> \expandafter\edef\csname ??def@ult\endcsname{\f@family}% |
| 757 |
%<latexrelease> \let\@elt\update@series@target@value |
| 758 |
%<latexrelease> \@meta@family@list |
| 759 |
%<latexrelease> \@elt{??}% |
| 760 |
%<latexrelease> \let\@elt\relax |
| 761 |
%<latexrelease> \fontfamily#2% |
| 762 |
%<latexrelease> \ifx\target@series@value\@empty |
| 763 |
%<latexrelease> \else |
| 764 |
%<latexrelease> \ifx \f@series\target@series@value |
| 765 |
%<latexrelease> \else |
| 766 |
%<latexrelease> \maybe@load@fontshape |
| 767 |
%<latexrelease> \series@maybe@drop@one@m\target@series@value\f@series |
| 768 |
%<latexrelease> \fi |
| 769 |
%<latexrelease> \fi |
| 770 |
%<latexrelease> \fi |
| 771 |
%<latexrelease>} |
| 772 |
%<latexrelease>\def\update@series@target@value#1{% |
| 773 |
%<latexrelease> \def\reserved@a{#1}% |
| 774 |
%<latexrelease> \ifx\target@meta@family@value\reserved@a % rm -> rm do nothing |
| 775 |
%<latexrelease> \else |
| 776 |
%<latexrelease> \expandafter\ifx\csname#1def@ult\endcsname\f@family |
| 777 |
%<latexrelease> \let\@elt\@gobble |
| 778 |
%<latexrelease> \expandafter\let\expandafter\reserved@b |
| 779 |
%<latexrelease> \csname mdseries@\target@meta@family@value\endcsname |
| 780 |
%<latexrelease> \expandafter\let\expandafter\reserved@c |
| 781 |
%<latexrelease> \csname bfseries@\target@meta@family@value\endcsname |
| 782 |
%<latexrelease> \expandafter\series@maybe@drop@one@m |
| 783 |
%<latexrelease> \csname mdseries@#1\endcsname\reserved@d |
| 784 |
%<latexrelease> \ifx\reserved@d\f@series |
| 785 |
%<latexrelease> \let\target@series@value\reserved@b |
| 786 |
%<latexrelease> \else |
| 787 |
%<latexrelease> \expandafter\series@maybe@drop@one@m |
| 788 |
%<latexrelease> \csname bfseries@#1\endcsname\reserved@d |
| 789 |
%<latexrelease> \ifx\reserved@d\f@series |
| 790 |
%<latexrelease> \let\target@series@value\reserved@c |
| 791 |
%<latexrelease> \else\ifx\f@series\mddef@ult \let\target@series@value\reserved@b |
| 792 |
%<latexrelease> \else\ifx\f@series\bfdef@ult \let\target@series@value\reserved@c |
| 793 |
%<latexrelease> \fi\fi\fi\fi |
| 794 |
%<latexrelease> \fi |
| 795 |
%<latexrelease> \fi |
| 796 |
%<latexrelease>} |
| 797 |
% \end{macrocode} |
| 798 |
% |
| 799 |
% \begin{macrocode} |
| 800 |
%<latexrelease>\EndIncludeInRelease |
| 801 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 802 |
%<latexrelease> {\prepare@family@series@update}{Custom series}% |
| 803 |
%<latexrelease> |
| 804 |
%<latexrelease>\let\@meta@family@list\@undefined |
| 805 |
%<latexrelease>\let\prepare@family@series@update\@undefined |
| 806 |
%<latexrelease>\let\update@series@target@value\@undefined |
| 807 |
%<latexrelease> |
| 808 |
%<latexrelease>\EndIncludeInRelease |
| 809 |
%<*2ekernel> |
| 810 |
% \end{macrocode} |
| 811 |
% |
| 812 |
% |
| 813 |
% |
| 814 |
% |
| 815 |
% \begin{macro}{\init@series@setup} |
| 816 |
% |
| 817 |
% \begin{macrocode} |
| 818 |
%</2ekernel> |
| 819 |
%<*2ekernel|latexrelease> |
| 820 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 821 |
%<latexrelease> {\init@series@setup}{Custom series}% |
| 822 |
% \end{macrocode} |
| 823 |
% |
| 824 |
% This is code to be run at begin document \ldots |
| 825 |
% \begin{macrocode} |
| 826 |
\def\init@series@setup{% |
| 827 |
% \end{macrocode} |
| 828 |
% |
| 829 |
% We only want \texttt{bx} in \cs{bfseries@rm} if the roman font is |
| 830 |
% Computer Modern or Latin Modern, otherwise it should be |
| 831 |
% \texttt{b}. It was set to \texttt{bx} in the kernel so that any |
| 832 |
% font use with the default families in the preamble get this |
| 833 |
% value. Now at the real document start we check if the fonts have |
| 834 |
% been changed. If there was a \cs{DeclareFontSeriesDefault} |
| 835 |
% declaration or \cs{bfseries@rm} was directly altered then it |
| 836 |
% differs from \cs{bfseries@rm@kernel} and we do nothing. |
| 837 |
% Otherwise we check if \cs{rmdefault} is one of the CM/LM font |
| 838 |
% families and if so we keep \texttt{bx} otherwise we change it to |
| 839 |
% \texttt{b}. |
| 840 |
% |
| 841 |
% This approach doesn't cover one case: CM/LM got changed to a |
| 842 |
% different family that supports \texttt{bx}, but the support |
| 843 |
% package for that family used \verb=\def\bfseries@rm{bx}= instead |
| 844 |
% of using \cs{DeclareFontSeriesDefault}. In that case the code |
| 845 |
% here changes it to \texttt{b}. Solution: use the |
| 846 |
% \cs{DeclareFontSeriesDefault} interface. |
| 847 |
% \begin{macrocode} |
| 848 |
\ifx\bfseries@rm@kernel\bfseries@rm |
| 849 |
\expandafter\in@\expandafter{\rmdefault}% |
| 850 |
{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}% |
| 851 |
\ifin@ \else \def\bfseries@rm{b}\fi\fi |
| 852 |
% \end{macrocode} |
| 853 |
% Same approach for \cs{bfseries@sf} and \cs{bfseries@tt}: |
| 854 |
% \begin{macrocode} |
| 855 |
\ifx\bfseries@sf@kernel\bfseries@sf |
| 856 |
\expandafter\in@\expandafter{\sfdefault}% |
| 857 |
{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}% |
| 858 |
\ifin@ \else \def\bfseries@sf{b}\fi\fi |
| 859 |
\ifx\bfseries@tt@kernel\bfseries@tt |
| 860 |
\expandafter\in@\expandafter{\ttdefault}% |
| 861 |
{cmr,cmss,cmtt,lcmss,lcmtt,lmr,lmss,lmtt}% |
| 862 |
\ifin@ \else \def\bfseries@tt{b}\fi\fi |
| 863 |
% \end{macrocode} |
| 864 |
% |
| 865 |
% If the document preamble has changed the \cs{familydefault} or if |
| 866 |
% the if the \cs{rmdefault} contains a new font family, we may have to |
| 867 |
% adjust the series defaults accordingly, before starting |
| 868 |
% typesetting. |
| 869 |
% |
| 870 |
% Similarly, if the user has changed the \cs{mddefault} or the |
| 871 |
% medium series for the family selected as document font we may |
| 872 |
% also have to adjust the \cs{seriesdefault}. |
| 873 |
% |
| 874 |
% On the other hand if the document font is still CM or LM then |
| 875 |
% \cs{bfdefault} is wrong, because it is now saying \texttt{b} and not |
| 876 |
% \texttt{bx} as it should for such fonts. |
| 877 |
% |
| 878 |
% To fix all this we first run \cs{reset@font} (the internal kernel |
| 879 |
% name for \cs{normalfont}). This will set up the document encoding, |
| 880 |
% family, series and shape based on the current values of |
| 881 |
% \cs{encodingdefault}, \cs{familydefault}, \cs{seriesdefault} and |
| 882 |
% \cs{shapedefault}. |
| 883 |
% However, if the family (from \cs{familydefault}) has special medium |
| 884 |
% default we should switch to that (and not use what is current |
| 885 |
% value from \cs{seriesdefault}). This can be achieved by afterwards |
| 886 |
% calling \cs{mediumseries} and then changing \cs{seriesdefault} to |
| 887 |
% the now current series value (in \cs{f@series}). |
| 888 |
% |
| 889 |
% But what should happen if \cs{seriesdefault} got explicitly |
| 890 |
% changed? In that case the explicit change should survive and we |
| 891 |
% should not alter \cs{seriesdefault}. This is solved by comparing |
| 892 |
% the current value of \cs{seriesdefault} with a kernel version |
| 893 |
% saved in the format and if they differ we do not call |
| 894 |
% \cs{mdseries} or change \cs{seriesdefault}. |
| 895 |
% \changes{v3.1n}{2020/04/13}{Handling \cs{seriesdefault} changes (gh/315)} |
| 896 |
% \begin{macrocode} |
| 897 |
\reset@font |
| 898 |
\ifx\seriesdefault\seriesdefault@kernel |
| 899 |
\mdseries |
| 900 |
\let\seriesdefault\f@series |
| 901 |
\fi |
| 902 |
}% |
| 903 |
% \end{macrocode} |
| 904 |
% \end{macro} |
| 905 |
% |
| 906 |
% |
| 907 |
% |
| 908 |
% As the kernel code now implements the same functionality as |
| 909 |
% \textsf{mweights}, albeit internally coded slightly differently, |
| 910 |
% that package shouldn't be loaded any more. We therefore pretend |
| 911 |
% that it already got loaded. Thus, a font package that tries to |
| 912 |
% load it and then sets \cs{mdseries@..}, etc.\ will continue to |
| 913 |
% work but will now use the kernel code. |
| 914 |
% |
| 915 |
% Of course, mid-term such package should probably use |
| 916 |
% \cs{DeclareFontSeriesDefault} instead of making using low-level |
| 917 |
% definitions. |
| 918 |
% |
| 919 |
% \begin{macrocode} |
| 920 |
\expandafter\let\csname [email protected]\endcsname\fmtversion |
| 921 |
% \end{macrocode} |
| 922 |
% |
| 923 |
% |
| 924 |
% |
| 925 |
% \begin{macrocode} |
| 926 |
%</2ekernel|latexrelease> |
| 927 |
%<latexrelease>\EndIncludeInRelease |
| 928 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 929 |
%<latexrelease> {\init@series@setup}{Custom series}% |
| 930 |
% \end{macrocode} |
| 931 |
% This is always called in \cs{document} so don't make it undefined. |
| 932 |
% \begin{macrocode} |
| 933 |
%<latexrelease>\let\init@series@setup\relax |
| 934 |
%<latexrelease> |
| 935 |
%<latexrelease>\expandafter\let\csname [email protected]\endcsname\@undefined |
| 936 |
%<latexrelease> |
| 937 |
%<latexrelease>\EndIncludeInRelease |
| 938 |
%<*2ekernel> |
| 939 |
% \end{macrocode} |
| 940 |
% |
| 941 |
% |
| 942 |
% \begin{macrocode} |
| 943 |
%</2ekernel> |
| 944 |
%<*2ekernel|latexrelease> |
| 945 |
%<latexrelease>\IncludeInRelease{2021/11/15}% |
| 946 |
%<latexrelease> {\bfseries}{Custom series with hooks}% |
| 947 |
% \end{macrocode} |
| 948 |
|
| 949 |
|
| 950 |
% \begin{macro}{\bfseries} |
| 951 |
% This document command switches to the bold series. |
| 952 |
% \begin{macrocode} |
| 953 |
\DeclareRobustCommand\bfseries{% |
| 954 |
\not@math@alphabet\bfseries\mathbf |
| 955 |
% \end{macrocode} |
| 956 |
% In the original NFSS definition it then called \cs{fontseries} |
| 957 |
% with the value \cs{bfdefault}. In the new scheme we have more |
| 958 |
% alternatives and therefore check if the current family |
| 959 |
% (\cs{f@family}) is the current \cs{rmdef@ult}, \cs{sfdef@ult} or |
| 960 |
% \cs{ttdef@ult} and the select the correct family default in that case. |
| 961 |
% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside |
| 962 |
% of \cs{fontseries} argument so that it is not done several times} |
| 963 |
% \changes{v3.2i}{2021/09/10}{Do delayed changes to \cs{bfdefault} in |
| 964 |
% a separate macro for better reuse (gh/663)} |
| 965 |
% \begin{macrocode} |
| 966 |
\expand@font@defaults |
| 967 |
\maybe@update@bfseries@defaults |
| 968 |
% \end{macrocode} |
| 969 |
% |
| 970 |
% \begin{macrocode} |
| 971 |
\ifx\f@family\rmdef@ult \fontseries\bfseries@rm |
| 972 |
\else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf |
| 973 |
\else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt |
| 974 |
% \end{macrocode} |
| 975 |
% If not \cs{bfdefault} is used. |
| 976 |
% \begin{macrocode} |
| 977 |
\else \fontseries\bfdefault |
| 978 |
\fi\fi\fi |
| 979 |
% \end{macrocode} |
| 980 |
% This hook in contrast is always executed. |
| 981 |
% \begin{macrocode} |
| 982 |
\UseHook{bfseries}% |
| 983 |
\selectfont |
| 984 |
} |
| 985 |
% \end{macrocode} |
| 986 |
% \end{macro} |
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
% \begin{macro}{\maybe@update@bfseries@defaults} |
| 991 |
% |
| 992 |
% If \cs{bfdefault} and \cs{bfdefault@previous} are different then |
| 993 |
% the default got changed directly through the legacy interface |
| 994 |
% (i.e., via \cs{def} or \cs{renewcommand}). In that case we reset |
| 995 |
% all meta family defaults so that the document behaves like it was |
| 996 |
% the case before the new mechanism was introduced. |
| 997 |
% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault} |
| 998 |
% and \cs{mddefault} (gh/306)} |
| 999 |
% \changes{v3.2i}{2021/09/10}{Do delayed changes to \cs{bfdefault} in |
| 1000 |
% a separate macro for better reuse (gh/663)} |
| 1001 |
% \begin{macrocode} |
| 1002 |
\def\maybe@update@bfseries@defaults{% |
| 1003 |
\ifx\bfdefault\bfdefault@previous\else |
| 1004 |
% \end{macrocode} |
| 1005 |
% We add \cs{@empty} and then let \cs{bfdefault@previous} to |
| 1006 |
% \cs{bfdefault} so that we can detect any further change. |
| 1007 |
% \changes{v3.2d}{2020/09/30}{\cs{bfdefault@previous} not \cs{bfseries@previous} |
| 1008 |
% (gh/395)} |
| 1009 |
% \begin{macrocode} |
| 1010 |
\expandafter\def\expandafter\bfdefault |
| 1011 |
\expandafter{\bfdefault\@empty}% |
| 1012 |
\let\bfdefault@previous\bfdefault |
| 1013 |
% \end{macrocode} |
| 1014 |
% And we reset the meta family defaults (\cs{bfdef@ult} is an |
| 1015 |
% expanded version of \cs{bfdefault}). |
| 1016 |
% \begin{macrocode} |
| 1017 |
\let\bfseries@rm\bfdef@ult |
| 1018 |
\let\bfseries@sf\bfdef@ult |
| 1019 |
\let\bfseries@tt\bfdef@ult |
| 1020 |
% \end{macrocode} |
| 1021 |
% |
| 1022 |
% Formats that set up parallel fonts, e.g., for Japanese, can use |
| 1023 |
% this hook to add resets here. Not that this hook is only run when |
| 1024 |
% resets are necessary. |
| 1025 |
% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)} |
| 1026 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1027 |
% \begin{macrocode} |
| 1028 |
\UseHook{bfseries/defaults}% |
| 1029 |
\fi |
| 1030 |
} |
| 1031 |
% \end{macrocode} |
| 1032 |
% \end{macro} |
| 1033 |
|
| 1034 |
|
| 1035 |
% \begin{macro}{\mdseries} |
| 1036 |
% This document command switches to the medium series. |
| 1037 |
% \changes{v3.1i}{2020/02/18}{Make the \cs{ifx} selection outside |
| 1038 |
% of \cs{fontseries} argument so that it is not done several times} |
| 1039 |
% \changes{v3.1k}{2020/03/19}{Support legacy use of \cs{bfdefault} |
| 1040 |
% and \cs{mddefault} (gh/306)} |
| 1041 |
% \changes{v3.2d}{2020/09/30}{\cs{mddefault@previous} not \cs{mdseries@previous} |
| 1042 |
% (gh/395)} |
| 1043 |
% \changes{v3.2i}{2021/09/10}{Do delayed changes to \cs{mddefault} in |
| 1044 |
% a separate macro for better reuse (gh/663)} |
| 1045 |
% \begin{macrocode} |
| 1046 |
\DeclareRobustCommand\mdseries{% |
| 1047 |
\not@math@alphabet\mdseries\relax |
| 1048 |
\expand@font@defaults |
| 1049 |
\maybe@update@mdseries@defaults |
| 1050 |
\ifx\f@family\rmdef@ult \fontseries\mdseries@rm |
| 1051 |
\else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf |
| 1052 |
\else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt |
| 1053 |
\else \fontseries\mddefault |
| 1054 |
\fi\fi\fi |
| 1055 |
\UseHook{mdseries}% |
| 1056 |
\selectfont |
| 1057 |
} |
| 1058 |
% \end{macrocode} |
| 1059 |
% \end{macro} |
| 1060 |
|
| 1061 |
% \begin{macro}{\maybe@update@mdseries@defaults} |
| 1062 |
% |
| 1063 |
% \changes{v3.2i}{2021/09/10}{Do delayed changes to \cs{mddefault} in |
| 1064 |
% a separate macro for better reuse (gh/663)} |
| 1065 |
% \begin{macrocode} |
| 1066 |
\def\maybe@update@mdseries@defaults{% |
| 1067 |
\ifx\mddefault\mddefault@previous\else |
| 1068 |
\expandafter\def\expandafter\mddefault\expandafter{\mddefault\@empty}% |
| 1069 |
\let\mddefault@previous\mddefault |
| 1070 |
\let\mdseries@rm\mddef@ult |
| 1071 |
\let\mdseries@sf\mddef@ult |
| 1072 |
\let\mdseries@tt\mddef@ult |
| 1073 |
% \end{macrocode} |
| 1074 |
% |
| 1075 |
% Formats that set up parallel fonts, e.g., for Japanese, can use |
| 1076 |
% this hook to add resets here. |
| 1077 |
% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)} |
| 1078 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1079 |
% \begin{macrocode} |
| 1080 |
\UseHook{mdseries/defaults}% |
| 1081 |
\fi |
| 1082 |
} |
| 1083 |
% \end{macrocode} |
| 1084 |
% \end{macro} |
| 1085 |
|
| 1086 |
% |
| 1087 |
% \begin{macrocode} |
| 1088 |
%</2ekernel|latexrelease> |
| 1089 |
%<latexrelease>\EndIncludeInRelease |
| 1090 |
%<latexrelease>\IncludeInRelease{2020/10/01}% |
| 1091 |
%<latexrelease> {\bfseries}{Custom series with hooks}% |
| 1092 |
%<latexrelease> |
| 1093 |
%<latexrelease>\let\maybe@update@bfseries@defaults\@undefined |
| 1094 |
%<latexrelease>\let\maybe@update@mdseries@defaults\@undefined |
| 1095 |
%<latexrelease> |
| 1096 |
%<latexrelease>\DeclareRobustCommand\bfseries{% |
| 1097 |
%<latexrelease> \not@math@alphabet\bfseries\mathbf |
| 1098 |
%<latexrelease> \expand@font@defaults |
| 1099 |
%<latexrelease> \ifx\bfdefault\bfdefault@previous\else |
| 1100 |
%<latexrelease> \expandafter\def\expandafter\bfdefault |
| 1101 |
%<latexrelease> \expandafter{\bfdefault\@empty}% |
| 1102 |
%<latexrelease> \let\bfdefault@previous\bfdefault |
| 1103 |
%<latexrelease> \let\bfseries@rm\bfdef@ult |
| 1104 |
%<latexrelease> \let\bfseries@sf\bfdef@ult |
| 1105 |
%<latexrelease> \let\bfseries@tt\bfdef@ult |
| 1106 |
%<latexrelease> \UseHook{bfseries/defaults}% |
| 1107 |
%<latexrelease> \fi |
| 1108 |
%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\bfseries@rm |
| 1109 |
%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf |
| 1110 |
%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt |
| 1111 |
%<latexrelease> \else \fontseries\bfdefault |
| 1112 |
%<latexrelease> \fi\fi\fi |
| 1113 |
%<latexrelease> \UseHook{bfseries}% |
| 1114 |
%<latexrelease> \selectfont |
| 1115 |
%<latexrelease>} |
| 1116 |
%<latexrelease> |
| 1117 |
%<latexrelease>\DeclareRobustCommand\mdseries{% |
| 1118 |
%<latexrelease> \not@math@alphabet\mdseries\relax |
| 1119 |
%<latexrelease> \expand@font@defaults |
| 1120 |
%<latexrelease> \ifx\mddefault\mddefault@previous\else |
| 1121 |
%<latexrelease> \expandafter\def\expandafter\mddefault\expandafter{\mddefault\@empty}% |
| 1122 |
%<latexrelease> \let\mddefault@previous\mddefault |
| 1123 |
%<latexrelease> \let\mdseries@rm\mddef@ult |
| 1124 |
%<latexrelease> \let\mdseries@sf\mddef@ult |
| 1125 |
%<latexrelease> \let\mdseries@tt\mddef@ult |
| 1126 |
%<latexrelease> \UseHook{mdseries/defaults}% |
| 1127 |
%<latexrelease> \fi |
| 1128 |
%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\mdseries@rm |
| 1129 |
%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf |
| 1130 |
%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt |
| 1131 |
%<latexrelease> \else \fontseries\mddefault |
| 1132 |
%<latexrelease> \fi\fi\fi |
| 1133 |
%<latexrelease> \UseHook{mdseries}% |
| 1134 |
%<latexrelease> \selectfont |
| 1135 |
%<latexrelease>} |
| 1136 |
%<latexrelease>\EndIncludeInRelease |
| 1137 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 1138 |
%<latexrelease> {\bfseries}{Custom series with hooks}% |
| 1139 |
%<latexrelease> |
| 1140 |
%<latexrelease> |
| 1141 |
%<latexrelease>\DeclareRobustCommand\bfseries{% |
| 1142 |
%<latexrelease> \not@math@alphabet\bfseries\mathbf |
| 1143 |
%<latexrelease> \expand@font@defaults |
| 1144 |
%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\bfseries@rm |
| 1145 |
%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf |
| 1146 |
%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt |
| 1147 |
%<latexrelease> \else \fontseries\bfdefault |
| 1148 |
%<latexrelease> \fi\fi\fi |
| 1149 |
%<latexrelease> \selectfont |
| 1150 |
%<latexrelease>} |
| 1151 |
%<latexrelease> |
| 1152 |
%<latexrelease>\DeclareRobustCommand\mdseries{% |
| 1153 |
%<latexrelease> \not@math@alphabet\mdseries\relax |
| 1154 |
%<latexrelease> \expand@font@defaults |
| 1155 |
%<latexrelease> \ifx\f@family\rmdef@ult \fontseries\mdseries@rm |
| 1156 |
%<latexrelease> \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf |
| 1157 |
%<latexrelease> \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt |
| 1158 |
%<latexrelease> \else \fontseries\mddefault |
| 1159 |
%<latexrelease> \fi\fi\fi |
| 1160 |
%<latexrelease> \selectfont |
| 1161 |
%<latexrelease>} |
| 1162 |
%<latexrelease> |
| 1163 |
%<latexrelease> |
| 1164 |
% \end{macrocode} |
| 1165 |
% |
| 1166 |
% \begin{macrocode} |
| 1167 |
%<latexrelease> |
| 1168 |
%<latexrelease>\EndIncludeInRelease |
| 1169 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 1170 |
%<latexrelease> {\bfseries}{Custom series with hooks}% |
| 1171 |
%<latexrelease> |
| 1172 |
%<latexrelease>\DeclareRobustCommand\bfseries |
| 1173 |
%<latexrelease> {\not@math@alphabet\bfseries\mathbf |
| 1174 |
%<latexrelease> \fontseries\bfdefault\selectfont} |
| 1175 |
%<latexrelease>\DeclareRobustCommand\mdseries |
| 1176 |
%<latexrelease> {\not@math@alphabet\mdseries\relax |
| 1177 |
%<latexrelease> \fontseries\mddefault\selectfont} |
| 1178 |
%<latexrelease> |
| 1179 |
%<latexrelease>\EndIncludeInRelease |
| 1180 |
%<*2ekernel> |
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
%</2ekernel> |
| 1186 |
%<*2ekernel|latexrelease> |
| 1187 |
%<latexrelease>\IncludeInRelease{2020/10/01}% |
| 1188 |
%<latexrelease> {\expand@font@defaults}{Custom series with hooks}% |
| 1189 |
% \end{macrocode} |
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
% \begin{macro}{\expand@font@defaults} |
| 1194 |
% \begin{macro}{\rm@def@ult} |
| 1195 |
% \begin{macro}{\sf@def@ult} |
| 1196 |
% \begin{macro}{\tt@def@ult} |
| 1197 |
% \begin{macro}{\md@def@ult} |
| 1198 |
% \begin{macro}{\bf@def@ult} |
| 1199 |
% |
| 1200 |
% The family specific defaults are fully expanded, i.e., they are |
| 1201 |
% defined via \cs{edef} inside \cs{DeclareFontSeriesDefault}. |
| 1202 |
% However, the overall defaults, e.g., \cs{bfdefault} may have been |
| 1203 |
% redefined by the user and thus may not be fully expanded. So to |
| 1204 |
% enable reliable comparison we make expanded versions of |
| 1205 |
% them. That we rerun each time. The alternative would be to only |
| 1206 |
% allow for changes before begin document. |
| 1207 |
% \begin{macrocode} |
| 1208 |
\def\expand@font@defaults{% |
| 1209 |
\edef\rmdef@ult{\rmdefault}% |
| 1210 |
\edef\sfdef@ult{\sfdefault}% |
| 1211 |
\edef\ttdef@ult{\ttdefault}% |
| 1212 |
% \end{macrocode} |
| 1213 |
% The series defaults may contain some surplus \texttt{m} that we |
| 1214 |
% need to drop here. |
| 1215 |
% \changes{v3.1j}{2020/02/25}{Drop surplus ``m'' from \cs{bfdef@ult} |
| 1216 |
% and \cs{mddef@ult} (gh/291)} |
| 1217 |
% \begin{macrocode} |
| 1218 |
\series@maybe@drop@one@m\bfdefault\bfdef@ult |
| 1219 |
\series@maybe@drop@one@m\mddefault\mddef@ult |
| 1220 |
% \end{macrocode} |
| 1221 |
% Formats that set up parallel fonts, e.g., for Japanese, can use |
| 1222 |
% this hook to add additional code here. |
| 1223 |
% \changes{v3.1m}{2020/04/06}{Hook added (gh/306)} |
| 1224 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1225 |
% \begin{macrocode} |
| 1226 |
\UseHook{expand@font@defaults}% |
| 1227 |
} |
| 1228 |
% \end{macrocode} |
| 1229 |
% \end{macro} |
| 1230 |
% \end{macro} |
| 1231 |
% \end{macro} |
| 1232 |
% \end{macro} |
| 1233 |
% \end{macro} |
| 1234 |
% \end{macro} |
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
% \begin{macro}{\rmfamily} |
| 1239 |
% Here are the document level commands for changing the main font |
| 1240 |
% families, or rather, here is a documented outline of the code, |
| 1241 |
% the actual code is then streamlined and somewhat generalized. |
| 1242 |
%\begin{verbatim} |
| 1243 |
%\DeclareRobustCommand\rmfamily{% |
| 1244 |
% \not@math@alphabet\rmfamily\mathrm |
| 1245 |
%\end{verbatim} |
| 1246 |
% If families are changed then we have to do a bit more work. |
| 1247 |
% In the original NFSS implementation |
| 1248 |
% a family change kept encoding, series shape and size unchanged |
| 1249 |
% but now we can't any |
| 1250 |
% longer simply reuse the current series value. Instead we may have |
| 1251 |
% to change it from one family default to the next. |
| 1252 |
%\begin{verbatim} |
| 1253 |
% \expand@font@defaults |
| 1254 |
%\end{verbatim} |
| 1255 |
% We have to do the testing while the current family is still |
| 1256 |
% unchanged but we have to do the adjustment of the series after it |
| 1257 |
% got changed (because the new family might have different sets |
| 1258 |
% of shapes available and we certainly don't want to see |
| 1259 |
% substitution going on. So we use \cs{target@series@value} to |
| 1260 |
% hold the target series (if any). |
| 1261 |
%\begin{verbatim} |
| 1262 |
% \let\target@series@value\@empty |
| 1263 |
%\end{verbatim} |
| 1264 |
% Thus, if the current family is the sans family |
| 1265 |
%\begin{verbatim} |
| 1266 |
% \ifx\f@family\sfdef@ult |
| 1267 |
%\end{verbatim} |
| 1268 |
% and if we using the medium series of the sans family |
| 1269 |
%\begin{verbatim} |
| 1270 |
% \ifx\f@series\mdseries@sf |
| 1271 |
%\end{verbatim} |
| 1272 |
% then lets switch to the medium series for the serif family |
| 1273 |
%\begin{verbatim} |
| 1274 |
% \let\target@series@value\mdseries@rm |
| 1275 |
%\end{verbatim} |
| 1276 |
% and if we use the bold series of the sans family switch to the |
| 1277 |
% bold default of the serif family: |
| 1278 |
%\begin{verbatim} |
| 1279 |
% \else\ifx\f@series\bfseries@sf \let\target@series@value\bfseries@rm |
| 1280 |
%\end{verbatim} |
| 1281 |
% However, the sans family may not have any specific defaults set, |
| 1282 |
% so we also compare with the overall defaults. |
| 1283 |
%\begin{verbatim} |
| 1284 |
% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm |
| 1285 |
% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm |
| 1286 |
%\end{verbatim} |
| 1287 |
% If neither test was true we leave the series alone. This way a |
| 1288 |
% special manual setting such as \verb=\fontseries{lc}= is not |
| 1289 |
% undone if the family changes (of course there may not be any |
| 1290 |
% support for it in the new family but then the NFSS |
| 1291 |
% substitution kicks in and sorts it out). |
| 1292 |
%\begin{verbatim} |
| 1293 |
% \fi\fi\fi\fi |
| 1294 |
% |
| 1295 |
%\end{verbatim} |
| 1296 |
% We need to do the same if the current family is the typewriter family: |
| 1297 |
%\begin{verbatim} |
| 1298 |
% \else\ifx\f@family\ttdef@ult |
| 1299 |
% \ifx\f@series\mdseries@tt \let\target@series@value\mdseries@rm |
| 1300 |
% \else\ifx\f@series\bfseries@tt \let\target@series@value\bfseries@rm |
| 1301 |
% \else\ifx\f@series\mddef@ult \let\target@series@value\mdseries@rm |
| 1302 |
% \else\ifx\f@series\bfdef@ult \let\target@series@value\bfseries@rm |
| 1303 |
% \fi\fi\fi\fi |
| 1304 |
% \fi\fi |
| 1305 |
%\end{verbatim} |
| 1306 |
% With these preparations for series out of the way we can now |
| 1307 |
% change the font family to \cs{rmdefault}. |
| 1308 |
%\begin{verbatim} |
| 1309 |
% \fontfamily\rmdefault |
| 1310 |
%\end{verbatim} |
| 1311 |
% |
| 1312 |
% If \cs{target@series@value} is still empty there is nothing more |
| 1313 |
% to do other than selecting the new family. However, if not then |
| 1314 |
% we should update the font series now as well. But there is one |
| 1315 |
% further subtle issue. We may not have loaded an \texttt{.fd} file |
| 1316 |
% for our target font family yet. In the past that was done in |
| 1317 |
% \cs{selectfont} if necessary but since we are now doing all the |
| 1318 |
% comparisons in \cs{fontseries} we need to make sure that the font |
| 1319 |
% family specifications are already loaded prior to calling |
| 1320 |
% \cs{fontseries}. |
| 1321 |
%\begin{verbatim} |
| 1322 |
% \ifx\target@series@value\@empty \else |
| 1323 |
% \maybe@load@fontshape |
| 1324 |
%\end{verbatim} |
| 1325 |
% Updating the series in this case means directly changing |
| 1326 |
% \cs{f@series} to the target value. We don't want to go through |
| 1327 |
% \cs{fontseries} because that would apply the mappings and then |
| 1328 |
% \texttt{bx + b} would keep \texttt{bx} instead of changing to |
| 1329 |
% \texttt{b} as desired. |
| 1330 |
% as |
| 1331 |
%\begin{verbatim} |
| 1332 |
% \let\f@series\target@series@value |
| 1333 |
% \fi |
| 1334 |
% \selectfont} |
| 1335 |
%\end{verbatim} |
| 1336 |
% |
| 1337 |
% So now for the real definition: most of the code above gets |
| 1338 |
% delegated to a helper command \cs{prepare@family@series@update} |
| 1339 |
% so that the definition becomes again fairly short. In addition we |
| 1340 |
% add a hook, mainly for our Japanese friends so that the code can |
| 1341 |
% be extended prior to the call to \cs{selectfont}. |
| 1342 |
% |
| 1343 |
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook} |
| 1344 |
% \begin{macrocode} |
| 1345 |
\DeclareRobustCommand\rmfamily{% |
| 1346 |
\not@math@alphabet\rmfamily\mathrm |
| 1347 |
% \end{macrocode} |
| 1348 |
% This holds all the code discussed above, first argument is the |
| 1349 |
% meta family, i.e., \texttt{rm} in this case, and second argument |
| 1350 |
% is the default family name, e.g., \texttt{cmr} indirectly |
| 1351 |
% accessed via \cs{rmdefault}. This is calling \cs{fontfamily} and |
| 1352 |
% if necessary \cs{fontseries} as outline above. |
| 1353 |
% \begin{macrocode} |
| 1354 |
\prepare@family@series@update{rm}\rmdefault |
| 1355 |
% \end{macrocode} |
| 1356 |
% Then comes the hook code (by default a no-op) and finally the call |
| 1357 |
% to \cs{selectfont}. |
| 1358 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1359 |
% \begin{macrocode} |
| 1360 |
\UseHook{rmfamily}% |
| 1361 |
\selectfont} |
| 1362 |
% \end{macrocode} |
| 1363 |
% |
| 1364 |
% \begin{macro}{\sffamily} |
| 1365 |
% \begin{macro}{\ttfamily} |
| 1366 |
% The definitions for \cs{sffamily} and \cs{ttfamily} are similar, |
| 1367 |
% the differences are only in what font families get checked. |
| 1368 |
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook} |
| 1369 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1370 |
% \begin{macrocode} |
| 1371 |
\DeclareRobustCommand\sffamily{% |
| 1372 |
\not@math@alphabet\sffamily\mathsf |
| 1373 |
\prepare@family@series@update{sf}\sfdefault |
| 1374 |
\UseHook{sffamily}% |
| 1375 |
\selectfont} |
| 1376 |
% \end{macrocode} |
| 1377 |
% |
| 1378 |
% \changes{v3.1f}{2020/01/11}{Streamlined implementation with hook} |
| 1379 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1380 |
% \begin{macrocode} |
| 1381 |
\DeclareRobustCommand\ttfamily{% |
| 1382 |
\not@math@alphabet\ttfamily\mathtt |
| 1383 |
\prepare@family@series@update{tt}\ttdefault |
| 1384 |
\UseHook{ttfamily}% |
| 1385 |
\selectfont} |
| 1386 |
% \end{macrocode} |
| 1387 |
% \end{macro} |
| 1388 |
% \end{macro} |
| 1389 |
% \end{macro} |
| 1390 |
% |
| 1391 |
% |
| 1392 |
% \begin{macro}{rmfamily,sffamily,ttfamily,normalfont,expand@font@defaults, |
| 1393 |
% bfseries,bfseries/defaults,mdseries,mdseries/defaults} |
| 1394 |
% Declare the hooks used above. |
| 1395 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 1396 |
% \begin{macrocode} |
| 1397 |
\NewHook{rmfamily} |
| 1398 |
\NewHook{sffamily} |
| 1399 |
\NewHook{ttfamily} |
| 1400 |
\NewHook{normalfont} |
| 1401 |
\NewHook{expand@font@defaults} |
| 1402 |
\NewHook{bfseries} |
| 1403 |
\NewHook{bfseries/defaults} |
| 1404 |
\NewHook{mdseries} |
| 1405 |
\NewHook{mdseries/defaults} |
| 1406 |
% \end{macrocode} |
| 1407 |
% \end{macro} |
| 1408 |
% |
| 1409 |
% \begin{macro}{\@rmfamilyhook} |
| 1410 |
% \begin{macro}{\@sffamilyhook} |
| 1411 |
% \begin{macro}{\@ttfamilyhook} |
| 1412 |
% \begin{macro}{\@defaultfamilyhook} |
| 1413 |
% \changes{v3.1h}{2020/02/10}{Add \cs{@defaultfamilyhook} to \cs{normalfont} (gh/269)} |
| 1414 |
% These four hooks have legacy versions used in 2020/02/02 so we |
| 1415 |
% should support them until they aren't any longer used. |
| 1416 |
% |
| 1417 |
% By default the hooks do nothing and in new code they should not |
| 1418 |
% any longer be used. Instead use the standard hook system and the |
| 1419 |
% hook names \texttt{rmfamily}, \texttt{sffamily}, |
| 1420 |
% \texttt{ttfamily}. Instead of \cs{@defaultfamilyhook} use \texttt{normalfont}. |
| 1421 |
% |
| 1422 |
% \begin{macrocode} |
| 1423 |
\let\@rmfamilyhook\@empty |
| 1424 |
\let\@sffamilyhook\@empty |
| 1425 |
\let\@ttfamilyhook\@empty |
| 1426 |
\let\@defaultfamilyhook\@empty |
| 1427 |
% \end{macrocode} |
| 1428 |
% \end{macro} |
| 1429 |
% \end{macro} |
| 1430 |
% \end{macro} |
| 1431 |
% \end{macro} |
| 1432 |
% |
| 1433 |
% |
| 1434 |
% \changes{v3.2g}{2021/03/18} |
| 1435 |
% {Add legacy hook definitions for rollback.} |
| 1436 |
% \begin{macrocode} |
| 1437 |
%</2ekernel|latexrelease> |
| 1438 |
%<latexrelease>\EndIncludeInRelease |
| 1439 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 1440 |
%<latexrelease> {\expand@font@defaults}{Custom series with hooks}% |
| 1441 |
%<latexrelease> |
| 1442 |
%<latexrelease>\def\expand@font@defaults{% |
| 1443 |
%<latexrelease> \edef\rmdef@ult{\rmdefault}% |
| 1444 |
%<latexrelease> \edef\sfdef@ult{\sfdefault}% |
| 1445 |
%<latexrelease> \edef\ttdef@ult{\ttdefault}% |
| 1446 |
%<latexrelease> \edef\bfdef@ult{\bfdefault}% |
| 1447 |
%<latexrelease> \edef\mddef@ult{\mddefault}% |
| 1448 |
%<latexrelease> \edef\famdef@ult{\familydefault}% |
| 1449 |
%<latexrelease>} |
| 1450 |
%<latexrelease> |
| 1451 |
%<latexrelease> |
| 1452 |
%<latexrelease>\DeclareRobustCommand\rmfamily{% |
| 1453 |
%<latexrelease> \not@math@alphabet\rmfamily\mathrm |
| 1454 |
%<latexrelease> \prepare@family@series@update{rm}\rmdefault |
| 1455 |
%<latexrelease> \@rmfamilyhook |
| 1456 |
%<latexrelease> \selectfont} |
| 1457 |
%<latexrelease>\DeclareRobustCommand\sffamily{% |
| 1458 |
%<latexrelease> \not@math@alphabet\sffamily\mathsf |
| 1459 |
%<latexrelease> \prepare@family@series@update{sf}\sfdefault |
| 1460 |
%<latexrelease> \@sffamilyhook |
| 1461 |
%<latexrelease> \selectfont} |
| 1462 |
%<latexrelease>\DeclareRobustCommand\ttfamily{% |
| 1463 |
%<latexrelease> \not@math@alphabet\ttfamily\mathtt |
| 1464 |
%<latexrelease> \prepare@family@series@update{tt}\ttdefault |
| 1465 |
%<latexrelease> \@ttfamilyhook |
| 1466 |
%<latexrelease> \selectfont} |
| 1467 |
%<latexrelease>\let\@rmfamilyhook\@empty |
| 1468 |
%<latexrelease>\let\@sffamilyhook\@empty |
| 1469 |
%<latexrelease>\let\@ttfamilyhook\@empty |
| 1470 |
%<latexrelease> |
| 1471 |
% \end{macrocode} |
| 1472 |
% |
| 1473 |
% \begin{macrocode} |
| 1474 |
%<latexrelease> |
| 1475 |
%<latexrelease>\EndIncludeInRelease |
| 1476 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 1477 |
%<latexrelease> {\expand@font@defaults}{Custom series with hooks}% |
| 1478 |
%<latexrelease> |
| 1479 |
%<latexrelease>\let\expand@font@defaults\@undefined |
| 1480 |
%<latexrelease> |
| 1481 |
%<latexrelease>\DeclareRobustCommand\bfseries |
| 1482 |
%<latexrelease> {\not@math@alphabet\bfseries\mathbf |
| 1483 |
%<latexrelease> \fontseries\bfdefault\selectfont} |
| 1484 |
%<latexrelease>\DeclareRobustCommand\mdseries |
| 1485 |
%<latexrelease> {\not@math@alphabet\mdseries\relax |
| 1486 |
%<latexrelease> \fontseries\mddefault\selectfont} |
| 1487 |
%<latexrelease>\DeclareRobustCommand\rmfamily |
| 1488 |
%<latexrelease> {\not@math@alphabet\rmfamily\mathrm |
| 1489 |
%<latexrelease> \fontfamily\rmdefault\selectfont} |
| 1490 |
%<latexrelease>\DeclareRobustCommand\sffamily |
| 1491 |
%<latexrelease> {\not@math@alphabet\sffamily\mathsf |
| 1492 |
%<latexrelease> \fontfamily\sfdefault\selectfont} |
| 1493 |
%<latexrelease>\DeclareRobustCommand\ttfamily |
| 1494 |
%<latexrelease> {\not@math@alphabet\ttfamily\mathtt |
| 1495 |
%<latexrelease> \fontfamily\ttdefault\selectfont} |
| 1496 |
%<latexrelease> |
| 1497 |
%<latexrelease>\let\@rmfamilyhook\@undefined |
| 1498 |
%<latexrelease>\let\@sffamilyhook\@undefined |
| 1499 |
%<latexrelease>\let\@ttfamilyhook\@undefined |
| 1500 |
%<latexrelease> |
| 1501 |
%<latexrelease>\EndIncludeInRelease |
| 1502 |
%<*2ekernel> |
| 1503 |
% \end{macrocode} |
| 1504 |
% |
| 1505 |
% |
| 1506 |
% |
| 1507 |
% \begin{macro}{\IfFontSeriesContextTF} |
| 1508 |
% |
| 1509 |
% With the ability for \cs{bfseries} or \cs{mdseries} to be mapped |
| 1510 |
% to different NFSS axis values it becomes important to have the |
| 1511 |
% ability to determine the current context as we can no longer look |
| 1512 |
% at \cs{f@series} to answer a question such as ``am I currently |
| 1513 |
% typesetting in a bold typeface?'' |
| 1514 |
% |
| 1515 |
% This is provided by the test \cs{IfFontSeriesContextTF}. It takes |
| 1516 |
% three arguments: |
| 1517 |
% \begin{itemize} |
| 1518 |
% \item |
| 1519 |
% The context we try to check (either \texttt{bf} for bold or |
| 1520 |
% \texttt{md} for medium, i.e., the same that can go into the |
| 1521 |
% first mandatory argument of \cs{DeclareFontSeriesDefault}), |
| 1522 |
% |
| 1523 |
% \item |
| 1524 |
% what to do if we are in this context (true case) and |
| 1525 |
% |
| 1526 |
% \item |
| 1527 |
% what to do if we are not (false case). |
| 1528 |
% \end{itemize} |
| 1529 |
% This allows you to define commands like \cs{IfBold}, e.g., |
| 1530 |
%\begin{verbatim} |
| 1531 |
% \NewDocumentCommand\IfBold{mm}{\IfFontSeriesContextTF{bf}{#1}{#2}} |
| 1532 |
%\end{verbatim} |
| 1533 |
% and then do |
| 1534 |
%\begin{verbatim} |
| 1535 |
% This is \IfBold{bold}{non-bold} text. |
| 1536 |
%\end{verbatim} |
| 1537 |
% and get the appropriate result. |
| 1538 |
% |
| 1539 |
% \changes{v3.2a}{2020/05/19}{Macros added (gh/335)} |
| 1540 |
% \begin{macrocode} |
| 1541 |
%</2ekernel> |
| 1542 |
%<*2ekernel|latexrelease> |
| 1543 |
%<latexrelease>\IncludeInRelease{2020/10/01}% |
| 1544 |
%<latexrelease> {\IfFontSeriesContextTF}{Font series context}% |
| 1545 |
% \end{macrocode} |
| 1546 |
% |
| 1547 |
% \begin{macrocode} |
| 1548 |
\DeclareRobustCommand\IfFontSeriesContextTF[1]{% |
| 1549 |
\expand@font@defaults |
| 1550 |
% \end{macrocode} |
| 1551 |
% In the beginning we haven't found the context we are looking for. |
| 1552 |
% \begin{macrocode} |
| 1553 |
\@font@series@contextfalse |
| 1554 |
% \end{macrocode} |
| 1555 |
% We store the requested context away for use in the tests. |
| 1556 |
% \begin{macrocode} |
| 1557 |
\def\requested@test@context{#1}% |
| 1558 |
% \end{macrocode} |
| 1559 |
% The next definition is there to ensure that get a final match |
| 1560 |
% during testing |
| 1561 |
% even if the current family is non of the meta families |
| 1562 |
% (\texttt{rm}, \texttt{sf} or \texttt{tt}). This will then |
| 1563 |
% basically tests if the current font family matches the overall default. |
| 1564 |
% \begin{macrocode} |
| 1565 |
\expandafter\edef\csname ??def@ult\endcsname{\f@family}% |
| 1566 |
% \end{macrocode} |
| 1567 |
% Then we run through the meta family list (currently containing |
| 1568 |
% just the three values) followed by the artificial meta family |
| 1569 |
% \texttt{??} and test each of them in turn using |
| 1570 |
% \cs{test@font@series@context} as the testing command. |
| 1571 |
% \begin{macrocode} |
| 1572 |
\let\@elt\test@font@series@context |
| 1573 |
\@meta@family@list |
| 1574 |
\@elt{??}% |
| 1575 |
\let\@elt\relax |
| 1576 |
% \end{macrocode} |
| 1577 |
% Following that we evaluate the status of |
| 1578 |
% \cs{if@font@series@context} to determine which of the remaining |
| 1579 |
% arguments (true/false case) we have to execute. |
| 1580 |
% \begin{macrocode} |
| 1581 |
\if@font@series@context |
| 1582 |
\expandafter\@firstoftwo |
| 1583 |
\else |
| 1584 |
\expandafter\@secondoftwo |
| 1585 |
\fi |
| 1586 |
} |
| 1587 |
% \end{macrocode} |
| 1588 |
% The T/F variants were introduced in 2025 but to simplify rollback |
| 1589 |
% we pretend that this happened at the same time as |
| 1590 |
% \cs{IfFontSeriesContextTF}. |
| 1591 |
% \changes{v3.2k}{2025/03/01}{Provide T F variants of |
| 1592 |
% \cs{IfFontSeriesContextTF} (gh/1522)} |
| 1593 |
% \begin{macrocode} |
| 1594 |
\long\def\IfFontSeriesContextT#1{\IfFontSeriesContextTF{#1}{}} |
| 1595 |
\def\IfFontSeriesContextF{\IfFontSeriesContextTF{}} |
| 1596 |
% \end{macrocode} |
| 1597 |
% \end{macro} |
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
% \begin{macro}{\test@font@series@context} |
| 1602 |
% This tests the context (stored in \cs{requested@test@context}) |
| 1603 |
% and updates the boolean if the right context is found. |
| 1604 |
% \begin{macrocode} |
| 1605 |
\def\test@font@series@context#1{% |
| 1606 |
% \end{macrocode} |
| 1607 |
% First task is to figure out whether the current family matches |
| 1608 |
% \cs{rmfamily}, \cs{sffamily}, etc.\ so in \cs{reserved@a} we |
| 1609 |
% store the value of \cs{rmdef@ult} (or whatever the given meta |
| 1610 |
% family is) and compare that to \cs{f@family}. |
| 1611 |
% \begin{macrocode} |
| 1612 |
\edef\reserved@a{\csname #1def@ult\endcsname}% |
| 1613 |
\ifx\f@family\reserved@a |
| 1614 |
% \end{macrocode} |
| 1615 |
% If they match we have found the right meta family so we don't |
| 1616 |
% need to test any of the remaining meta family and therefore |
| 1617 |
% change \cs{@elt} to \cs{@gobble}. |
| 1618 |
% \begin{macrocode} |
| 1619 |
\let\@elt\@gobble |
| 1620 |
% \end{macrocode} |
| 1621 |
% Now we have to test if \cs{f@series} matches the requested |
| 1622 |
% context (e.g., whether \cs{bfseries@rm} has that value if the |
| 1623 |
% current meta family is \texttt{rm} and we are looking for the |
| 1624 |
% \texttt{bf} context). |
| 1625 |
% \begin{macrocode} |
| 1626 |
\expandafter\ifx |
| 1627 |
\csname\requested@test@context series@#1\endcsname\f@series |
| 1628 |
% \end{macrocode} |
| 1629 |
% If yes we change the boolean and are done. |
| 1630 |
% \begin{macrocode} |
| 1631 |
\@font@series@contexttrue |
| 1632 |
% \end{macrocode} |
| 1633 |
% If not then maybe the reason is that nothing special was set up |
| 1634 |
% for that meta family so we also check now check if \cs{f@series} |
| 1635 |
% matches the overall default (e.g., \cs{bfdef@ult} if we are |
| 1636 |
% looking for the bold context). If that matches we change the boolean. |
| 1637 |
% \begin{macrocode} |
| 1638 |
\else |
| 1639 |
\expandafter\ifx |
| 1640 |
\csname\requested@test@context def@ult\endcsname\f@series |
| 1641 |
\@font@series@contexttrue |
| 1642 |
\fi\fi\fi |
| 1643 |
} |
| 1644 |
% \end{macrocode} |
| 1645 |
% \end{macro} |
| 1646 |
% |
| 1647 |
% |
| 1648 |
% |
| 1649 |
% \begin{macro}{\if@font@series@context} |
| 1650 |
% The boolean to signal if we found the requested font series context. |
| 1651 |
% \begin{macrocode} |
| 1652 |
\newif\if@font@series@context |
| 1653 |
% \end{macrocode} |
| 1654 |
% \end{macro} |
| 1655 |
% |
| 1656 |
% |
| 1657 |
% \begin{macrocode} |
| 1658 |
%</2ekernel|latexrelease> |
| 1659 |
%<latexrelease>\EndIncludeInRelease |
| 1660 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 1661 |
%<latexrelease> {\IfFontSeriesContextTF}{Font series context}% |
| 1662 |
%<latexrelease> |
| 1663 |
%<latexrelease>\let\IfFontSeriesContextTF\@undefined |
| 1664 |
%<latexrelease>\let\IfFontSeriesContextT\@undefined |
| 1665 |
%<latexrelease>\let\IfFontSeriesContextF\@undefined |
| 1666 |
%<latexrelease>\let\test@font@series@context\@undefined |
| 1667 |
%<latexrelease>\let\if@font@series@context\@undefined |
| 1668 |
%<latexrelease>\let\@font@series@contexttrue\@undefined |
| 1669 |
%<latexrelease>\let\@font@series@contextfalse\@undefined |
| 1670 |
%<latexrelease>\EndIncludeInRelease |
| 1671 |
%<*2ekernel> |
| 1672 |
% \end{macrocode} |
| 1673 |
% |
| 1674 |
% |
| 1675 |
% |
| 1676 |
% |
| 1677 |
% |
| 1678 |
% |
| 1679 |
% \section{Supporting nested emphasis} |
| 1680 |
% |
| 1681 |
% By default \LaTeXe{} supports two levels of nested emphasis: if |
| 1682 |
% the current font has an upright shape then it switches to |
| 1683 |
% \cs{itshape} otherwise to \cs{eminnershape} (which defaults to |
| 1684 |
% \cs{upshape}). This means nested emphasis will oscillate between |
| 1685 |
% italic and upright shapes. |
| 1686 |
% |
| 1687 |
% Sometimes it would be nice to allow for a more lengthy sequence, |
| 1688 |
% but instead of providing a fixed one \LaTeX{} now offers a |
| 1689 |
% general mechanism that allows to define arbitrary sequences. |
| 1690 |
% |
| 1691 |
% \DescribeMacro\DeclareEmphSequence |
| 1692 |
% \DescribeMacro\emforce |
| 1693 |
% |
| 1694 |
% This declaration expects a comma separated list of (font) change |
| 1695 |
% declarations corresponding to increasing levels of emphasis. |
| 1696 |
% The mechanism tries to be ``smart'' and verifies that the |
| 1697 |
% declarations actually alter the font. If not it will ignore this |
| 1698 |
% level and tries the next one---the assumption being that |
| 1699 |
% there was a manual font change in the document to the font that |
| 1700 |
% is now supposed to be used for emphasis. Of course, this only |
| 1701 |
% works if the declarations in the list actually change the font |
| 1702 |
% and not, say, just the color. |
| 1703 |
% In such a case one has to use \cs{emforce} to which directs the |
| 1704 |
% mechanism to use the level even if the font attributes haven't changed. |
| 1705 |
% |
| 1706 |
% \DescribeMacro\emreset |
| 1707 |
% If the nesting is so deep, that the specified levels are |
| 1708 |
% exhausted then \cs{emreset} is used as a final set of |
| 1709 |
% declarations (which by default returns |
| 1710 |
% back to the upright shape). Any additional nesting levels will |
| 1711 |
% then reuse the list from its beginning. |
| 1712 |
% |
| 1713 |
% |
| 1714 |
% |
| 1715 |
% \begin{macro}{\DeclareEmphSequence} |
| 1716 |
% |
| 1717 |
% \cs{DeclareEmphSequence} expects a clist of declaration. Spaces in the |
| 1718 |
% argument are dropped to avoid spurious spaces in the output. The |
| 1719 |
% declarations are additive. At the very end the shape is reset |
| 1720 |
% using |\emreset| and |\emforce| so that this case is never |
| 1721 |
% skipped.\footnote{Maybe we should not add \cs{emforce} but allow |
| 1722 |
% that case to be skipped as well. Of course, that might result in |
| 1723 |
% an endless loop if somebody defines a sequence without any font |
| 1724 |
% change and without \cs{emforce} but \ldots} |
| 1725 |
% Further nested calls restart at the beginning. |
| 1726 |
% \changes{v3.1e}{2019/12/17}{Provide \cs{emph} sequences} |
| 1727 |
% \begin{macrocode} |
| 1728 |
%</2ekernel> |
| 1729 |
%<*2ekernel|latexrelease> |
| 1730 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 1731 |
%<latexrelease> {\DeclareEmphSequence}{Nested emph}% |
| 1732 |
\def\DeclareEmphSequence#1{% |
| 1733 |
\protected@edef\emfontdeclare@clist{\zap@space#1, \@empty\emforce\emreset}% |
| 1734 |
} |
| 1735 |
% \end{macrocode} |
| 1736 |
% By default the it is empty, in which case \cs{eminnershape} is |
| 1737 |
% used by \LaTeX. |
| 1738 |
% \begin{macrocode} |
| 1739 |
\let\emfontdeclare@clist\@empty |
| 1740 |
% \end{macrocode} |
| 1741 |
% \end{macro} |
| 1742 |
% |
| 1743 |
% |
| 1744 |
% |
| 1745 |
% \begin{macro}{\emrest} |
| 1746 |
% Reset the font to upright and upper/lower case. With the default rules |
| 1747 |
% using \cs{shapedefault} does that for us but to be on the safe side we |
| 1748 |
% do it like this: |
| 1749 |
% \begin{macrocode} |
| 1750 |
\DeclareRobustCommand\emreset{\upshape\ulcshape} |
| 1751 |
% \end{macrocode} |
| 1752 |
% \end{macro} |
| 1753 |
% |
| 1754 |
% |
| 1755 |
% |
| 1756 |
% \begin{macro}{\em} |
| 1757 |
% |
| 1758 |
% The new definition for \cs{em} (and implicitly \cs{emph}) is the |
| 1759 |
% same as before as long as \cs{emfontdeclare@clist} is empty. |
| 1760 |
% \begin{macrocode} |
| 1761 |
\DeclareRobustCommand\em{% |
| 1762 |
\@nomath\em |
| 1763 |
\ifx\emfontdeclare@clist\@empty |
| 1764 |
\ifdim \fontdimen\@ne\font >\z@ |
| 1765 |
\eminnershape \else \itshape \fi |
| 1766 |
\else |
| 1767 |
% \end{macrocode} |
| 1768 |
% But if not we use the list to decide how to do emphasis. |
| 1769 |
% |
| 1770 |
% We use the current font to check if the declarations have any |
| 1771 |
% effect, so even a size change is allowed and identified as a |
| 1772 |
% modification (but a color change, for example, isn't). So first |
| 1773 |
% we save the current status. |
| 1774 |
% \begin{macrocode} |
| 1775 |
\edef\em@currfont{\csname\curr@fontshape/\f@size\endcsname}% |
| 1776 |
% \end{macrocode} |
| 1777 |
% Then we grab the next element from the list and check if it can |
| 1778 |
% be used. |
| 1779 |
% \begin{macrocode} |
| 1780 |
\expandafter\do@emfont@update\emfontdeclare@clist\do@emfont@update |
| 1781 |
\fi |
| 1782 |
} |
| 1783 |
% \end{macrocode} |
| 1784 |
% |
| 1785 |
% \begin{macrocode} |
| 1786 |
\def\eminnershape{\upshape} |
| 1787 |
% \end{macrocode} |
| 1788 |
% \end{macro} |
| 1789 |
% |
| 1790 |
% |
| 1791 |
% |
| 1792 |
% \begin{macro}{\do@emfont@update} |
| 1793 |
% We know that the list (if not empty) has at least 2 elements |
| 1794 |
% separated by a comma, so we pick up the first in \texttt{\#1} and |
| 1795 |
% the rest in \texttt{\#2}. |
| 1796 |
% \begin{macrocode} |
| 1797 |
\def\do@emfont@update#1,#2\do@emfont@update{% |
| 1798 |
% \end{macrocode} |
| 1799 |
% First action is to alter the list and move the first entry to the end |
| 1800 |
% \begin{macrocode} |
| 1801 |
\def\emfontdeclare@clist{#2,#1}% |
| 1802 |
% \end{macrocode} |
| 1803 |
% Then we execute the current declaration. Appending |\selectfont| means one |
| 1804 |
% can write just |\fontshape{it}| and that works then too. |
| 1805 |
% \begin{macrocode} |
| 1806 |
% \typeout{Use: \detokenize{#1}}% |
| 1807 |
#1\selectfont |
| 1808 |
% \end{macrocode} |
| 1809 |
% We then compare the current font with our saved version, but with |
| 1810 |
% a slight twist: we add \cs{em@force} at the end of the |
| 1811 |
% name. Normally this is empty so has no effect but if there was an |
| 1812 |
% \cs{emforce} as part of \texttt{\#1} it will append a |/| to the |
| 1813 |
% font name (making it invalid) thus this will then always fail the |
| 1814 |
% test. |
| 1815 |
% |
| 1816 |
% If the test fails we are done and the declarations will be used. |
| 1817 |
% Otherwise we will try the next declaration in the sequence. |
| 1818 |
% \begin{macrocode} |
| 1819 |
\expandafter\ifx\csname \curr@fontshape/\f@size\em@force |
| 1820 |
% \end{macrocode} |
| 1821 |
% For the comparison with \cs{ifx} we have to expand |
| 1822 |
% \cs{em@currfont} once as the relevant info is inside. |
| 1823 |
% \begin{macrocode} |
| 1824 |
\expandafter\endcsname |
| 1825 |
\em@currfont |
| 1826 |
\expandafter\do@emfont@update\emfontdeclare@clist\do@emfont@update |
| 1827 |
% \end{macrocode} |
| 1828 |
% If \cs{emforce} was used, we have to undo its effect: |
| 1829 |
% \begin{macrocode} |
| 1830 |
\else |
| 1831 |
\let\em@force\@empty |
| 1832 |
\fi |
| 1833 |
} |
| 1834 |
% \end{macrocode} |
| 1835 |
% \end{macro} |
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
% \begin{macro}{\emforce} |
| 1840 |
% \begin{macro}{\em@force} |
| 1841 |
% The definition of \cs{emforce} is simple: change \cs{em@force} to |
| 1842 |
% make the above test always invalid. |
| 1843 |
% \begin{macrocode} |
| 1844 |
\protected\def\emforce{\def\em@force{/}} |
| 1845 |
\let\em@force\@empty |
| 1846 |
%</2ekernel|latexrelease> |
| 1847 |
%<latexrelease>\EndIncludeInRelease |
| 1848 |
% \end{macrocode} |
| 1849 |
% \end{macro} |
| 1850 |
% \end{macro} |
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
% |
| 1855 |
% \begin{macro}{\em} |
| 1856 |
% \changes{v1.2b}{1990/01/28}{Call to \cs{@nomath} added.} |
| 1857 |
% \changes{v3.1a}{2015/01/09}{Allow \cs{emph} to produce small caps (latexrelease)} |
| 1858 |
% \begin{macro}{\eminnershape} |
| 1859 |
% \changes{v3.1a}{2015/01/09}{macro added (latexrelease)} |
| 1860 |
% |
| 1861 |
% These are the older definitions for \cs{em}, prior to 2020. |
| 1862 |
% |
| 1863 |
% We also have to define the {\em emphasize\/} font change command |
| 1864 |
% (i.e.\ |\em|). This command will look is the current font is |
| 1865 |
% sloped (i.e.\ has a positive |\fontdimen1|) and will then |
| 1866 |
% select either |\upshape| or |\itshape|. |
| 1867 |
% \begin{macrocode} |
| 1868 |
%<latexrelease>\IncludeInRelease{2015/01/01}{\DeclareEmphSequence}{Nested emph}% |
| 1869 |
%<latexrelease>\let\DeclareEmphSequence\@undefined |
| 1870 |
%<latexrelease>\let\emfontdeclare@clist\@undefined |
| 1871 |
%<latexrelease>\let\emreset\@undefined |
| 1872 |
%<latexrelease>\let\do@emfont@update\@undefined |
| 1873 |
%<latexrelease>\let\emforce\@undefined |
| 1874 |
%<latexrelease>\let\em@force\@undefined |
| 1875 |
%<latexrelease> |
| 1876 |
%<latexrelease>\DeclareRobustCommand\em |
| 1877 |
%<latexrelease> {\@nomath\em \ifdim \fontdimen\@ne\font >\z@ |
| 1878 |
%<latexrelease> \eminnershape \else \itshape \fi}% |
| 1879 |
%<latexrelease>\EndIncludeInRelease |
| 1880 |
%<latexrelease> |
| 1881 |
%<latexrelease>\IncludeInRelease{0000/00/00}{\DeclareEmphSequence}{Nested emph}% |
| 1882 |
%<latexrelease>\DeclareRobustCommand\em |
| 1883 |
%<latexrelease> {\@nomath\em \ifdim \fontdimen\@ne\font >\z@ |
| 1884 |
%<latexrelease> \upshape \else \itshape \fi}% |
| 1885 |
%<latexrelease>\let\eminnershape\@undefined |
| 1886 |
%<latexrelease>\EndIncludeInRelease |
| 1887 |
%<*2ekernel> |
| 1888 |
% \end{macrocode} |
| 1889 |
% \end{macro} |
| 1890 |
% \end{macro} |
| 1891 |
% |
| 1892 |
% |
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1897 |
% |
| 1898 |
% |
| 1899 |
% \begin{macro}{\not@math@alphabet} |
| 1900 |
% This function generates an error message when it is called in |
| 1901 |
% math mode. The same function should be defined in |
| 1902 |
% \texttt{newlfont.sty}. |
| 1903 |
% \changes{v1.4d}{1992/09/21}{Macro defined.} |
| 1904 |
% \changes{v2.1e}{1994/01/17}{Message changed} |
| 1905 |
% \changes{v2.1f}{1994/01/18}{Message corrected} |
| 1906 |
% \changes{v2.1g}{1994/04/22}{Message changed again} |
| 1907 |
% \changes{v2.2d}{1995/04/02}{add \cs{noexpand} to second part of message} |
| 1908 |
% \begin{macrocode} |
| 1909 |
\def\not@math@alphabet#1#2{% |
| 1910 |
\relax |
| 1911 |
\ifmmode |
| 1912 |
\@latex@error{Command \noexpand#1invalid in math mode}% |
| 1913 |
{% |
| 1914 |
Please |
| 1915 |
\ifx#2\relax |
| 1916 |
define a new math alphabet^^J% |
| 1917 |
if you want to use a special font in math mode% |
| 1918 |
\else |
| 1919 |
% \end{macrocode} |
| 1920 |
% We have to a |\noexpand| below to prevent expansion of |#2|. In |
| 1921 |
% case of |#1| we can omit this (due to the current definition of |
| 1922 |
% robust commands since they do come out right there :-). |
| 1923 |
% \begin{macrocode} |
| 1924 |
use the math alphabet \noexpand#2instead of |
| 1925 |
the #1command% |
| 1926 |
\fi |
| 1927 |
. |
| 1928 |
}% |
| 1929 |
\fi} |
| 1930 |
% \end{macrocode} |
| 1931 |
% \end{macro} |
| 1932 |
% |
| 1933 |
% |
| 1934 |
% |
| 1935 |
% Finally we provide two abbreviations to switch to the \LaTeX{} |
| 1936 |
% \emph{versions}. |
| 1937 |
% \begin{macrocode} |
| 1938 |
\DeclareRobustCommand\boldmath{\@nomath\boldmath |
| 1939 |
\mathversion{bold}} |
| 1940 |
\DeclareRobustCommand\unboldmath{\@nomath\unboldmath |
| 1941 |
\mathversion{normal}} |
| 1942 |
% \end{macrocode} |
| 1943 |
% Here we switch to the default math version by defining the internal |
| 1944 |
% macro |\math@version|. We dare not to call |\mathversion| |
| 1945 |
% at this place because this would call |\glb@settings|. |
| 1946 |
% \begin{macrocode} |
| 1947 |
\def\math@version{normal} |
| 1948 |
% \end{macrocode} |
| 1949 |
% |
| 1950 |
% \subsection{Legacy} |
| 1951 |
% |
| 1952 |
% We start by defining a few macros that are part of |
| 1953 |
% standard \LaTeX's user interface. The use of these functions is |
| 1954 |
% not encouraged, but they will allow to process older documents |
| 1955 |
% without changes to the source. |
| 1956 |
% |
| 1957 |
% \begin{macro}{\newfont} |
| 1958 |
% \changes{v1.2g}{1991/03/30}{Definition added.} |
| 1959 |
% \changes{v2.2e}{1995/05/23}{Font assignment made local again.} |
| 1960 |
% \begin{macrocode} |
| 1961 |
\def\newfont#1#2{\@ifdefinable#1{\font#1=#2\relax}} |
| 1962 |
% \end{macrocode} |
| 1963 |
% \end{macro} |
| 1964 |
% |
| 1965 |
% \begin{macro}{\symbol} |
| 1966 |
% \changes{v1.2g}{1991/03/30}{Definition added.} |
| 1967 |
% \changes{v3.1h}{2020/02/07}{XeTeX-specific version to avoid bug in maths mode.} |
| 1968 |
% \begin{macrocode} |
| 1969 |
%</2ekernel> |
| 1970 |
%<*2ekernel|latexrelease> |
| 1971 |
%<latexrelease>\IncludeInRelease{2020/10/01}% |
| 1972 |
%<latexrelease> {\symbol}{XeTeX change for math}% |
| 1973 |
\ifdefined\XeTeXversion |
| 1974 |
\DeclareRobustCommand\symbol[1]{\Ucharcat#1 12\relax} |
| 1975 |
\else |
| 1976 |
\DeclareRobustCommand\symbol[1]{\char#1\relax} |
| 1977 |
\fi |
| 1978 |
%</2ekernel|latexrelease> |
| 1979 |
% \end{macrocode} |
| 1980 |
% |
| 1981 |
% \begin{macrocode} |
| 1982 |
%<latexrelease>\EndIncludeInRelease |
| 1983 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 1984 |
%<latexrelease> {\symbol}{XeTeX change for math}% |
| 1985 |
%<latexrelease> |
| 1986 |
%<latexrelease>\DeclareRobustCommand\symbol[1]{\char#1\relax} |
| 1987 |
%<latexrelease> |
| 1988 |
%<latexrelease>\EndIncludeInRelease |
| 1989 |
%<*2ekernel> |
| 1990 |
% \end{macrocode} |
| 1991 |
% \end{macro} |
| 1992 |
% |
| 1993 |
% \subsection{Miscellaneous} |
| 1994 |
% |
| 1995 |
% \begin{macro}{\@setfontsize} |
| 1996 |
% \begin{macro}{\@setsize} |
| 1997 |
% This abbreviation is used by \LaTeX's user level size changing |
| 1998 |
% commands, such as |\large|. |
| 1999 |
% \begin{macrocode} |
| 2000 |
\def\@setfontsize#1#2#3{\@nomath#1% |
| 2001 |
% \end{macrocode} |
| 2002 |
% For the benefit of people relying on keeping the name of the |
| 2003 |
% current font command saved in |\@currsize| we define it. To ensure |
| 2004 |
% that |\@setfontsize| keeps being robust we omit this assignment |
| 2005 |
% during times where |\protect| differs from |\@typeset@protect|. |
| 2006 |
% \changes{v1.4b}{1992/08/20}{Added \cs{@currsize}.} |
| 2007 |
% \changes{v2.2b}{1994/11/06}{Use \cs{@typeset@protect}} |
| 2008 |
% \begin{macrocode} |
| 2009 |
\ifx\protect\@typeset@protect |
| 2010 |
\let\@currsize#1% |
| 2011 |
\fi |
| 2012 |
\fontsize{#2}{#3}\selectfont} |
| 2013 |
% \end{macrocode} |
| 2014 |
% For compatibility we also define |\@setsize| the 209 command |
| 2015 |
% \begin{macrocode} |
| 2016 |
%<*compat> |
| 2017 |
\def\@setsize#1#2#3#4{\@setfontsize#1{#4}{#2}} |
| 2018 |
%</compat> |
| 2019 |
% \end{macrocode} |
| 2020 |
% \end{macro} |
| 2021 |
% \end{macro} |
| 2022 |
% |
| 2023 |
% |
| 2024 |
% \begin{macro}{\hexnumber@} |
| 2025 |
% To set up \LaTeX's special math character |
| 2026 |
% definitions we first provide a macro to generate hexadecimal |
| 2027 |
% numbers. It is a rather simple |\ifcase|. |
| 2028 |
% \changes{v?}{1992/11/13}{Made expandable.} |
| 2029 |
% \changes{v?}{1992/12/03}{Make it accept counters.} |
| 2030 |
% \begin{macrocode} |
| 2031 |
\def\hexnumber@#1{\ifcase\number#1 |
| 2032 |
0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or |
| 2033 |
9\or A\or B\or C\or D\or E\or F\fi} |
| 2034 |
% \end{macrocode} |
| 2035 |
% \end{macro} |
| 2036 |
% |
| 2037 |
% |
| 2038 |
% |
| 2039 |
% \begin{macro}{\nfss@text} |
| 2040 |
% \changes{v1.1e}{1990/01/25}{Macro added.} |
| 2041 |
% In its simplest form |\nfss@text| is an |\mbox|. This will |
| 2042 |
% produce unbreakable text outside math and inside math you will |
| 2043 |
% get text with the same fonts as outside. The only drawback is |
| 2044 |
% that such item won't change sizes in subscripts. But this |
| 2045 |
% behavior can be easily changed. With the \texttt{amstex} style |
| 2046 |
% option one will get a sub style called \texttt{amstext} which will |
| 2047 |
% redefine the |\nfss@text| macro to produce correct text in all |
| 2048 |
% sizes. |
| 2049 |
% |
| 2050 |
% We have to use |\def| instead of the shorter |\let| since |
| 2051 |
% |\mbox| is undefined when we reach this point. |
| 2052 |
% \changes{v1.1k}{1990/06/23}{Changed to \cs{mbox}.} |
| 2053 |
% \changes{v2.1n}{1994/05/17}{Added braces to allow use in subscripts} |
| 2054 |
% \begin{macrocode} |
| 2055 |
\def\nfss@text#1{{\mbox{#1}}} |
| 2056 |
% \end{macrocode} |
| 2057 |
% \end{macro} |
| 2058 |
% |
| 2059 |
% \begin{macro}{\copyright} |
| 2060 |
% The definition of |\copyright| was changed so |
| 2061 |
% that it works in other type styles, |
| 2062 |
% and to make it robust. We leave the family untouched so that |
| 2063 |
% the copyright notice will come out differently if a different |
| 2064 |
% font family is in use. |
| 2065 |
% This command is commented out, since it is now defined in |
| 2066 |
% ltoutenc.dtx. |
| 2067 |
% \changes{v1.1m}{1991/03/28}{Extra braces added.} |
| 2068 |
% \changes{v2.1n}{1994/05/17}{Really add extra braces} |
| 2069 |
% \changes{v2.2c}{1994/12/02}{\cs{copyright} is now in ltoutenc. |
| 2070 |
% ASAJ} |
| 2071 |
% \begin{macrocode} |
| 2072 |
%\DeclareRobustCommand\copyright |
| 2073 |
% {{\ooalign{\hfil |
| 2074 |
% \raise.07ex\hbox{\mdseries\upshape c}\hfil\crcr |
| 2075 |
% \mathhexbox20D}}} |
| 2076 |
% \end{macrocode} |
| 2077 |
% \end{macro} |
| 2078 |
% |
| 2079 |
% \changes{v2.1a}{1993/11/24}{Removed \cs{xpt} stuff} |
| 2080 |
% |
| 2081 |
% |
| 2082 |
% \begin{macro}{\normalfont} |
| 2083 |
% \changes{v2.1a}{1993/11/11}{Macro added} |
| 2084 |
% \begin{macro}{\reset@font} |
| 2085 |
% \changes{v1.1n}{1991/08/26}{Macro introduced} |
| 2086 |
% The macro |\reset@font| is used in \LaTeX{} to switch to a standard |
| 2087 |
% font, in order to initialize the current font in situations where |
| 2088 |
% typesetting is done in a new visual context (e.g.\ in a |
| 2089 |
% footnote). We define it here to allow the test for the new |
| 2090 |
% \LaTeX{} version above but nevertheless are able to run all kind |
| 2091 |
% of mixtures. |
| 2092 |
% \changes{v1.1o}{1991/11/21}{Changed to protected version of macro.} |
| 2093 |
% \changes{v1.1o}{1991/11/21}{Added extra braces for robustness.} |
| 2094 |
% |
| 2095 |
% The user interface name for |\reset@font| is |\normalfont|: |
| 2096 |
% \changes{v2.1k}{1994/05/14}{Remove surplus braces} |
| 2097 |
% \changes{v3.0f}{1995/10/16}{Added \cs{relax} after \cs{usefont}, |
| 2098 |
% as the latter eats up spaces.} |
| 2099 |
% \changes{v3.1h}{2020/02/10}{Add \cs{@defaultfamilyhook} to \cs{normalfont} (gh/269)} |
| 2100 |
% \begin{macrocode} |
| 2101 |
%</2ekernel> |
| 2102 |
%<*2ekernel|latexrelease> |
| 2103 |
%<latexrelease>\IncludeInRelease{2025/11/01}% |
| 2104 |
%<latexrelease> {\normalfont}{Support meta family}% |
| 2105 |
\DeclareRobustCommand\normalfont{% |
| 2106 |
% \end{macrocode} |
| 2107 |
% Instead of calling \cs{usefont}, as it was done in the past, we |
| 2108 |
% inline the code from \cs{usefont} as we want to add the hook |
| 2109 |
% before \cs{selectfont}, but after all the font attributes are set. |
| 2110 |
% \begin{macrocode} |
| 2111 |
\fontencoding\encodingdefault |
| 2112 |
\edef\f@family{\familydefault}% |
| 2113 |
\edef\f@series{\seriesdefault}% |
| 2114 |
\edef\f@shape{\shapedefault}% |
| 2115 |
% \end{macrocode} |
| 2116 |
% Now that \cs{f@family} is set we can update the meta family macro. |
| 2117 |
% \changes{v3.2l}{2025/09/15}{Set current meta family} |
| 2118 |
% \begin{macrocode} |
| 2119 |
\set@current@meta@family |
| 2120 |
% \end{macrocode} |
| 2121 |
% Any earlier \cs{fontseries}, etc.\ should be canceled and we |
| 2122 |
% should switch unconditionally to the requested font face so we |
| 2123 |
% drop any code that may have been stored in |
| 2124 |
% \cs{delayed@f@adjustment}. |
| 2125 |
% \changes{v3.2h}{2021/04/26}{Unconditionally switch to the requested |
| 2126 |
% font face (gh/444)} |
| 2127 |
% \begin{macrocode} |
| 2128 |
\let\delayed@f@adjustment\@empty |
| 2129 |
% \end{macrocode} |
| 2130 |
% |
| 2131 |
% \changes{v3.2b}{2020/08/21}{Integration of new hook management interface} |
| 2132 |
% \changes{v3.2l}{2025/09/15}{Drop old 2020 hook \cs{@defaultfamilyhook}} |
| 2133 |
% \begin{macrocode} |
| 2134 |
\UseHook{normalfont}% |
| 2135 |
\selectfont} |
| 2136 |
% \end{macrocode} |
| 2137 |
% |
| 2138 |
% \begin{macrocode} |
| 2139 |
\let\reset@font\normalfont |
| 2140 |
% \end{macrocode} |
| 2141 |
% \end{macro} |
| 2142 |
% \end{macro} |
| 2143 |
% |
| 2144 |
% |
| 2145 |
% \begin{macro}{\set@current@meta@family} |
| 2146 |
% This macros determines the current meta family by comparing the |
| 2147 |
% current family in \cs{f@family} with the various document font defaults, |
| 2148 |
% e.g., \cs{rmdefault}. |
| 2149 |
% \changes{v3.2l}{2025/09/15}{Macro added} |
| 2150 |
% \begin{macrocode} |
| 2151 |
\def\set@current@meta@family {% |
| 2152 |
% \end{macrocode} |
| 2153 |
% Because these defaults can be set by the user and may contain the |
| 2154 |
% family name indirectly, we first expand them to ensure we do not |
| 2155 |
% get false negatives. |
| 2156 |
% \begin{macrocode} |
| 2157 |
\edef\rmdef@ult{\rmdefault}% |
| 2158 |
\ifx\f@family\rmdef@ult |
| 2159 |
\def\@currentmetafamily{rm}% |
| 2160 |
\else |
| 2161 |
\ifx\f@family\sfdef@ult |
| 2162 |
\def\@currentmetafamily{sf}% |
| 2163 |
\else |
| 2164 |
\ifx\f@family\ttdef@ult |
| 2165 |
\def\@currentmetafamily{tt}% |
| 2166 |
\else |
| 2167 |
\def\@currentmetafamily{??}% |
| 2168 |
\fi |
| 2169 |
\fi |
| 2170 |
\fi |
| 2171 |
} |
| 2172 |
% \end{macrocode} |
| 2173 |
% \end{macro} |
| 2174 |
% |
| 2175 |
% \begin{macrocode} |
| 2176 |
% \changes{v3.2g}{2021/03/18} |
| 2177 |
% {Add missing 2020/02/02 latexrelease entry.} |
| 2178 |
%</2ekernel|latexrelease> |
| 2179 |
%<latexrelease>\EndIncludeInRelease |
| 2180 |
%<latexrelease>\IncludeInRelease{2021/06/01}% |
| 2181 |
%<latexrelease> {\normalfont}{Cancel delayed actions}% |
| 2182 |
%<latexrelease> |
| 2183 |
%<latexrelease>\DeclareRobustCommand\normalfont{% |
| 2184 |
%<latexrelease> \fontencoding\encodingdefault |
| 2185 |
%<latexrelease> \edef\f@family{\familydefault}% |
| 2186 |
%<latexrelease> \edef\f@series{\seriesdefault}% |
| 2187 |
%<latexrelease> \edef\f@shape{\shapedefault}% |
| 2188 |
%<latexrelease> \let\delayed@f@adjustment\@empty |
| 2189 |
%<latexrelease> \UseHook{normalfont}% |
| 2190 |
%<latexrelease> \@defaultfamilyhook % hookname from 2020/02 will vanish |
| 2191 |
%<latexrelease> \selectfont} |
| 2192 |
%<latexrelease>\let\reset@font\normalfont |
| 2193 |
%<latexrelease> |
| 2194 |
%<latexrelease>\let\set@current@meta@family\undefined |
| 2195 |
%<latexrelease>\EndIncludeInRelease |
| 2196 |
% \end{macrocode} |
| 2197 |
% |
| 2198 |
% \begin{macrocode} |
| 2199 |
%<latexrelease>\IncludeInRelease{2020/10/01}% |
| 2200 |
%<latexrelease> {\normalfont}{Add hook to \normalfont}% |
| 2201 |
%<latexrelease> |
| 2202 |
%<latexrelease>\DeclareRobustCommand\normalfont{% |
| 2203 |
%<latexrelease> \fontencoding\encodingdefault |
| 2204 |
%<latexrelease> \edef\f@family{\familydefault}% |
| 2205 |
%<latexrelease> \edef\f@series{\seriesdefault}% |
| 2206 |
%<latexrelease> \edef\f@shape{\shapedefault}% |
| 2207 |
%<latexrelease> \UseHook{normalfont}% |
| 2208 |
%<latexrelease> \@defaultfamilyhook % hookname from 2020/02 will vanish |
| 2209 |
%<latexrelease> \selectfont} |
| 2210 |
%<latexrelease> |
| 2211 |
%<latexrelease>\let\reset@font\normalfont |
| 2212 |
%<latexrelease> |
| 2213 |
%<latexrelease>\EndIncludeInRelease |
| 2214 |
%<latexrelease> |
| 2215 |
%<latexrelease>\IncludeInRelease{2020/02/02}% |
| 2216 |
%<latexrelease> {\normalfont}{Add hook to \normalfont}% |
| 2217 |
%<latexrelease> |
| 2218 |
%<latexrelease>\DeclareRobustCommand\normalfont{% |
| 2219 |
%<latexrelease> \fontencoding\encodingdefault |
| 2220 |
%<latexrelease> \edef\f@family{\familydefault}% |
| 2221 |
%<latexrelease> \edef\f@series{\seriesdefault}% |
| 2222 |
%<latexrelease> \edef\f@shape{\shapedefault}% |
| 2223 |
%<latexrelease> \@defaultfamilyhook |
| 2224 |
%<latexrelease> \selectfont} |
| 2225 |
%<latexrelease> |
| 2226 |
%<latexrelease>\let\reset@font\normalfont |
| 2227 |
%<latexrelease> |
| 2228 |
%<latexrelease>\let\@defaultfamilyhook\@empty |
| 2229 |
%<latexrelease> |
| 2230 |
%<latexrelease>\EndIncludeInRelease |
| 2231 |
%<latexrelease> |
| 2232 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 2233 |
%<latexrelease> {\normalfont}{Add hook to \normalfont}% |
| 2234 |
%<latexrelease> |
| 2235 |
%<latexrelease>\DeclareRobustCommand\normalfont |
| 2236 |
%<latexrelease> {\usefont\encodingdefault |
| 2237 |
%<latexrelease> \familydefault |
| 2238 |
%<latexrelease> \seriesdefault |
| 2239 |
%<latexrelease> \shapedefault |
| 2240 |
%<latexrelease> \relax} |
| 2241 |
%<latexrelease>\let\reset@font\normalfont |
| 2242 |
%<latexrelease> |
| 2243 |
%<latexrelease>\let\@defaultfamilyhook\@undefined |
| 2244 |
%<latexrelease> |
| 2245 |
%<latexrelease>\EndIncludeInRelease |
| 2246 |
%<*2ekernel> |
| 2247 |
% \end{macrocode} |
| 2248 |
% |
| 2249 |
% |
| 2250 |
% \begin{macro}{\fontfamily} |
| 2251 |
% One place where the current meta family should be set is |
| 2252 |
% \cs{fontfamily}, which is why we defined it here after the |
| 2253 |
% definition of \cs{set@current@meta@family} in this file. |
| 2254 |
% \begin{macrocode} |
| 2255 |
%</2ekernel> |
| 2256 |
%<*2ekernel|latexrelease> |
| 2257 |
%<latexrelease>\IncludeInRelease{2025/11/01}% |
| 2258 |
%<latexrelease> {\fontfamily}{Set meta family}% |
| 2259 |
\DeclareRobustCommand\fontfamily[1] |
| 2260 |
{\edef\f@family{#1}\set@current@meta@family} |
| 2261 |
%</2ekernel|latexrelease> |
| 2262 |
%<latexrelease>\EndIncludeInRelease |
| 2263 |
%<latexrelease>\IncludeInRelease{0000/00/00}% |
| 2264 |
%<latexrelease> {\fontfamily}{Set meta family}% |
| 2265 |
%<latexrelease> |
| 2266 |
%<latexrelease>\DeclareRobustCommand\fontfamily[1]{\edef\f@family{#1}} |
| 2267 |
%<latexrelease>\EndIncludeInRelease |
| 2268 |
%<*2ekernel> |
| 2269 |
% \end{macrocode} |
| 2270 |
% \end{macro} |
| 2271 |
% |
| 2272 |
% We left out the special \LaTeX{} fonts which are not automatically |
| 2273 |
% included in the base version of the font selection since these fonts |
| 2274 |
% contain only a few characters which are also included in the AMS |
| 2275 |
% fonts so anybody who is using these fonts doesn't need them. |
| 2276 |
% But for compatibility reasons we will define these symbols. |
| 2277 |
% |
| 2278 |
% \changes{v2.1g}{1994/02/22}{Correct error message} |
| 2279 |
% \begin{macrocode} |
| 2280 |
\def\not@base#1{\@latex@error |
| 2281 |
{Command \noexpand#1not provided in base LaTeX2e}% |
| 2282 |
{Load the latexsym or the amsfonts package to |
| 2283 |
define this symbol}} |
| 2284 |
\def\mho{\not@base\mho} |
| 2285 |
\def\Join{\not@base\Join} |
| 2286 |
\def\Box{\not@base\Box} |
| 2287 |
\def\Diamond{\not@base\Diamond} |
| 2288 |
\def\leadsto{\not@base\leadsto} |
| 2289 |
\def\sqsubset{\not@base\sqsubset} |
| 2290 |
\def\sqsupset{\not@base\sqsupset} |
| 2291 |
\def\lhd{\not@base\lhd} |
| 2292 |
\def\unlhd{\not@base\unlhd} |
| 2293 |
\def\rhd{\not@base\rhd} |
| 2294 |
\def\unrhd{\not@base\unrhd} |
| 2295 |
% \end{macrocode} |
| 2296 |
% |
| 2297 |
% |
| 2298 |
% |
| 2299 |
% We now initialize all variables set by |\DeclareErrorFont|. These |
| 2300 |
% values are not really important since they will be overwritten |
| 2301 |
% later on by the definition in |fontdef.ltx|. |
| 2302 |
% |
| 2303 |
% However, if \texttt{fontdef.cfg} is corrupted then at least a |
| 2304 |
% hopefully suitable error font is present. |
| 2305 |
% |
| 2306 |
% \changes{v2.1k}{1994/05/14}{Init error font just before checking for |
| 2307 |
% fontdef.cfg} |
| 2308 |
% \begin{macrocode} |
| 2309 |
\DeclareErrorFont{OT1}{cmr}{m}{n}{10} %% don't modify this setting |
| 2310 |
%% overwrite it in fontdef.cfg |
| 2311 |
%% if necessary |
| 2312 |
% \end{macrocode} |
| 2313 |
% We also set some default values for |\f@family| etc. Note that we |
| 2314 |
% don't yet have any encodings that comes later. In the past this |
| 2315 |
% was implicitly done by |\DeclareErrorFont|. |
| 2316 |
% \changes{v3.1c}{2019/07/09}{Explicitly set some defaults} |
| 2317 |
% \begin{macrocode} |
| 2318 |
\def\f@family{cmr} % can't use \fontfamily at this point as |
| 2319 |
% defaults aren't set up yet |
| 2320 |
% \end{macrocode} |
| 2321 |
% |
| 2322 |
% \changes{v3.2f}{2020/12/04}{Adjust start values for series and shape (gh/444)} |
| 2323 |
% Previously the default values for series and shape were set by |
| 2324 |
% calling \cs{fontseries} and \cs{fontshape}, but their action is |
| 2325 |
% now delayed until \cs{selectfont} which isn't called inside the |
| 2326 |
% format (to avoid unnecessarily loading a font that may never get used). |
| 2327 |
% We therefore have to set \cs{f@series} and \cs{f@shape} directly instead. |
| 2328 |
% \begin{macrocode} |
| 2329 |
\def\f@series{m} % \fontseries{m} |
| 2330 |
\def\f@shape{n} % \fontshape{n} |
| 2331 |
% \end{macrocode} |
| 2332 |
% |
| 2333 |
% \begin{macrocode} |
| 2334 |
\fontsize{10}{10} |
| 2335 |
% \end{macrocode} |
| 2336 |
% |
| 2337 |
% |
| 2338 |
% The initial \texttt{fontenc} package load list. This will get |
| 2339 |
% overwritten in \texttt{fonttext} and is only provided in case an |
| 2340 |
% old \texttt{fonttext.cfg} does not define the command: |
| 2341 |
% \changes{v3.1h}{2020/02/11}{Provide default value for |
| 2342 |
% \cs{@fontenc@load@list} (gh/273)} |
| 2343 |
% \begin{macrocode} |
| 2344 |
\def\@fontenc@load@list{\@elt{T1,OT1}} |
| 2345 |
% \end{macrocode} |
| 2346 |
% |
| 2347 |
% |
| 2348 |
% We now load the customizable parts of NFSS. |
| 2349 |
% \changes{v3.0d}{1995/07/19} |
| 2350 |
% {(DPC) TeX2 support} |
| 2351 |
% \changes{v3.0e}{1995/09/15} |
| 2352 |
% {(DPC) Modify TeX2 message} |
| 2353 |
% \changes{v3.0g}{1995/11/01} |
| 2354 |
% {(DPC) Switch meaning of \cs{@addtofilelist} for cfg files} |
| 2355 |
% \changes{v3.0h}{1996/12/06} |
| 2356 |
% {(DPC) Remove *** from messages internal/2338} |
| 2357 |
% \begin{macrocode} |
| 2358 |
\InputIfFileExists{fonttext.cfg} |
| 2359 |
{\typeout{====================================^^J% |
| 2360 |
^^J% |
| 2361 |
Local config file fonttext.cfg used^^J% |
| 2362 |
^^J% |
| 2363 |
====================================}% |
| 2364 |
\def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}% |
| 2365 |
} |
| 2366 |
{\input{fonttext.ltx}} |
| 2367 |
\let\@addtofilelist\@gobble |
| 2368 |
% \end{macrocode} |
| 2369 |
% |
| 2370 |
% |
| 2371 |
% Ditto for math although I don't think that we will get a lot of |
| 2372 |
% customization :-) |
| 2373 |
% \begin{macrocode} |
| 2374 |
\InputIfFileExists{fontmath.cfg} |
| 2375 |
{\typeout{====================================^^J% |
| 2376 |
^^J% |
| 2377 |
Local config file fontmath.cfg used^^J% |
| 2378 |
^^J% |
| 2379 |
====================================}% |
| 2380 |
\def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}% |
| 2381 |
} |
| 2382 |
{\input{fontmath.ltx}} |
| 2383 |
\let\@addtofilelist\@gobble |
| 2384 |
% \end{macrocode} |
| 2385 |
% |
| 2386 |
% Then we preload several fonts. This file might be customized |
| 2387 |
% \emph{without} changing the behavior of the format (i.e.\ necessary |
| 2388 |
% font definitions will be loaded at runtime if they are not |
| 2389 |
% preloaded). This is done in the file \texttt{preload.ltx}. |
| 2390 |
% \begin{macrocode} |
| 2391 |
\InputIfFileExists{preload.cfg} |
| 2392 |
{\typeout{====================================^^J% |
| 2393 |
^^J% |
| 2394 |
Local config file preload.cfg used^^J% |
| 2395 |
^^J% |
| 2396 |
=====================================}% |
| 2397 |
\def\@addtofilelist##1{\xdef\@filelist{\@filelist,##1}}% |
| 2398 |
} |
| 2399 |
{\input{preload.ltx}} |
| 2400 |
\let\@addtofilelist\@gobble |
| 2401 |
% \end{macrocode} |
| 2402 |
% |
| 2403 |
% |
| 2404 |
% |
| 2405 |
% \begin{macro}{\seriesdefault} |
| 2406 |
% \begin{macro}{\seriesdefault@kernel} |
| 2407 |
% After \cs{seriesdefault} got defined inside \texttt{fonttext.ltx} |
| 2408 |
% or a \texttt{.cfg} file overwriting it, we alter its value by |
| 2409 |
% appending \cs{@empty} to it. This will vanish if expanded but |
| 2410 |
% allows us to check if the default gets altered (even to the same |
| 2411 |
% value) in the document preamble. All we have to do is to save the |
| 2412 |
% current value somewhere and later compare the two. For this we |
| 2413 |
% use \cs{seriesdefault@kernel}. |
| 2414 |
% \changes{v3.1n}{2020/04/13}{Handling \cs{seriesdefault} changes (gh/315)} |
| 2415 |
% \begin{macrocode} |
| 2416 |
\expandafter\def\expandafter\seriesdefault\expandafter{\seriesdefault\@empty} |
| 2417 |
\let\seriesdefault@kernel\seriesdefault |
| 2418 |
% \end{macrocode} |
| 2419 |
% \end{macro} |
| 2420 |
% \end{macro} |
| 2421 |
% |
| 2422 |
% |
| 2423 |
% |
| 2424 |
% \begin{macro}{\@acci} |
| 2425 |
% \begin{macro}{\@accii} |
| 2426 |
% \begin{macro}{\@acciii} |
| 2427 |
% \changes{v2.1m}{1994/05/16}{Define saved versions of accents} |
| 2428 |
% We also save the values of some accents in |\@acci|, |\@accii| |
| 2429 |
% and |\@acciii| so they can be restored by a |minipage| inside a |
| 2430 |
% |tabbing| environment. |
| 2431 |
% \begin{macrocode} |
| 2432 |
\let\@acci\' \let\@accii\` \let\@acciii\= |
| 2433 |
% \end{macrocode} |
| 2434 |
% \end{macro} |
| 2435 |
% \end{macro} |
| 2436 |
% \end{macro} |
| 2437 |
% |
| 2438 |
% |
| 2439 |
% \begin{macro}{\cal} |
| 2440 |
% \changes{v3.0a}{1995/05/24} |
| 2441 |
% {(DPC) Remove definition} |
| 2442 |
% \begin{macro}{\mit} |
| 2443 |
% \changes{v3.0a}{1995/05/24} |
| 2444 |
% {(DPC) Remove definition} |
| 2445 |
% Here were the two old \meta{alphabet identifiers}. |
| 2446 |
% \end{macro} |
| 2447 |
% \end{macro} |
| 2448 |
% |
| 2449 |
% |
| 2450 |
% \iffalse |
| 2451 |
%<+checkmem>\CHECKMEM |
| 2452 |
% \fi |
| 2453 |
% |
| 2454 |
% \begin{macrocode} |
| 2455 |
%</2ekernel> |
| 2456 |
% \end{macrocode} |
| 2457 |
% |
| 2458 |
% \Finale |
| 2459 |
% |