1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
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 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
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
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.
31 %%% From File: ltfsstrc.dtx
32 %% Copyright (C) 1989-97 by Frank Mittelbach and Rainer Sch\"opf.
33 %% Copyright (C) 1994-97 by LaTeX3 project. All rights reserved.
35 %<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
36 %<package>\ProvidesPackage{tracefnt}
37 %<package> [2015/02/21 v3.0k Standard LaTeX package (font tracing)]
39 % \ProvidesFile{ltfsstrc.dtx}
40 % [2015/02/21 v3.0k LaTeX Kernel (NFSS tracing)]
50 % \changes{v3.0g}{1995/11/28}
51 % {documentation fixes}
52 % \changes{v3.0f}{1995/10/22}{Added `genb' and `sgenb' size functions
53 % to support new DC font naming scheme.}
54 % \changes{v3.0e}{1995/10/20}
55 % {(DPC) Modify autoload code}
56 % \changes{v3.0d}{1995/10/04}
57 % {(DPC) Modify autoload code}
58 % \changes{v3.0b}{1995/05/24}
59 % {(DPC) Fix \cs{ProvidesFile} usage}
60 % \changes{v3.0a}{1995/05/24}
61 % {(DPC) Make file from previous file, tracefnt 1995/05/16 v2.3o}
62 % \changes{v3.0k}{2015/02/21}
63 % {Removed autoload code}
65 % \changes{v2.3m}{1994/11/18}
66 % {\cs{next} to \cs{reserved@f}}
67 % \changes{v2.3l}{1994/11/17}
68 % {\cs{@tempa} to \cs{reserved@a}}
69 % \changes{v2.3i}{1994/05/20}{Use new error command names}
70 % \changes{v2.3g}{1994/05/13}{Removed typeouts as
71 % \cs{ProvidesPackage} writes to log.}
72 % \changes{v2.3e}{1994/04/27}{Corrected item that was forgotten
74 % \changes{v2.3d}{1994/04/18}{Changed to new error/warning scheme}
75 % \changes{v2.3a}{1994/01/17}{New math font setup}
76 % \changes{v2.2a}{1993/11/11}{Option concept added for LaTeX2e}
77 % \changes{v2.1j}{1993/09/15}{Corrected spelling of \cs{noxpand}.}
78 % \changes{v2.1i}{1993/09/02}{Corrected name of sgen size function.}
79 % \changes{v2.1h}{1993/07/16}{Changed layout of info messages}
80 % \changes{v2.1b}{1993/03/18}
81 % {Changed all \cs{@tempdimb} in \cs{@tempdimx}
82 % to avoid killing \cs{numberline}}
83 % \changes{v2.1b}{1993/03/18}
84 % {Changed all \cs{@tempdima} in \cs{@tempdimb}
85 % to avoid killing \cs{numberline}}
86 % \changes{v1.0l}{1990/04/01}{Part of code moved to fam.dtx.}
87 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
88 % \changes{v1.0h}{1990/01/18}{\cs{tracingfonts} meaning changed.}
90 % \newcommand\module[1]{\texttt{#1}}
91 % \providecommand{\dst}{\textsc{DocStrip}}
92 % \newcommand\Loption[1]{\texttt{#1}}
94 % \GetFileInfo{ltfsstrc.dtx}
95 % \title{The \texttt{tracefnt} package\thanks
96 % {This file has version number \fileversion, dated
98 % for use with the new font selection scheme}
99 % \author{Frank Mittelbach \and Rainer Sch\"opf}
102 % \MaintainedByLaTeXTeam{latex}
105 % \section{Introduction}
107 % This package contains the code for tracing font loading and font
108 % changes. It basically overlays some of the low-level functions of
109 % NFSS with additional code used for tracing.
111 % The package accepts the following options:
112 % \begin{description}
113 % \item[errorshow] Write all information about font changes etc.\
114 % only to the transcript file unless an error happens. This means
115 % that information about font substitution will not be shown on the
118 % \item[warningshow] Show all NFSS warnings on the terminal. This
119 % setting corresponds to the default behaviour of NFSS if the
120 % \texttt{tracefnt} package is \emph{not} loaded!
122 % \item[infoshow] Show all NFSS warning and all NFSS info
123 % messages (that are normally only written to the transcript file)
124 % also on the terminal. This is the default if the \texttt{tracefnt}
127 % \item[debugshow] In addition to \texttt{infoshow} show also
128 % changing of math fonts as far as possible (this option can produce a
129 % large amount of output.
131 % \item[loading] Show the name of external fonts when they are
132 % loaded. This option shows only ``newly'' loaded fonts not those
133 % already preloaded in the format or the class file before the
134 % \texttt{tracefnt} package became active.
137 % Turn all font warnings into errors so that \LaTeX{} will stop.
144 % \section{A driver for this document}
146 % The next bit of code contains the documentation driver file for
147 % \TeX{}, i.e., the file that will produce the documentation you
148 % are currently reading. It will be extracted from this file by the
151 % When this file is processed directly by \LaTeX{} this will
152 % produce the documentation as well.
156 \documentclass{ltxdoc}
159 %\OnlyDescription % comment out for implementation details
162 \DocInput{ltfsstrc.dtx}
168 % \section{The Implementation}
171 % \textbf{Warning:} Read the macro documentation with a grain of
172 % salt. It is still basically the documentation from the first NFSS
173 % release and therefore in some cases probably not completely
177 % If we are making a package file it is a good idea to test whether
178 % we are running under 2e.
179 % This code is actually placed at the very beginning of this file
180 % for easier maintenance, thus commented out here.
183 %\NeedsTeXFormat{LaTeX2e}
184 %\ProvidesPackage{tracefnt}[??/??/?? v?.??
185 % Standard LaTeX package (font tracing)]
190 % The \texttt{debug} module makes use of commands contained in a
191 % special package file named \texttt{trace.sty}.\footnote{This package
192 % is not in distribution at the moment (and probably doesn't any
193 % longer work). Think of this part of the code as being historical
196 %<+debug> \input trace.sty
200 % \section{Handling Options}
202 % \begin{macro}{\tracingfonts}
203 % Here is the definition of the integer register for the font
204 % trace. As a default in a package file we use $1$ to give error
205 % messages if fonts are substituted. If this code is used for
206 % debugging or tracing reasons in the format file (i.e.\ in
207 % \texttt{fam.dtx}) we use $0$ as the default. But if no font
208 % trace is used we build a definition that will produce a warning
210 % \changes{v1.0l}{1990/04/01}
211 % {Check if \cs{tracingfonts} already defined.}
212 % \changes{v1.0o}{1990/04/01}
213 % {Check if \cs{tracingfonts} defined removed again.}
217 \@font@warning{Command \noexpand\tracingfonts
218 not provided.\MessageBreak
219 Use the `tracefnt' package.\MessageBreak Command found:}%
223 % The |\count@| in the line above will remove the number after
224 % |\tracingfonts|. Note that this definition will be overwritten be
225 % the next line if one of these modules are included.
227 %<*package,trace,debug>
228 \newcount\tracingfonts
230 %</package,trace,debug>
235 % The option \Loption{errorshow} turns off all warnings so that only
236 % real errors are shown. \Loption{warningshow} corresponds to the
237 % NFSS default (when \texttt{tracefnt} is not loaded).
238 % \Loption{infoshow} is the default for this package here; and
239 % \Loption{debugshow}, \Loption{loading}, and
240 % \Loption{pausing} extend the amount of information even further.
241 % \changes{v2.3o}{1995/05/13}
242 % {Use single hash mark in \cs{DeclareOption}}
245 \DeclareOption{errorshow}{%
247 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
248 {LaTeX Font Info: \space\space\space#1}}%
249 \def\@font@warning#1{%
250 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
251 {LaTeX Font Warning: #1}}%
256 \DeclareOption{warningshow}{%
258 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
259 {LaTeX Font Info: \space\space\space#1}}%
260 \def\@font@warning#1{%
261 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
262 {LaTeX Font Warning: #1}}%
267 \DeclareOption{infoshow}{%
269 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
270 {LaTeX Font Info: \space\space\space#1}}%
271 \def\@font@warning#1{%
272 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
273 {LaTeX Font Warning: #1}}%
278 \DeclareOption{loading}{%
284 \DeclareOption{debugshow}{%
285 \ExecuteOptions{infoshow}%
290 % \changes{v3.0j}{1997/05/29}{Replaced \texttt{\symbol{92}\symbol{92}}
291 % by \cs{MessageBreak}, as suggested by Donald Arseneau.}
293 \DeclareOption{pausing}{%
294 \def\@font@warning#1{%
296 {(Font)\@spaces\@spaces\@spaces\space\space}%
297 {LaTeX Font Warning: #1}%
298 {See the LaTeX Companion for details.}%
299 {I'll stop for every LaTeX Font Warning because
300 you requested\MessageBreak the `pausing' option
301 to the tracefnt package.}}%
304 % We make |infoshow| the default, which in turn defines
305 % |\font@warning| and |\font@info|.
307 \ExecuteOptions{infoshow}
312 % We also need a default definition inside the kernel:
316 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
317 {LaTeX Font Info: \space\space\space#1}}%
318 \def\@font@warning#1{%
319 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
320 {LaTeX Font Warning: #1}}%
325 % \section{Macros common to \texttt{fam.tex} and \texttt{tracefnt.sty}}
327 % In the first versions of \texttt{tracefnt.dtx} some macros of
328 % \texttt{fam.dtx}\footnote{This file is currently not distributed in
329 % documented form. Its code is part of \texttt{ltfss.dtx}.}
330 % were redefined to included the extra tracing
331 % information. Now these macros are all defined in this file (i.e.\
332 % removed from \texttt{fam.dtx}) and different production versions can
333 % be obtained simply by specifying a different set of modules to
334 % include when generating \texttt{ltfss.dtx}.
338 % \subsection{General font loading}
341 % \begin{macro}{\extract@font}
343 % This macro organizes the font loading.
344 % It first calls |\get@external@font|
345 % which will return in |\external@font| the name of the external
346 % font file (the \texttt{.tfm}) as it was determined by the NFSS
353 % Then the external font is loaded and assigned to the font
354 % identifier stored inside |\font@name|
355 % (for this reason we need |\expandafter|).
357 \global\expandafter\font\font@name\external@font\relax
359 % When tracing we typeout the internal and external font name.
360 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
363 \ifnum \tracingfonts >\@ne
364 \@font@info{External font `\external@font'
365 loaded as\MessageBreak \font@name}\fi
368 % Finally we call the corresponding ``loading action'' macros to
369 % finish things. First the font is locally selected to allow the
370 % use of |\font| inside the loading action macros.
374 % The next two lines execute the ``loading actions'' for the
375 % family and then for the individual font shape.
377 \csname \f@encoding+\f@family\endcsname
378 \csname\curr@fontshape\endcsname
383 % The |\relax| at the end needs to be explained.
384 % This is inserted to prevent \TeX{} from scanning too far
385 % when it is executing the replacement text of the loading
390 % \begin{macro}{\get@external@font}
391 % This function tries to find an external font name. It will place
392 % the name into the macro
393 % |\external@font|. If no font is found it will return the one
394 % that was defined via |\DeclareErrorFont|.
397 \def\get@external@font{%
399 % We don't know the external font name at the beginning.
401 \let\external@font\@empty
402 \edef\font@info{\expandafter\expandafter\expandafter\string
403 \csname \curr@fontshape \endcsname}%
406 % If this failed, we'll try to substitute another size of the same
407 % font. This is done by the |\try@size@substitution| macro. It
408 % ``knows about'' |\do@extract@font|, |\font@name|, |\f@size|, and
411 \ifx\external@font\@empty
412 \try@size@substitution
413 \ifx\external@font\@empty
414 \@latex@error{Font \expandafter \string\font@name\space
425 % \changes{v1.0j}{1990/02/18}
426 % {Redefine unprotected version \cs{p@selectfont}
427 % instead of \cs{selectfont}.}
430 % \begin{macro}{\selectfont}
431 % \changes{v1.1a}{1989/12/16}{Changed order of calls.}
432 % \changes{v2.3f}{1994/05/12}{Use \cs{DeclareRobustCommand}}
433 % The macro |\selectfont| is called whenever a font change must
437 \DeclareRobustCommand\selectfont
440 % When \module{debug} is specified we actually want something like
441 % `undebug'. The font selection is now stable so that using
442 % |\tracingall| on some other macros will show us a lot of unwanted
443 % information about font loading. Therefore we disable tracing during
444 % font loading as long as |\tracingfonts| is less than $4$.
445 % \changes{v1.0m}{1990/04/05}
446 % {Call \cs{tracingon} only if \cs{tracingfonts} greater than 3.}
447 % \changes{v1.0n}{1990/05/05}{\cs{tracingon} with new syntax.}
449 %<+debug> \pushtracing
450 %<+debug> \ifnum\tracingfonts<4 \tracingoff
451 %<+debug> \else \tracingon\p@selectfont \fi
453 % If |\baselinestretch| was redefined by the user it will not
454 % longer match its internal counterpart |\f@linespread|. If so we
455 % call |\set@fontsize| to prepare |\size@update|.
457 \ifx\f@linespread\baselinestretch \else
458 \set@fontsize\baselinestretch\f@size\f@baselineskip \fi
460 % Then we generate the internal name of the font
461 % by concatenating {\em family}, {\em series},
462 % {\em shape}, and current {\em size},
463 % with slashes as delimiters between them.
464 % This is much more readable than standard
465 % \LaTeX's |\twfbf|, etc.
466 % We define |\font@name| globally, as always.
467 % The reason for this is explained later on.
468 % \changes{v2.0b}{1992/07/26}{}
471 \csname\curr@fontshape/\f@size\endcsname}%
473 % We call the macro |\pickup@font| which will load the font if
478 % Then we select the font.
482 % If |\tracingfonts| is
483 % greater than 2 we also show the font switch.
484 % We do this before |\glb@settings| is called since this
485 % macro might redefine |\font@name|.
486 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
487 % \changes{v1.0i}{1990/02/16}{Changed \cs{f@size} to \cs{lcl@currsize}
491 \ifnum \tracingfonts>\tw@
492 \@font@info{Switching to \font@name}\fi
495 % Finally we call |\size@update|. This macro is normally empty but
496 % will contain actions (like setting the |\baselineskip|) that have
497 % to be carried out when the font size, the base |\baselineskip| or
498 % the |\baselinestretch| have changed.
502 % A similar function is called to handle anything related to
503 % encoding updates. This one is changed from |\relax| by
505 % \changes{v2.3h}{1994/05/14}{Added \cs{enc@update}}
509 % Just before ending this macro we have to pop the tracing stack
510 % if it was pushed before.
512 %<+debug> \poptracing
519 % \begin{macro}{\set@fontsize}
520 % The macro |\set@fontsize| does the actual work. First it assigns
521 % new values to |\f@size|, |\f@baselineskip| and |\f@linespread|.
523 \def\set@fontsize#1#2#3{%
524 \@defaultunits\@tempdimb#2pt\relax\@nnil
525 \edef\f@size{\strip@pt\@tempdimb}%
526 \@defaultunits\@tempskipa#3pt\relax\@nnil
527 \edef\f@baselineskip{\the\@tempskipa}%
528 \edef\f@linespread{#1}%
530 % For backward compatibility and for later testing within
531 % |\selectfont| the internal value of |\f@linespread| is passed
532 % back to |\baselinestretch|.
534 \let\baselinestretch\f@linespread
536 % Additional processing will happen within |\selectfont|. For this
537 % reason the macro |\size@update| (which will be called in
538 % |\selectfont|) will be defined to be:
542 % First calculate the new |\baselineskip| and also store it in
543 % |normalbaselineskip|
545 \baselineskip\f@baselineskip\relax
546 \baselineskip\f@linespread\baselineskip
547 \normalbaselineskip\baselineskip
549 % then to set up a new |\strutbox|
551 \setbox\strutbox\hbox{%
552 \vrule\@height.7\baselineskip
553 \@depth.3\baselineskip
556 % We end with a bit of tracing information.
559 \ifnum \tracingfonts>\tw@
560 \ifx\f@linespread\@empty
561 \let\reserved@a\@empty
563 \def\reserved@a{\f@linespread x}%
565 \@font@info{Changing size to \f@size/\reserved@a
567 \aftergroup\type@restoreinfo \fi
570 % When all this is processed |\size@update| redefines itself to
571 % |\relax| so that in later calls of |\selectfont| no extra code
574 \let\size@update\relax}%
577 % Instead of defining this macro internally we might speed things
578 % up by placing the code into a separate macro and use |\let|!
582 % \begin{macro}{\size@update}
583 % Normally this macro does nothing; it will be redefined by
584 % |\set@fontsize| to initiate an update.
586 \let\size@update\relax
591 % \begin{macro}{\type@restoreinfo}
592 % This macro produces some info when a font size and/or baseline
593 % change will get restored.
594 % \changes{1.0r}{1990/08/27}{Some extra tracing info.}
597 \def\type@restoreinfo{%
598 \ifx\f@linespread\@empty
599 \let\reserved@a\@empty
601 \def\reserved@a{\f@linespread x}%
603 \@font@info{Restoring size to
604 \f@size/\reserved@a\f@baselineskip}}
609 % \begin{macro}{\glb@settings}
610 % \begin{macro}{\glb@currsize}
611 % \changes{v2.3a}{1994/01/17}{New math font setup}
612 % \changes{v2.3k}{1994/11/06}{New implementation}
613 % The macro |\glb@settings| globally selects
614 % all math fonts for the current size if necessary.
618 % When |\glb@settings| gains control a size
619 % change was requested and all previous font assignments need to
621 % Therefore the old values of the fonts are no longer needed.
622 % For every {\em math group\/} the new assignments are appended to
624 % But this happens only if the |math@fonts| switch
626 % However, we always set up the correct math sizes for script and
627 % scriptscript fonts since they may be needed even if we don't set
628 % up the whole math machinery.
630 % Here we set the math size, script size and scriptscript size.
631 % If the |S@|\ldots{} macro is not defined we have to first
632 % calculate the three sizes.
634 \expandafter\ifx\csname S@\f@size\endcsname\relax
635 \calculate@math@sizes
638 % The effect of this is that |\calculate@math@sizes|
639 % may or may not define the |S@|\ldots{} macro. In the
640 % first case the next time the same size is requested
641 % this macro is used, otherwise |\calculate@math@sizes| is
643 % This also sets the |math@fonts| switch.
644 % If it is true we must switch the math fonts.
646 \csname S@\f@size\endcsname
649 \ifnum \tracingfonts>\tw@
650 \@font@info{Setting up math fonts for
651 \f@size/\f@baselineskip}\fi
654 % Inside a group we execute the macro for the current math {\em
655 % version}. This sets |\math@fonts| to a list of
656 % |\textfont|\dots{} assignments. |\getanddefine@fonts| (which may
657 % be called at this point) needs the |\escapechar| parameter to be
662 \csname mv@\math@version \endcsname
664 % Then we set |\globaldefs| to 1 so that all following changes are
665 % done globally. The math font assignments recorded in
666 % |\math@fonts| are executed and |\glb@currsize| is set equal to
667 % |\f@size|. This signals that the fonts for math in this size are
672 \let \glb@currsize \f@size
675 % Finally we execute any code that is supposed to happen
676 % whenever the math font setup changes. This register will
677 % be executed in local mode which means that everything that is
678 % supposed to have any effect should be done globally inside.
679 % We can't execute it within |\globaldefs\@ne| as we don't know
680 % what ends up inside this register, e.g., it might contain
681 % calculations which use some local registers to calculate the
682 % final (global) value.
686 % Otherwise we announce that the math fonts are not set up for this
691 \ifnum \tracingfonts>\tw@
692 \@font@info{No math setup for
693 \f@size/\f@baselineskip}\fi
703 % \begin{macro}{\baselinestretch}
704 % \changes{v1.0o}{1990/06/24}{Moved to tracefnt.dtx.}
705 % In |\selectfont| we used |\baselinestretch| as
706 % a factor when assigning a value to |\baselineskip|.
707 % We use 1 as a default (i.e.\ no stretch).
710 \def\baselinestretch{1}
714 % \begin{macro}{\every@math@size}
715 % \changes{v1.0u fam.dtx}{1989/12/05}{Hook \cs{every@size} added.}
716 % \changes{v23.k}{1994/10/23}{Renamed to \cs{every@math@size}}
717 % We must still define the hook |\every@math@size| we used in
718 % |\glb@settings|. We initialize it to nothing. It is important to
719 % remember that everything that goes into this hook should to global
720 % updates, local changes will have weird effects.
722 \newtoks\every@math@size
730 % \subsection{Math fonts setup}
733 % \subsubsection{Outline of algorithm for math font sizes}
735 % \TeX{} uses the the math fonts that are current when the end of a
736 % formula is reached. If we don't want to keep font setups local to
737 % every formula (which would result in an enormous overhead, we have
738 % to be careful not to end up with the wrong setup in case formulas
739 % are nested, e.g., we need to be able to handle
741 % $ a=b+c \mbox{ \small for all $b$ and $c\in Z$}$
743 % Here the inner formulae |b| and |c\in Z| are typeset in |\small| but
744 % we have to return to |\normalsize| before we reach the closing |$|
745 % of the outer formula.
747 % This is handled in the following way:
749 % \item At any point in the document the global variable
750 % |\gbl@currsize| contains the point size for which the math fonts
751 % currently are set up.
753 % \item \label{it:everymath} Whenever we start a formula we compare
754 % its value with the local variable |\f@size| that describes the
755 % current text font size.
757 % \item If both are the same we assume that we can use the current
758 % math font setup without adjustment.
760 % \item \label{it:everymathend} If they differ we call |\gbl@settings|
761 % which changes the math font setup and updates |\gbl@currsize|.
763 % \item If we are recursively inside another formula (|\if@inmath|) we
764 % ensure that |\gbl@settings| is executed again in the outer
765 % formula, so that the old setup is automatically restored.
766 % \item Otherwise, we set the switch |@inmath| locally to |true| so
767 % that all nested formulae will be able to detect that they are
768 % nested in some outer formula.
773 % The above algorithm has the following features:
775 % \item For sizes which are not containing any formula no math setup
776 % is done. Compared to the original algorithm of NFSS this results
777 % in the following savings:
779 % \item No unnecessary loading of math fonts for sizes that are not
780 % used to typeset any math formulae (explicit or implicit ones).
781 % \item No time overhead due to unnecessary changes of the math font
782 % setup on entrance and exit of the text font size.
785 % \item Math font setup changes for top-level formulae will survive
786 % (there is no restoration after the formula) thus any following
787 % formula in the same size will be directly typesetable. Compared to
788 % original implementation in NFSS2
789 % the new algorithm has the overhead of one test per formula
790 % to see if the current math setup is valid (in the original
791 % algorithm the setup was always valid, thus no test was necessary).
793 % \item In nested formulae the math font setup is restored in the
794 % outer formula by a series of |\aftergroup| commands and checks.
795 % Compared to the original algorithm this involves additional checks
796 % ($2 \times \langle\mbox{non-math levels}\rangle$ per inner
800 % \subsubsection{Code for math font size setting}
802 % \begin{macro}{\check@mathfonts}
803 % \changes{v2.3a}{1994/01/17}{New math font setup}
804 % \changes{v2.3c}{1994/01/26}{Correct trace info placement}
805 % In the |\check@mathfonts| macros we implement the steps
806 % \ref{it:everymath} to \ref{it:everymathend} except that instead
807 % of a switch the macro |\init@restore@glb@settings| is used.
810 \def\check@mathfonts{%
811 \ifx \glb@currsize \f@size
813 \ifnum \tracingfonts>\thr@@
814 \@font@info{*** MATH: no change \f@size\space
815 curr/global (\curr@math@size/\glb@currsize)}\fi
819 \ifnum \tracingfonts>\thr@@
820 \@font@info{*** MATH: setting up \f@size\space
821 curr/global (\curr@math@size/\glb@currsize)}\fi
824 \init@restore@glb@settings
826 \let\curr@math@size\f@size
827 \def\init@restore@glb@settings{\aftergroup\restglb@settings}%
835 % \begin{macro}{\init@restore@glb@settings}
836 % \changes{v3.0i}{1996/07/26}{macro added replacing \cs{if@inmath} switch}
837 % This macros does by default nothing but get redefined inside
838 % |\check@mathfonts| to initiate fontsize restoring in nested
841 %<-trace>\let\init@restore@glb@settings\relax
843 \def\init@restore@glb@settings{%
844 \ifnum \tracingfonts>\thr@@
845 \@font@info{*** MATH: no resetting (not in
853 % \begin{macro}{\restglb@settings}
854 % \changes{v2.3a}{1994/01/17}{New math font setup}
855 % \changes{v2.3c}{1994/01/26}{Correct trace info placement}
856 % This macro will be executed the first time after the current
859 \def\restglb@settings{%
861 \ifnum \tracingfonts>\thr@@
862 \@font@info{*** MATH: restoring}\fi
865 \let\f@size\curr@math@size
866 \ifx\glb@currsize \f@size
868 \ifnum \tracingfonts>\thr@@
869 \@font@info{*** MATH: ... already okay (\f@size)}\fi
873 \ifnum \tracingfonts>\thr@@
874 \@font@info{*** MATH: ... to \f@size}\fi
884 % \subsubsection{Other code for math}
887 % \begin{macro}{\use@mathgroup}
888 % \changes{v1.2b}{1990/01/21}{Macro added to allow cleaner interface.}
889 % \changes{v1.2h}{1990/03/30}{Third argument removed (see
890 % \cs{math@egroup}).}
891 % The |\use@mathgroup| macro should be used in user
892 % macros to select a math group. Depending on whether or not the
893 % \texttt{margid} option is in force it has two or three arguments.
894 % For this reason it should be called as the last macro.
896 % First we test if we are inside math mode since we don't want to
897 % apply a useless definition.
898 % \changes{v1.1a}{1989/12/16}{Usage of `\quotechar=' macro added.}
899 % \changes{v1.1a}{1989/12/16}{Redefinition of alphabet now simpler.}
901 \def\use@mathgroup#1#2{\relax\ifmmode
903 % \changes{v1.0o}{1990/06/24}{Tracing code added.}
904 % \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
907 \ifnum \tracingfonts>\tw@
909 \@font@info{Using \noexpand\mathgroup
913 % If so we first call the `=' macro (i.e.\ argument three) to set
914 % up special things for the selected math group. Then we call
915 % |\mathgroup| to select the group given by argument two and
916 % finally we place |#1| (i.e.\ the argument of the \meta{math
917 % alphabet identifier} at the end. This part of the code is
918 % surrounded by two commands which behave like |\begingroup|
919 % and |\endgroup| if we want \meta{math alphabet identifier}s
920 % but will expand into |\@empty| if we want simply switches to
922 % \changes{v1.0p}{1990/06/30}{Added \cs{relax} after math group number.}
923 % Since argument number $2$ may be a digit instead of a control
924 % sequence we add a |\relax|.
925 % Otherwise something like |\mit{1}| would switch to math group
926 % $11$ (and back) instead of printing an oldstyle $\mit {1}$.
927 % \changes{v2.0b}{1992/07/26}{}
930 \expandafter\ifx\csname M@\f@encoding\endcsname#1\else
934 % Before we reinsert the swallowed token (arg.\ three) into the
935 % input stream, in the case that the \meta{math alphabet
936 % identifier} isn't called in math mode, we remove the |\fi|
937 % with the |\expandafter| trick. This is necessary if the
938 % token is actually an macro with arguments. In such a case the
939 % |\fi| will be misinterpreted as the first argument which
940 % would be disastrous.
941 % \changes{v1.0f}{1989/12/13}
942 % {\cs{expandafter} added before final \cs{fi}.}
944 \expandafter\math@egroup\fi}%
946 % The surrounding macros equal |\begingroup| and |\endgroup|. But
947 % using internal names makes it possible to overwrite their meaning
948 % in certain cases. This is for example used in \AmSTeX{} macros
949 % for placing accents.
952 % \begin{macro}{\math@egroup}
953 % \changes{v1.0q}{1990/07/07}{Tracing code added.} If the
954 % \texttt{margid} option is in force (which can be tested by
955 % looking at the definition of |\math@bgroup| we change the
956 % |\math@egroup| command a bit to display the current \meta{math
957 % group number} after it closes the scope of \meta{math alphabet}
959 % \changes{v3.0h}{1996/05/08}{Use \cs{bgroup} instead of \cs{begingroup}
960 % to match a kernel change made in 1994!!!!}
963 \ifx\math@bgroup\bgroup
964 \def\math@egroup#1{#1\egroup
965 \ifnum \tracingfonts>\tw@
966 \@font@info{Restoring \noexpand\mathgroup
967 (\ifnum\mathgroup=\m@ne default\else \the\mathgroup \fi)%
974 % \begin{macro}{\getanddefine@fonts}
975 % \changes{v1.0o}{1990/06/24}{\cs{Macro} moved from fam.dtx.}
976 % |\getanddefine@fonts| has two arguments: the \meta{math
977 % group number} and the {\em family/series/shape\/} name as a
980 \def\getanddefine@fonts#1#2{%
982 % First we turn of tracing when |\tracingfonts| is less than $4$.
983 % \changes{v1.0o}{1990/06/24}{Adding debug code.}
984 % \changes{v1.0r}{1990/08/27}
985 % {Correcting missing name after \cs{tracingon}.}
987 %<+debug> \pushtracing
988 %<+debug> \ifnum\tracingfonts<4 \tracingoff
989 %<+debug> \else \tracingon\getanddefine@fonts \fi
991 % \changes{v1.0o}{1990/06/24}{\cs{Adding} tracing code.}
992 % \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
993 % \changes{v2.1a}{1992/09/22}{Introduced \cs{tf@size} for math size.}
996 \ifnum \tracingfonts>\tw@
998 \@font@info{\noexpand\mathgroup (\the\count@) #1 :=\MessageBreak
999 \string#2 \tf@size/\sf@size/\ssf@size}\fi
1002 % We append the current |\tf@size| to |#2| to obtain the font
1003 % name.\footnote{One might ask why this expansion does not generate
1004 % a macro name that starts with an additional \texttt{\bslash}
1005 % character. The solution is that \texttt{\bslash escapechar} is
1006 % set to $-1$ before \texttt{\bslash getanddefine@fonts} is
1007 % called.} Again, |font@name| is defined globally, for the reasons
1008 % explained in the description of |\wrong@fontshape|.
1010 \xdef\font@name{\csname \string#2/\tf@size\endcsname}%
1012 % Then we call |\pickup@font| to load it if necessary.
1013 % We remember the internal name as |\textfont@name|.
1015 \pickup@font \let\textfont@name\font@name
1017 % Same game for |\scriptfont| and |\scriptscriptfont|:
1019 \xdef\font@name{\csname \string#2/\sf@size\endcsname}%
1020 \pickup@font \let\scriptfont@name\font@name
1021 \xdef\font@name{\csname \string#2/\ssf@size\endcsname}%
1024 % Then we append the new |\textfont|\ldots{} assignments to
1025 % the |\math@fonts|.
1027 \edef\math@fonts{\math@fonts
1028 \textfont#1\textfont@name
1029 \scriptfont#1\scriptfont@name
1030 \scriptscriptfont#1\font@name}%
1032 % Just before ending this macro we have to pop the tracing stack
1033 % if it was pushed before.
1035 %<+debug> \poptracing
1037 %</2ekernel|package>
1042 % \section{Scaled font extraction}
1044 % \begin{macro}{\ifnot@nil}
1045 % We begin with a simple auxiliary macro. It checks
1046 % whether its argument is the token |\@nil|. If so,
1047 % it expands to |\@gobble| which discards the following
1048 % argument, otherwise it expands to |\@firstofone| which
1049 % reproduces it argument.
1050 % \changes{v2.3n}{1995/05/08}{Use \cs{@firstofone}}
1053 \def\ifnot@nil#1{\def\reserved@a{#1}%
1054 \ifx\reserved@a\@nnil \expandafter\@gobble
1055 \else \expandafter\@firstofone\fi}
1060 % \begin{macro}{\remove@to@nnil}
1061 % \begin{macro}{\remove@angles}
1062 % \begin{macro}{\remove@star}
1063 % Three other auxiliary macros will be needed in the following:
1064 % |\remove@to@nnil| gobbles up everything up to, and including,
1065 % the next |\@nnil| token, and |\remove@angles| and |\remove@star|
1067 % for the character |>| and |*|, respectively, instead of |\@nnil|.
1069 \def\remove@to@nnil#1\@nnil{}
1070 \def\remove@angles#1>{\set@simple@size@args}
1071 \def\remove@star#1*{#1}
1076 % \changes{v3.0c}{1995/08/24}{Macro \cs{gobble@font@spec} removed}
1078 % \begin{macro}{\extract@sizefn}
1079 % This macro takes a size specification and parses it into size
1080 % function and the optional and mandatory arguments.
1082 \def\extract@sizefn#1*#2\@nil{%
1083 \if>#2>\set@size@funct@args#1\@nil
1084 \let\sizefn@info\@empty
1085 \else\expandafter\set@size@funct@args\remove@star#2\@nil
1086 \def\sizefn@info{#1}\fi
1092 % \begin{macro}{\try@simple@size}
1093 % This function tries to extract the given size (specified by
1094 % |\f@size|) for the requested font shape. The font information
1095 % must already be present in |\font@info|.
1096 % The central macro that does the real work is |\extract@fontinfo|.
1097 % We will first give a simple example how this macro works, and
1098 % describe it in full generality later.
1100 % Assume that the requested parameters are: {\em encoding scheme\/}
1101 % `OT1', {\em family\/} `cm', {\em series\/} `sansserif',
1102 % {\em shape\/} `normal', and {\em size\/} `$12$'.
1103 % The corresponding font definitions have already been
1104 % extracted from the macro |\OT1/cm/sansserif/normal| and
1105 % stored in |font@info|.
1106 % (Otherwise |\extract@fontinfo| doesn't get called.)
1107 % This information consists of a token list made of characters
1108 % of category code $12$ of the form
1110 % <10*>cmss10<12*>cmss12<17*>cmss17
1112 % For reasonable packages one usually needs more sizes but this is
1113 % sufficient to get the flavour.
1114 % We will define a macro |\extract@fontinfo| to find
1115 % the external font name (`cmss12') for us:
1117 % \def\extract@fontinfo#1<12*#2>#3<#4\@nnil{%
1118 % \set@simple@size@args#3<#4\@nnil
1119 % \execute@size@function{#2}}
1121 % so that when it gets called via
1123 % \extract@fontinfo<10*>cmss10<12*>cmss12<17*>cmss17\@nnil
1125 % |#1| will contain all characters before |<12*>|,
1126 % |#2| will be empty, |#3| will be exactly |cmss12|,
1127 % and |#3| will be |17>cmss17|.
1128 % The expansion is therefore
1130 % \set@simple@size@args cmss12<17*>cmss17\@nnil
1131 % \execute@size@function{}
1133 % This means: the default (empty) size function will be executed,
1134 % with its optional argument argument set to empty and its mandatory
1135 % argument set to |cmss12| by |\set@simple@size@args|.
1136 % As we discussed earlier, the effect of the default size function
1137 % is to load the given external font (cmss12) at the specified size
1138 % (12)---which is exactly what was intended.
1140 % But this is only part of the whole story.
1141 % It may be that the size requested does not occur
1142 % in the token list |\font@info|.
1143 % And the simple definition of |\extract@fontinfo| we gave
1144 % above does not allow to specify give more than one
1145 % size specification in front of the external font name.
1147 % Let's address these two problems separately. The first one
1148 % is solved with the following trick:
1149 % We define |\extract@fontinfo| as follows:
1151 % \def\extract@fontinfo#1<12*#2>#3<#4\@nnil{%
1153 % {\set@simple@size@args#3<#4\@nnil
1154 % \execute@size@function{#2}%
1157 % How does this work?
1158 % We call |\extract@fontinfo| via
1160 % \expandafter\extract@fontinfo\font@info<12*>\@nil<\@nnil
1162 % i.e. by appending |<12*>\@nil<\@nnil|.
1163 % If the size (`12' in this case) appears in |\font@info|
1164 % everything works as explained above, the only difference being
1165 % that argument |#4| of |\extract@fontinfo|
1166 % additionally gets the tokens |<12*>\@nil<\@nnil|.
1167 % However, if the size is not found everything up to the final
1168 % |<12*>| is in argument |#1|,
1169 % |#3| gets |\@nil|,
1170 % and |#2| and |#4| are empty.
1171 % The macro |\ifnot@nil| will discard the calls to
1172 % |\set@simple@size@args| and |execute@size@function|, and
1173 % hence |\font@info| will continue to be equal to |\@empty|.
1174 % This means that no simple size specification matching the
1175 % requested size could be found.
1177 % The second problem (more than one simple size specification
1178 % for one external font name) will be addressed in
1179 % |\set@simple@size@args| below.
1181 % The macros are hidden inside other control sequences
1182 % so that we have to build |\extract@fontinfo| in
1185 % So here's the actual definition of |\extract@font| in
1186 % |\try@simple@size|.
1188 % % this could be replaced by \try@size@range making the subst slower!
1189 \def\try@simple@size{%
1191 % |\reserved@a| is made an abbreviation for the head of the
1192 % definition of the macro |\extract@fontinfo|.
1194 \def\reserved@a{\def\extract@fontinfo####1}%
1196 % Now we can define |\extract@fontinfo|. Here we handle a small
1197 % but convenient variation: in case of the default (empty) size
1198 % function it is allowed to omit the |*| character.
1199 % \changes{v2.0b}{1992/07/26}{}
1200 % \changes{v2.0c}{1992/09/19}{}
1202 \expandafter\reserved@a\expandafter<\f@size>##2<##3\@nnil{%
1204 {\set@simple@size@args##2<##3\@nnil
1205 \execute@size@function\sizefn@info
1208 % \changes{v2.0b}{1992/07/26}{}
1209 % Now we call |\extract@fontinfo|. Note the |<\@nil| \textsf{tokens}
1212 \expandafter\expandafter
1213 \expandafter\extract@fontinfo\expandafter\font@info
1214 \expandafter<\f@size>\@nil<\@nnil
1219 % \begin{macro}{\set@simple@size@args}
1220 % As promised above, the macro |\set@simple@size@args| will handle
1221 % the case of several size specifications in a row.
1222 % If another size specification follows, the very first token of
1223 % its argument list is the character |<|.
1224 % By starting the definition as follows,
1226 \def\set@simple@size@args#1<{%
1228 % parameter |#1| is empty in this case, and contains the size
1229 % function's arguments otherwise. We distinguish these two cases
1230 % (Note that the character |<| cannot appear in |#1|) by calling
1231 % |\remove@angles| for empty |#1| and |\extract@sizefn|
1232 % otherwise. In the latter case we have to take care of the
1233 % remaining character tokens and discard them. This is done by
1234 % |\remove@to@nnil|. Note also the use of Kabelschacht's method.
1237 \expandafter\remove@angles
1239 \extract@sizefn#1*\@nil
1240 \expandafter\remove@to@nnil
1246 % Now, we are through with the case of a simple size, except for
1247 % calling the size function. This will be handled later, as it is
1248 % the same mechanism for all types of size specification. We will
1249 % now proceed to macors for extraction of size range specification.
1253 % \begin{macro}{\extract@rangefontinfo}
1254 % |\extract@rangefontinfo| goes through a font shape definition
1255 % in the input until it recognizes the tokens |<\@nil->|.
1256 % It looks for font ranges with font size functions. It's operation
1257 % is rather simple: it discards everything up to the next size
1258 % specification and passes this on to |\is@range| for inspection.
1259 % The specification (parameter |#2| is inserted again, in case
1260 % it is needed later.
1262 \def\extract@rangefontinfo#1<#2>{%
1263 \is@range#2->\@nil#2>}
1267 % \begin{macro}{\is@range}
1268 % |\is@range| is again a sort of dispatcher macro: if the size
1269 % specification it is looking at is not a range specification
1270 % it discards it and calls |\extract@rangefontinfo| to continue
1271 % the search. Otherwise it calls |\check@range| to check the
1272 % requested size against the specified range.
1274 % From the way |\is@range| is called inside |\extract@rangefontinfo|
1275 % we see that |#2| is the character |>| if the size specification
1276 % found is a simple one (as it does not contain a |-| character.
1277 % This is checked easily enough and |\extract@rangefontinfo|
1278 % called again. Note that the extra tokens inserted after the
1279 % |\@nil| in the call to |\is@range| appear at the beginning of
1280 % the first argument to |\extract@rangefontinfo| and are hence
1283 \def\is@range#1-#2\@nil{%
1284 \if>#2\expandafter\check@single\else
1285 \expandafter\check@range\fi}
1290 % \begin{macro}{\check@range}
1291 % |\check@range| takes lower bound as parameter |#1|, upper bound
1292 % as |#2|, size function as |#3| and the size function's arguments
1293 % as |#4|. If |#3| is the special token |\@nil| |\font@info| is
1294 % exhausted and we can stop searching.
1296 \def\check@range#1-#2>#3<#4\@nnil{%
1299 % If |#3| wasn't |\@nil| we have a range. We start by assuming that
1300 % we have to recurse. Note that we have to reinsert an |<| as it
1301 % was already removed by scanning.
1303 \def\reserved@f{\extract@rangefontinfo<#4\@nnil}%
1305 % We have to make sure that both boundaries are present, if not we
1306 % have to set them. Here we check the upper bound. If |\upper@bound|
1307 % is zero after the assignment we set it to |\maxdimen| (upper open
1308 % range). We need to use a \meta{dimen} register for the scan since
1309 % we may have a decimal number as the boundary.
1312 \ifdim\upper@bound=\z@ \upper@bound\maxdimen\fi
1314 % Now we check the upper boundary against |\f@size|.
1315 % If it is larger or equal than |\f@size| this
1316 % range is no good and we have to recurse.
1318 \ifdim \f@size \p@<\upper@bound
1320 % Otherwise we have to check the lower bound. This time it is not
1321 % necessary to scan the boundary value into a register because if
1322 % it is empty we get zero as desired. We could even omit the |0|
1323 % which would result in |1pt| as default lower boundary. If
1324 % |\f@size| is smaller than the boundary we have to recurse.
1327 \ifdim \f@size \p@<\lower@bound
1330 % If both tests are passed we can try executing the size function.
1332 \set@simple@size@args#3<#4\@nnil
1333 \execute@size@function\sizefn@info
1335 % If the function was successful it should have left an external
1336 % font name in |\external@font|. We use this to see if we can stop
1337 % scanning. Otherwise we recurse.
1339 \ifx\external@font\@empty
1341 \let\reserved@f\@empty
1349 % \begin{macro}{\lower@bound}
1350 % \begin{macro}{\upper@bound}
1351 % We use two dimen registers |\lower@bound| and |\upper@bound|
1352 % to store the lower and upper endpoints of the range we found.
1354 \newdimen\lower@bound
1355 \newdimen\upper@bound
1361 % \begin{macro}{\check@single}
1362 % |\check@single| takes the size as parameter |#1|, size function
1363 % as |#2| and the size function's arguments as |#3|. We can assume
1364 % that there is always something in the pipeline since the very
1365 % last entry is a faked range (see above).
1367 \def\check@single#1>#2<#3\@nnil{%
1369 % We start by assuming that
1370 % we have to recurse. Note that we have to reinsert an |<| as it
1371 % was already removed by scanning.
1373 \def\reserved@f{\extract@rangefontinfo<#3\@nnil}%
1375 % Now we check the the size against |\f@size|. If it is not equal
1376 % |\f@size| it is no good and we have to recurse.
1378 \ifdim \f@size \p@=#1\p@
1380 % Otherwise if this test is passed we can try executing the size
1383 \set@simple@size@args#2<#3\@nnil
1384 \execute@size@function\sizefn@info
1386 % If the function was successful it should have left an external
1387 % font name in |\external@font|. We use this to see if we can stop
1388 % scanning. Otherwise we recurse.
1390 \ifx\external@font\@empty
1392 \let\reserved@f\@empty
1400 % \begin{macro}{\set@size@funct@args}
1401 % \begin{macro}{\set@size@funct@args@}
1402 % This macro sets the optional and mandatory arguments for a size
1403 % function. If the optional argument is not present it is set to
1404 % the empty token list. The mandatory argument is delimited by the
1407 \def\set@size@funct@args{\@ifnextchar[%
1408 \set@size@funct@args@{\set@size@funct@args@[]}}
1412 \def\set@size@funct@args@[#1]#2\@nil{%
1413 \def\mandatory@arg{#2}%
1414 \def\optional@arg{#1}}
1421 % \begin{macro}{\DeclareSizeFunction}
1422 % This function defines a new size function hiding the internal
1423 % from the designer. The body of the size function may use
1424 % |\optional@arg| and |\mandatory@arg| denoting the optional and
1425 % mandatory argument that may follow the size specification |<...>|.
1426 % \changes{v2.1c}{1993/03/18}{Added all args to avoid blanks problems}
1429 \def\DeclareSizeFunction#1#2{\@namedef{s@fct@#1}{#2}}
1430 \@onlypreamble\DeclareSizeFunction
1436 % \begin{macro}{\execute@size@function}
1437 % This macro is very simple. The only point worth noting
1438 % is that calling an undefined size function will do nothing
1439 % (actually execute a |\relax|).
1441 %<*2ekernel|package>
1442 \def\execute@size@function#1{%
1444 \@ifundefined{s@fct@#1}%
1445 {\errmessage{Undefined font size function #1}%
1447 {\csname s@fct@#1\endcsname}%
1449 %<-trace> \csname s@fct@#1\endcsname
1451 %</2ekernel|package>
1455 % \changes{v2.3j}{1994/05/23}{Removed def of \cs{f@warn@break}}
1458 % \begin{macro}{\try@size@range}
1459 % This macro tries to find a suitable range for requested size
1460 % (specified by |\f@size|) in |\font@info|. All the relevant
1461 % action is done in |\extract@rangefontinfo|. All that needs
1462 % to be done is to stuff in the token list in |\font@info| so
1463 % that |\extract@rangefontinfo| can inspect it.
1464 % Note the |<-*\@nil><| token at the end to stop scanning.
1465 % \changes{v2.0b}{1992/07/26}{}
1468 \def\try@size@range{%
1469 \expandafter\extract@rangefontinfo\font@info <-*>\@nil<\@nnil
1475 % \begin{macro}{\try@size@substitution}
1476 % \changes{v2.3k}{1994/11/06}{New implementation}
1477 % This is the last thing that can be tried. If the desired |\f@size|
1478 % is found neither among the simple size specifications nor in one
1479 % of the ranges the whole list of size specifications is searched for
1480 % a nearby simple size.
1482 \gdef\try@size@substitution{%
1484 % First we do some initializations. |\@tempdimb|
1485 % will hold the difference between the wanted size and the best
1486 % solution found so far, so we initialise it with |\maxdimen|.
1487 % The macro |\best@size| will hold the best size found, nothing
1488 % found is indicated by the empty value.
1490 \@tempdimb \maxdimen
1491 \let \best@size \@empty
1493 % Now we loop over the specification
1495 \expandafter \try@simples \font@info <\number\@M>\@nil<\@nnil
1501 % \begin{macro}{\font@submax}
1502 % \changes{v2.3d}{1994/04/18}{Changed dimen to macro}
1503 % \begin{macro}{\fontsubfuzz}
1504 % \changes{v2.3d}{1994/04/18}{Changed dimen to macro}
1505 % The macro |\font@submax| records the maximal deviation from the
1506 % desired size encountered so far. Its value is used in a warning
1507 % message at |\end{document}|. The macro
1508 % |\fontsubfuzz| contains the amount that will not cause terminal
1509 % warnings (warnings still go into the transcript file).
1511 \def\font@submax{0pt}
1512 \def\fontsubfuzz{.4pt}
1514 %<+package>\def\fontsubfuzz{0pt}
1521 % \begin{macro}{\try@simples}
1522 % \changes{v2.3k}{1994/11/06}{New implementation}
1523 % |\try@simples| goes through a font shape definition
1524 % in the input until it recognizes the tokens |<*\@nil><|.
1525 % It looks for simple sizes to determine the two closest sizes.
1526 % It is assumed that simple sizes are in increasing order.
1529 \gdef\try@simples#1<#2>{%
1530 \tryif@simple#2->\tryif@simple}
1534 % \begin{macro}{\tryis@simple}
1535 % \changes{v2.3k}{1994/11/06}{New implementation}
1536 % |\tryis@simple| is similar to |\is@range|. If it sees a simple size,
1537 % it checks it against the value of |\f@size| and sets
1538 % |\lower@font@size| or |\higher@font@size|. In the latter case, it
1539 % stops the iteration. By adding |<\number\@M>| at the end of the
1540 % line we always have an end point. This is a hack which probably
1541 % should be corrected.
1543 % First it checks whether it is finished already, then whether the
1544 % size specification in question is a simple one.
1546 \gdef\tryif@simple#1-#2\tryif@simple{%
1548 % Most common case for |\reserved@f| first:
1550 \let \reserved@f \try@simples
1553 % If so, it compares it to the value of |\f@size|. This is done using
1554 % a dimen register since there may be fractional numbers.
1557 \ifdim \dimen@<\@M\p@
1559 % If |\dimen@| is |\@M\p@| we have reached the end of the fontspec
1560 % (hopefully) otherwise we compare the value with |\f@size| and
1561 % compute in |\@tempdimc| the absolute value of the difference
1562 % between the two values.
1564 \ifdim \f@size\p@<\dimen@
1566 \advance\@tempdimc -\f@size\p@
1568 \@tempdimc \f@size\p@
1569 \advance\@tempdimc -\dimen@
1572 % The result is then compared with the smallest difference we have
1573 % encountered, if the new value (in |\@tempdimc| is smaller) we
1574 % have found a size which is a better approximation so we make it
1575 % the |\best@size| and adjust |\@tempdimb|.
1577 \ifdim \@tempdimc<\@tempdimb
1578 \@tempdimb \@tempdimc
1579 \def \best@size{#1}%
1582 % When we have reached the end of the fontspec we substitute the
1583 % best size found (if any). We code this inline to save macro
1584 % space; in the past this was done by a macro called |\subst@size|.
1590 % \begin{macro}{\subst@size}
1591 % This macro substitutes the size recorded in |\best@size| for
1592 % the unavailable size |\f@size|. |\font@submax| records the maximum
1593 % difference between desired size and selected size in the
1595 % \changes{v2.3d}{1994/04/18}{\cs{font@submax} and \cs{fontsubfuzz}
1598 % %\subst@size %% coded inline
1599 % %\def\subst@size{%
1600 \ifx \external@font\@empty
1601 \ifx \best@size\@empty
1603 \ifdim \@tempdimb>\font@submax \relax
1604 \xdef \font@submax {\the\@tempdimb}%
1606 \let \f@user@size \f@size
1607 \let \f@size \best@size
1608 \ifdim \@tempdimb>\fontsubfuzz\relax
1609 \@font@warning{Font\space shape\space
1610 `\curr@fontshape'\space in\space size\space
1611 <\f@user@size>\space not\space available\MessageBreak
1612 size\space <\f@size>\space substituted}%
1615 \do@subst@correction
1622 % This brings us back into the main part of |\tryif@simple|.
1623 % Finally we get rid of any rubbish left over on the input stack.
1625 % \changes{v3.0c}{1995/08/24}{}
1627 \let \reserved@f \remove@to@nnil
1631 % If it's a range iterate also.
1639 % \subsection{Sizefunctions}
1641 % In the following we define some useful size functions.
1644 % \begin{macro}{\s@fct@}
1645 % This is the default size function. Mandatory argument is an
1646 % external font name, optional argument a scale factor.
1647 % The font is scaled
1648 % to |\f@size| if no optional argument is present, and to
1649 % |\f@size| multiplied by the optional argument otherwise.
1650 % \changes{v2.0b}{1992/07/26}{}
1652 \DeclareSizeFunction{}{\empty@sfcnt\@font@warning}
1653 \DeclareSizeFunction{s}{\empty@sfcnt\@font@info}
1657 \def\empty@sfcnt#1{%
1658 \@tempdimb \f@size\p@
1659 \ifx\optional@arg\@empty
1661 \@tempdimb \optional@arg\@tempdimb
1662 #1{Font\space shape\space `\curr@fontshape'\space
1663 will\space be\MessageBreak
1664 scaled\space to\space size\space \the\@tempdimb}%
1666 \edef\external@font{\mandatory@arg\space at\the\@tempdimb}}
1672 % \begin{macro}{\s@fct@gen}
1673 % \begin{macro}{\s@fct@sgen}
1674 % This size function generates the external name from the mandatory
1675 % argument and the requested user size, and thus can be used for
1676 % external names where the size is encoded in the font name. The
1677 % optional argument a scale factor. The font is scaled to |\f@size|
1678 % if no optional argument is present, and to |\f@size| multiplied
1679 % by the optional argument otherwise.
1681 \DeclareSizeFunction{gen}{\gen@sfcnt\@font@warning}
1682 \DeclareSizeFunction{sgen}{\gen@sfcnt\@font@info}
1687 \edef\mandatory@arg{\mandatory@arg\f@size}%
1695 % \begin{macro}{\s@fct@genb}
1696 % \begin{macro}{\s@fct@sgenb}
1697 % This size function is similar to |gen|, but for fonts where the
1698 % size is encoded in the font name in centipoints, as in the DC
1699 % fonts version 1.2. The font is scaled to |\f@size|
1700 % if no optional argument is present, and to |\f@size| multiplied
1701 % by the optional argument otherwise.
1703 \DeclareSizeFunction{genb}{\genb@sfcnt\@font@warning}
1704 \DeclareSizeFunction{sgenb}{\genb@sfcnt\@font@info}
1709 \edef\mandatory@arg{\mandatory@arg\expandafter\genb@x\f@size..\@@}%
1716 % \begin{macro}{\genb@x}
1717 % \begin{macro}{\genb@y}
1718 % The auxiliary macros |\genb@x| and |\genb@y| are used to convert
1719 % the |\f@size| into centipoints.
1721 \def\genb@x#1.#2.#3\@@{\two@digits{#1}\genb@y#200\@@}
1722 \def\genb@y#1#2#3\@@{#1#2}
1729 % \begin{macro}{\s@fct@sub}
1730 % This size function handles font substitution.
1731 % The mandatory argument is a family/series/shape combination,
1732 % the optional argument (if present) is ignored. The font encoding
1733 % scheme cannot be changed. Therefore, the first thing we do is to
1734 % prepend the encoding scheme.
1735 % \changes{v2.0b}{1992/07/26}{}
1737 \DeclareSizeFunction{sub}{\sub@sfcnt\@font@warning}
1738 \DeclareSizeFunction{ssub}{\sub@sfcnt\@font@info}
1743 \edef\mandatory@arg{\f@encoding/\mandatory@arg}%
1745 % Next action is split the arg into its individual components and
1746 % allow for a late font shape load.
1749 \expandafter\split@name\mandatory@arg/\@nil
1753 % Then we record the current |\f@size| since it may get clobbered.
1755 \let\f@user@size\f@size
1757 % Then we check whether this new combination is defined and
1758 % give an error message if not. In this case we also switch to
1759 % |\error@fontshape|.
1762 \ifx\csname\mandatory@arg\endcsname\relax
1763 \errmessage{No\space declaration\space for\space
1764 shape\space \mandatory@arg}%
1768 % Otherwise we warn the user about the substitution taking place.
1770 #1{Font\space shape\space `\curr@fontshape'\space in\space
1771 size\space <\f@size>\space not\space available\MessageBreak
1772 Font\space shape\space `\mandatory@arg'\space tried\space
1774 \expandafter\split@name\mandatory@arg/\@nil
1777 % Then we restart the font specification scan by calling
1778 % |\get@external@font|.
1780 \edef\f@size{\f@user@size}%
1783 % Finally |\do@subst@correction| is called to get the font name
1786 \do@subst@correction
1792 % \begin{macro}{\s@fct@subf}
1793 % The |subf| size function allows substitution of another font. The
1794 % mandatory argument is the external name of the font to be
1795 % substituted, the optional argument a size scaling factor like
1796 % in the default size function.
1797 % The main difference to the default size function is the warning
1800 \DeclareSizeFunction{subf}{\subf@sfcnt\@font@warning}
1801 \DeclareSizeFunction{ssubf}{\subf@sfcnt\@font@info}
1806 #1{Font\space shape\space `\curr@fontshape'\space in\space
1807 size\space \f@size\space not\space available\MessageBreak
1808 external\space font\space `\mandatory@arg'\space used}%
1815 % \begin{macro}{\s@fct@fixed}
1816 % The |fixed| size function is for using a font at a different size
1817 % than requested. A warning message is printed, and the external
1818 % font to be used is taken from the mandatory argument.
1819 % If an optional argument is present it is used as the `at'
1820 % size for the font. Otherwise the font is loaded at its design size.
1822 \DeclareSizeFunction{fixed}{\fixed@sfcnt\@font@warning}
1823 \DeclareSizeFunction{sfixed}{\fixed@sfcnt\@font@info}
1827 \def\fixed@sfcnt#1{%
1828 \ifx\optional@arg\@empty
1829 \let\external@font\mandatory@arg
1831 \edef\external@font{\mandatory@arg\space at\optional@arg pt}%
1833 #1{External\space font\space `\external@font'\space loaded\space
1834 for\space size\MessageBreak
1842 %<+checkmem>\CHECKMEM