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)]
49 % \changes{v3.0g}{1995/11/28}
50 % {documentation fixes}
51 % \changes{v3.0f}{1995/10/22}{Added `genb' and `sgenb' size functions
52 % to support new DC font naming scheme.}
53 % \changes{v3.0e}{1995/10/20}
54 % {(DPC) Modify autoload code}
55 % \changes{v3.0d}{1995/10/04}
56 % {(DPC) Modify autoload code}
57 % \changes{v3.0b}{1995/05/24}
58 % {(DPC) Fix \cs{ProvidesFile} usage}
59 % \changes{v3.0a}{1995/05/24}
60 % {(DPC) Make file from previous file, tracefnt 1995/05/16 v2.3o}
61 % \changes{v3.0k}{2015/02/21}
62 % {Removed autoload code}
64 % \changes{v2.3m}{1994/11/18}
65 % {\cs{next} to \cs{reserved@f}}
66 % \changes{v2.3l}{1994/11/17}
67 % {\cs{@tempa} to \cs{reserved@a}}
68 % \changes{v2.3i}{1994/05/20}{Use new error command names}
69 % \changes{v2.3g}{1994/05/13}{Removed typeouts as
70 % \cs{ProvidesPackage} writes to log.}
71 % \changes{v2.3e}{1994/04/27}{Corrected item that was forgotten
73 % \changes{v2.3d}{1994/04/18}{Changed to new error/warning scheme}
74 % \changes{v2.3a}{1994/01/17}{New math font setup}
75 % \changes{v2.2a}{1993/11/11}{Option concept added for LaTeX2e}
76 % \changes{v2.1j}{1993/09/15}{Corrected spelling of \cs{noxpand}.}
77 % \changes{v2.1i}{1993/09/02}{Corrected name of sgen size function.}
78 % \changes{v2.1h}{1993/07/16}{Changed layout of info messages}
79 % \changes{v2.1b}{1993/03/18}
80 % {Changed all \cs{@tempdimb} in \cs{@tempdimx}
81 % to avoid killing \cs{numberline}}
82 % \changes{v2.1b}{1993/03/18}
83 % {Changed all \cs{@tempdima} in \cs{@tempdimb}
84 % to avoid killing \cs{numberline}}
85 % \changes{v1.0l}{1990/04/01}{Part of code moved to fam.dtx.}
86 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
87 % \changes{v1.0h}{1990/01/18}{\cs{tracingfonts} meaning changed.}
89 % \newcommand\module[1]{\texttt{#1}}
90 % \providecommand{\dst}{\textsc{DocStrip}}
91 % \newcommand\Loption[1]{\texttt{#1}}
93 % \GetFileInfo{ltfsstrc.dtx}
94 % \title{The \texttt{tracefnt} package\thanks
95 % {This file has version number \fileversion, dated
97 % for use with the new font selection scheme}
98 % \author{Frank Mittelbach \and Rainer Sch\"opf}
101 % \MaintainedByLaTeXTeam{latex}
104 % \section{Introduction}
106 % This package contains the code for tracing font loading and font
107 % changes. It basically overlays some of the low-level functions of
108 % NFSS with additional code used for tracing.
110 % The package accepts the following options:
111 % \begin{description}
112 % \item[errorshow] Write all information about font changes etc.\
113 % only to the transcript file unless an error happens. This means
114 % that information about font substitution will not be shown on the
117 % \item[warningshow] Show all NFSS warnings on the terminal. This
118 % setting corresponds to the default behaviour of NFSS if the
119 % \texttt{tracefnt} package is \emph{not} loaded!
121 % \item[infoshow] Show all NFSS warning and all NFSS info
122 % messages (that are normally only written to the transcript file)
123 % also on the terminal. This is the default if the \texttt{tracefnt}
126 % \item[debugshow] In addition to \texttt{infoshow} show also
127 % changing of math fonts as far as possible (this option can produce a
128 % large amount of output.
130 % \item[loading] Show the name of external fonts when they are
131 % loaded. This option shows only ``newly'' loaded fonts not those
132 % already preloaded in the format or the class file before the
133 % \texttt{tracefnt} package became active.
136 % Turn all font warnings into errors so that \LaTeX{} will stop.
143 % \section{A driver for this document}
145 % The next bit of code contains the documentation driver file for
146 % \TeX{}, i.e., the file that will produce the documentation you
147 % are currently reading. It will be extracted from this file by the
150 % When this file is processed directly by \LaTeX{} this will
151 % produce the documentation as well.
155 \documentclass{ltxdoc}
158 %\OnlyDescription % comment out for implementation details
161 \DocInput{ltfsstrc.dtx}
167 % \section{The Implementation}
170 % \textbf{Warning:} Read the macro documentation with a grain of
171 % salt. It is still basically the documentation from the first NFSS
172 % release and therefore in some cases probably not completely
176 % If we are making a package file it is a good idea to test whether
177 % we are running under 2e.
178 % This code is actually placed at the very beginning of this file
179 % for easier maintenance, thus commented out here.
182 %\NeedsTeXFormat{LaTeX2e}
183 %\ProvidesPackage{tracefnt}[??/??/?? v?.??
184 % Standard LaTeX package (font tracing)]
189 % The \texttt{debug} module makes use of commands contained in a
190 % special package file named \texttt{trace.sty}.\footnote{This package
191 % is not in distribution at the moment (and probably doesn't any
192 % longer work). Think of this part of the code as being historical
195 %<+debug> \input trace.sty
199 % \section{Handling Options}
201 % \begin{macro}{\tracingfonts}
202 % Here is the definition of the integer register for the font
203 % trace. As a default in a package file we use $1$ to give error
204 % messages if fonts are substituted. If this code is used for
205 % debugging or tracing reasons in the format file (i.e.\ in
206 % \texttt{fam.dtx}) we use $0$ as the default. But if no font
207 % trace is used we build a definition that will produce a warning
209 % \changes{v1.0l}{1990/04/01}
210 % {Check if \cs{tracingfonts} already defined.}
211 % \changes{v1.0o}{1990/04/01}
212 % {Check if \cs{tracingfonts} defined removed again.}
216 \@font@warning{Command \noexpand\tracingfonts
217 not provided.\MessageBreak
218 Use the `tracefnt' package.\MessageBreak Command found:}%
222 % The |\count@| in the line above will remove the number after
223 % |\tracingfonts|. Note that this definition will be overwritten be
224 % the next line if one of these modules are included.
226 %<*package,trace,debug>
227 \newcount\tracingfonts
229 %</package,trace,debug>
234 % The option \Loption{errorshow} turns off all warnings so that only
235 % real errors are shown. \Loption{warningshow} corresponds to the
236 % NFSS default (when \texttt{tracefnt} is not loaded).
237 % \Loption{infoshow} is the default for this package here; and
238 % \Loption{debugshow}, \Loption{loading}, and
239 % \Loption{pausing} extend the amount of information even further.
240 % \changes{v2.3o}{1995/05/13}
241 % {Use single hash mark in \cs{DeclareOption}}
244 \DeclareOption{errorshow}{%
246 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
247 {LaTeX Font Info: \space\space\space#1}}%
248 \def\@font@warning#1{%
249 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
250 {LaTeX Font Warning: #1}}%
255 \DeclareOption{warningshow}{%
257 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
258 {LaTeX Font Info: \space\space\space#1}}%
259 \def\@font@warning#1{%
260 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
261 {LaTeX Font Warning: #1}}%
266 \DeclareOption{infoshow}{%
268 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
269 {LaTeX Font Info: \space\space\space#1}}%
270 \def\@font@warning#1{%
271 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
272 {LaTeX Font Warning: #1}}%
277 \DeclareOption{loading}{%
283 \DeclareOption{debugshow}{%
284 \ExecuteOptions{infoshow}%
289 % \changes{v3.0j}{1997/05/29}{Replaced \texttt{\symbol{92}\symbol{92}}
290 % by \cs{MessageBreak}, as suggested by Donald Arseneau.}
292 \DeclareOption{pausing}{%
293 \def\@font@warning#1{%
295 {(Font)\@spaces\@spaces\@spaces\space\space}%
296 {LaTeX Font Warning: #1}%
297 {See the LaTeX Companion for details.}%
298 {I'll stop for every LaTeX Font Warning because
299 you requested\MessageBreak the `pausing' option
300 to the tracefnt package.}}%
303 % We make |infoshow| the default, which in turn defines
304 % |\font@warning| and |\font@info|.
306 \ExecuteOptions{infoshow}
311 % We also need a default definition inside the kernel:
315 \GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
316 {LaTeX Font Info: \space\space\space#1}}%
317 \def\@font@warning#1{%
318 \GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
319 {LaTeX Font Warning: #1}}%
324 % \section{Macros common to \texttt{fam.tex} and \texttt{tracefnt.sty}}
326 % In the first versions of \texttt{tracefnt.dtx} some macros of
327 % \texttt{fam.dtx}\footnote{This file is currently not distributed in
328 % documented form. Its code is part of \texttt{ltfss.dtx}.}
329 % were redefined to included the extra tracing
330 % information. Now these macros are all defined in this file (i.e.\
331 % removed from \texttt{fam.dtx}) and different production versions can
332 % be obtained simply by specifying a different set of modules to
333 % include when generating \texttt{ltfss.dtx}.
337 % \subsection{General font loading}
340 % \begin{macro}{\extract@font}
342 % This macro organizes the font loading.
343 % It first calls |\get@external@font|
344 % which will return in |\external@font| the name of the external
345 % font file (the \texttt{.tfm}) as it was determined by the NFSS
352 % Then the external font is loaded and assigned to the font
353 % identifier stored inside |\font@name|
354 % (for this reason we need |\expandafter|).
356 \global\expandafter\font\font@name\external@font\relax
358 % When tracing we typeout the internal and external font name.
359 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
362 \ifnum \tracingfonts >\@ne
363 \@font@info{External font `\external@font'
364 loaded as\MessageBreak \font@name}\fi
367 % Finally we call the corresponding ``loading action'' macros to
368 % finish things. First the font is locally selected to allow the
369 % use of |\font| inside the loading action macros.
373 % The next two lines execute the ``loading actions'' for the
374 % family and then for the individual font shape.
376 \csname \f@encoding+\f@family\endcsname
377 \csname\curr@fontshape\endcsname
382 % The |\relax| at the end needs to be explained.
383 % This is inserted to prevent \TeX{} from scanning too far
384 % when it is executing the replacement text of the loading
389 % \begin{macro}{\get@external@font}
390 % This function tries to find an external font name. It will place
391 % the name into the macro
392 % |\external@font|. If no font is found it will return the one
393 % that was defined via |\DeclareErrorFont|.
396 \def\get@external@font{%
398 % We don't know the external font name at the beginning.
400 \let\external@font\@empty
401 \edef\font@info{\expandafter\expandafter\expandafter\string
402 \csname \curr@fontshape \endcsname}%
405 % If this failed, we'll try to substitute another size of the same
406 % font. This is done by the |\try@size@substitution| macro. It
407 % ``knows about'' |\do@extract@font|, |\font@name|, |\f@size|, and
410 \ifx\external@font\@empty
411 \try@size@substitution
412 \ifx\external@font\@empty
413 \@latex@error{Font \expandafter \string\font@name\space
424 % \changes{v1.0j}{1990/02/18}
425 % {Redefine unprotected version \cs{p@selectfont}
426 % instead of \cs{selectfont}.}
429 % \begin{macro}{\selectfont}
430 % \changes{v1.1a}{1989/12/16}{Changed order of calls.}
431 % \changes{v2.3f}{1994/05/12}{Use \cs{DeclareRobustCommand}}
432 % The macro |\selectfont| is called whenever a font change must
436 \DeclareRobustCommand\selectfont
439 % When \module{debug} is specified we actually want something like
440 % `undebug'. The font selection is now stable so that using
441 % |\tracingall| on some other macros will show us a lot of unwanted
442 % information about font loading. Therefore we disable tracing during
443 % font loading as long as |\tracingfonts| is less than $4$.
444 % \changes{v1.0m}{1990/04/05}
445 % {Call \cs{tracingon} only if \cs{tracingfonts} greater than 3.}
446 % \changes{v1.0n}{1990/05/05}{\cs{tracingon} with new syntax.}
448 %<+debug> \pushtracing
449 %<+debug> \ifnum\tracingfonts<4 \tracingoff
450 %<+debug> \else \tracingon\p@selectfont \fi
452 % If |\baselinestretch| was redefined by the user it will not
453 % longer match its internal counterpart |\f@linespread|. If so we
454 % call |\set@fontsize| to prepare |\size@update|.
456 \ifx\f@linespread\baselinestretch \else
457 \set@fontsize\baselinestretch\f@size\f@baselineskip \fi
459 % Then we generate the internal name of the font
460 % by concatenating {\em family}, {\em series},
461 % {\em shape}, and current {\em size},
462 % with slashes as delimiters between them.
463 % This is much more readable than standard
464 % \LaTeX's |\twfbf|, etc.
465 % We define |\font@name| globally, as always.
466 % The reason for this is explained later on.
467 % \changes{v2.0b}{1992/07/26}{}
470 \csname\curr@fontshape/\f@size\endcsname}%
472 % We call the macro |\pickup@font| which will load the font if
477 % Then we select the font.
481 % If |\tracingfonts| is
482 % greater than 2 we also show the font switch.
483 % We do this before |\glb@settings| is called since this
484 % macro might redefine |\font@name|.
485 % \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
486 % \changes{v1.0i}{1990/02/16}{Changed \cs{f@size} to \cs{lcl@currsize}
490 \ifnum \tracingfonts>\tw@
491 \@font@info{Switching to \font@name}\fi
494 % Finally we call |\size@update|. This macro is normally empty but
495 % will contain actions (like setting the |\baselineskip|) that have
496 % to be carried out when the font size, the base |\baselineskip| or
497 % the |\baselinestretch| have changed.
501 % A similar function is called to handle anything related to
502 % encoding updates. This one is changed from |\relax| by
504 % \changes{v2.3h}{1994/05/14}{Added \cs{enc@update}}
508 % Just before ending this macro we have to pop the tracing stack
509 % if it was pushed before.
511 %<+debug> \poptracing
518 % \begin{macro}{\set@fontsize}
519 % The macro |\set@fontsize| does the actual work. First it assigns
520 % new values to |\f@size|, |\f@baselineskip| and |\f@linespread|.
522 \def\set@fontsize#1#2#3{%
523 \@defaultunits\@tempdimb#2pt\relax\@nnil
524 \edef\f@size{\strip@pt\@tempdimb}%
525 \@defaultunits\@tempskipa#3pt\relax\@nnil
526 \edef\f@baselineskip{\the\@tempskipa}%
527 \edef\f@linespread{#1}%
529 % For backward compatibility and for later testing within
530 % |\selectfont| the internal value of |\f@linespread| is passed
531 % back to |\baselinestretch|.
533 \let\baselinestretch\f@linespread
535 % Additional processing will happen within |\selectfont|. For this
536 % reason the macro |\size@update| (which will be called in
537 % |\selectfont|) will be defined to be:
541 % First calculate the new |\baselineskip| and also store it in
542 % |normalbaselineskip|
544 \baselineskip\f@baselineskip\relax
545 \baselineskip\f@linespread\baselineskip
546 \normalbaselineskip\baselineskip
548 % then to set up a new |\strutbox|
550 \setbox\strutbox\hbox{%
551 \vrule\@height.7\baselineskip
552 \@depth.3\baselineskip
555 % We end with a bit of tracing information.
558 \ifnum \tracingfonts>\tw@
559 \ifx\f@linespread\@empty
560 \let\reserved@a\@empty
562 \def\reserved@a{\f@linespread x}%
564 \@font@info{Changing size to \f@size/\reserved@a
566 \aftergroup\type@restoreinfo \fi
569 % When all this is processed |\size@update| redefines itself to
570 % |\relax| so that in later calls of |\selectfont| no extra code
573 \let\size@update\relax}%
576 % Instead of defining this macro internally we might speed things
577 % up by placing the code into a separate macro and use |\let|!
581 % \begin{macro}{\size@update}
582 % Normally this macro does nothing; it will be redefined by
583 % |\set@fontsize| to initiate an update.
585 \let\size@update\relax
590 % \begin{macro}{\type@restoreinfo}
591 % This macro produces some info when a font size and/or baseline
592 % change will get restored.
593 % \changes{1.0r}{1990/08/27}{Some extra tracing info.}
596 \def\type@restoreinfo{%
597 \ifx\f@linespread\@empty
598 \let\reserved@a\@empty
600 \def\reserved@a{\f@linespread x}%
602 \@font@info{Restoring size to
603 \f@size/\reserved@a\f@baselineskip}}
608 % \begin{macro}{\glb@settings}
609 % \begin{macro}{\glb@currsize}
610 % \changes{v2.3a}{1994/01/17}{New math font setup}
611 % \changes{v2.3k}{1994/11/06}{New implementation}
612 % The macro |\glb@settings| globally selects
613 % all math fonts for the current size if necessary.
617 % When |\glb@settings| gains control a size
618 % change was requested and all previous font assignments need to
620 % Therefore the old values of the fonts are no longer needed.
621 % For every {\em math group\/} the new assignments are appended to
623 % But this happens only if the |math@fonts| switch
625 % However, we always set up the correct math sizes for script and
626 % scriptscript fonts since they may be needed even if we don't set
627 % up the whole math machinery.
629 % Here we set the math size, script size and scriptscript size.
630 % If the |S@|\ldots{} macro is not defined we have to first
631 % calculate the three sizes.
633 \expandafter\ifx\csname S@\f@size\endcsname\relax
634 \calculate@math@sizes
637 % The effect of this is that |\calculate@math@sizes|
638 % may or may not define the |S@|\ldots{} macro. In the
639 % first case the next time the same size is requested
640 % this macro is used, otherwise |\calculate@math@sizes| is
642 % This also sets the |math@fonts| switch.
643 % If it is true we must switch the math fonts.
645 \csname S@\f@size\endcsname
648 \ifnum \tracingfonts>\tw@
649 \@font@info{Setting up math fonts for
650 \f@size/\f@baselineskip}\fi
653 % Inside a group we execute the macro for the current math {\em
654 % version}. This sets |\math@fonts| to a list of
655 % |\textfont|\dots{} assignments. |\getanddefine@fonts| (which may
656 % be called at this point) needs the |\escapechar| parameter to be
661 \csname mv@\math@version \endcsname
663 % Then we set |\globaldefs| to 1 so that all following changes are
664 % done globally. The math font assignments recorded in
665 % |\math@fonts| are executed and |\glb@currsize| is set equal to
666 % |\f@size|. This signals that the fonts for math in this size are
671 \let \glb@currsize \f@size
674 % Finally we execute any code that is supposed to happen
675 % whenever the math font setup changes. This register will
676 % be executed in local mode which means that everything that is
677 % supposed to have any effect should be done globally inside.
678 % We can't execute it within |\globaldefs\@ne| as we don't know
679 % what ends up inside this register, e.g., it might contain
680 % calculations which use some local registers to calculate the
681 % final (global) value.
685 % Otherwise we announce that the math fonts are not set up for this
690 \ifnum \tracingfonts>\tw@
691 \@font@info{No math setup for
692 \f@size/\f@baselineskip}\fi
702 % \begin{macro}{\baselinestretch}
703 % \changes{v1.0o}{1990/06/24}{Moved to tracefnt.dtx.}
704 % In |\selectfont| we used |\baselinestretch| as
705 % a factor when assigning a value to |\baselineskip|.
706 % We use 1 as a default (i.e.\ no stretch).
709 \def\baselinestretch{1}
713 % \begin{macro}{\every@math@size}
714 % \changes{v1.0u fam.dtx}{1989/12/05}{Hook \cs{every@size} added.}
715 % \changes{v23.k}{1994/10/23}{Renamed to \cs{every@math@size}}
716 % We must still define the hook |\every@math@size| we used in
717 % |\glb@settings|. We initialize it to nothing. It is important to
718 % remember that everything that goes into this hook should to global
719 % updates, local changes will have weird effects.
721 \newtoks\every@math@size
729 % \subsection{Math fonts setup}
732 % \subsubsection{Outline of algorithm for math font sizes}
734 % \TeX{} uses the the math fonts that are current when the end of a
735 % formula is reached. If we don't want to keep font setups local to
736 % every formula (which would result in an enormous overhead, we have
737 % to be careful not to end up with the wrong setup in case formulas
738 % are nested, e.g., we need to be able to handle
740 % $ a=b+c \mbox{ \small for all $b$ and $c\in Z$}$
742 % Here the inner formulae |b| and |c\in Z| are typeset in |\small| but
743 % we have to return to |\normalsize| before we reach the closing |$|
744 % of the outer formula.
746 % This is handled in the following way:
748 % \item At any point in the document the global variable
749 % |\gbl@currsize| contains the point size for which the math fonts
750 % currently are set up.
752 % \item \label{it:everymath} Whenever we start a formula we compare
753 % its value with the local variable |\f@size| that describes the
754 % current text font size.
756 % \item If both are the same we assume that we can use the current
757 % math font setup without adjustment.
759 % \item \label{it:everymathend} If they differ we call |\gbl@settings|
760 % which changes the math font setup and updates |\gbl@currsize|.
762 % \item If we are recursively inside another formula (|\if@inmath|) we
763 % ensure that |\gbl@settings| is executed again in the outer
764 % formula, so that the old setup is automatically restored.
765 % \item Otherwise, we set the switch |@inmath| locally to |true| so
766 % that all nested formulae will be able to detect that they are
767 % nested in some outer formula.
772 % The above algorithm has the following features:
774 % \item For sizes which are not containing any formula no math setup
775 % is done. Compared to the original algorithm of NFSS this results
776 % in the following savings:
778 % \item No unnecessary loading of math fonts for sizes that are not
779 % used to typeset any math formulae (explicit or implicit ones).
780 % \item No time overhead due to unnecessary changes of the math font
781 % setup on entrance and exit of the text font size.
784 % \item Math font setup changes for top-level formulae will survive
785 % (there is no restoration after the formula) thus any following
786 % formula in the same size will be directly typesetable. Compared to
787 % original implementation in NFSS2
788 % the new algorithm has the overhead of one test per formula
789 % to see if the current math setup is valid (in the original
790 % algorithm the setup was always valid, thus no test was necessary).
792 % \item In nested formulae the math font setup is restored in the
793 % outer formula by a series of |\aftergroup| commands and checks.
794 % Compared to the original algorithm this involves additional checks
795 % ($2 \times \langle\mbox{non-math levels}\rangle$ per inner
799 % \subsubsection{Code for math font size setting}
801 % \begin{macro}{\check@mathfonts}
802 % \changes{v2.3a}{1994/01/17}{New math font setup}
803 % \changes{v2.3c}{1994/01/26}{Correct trace info placement}
804 % In the |\check@mathfonts| macros we implement the steps
805 % \ref{it:everymath} to \ref{it:everymathend} except that instead
806 % of a switch the macro |\init@restore@glb@settings| is used.
809 \def\check@mathfonts{%
810 \ifx \glb@currsize \f@size
812 \ifnum \tracingfonts>\thr@@
813 \@font@info{*** MATH: no change \f@size\space
814 curr/global (\curr@math@size/\glb@currsize)}\fi
818 \ifnum \tracingfonts>\thr@@
819 \@font@info{*** MATH: setting up \f@size\space
820 curr/global (\curr@math@size/\glb@currsize)}\fi
823 \init@restore@glb@settings
825 \let\curr@math@size\f@size
826 \def\init@restore@glb@settings{\aftergroup\restglb@settings}%
834 % \begin{macro}{\init@restore@glb@settings}
835 % \changes{v3.0i}{1996/07/26}{macro added replacing \cs{if@inmath} switch}
836 % This macros does by default nothing but get redefined inside
837 % |\check@mathfonts| to initiate fontsize restoring in nested
840 %<-trace>\let\init@restore@glb@settings\relax
842 \def\init@restore@glb@settings{%
843 \ifnum \tracingfonts>\thr@@
844 \@font@info{*** MATH: no resetting (not in
852 % \begin{macro}{\restglb@settings}
853 % \changes{v2.3a}{1994/01/17}{New math font setup}
854 % \changes{v2.3c}{1994/01/26}{Correct trace info placement}
855 % This macro will be executed the first time after the current
858 \def\restglb@settings{%
860 \ifnum \tracingfonts>\thr@@
861 \@font@info{*** MATH: restoring}\fi
864 \let\f@size\curr@math@size
865 \ifx\glb@currsize \f@size
867 \ifnum \tracingfonts>\thr@@
868 \@font@info{*** MATH: ... already okay (\f@size)}\fi
872 \ifnum \tracingfonts>\thr@@
873 \@font@info{*** MATH: ... to \f@size}\fi
883 % \subsubsection{Other code for math}
886 % \begin{macro}{\use@mathgroup}
887 % \changes{v1.2b}{1990/01/21}{Macro added to allow cleaner interface.}
888 % \changes{v1.2h}{1990/03/30}{Third argument removed (see
889 % \cs{math@egroup}).}
890 % The |\use@mathgroup| macro should be used in user
891 % macros to select a math group. Depending on whether or not the
892 % \texttt{margid} option is in force it has two or three arguments.
893 % For this reason it should be called as the last macro.
895 % First we test if we are inside math mode since we don't want to
896 % apply a useless definition.
897 % \changes{v1.1a}{1989/12/16}{Usage of `\quotechar=' macro added.}
898 % \changes{v1.1a}{1989/12/16}{Redefinition of alphabet now simpler.}
900 \def\use@mathgroup#1#2{\relax\ifmmode
902 % \changes{v1.0o}{1990/06/24}{Tracing code added.}
903 % \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
906 \ifnum \tracingfonts>\tw@
908 \@font@info{Using \noexpand\mathgroup
912 % If so we first call the `=' macro (i.e.\ argument three) to set
913 % up special things for the selected math group. Then we call
914 % |\mathgroup| to select the group given by argument two and
915 % finally we place |#1| (i.e.\ the argument of the \meta{math
916 % alphabet identifier} at the end. This part of the code is
917 % surrounded by two commands which behave like |\begingroup|
918 % and |\endgroup| if we want \meta{math alphabet identifier}s
919 % but will expand into |\@empty| if we want simply switches to
921 % \changes{v1.0p}{1990/06/30}{Added \cs{relax} after math group number.}
922 % Since argument number $2$ may be a digit instead of a control
923 % sequence we add a |\relax|.
924 % Otherwise something like |\mit{1}| would switch to math group
925 % $11$ (and back) instead of printing an oldstyle $\mit {1}$.
926 % \changes{v2.0b}{1992/07/26}{}
929 \expandafter\ifx\csname M@\f@encoding\endcsname#1\else
933 % Before we reinsert the swallowed token (arg.\ three) into the
934 % input stream, in the case that the \meta{math alphabet
935 % identifier} isn't called in math mode, we remove the |\fi|
936 % with the |\expandafter| trick. This is necessary if the
937 % token is actually an macro with arguments. In such a case the
938 % |\fi| will be misinterpreted as the first argument which
939 % would be disastrous.
940 % \changes{v1.0f}{1989/12/13}
941 % {\cs{expandafter} added before final \cs{fi}.}
943 \expandafter\math@egroup\fi}%
945 % The surrounding macros equal |\begingroup| and |\endgroup|. But
946 % using internal names makes it possible to overwrite their meaning
947 % in certain cases. This is for example used in \AmSTeX{} macros
948 % for placing accents.
951 % \begin{macro}{\math@egroup}
952 % \changes{v1.0q}{1990/07/07}{Tracing code added.} If the
953 % \texttt{margid} option is in force (which can be tested by
954 % looking at the definition of |\math@bgroup| we change the
955 % |\math@egroup| command a bit to display the current \meta{math
956 % group number} after it closes the scope of \meta{math alphabet}
958 % \changes{v3.0h}{1996/05/08}{Use \cs{bgroup} instead of \cs{begingroup}
959 % to match a kernel change made in 1994!!!!}
962 \ifx\math@bgroup\bgroup
963 \def\math@egroup#1{#1\egroup
964 \ifnum \tracingfonts>\tw@
965 \@font@info{Restoring \noexpand\mathgroup
966 (\ifnum\mathgroup=\m@ne default\else \the\mathgroup \fi)%
973 % \begin{macro}{\getanddefine@fonts}
974 % \changes{v1.0o}{1990/06/24}{\cs{Macro} moved from fam.dtx.}
975 % |\getanddefine@fonts| has two arguments: the \meta{math
976 % group number} and the {\em family/series/shape\/} name as a
979 \def\getanddefine@fonts#1#2{%
981 % First we turn of tracing when |\tracingfonts| is less than $4$.
982 % \changes{v1.0o}{1990/06/24}{Adding debug code.}
983 % \changes{v1.0r}{1990/08/27}
984 % {Correcting missing name after \cs{tracingon}.}
986 %<+debug> \pushtracing
987 %<+debug> \ifnum\tracingfonts<4 \tracingoff
988 %<+debug> \else \tracingon\getanddefine@fonts \fi
990 % \changes{v1.0o}{1990/06/24}{\cs{Adding} tracing code.}
991 % \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
992 % \changes{v2.1a}{1992/09/22}{Introduced \cs{tf@size} for math size.}
995 \ifnum \tracingfonts>\tw@
997 \@font@info{\noexpand\mathgroup (\the\count@) #1 :=\MessageBreak
998 \string#2 \tf@size/\sf@size/\ssf@size}\fi
1001 % We append the current |\tf@size| to |#2| to obtain the font
1002 % name.\footnote{One might ask why this expansion does not generate
1003 % a macro name that starts with an additional \texttt{\bslash}
1004 % character. The solution is that \texttt{\bslash escapechar} is
1005 % set to $-1$ before \texttt{\bslash getanddefine@fonts} is
1006 % called.} Again, |font@name| is defined globally, for the reasons
1007 % explained in the description of |\wrong@fontshape|.
1009 \xdef\font@name{\csname \string#2/\tf@size\endcsname}%
1011 % Then we call |\pickup@font| to load it if necessary.
1012 % We remember the internal name as |\textfont@name|.
1014 \pickup@font \let\textfont@name\font@name
1016 % Same game for |\scriptfont| and |\scriptscriptfont|:
1018 \xdef\font@name{\csname \string#2/\sf@size\endcsname}%
1019 \pickup@font \let\scriptfont@name\font@name
1020 \xdef\font@name{\csname \string#2/\ssf@size\endcsname}%
1023 % Then we append the new |\textfont|\ldots{} assignments to
1024 % the |\math@fonts|.
1026 \edef\math@fonts{\math@fonts
1027 \textfont#1\textfont@name
1028 \scriptfont#1\scriptfont@name
1029 \scriptscriptfont#1\font@name}%
1031 % Just before ending this macro we have to pop the tracing stack
1032 % if it was pushed before.
1034 %<+debug> \poptracing
1036 %</2ekernel|package>
1041 % \section{Scaled font extraction}
1043 % \begin{macro}{\ifnot@nil}
1044 % We begin with a simple auxiliary macro. It checks
1045 % whether its argument is the token |\@nil|. If so,
1046 % it expands to |\@gobble| which discards the following
1047 % argument, otherwise it expands to |\@firstofone| which
1048 % reproduces it argument.
1049 % \changes{v2.3n}{1995/05/08}{Use \cs{@firstofone}}
1052 \def\ifnot@nil#1{\def\reserved@a{#1}%
1053 \ifx\reserved@a\@nnil \expandafter\@gobble
1054 \else \expandafter\@firstofone\fi}
1059 % \begin{macro}{\remove@to@nnil}
1060 % \begin{macro}{\remove@angles}
1061 % \begin{macro}{\remove@star}
1062 % Three other auxiliary macros will be needed in the following:
1063 % |\remove@to@nnil| gobbles up everything up to, and including,
1064 % the next |\@nnil| token, and |\remove@angles| and |\remove@star|
1066 % for the character |>| and |*|, respectively, instead of |\@nnil|.
1068 \def\remove@to@nnil#1\@nnil{}
1069 \def\remove@angles#1>{\set@simple@size@args}
1070 \def\remove@star#1*{#1}
1075 % \changes{v3.0c}{1995/08/24}{Macro \cs{gobble@font@spec} removed}
1077 % \begin{macro}{\extract@sizefn}
1078 % This macro takes a size specification and parses it into size
1079 % function and the optional and mandatory arguments.
1081 \def\extract@sizefn#1*#2\@nil{%
1082 \if>#2>\set@size@funct@args#1\@nil
1083 \let\sizefn@info\@empty
1084 \else\expandafter\set@size@funct@args\remove@star#2\@nil
1085 \def\sizefn@info{#1}\fi
1091 % \begin{macro}{\try@simple@size}
1092 % This function tries to extract the given size (specified by
1093 % |\f@size|) for the requested font shape. The font information
1094 % must already be present in |\font@info|.
1095 % The central macro that does the real work is |\extract@fontinfo|.
1096 % We will first give a simple example how this macro works, and
1097 % describe it in full generality later.
1099 % Assume that the requested parameters are: {\em encoding scheme\/}
1100 % `OT1', {\em family\/} `cm', {\em series\/} `sansserif',
1101 % {\em shape\/} `normal', and {\em size\/} `$12$'.
1102 % The corresponding font definitions have already been
1103 % extracted from the macro |\OT1/cm/sansserif/normal| and
1104 % stored in |font@info|.
1105 % (Otherwise |\extract@fontinfo| doesn't get called.)
1106 % This information consists of a token list made of characters
1107 % of category code $12$ of the form
1109 % <10*>cmss10<12*>cmss12<17*>cmss17
1111 % For reasonable packages one usually needs more sizes but this is
1112 % sufficient to get the flavour.
1113 % We will define a macro |\extract@fontinfo| to find
1114 % the external font name (`cmss12') for us:
1116 % \def\extract@fontinfo#1<12*#2>#3<#4\@nnil{%
1117 % \set@simple@size@args#3<#4\@nnil
1118 % \execute@size@function{#2}}
1120 % so that when it gets called via
1122 % \extract@fontinfo<10*>cmss10<12*>cmss12<17*>cmss17\@nnil
1124 % |#1| will contain all characters before |<12*>|,
1125 % |#2| will be empty, |#3| will be exactly |cmss12|,
1126 % and |#3| will be |17>cmss17|.
1127 % The expansion is therefore
1129 % \set@simple@size@args cmss12<17*>cmss17\@nnil
1130 % \execute@size@function{}
1132 % This means: the default (empty) size function will be executed,
1133 % with its optional argument argument set to empty and its mandatory
1134 % argument set to |cmss12| by |\set@simple@size@args|.
1135 % As we discussed earlier, the effect of the default size function
1136 % is to load the given external font (cmss12) at the specified size
1137 % (12)---which is exactly what was intended.
1139 % But this is only part of the whole story.
1140 % It may be that the size requested does not occur
1141 % in the token list |\font@info|.
1142 % And the simple definition of |\extract@fontinfo| we gave
1143 % above does not allow to specify give more than one
1144 % size specification in front of the external font name.
1146 % Let's address these two problems separately. The first one
1147 % is solved with the following trick:
1148 % We define |\extract@fontinfo| as follows:
1150 % \def\extract@fontinfo#1<12*#2>#3<#4\@nnil{%
1152 % {\set@simple@size@args#3<#4\@nnil
1153 % \execute@size@function{#2}%
1156 % How does this work?
1157 % We call |\extract@fontinfo| via
1159 % \expandafter\extract@fontinfo\font@info<12*>\@nil<\@nnil
1161 % i.e. by appending |<12*>\@nil<\@nnil|.
1162 % If the size (`12' in this case) appears in |\font@info|
1163 % everything works as explained above, the only difference being
1164 % that argument |#4| of |\extract@fontinfo|
1165 % additionally gets the tokens |<12*>\@nil<\@nnil|.
1166 % However, if the size is not found everything up to the final
1167 % |<12*>| is in argument |#1|,
1168 % |#3| gets |\@nil|,
1169 % and |#2| and |#4| are empty.
1170 % The macro |\ifnot@nil| will discard the calls to
1171 % |\set@simple@size@args| and |execute@size@function|, and
1172 % hence |\font@info| will continue to be equal to |\@empty|.
1173 % This means that no simple size specification matching the
1174 % requested size could be found.
1176 % The second problem (more than one simple size specification
1177 % for one external font name) will be addressed in
1178 % |\set@simple@size@args| below.
1180 % The macros are hidden inside other control sequences
1181 % so that we have to build |\extract@fontinfo| in
1184 % So here's the actual definition of |\extract@font| in
1185 % |\try@simple@size|.
1187 % % this could be replaced by \try@size@range making the subst slower!
1188 \def\try@simple@size{%
1190 % |\reserved@a| is made an abbreviation for the head of the
1191 % definition of the macro |\extract@fontinfo|.
1193 \def\reserved@a{\def\extract@fontinfo####1}%
1195 % Now we can define |\extract@fontinfo|. Here we handle a small
1196 % but convenient variation: in case of the default (empty) size
1197 % function it is allowed to omit the |*| character.
1198 % \changes{v2.0b}{1992/07/26}{}
1199 % \changes{v2.0c}{1992/09/19}{}
1201 \expandafter\reserved@a\expandafter<\f@size>##2<##3\@nnil{%
1203 {\set@simple@size@args##2<##3\@nnil
1204 \execute@size@function\sizefn@info
1207 % \changes{v2.0b}{1992/07/26}{}
1208 % Now we call |\extract@fontinfo|. Note the |<\@nil| \textsf{tokens}
1211 \expandafter\expandafter
1212 \expandafter\extract@fontinfo\expandafter\font@info
1213 \expandafter<\f@size>\@nil<\@nnil
1218 % \begin{macro}{\set@simple@size@args}
1219 % As promised above, the macro |\set@simple@size@args| will handle
1220 % the case of several size specifications in a row.
1221 % If another size specification follows, the very first token of
1222 % its argument list is the character |<|.
1223 % By starting the definition as follows,
1225 \def\set@simple@size@args#1<{%
1227 % parameter |#1| is empty in this case, and contains the size
1228 % function's arguments otherwise. We distinguish these two cases
1229 % (Note that the character |<| cannot appear in |#1|) by calling
1230 % |\remove@angles| for empty |#1| and |\extract@sizefn|
1231 % otherwise. In the latter case we have to take care of the
1232 % remaining character tokens and discard them. This is done by
1233 % |\remove@to@nnil|. Note also the use of Kabelschacht's method.
1236 \expandafter\remove@angles
1238 \extract@sizefn#1*\@nil
1239 \expandafter\remove@to@nnil
1245 % Now, we are through with the case of a simple size, except for
1246 % calling the size function. This will be handled later, as it is
1247 % the same mechanism for all types of size specification. We will
1248 % now proceed to macors for extraction of size range specification.
1252 % \begin{macro}{\extract@rangefontinfo}
1253 % |\extract@rangefontinfo| goes through a font shape definition
1254 % in the input until it recognizes the tokens |<\@nil->|.
1255 % It looks for font ranges with font size functions. It's operation
1256 % is rather simple: it discards everything up to the next size
1257 % specification and passes this on to |\is@range| for inspection.
1258 % The specification (parameter |#2| is inserted again, in case
1259 % it is needed later.
1261 \def\extract@rangefontinfo#1<#2>{%
1262 \is@range#2->\@nil#2>}
1266 % \begin{macro}{\is@range}
1267 % |\is@range| is again a sort of dispatcher macro: if the size
1268 % specification it is looking at is not a range specification
1269 % it discards it and calls |\extract@rangefontinfo| to continue
1270 % the search. Otherwise it calls |\check@range| to check the
1271 % requested size against the specified range.
1273 % From the way |\is@range| is called inside |\extract@rangefontinfo|
1274 % we see that |#2| is the character |>| if the size specification
1275 % found is a simple one (as it does not contain a |-| character.
1276 % This is checked easily enough and |\extract@rangefontinfo|
1277 % called again. Note that the extra tokens inserted after the
1278 % |\@nil| in the call to |\is@range| appear at the beginning of
1279 % the first argument to |\extract@rangefontinfo| and are hence
1282 \def\is@range#1-#2\@nil{%
1283 \if>#2\expandafter\check@single\else
1284 \expandafter\check@range\fi}
1289 % \begin{macro}{\check@range}
1290 % |\check@range| takes lower bound as parameter |#1|, upper bound
1291 % as |#2|, size function as |#3| and the size function's arguments
1292 % as |#4|. If |#3| is the special token |\@nil| |\font@info| is
1293 % exhausted and we can stop searching.
1295 \def\check@range#1-#2>#3<#4\@nnil{%
1298 % If |#3| wasn't |\@nil| we have a range. We start by assuming that
1299 % we have to recurse. Note that we have to reinsert an |<| as it
1300 % was already removed by scanning.
1302 \def\reserved@f{\extract@rangefontinfo<#4\@nnil}%
1304 % We have to make sure that both boundaries are present, if not we
1305 % have to set them. Here we check the upper bound. If |\upper@bound|
1306 % is zero after the assignment we set it to |\maxdimen| (upper open
1307 % range). We need to use a \meta{dimen} register for the scan since
1308 % we may have a decimal number as the boundary.
1311 \ifdim\upper@bound=\z@ \upper@bound\maxdimen\fi
1313 % Now we check the upper boundary against |\f@size|.
1314 % If it is larger or equal than |\f@size| this
1315 % range is no good and we have to recurse.
1317 \ifdim \f@size \p@<\upper@bound
1319 % Otherwise we have to check the lower bound. This time it is not
1320 % necessary to scan the boundary value into a register because if
1321 % it is empty we get zero as desired. We could even omit the |0|
1322 % which would result in |1pt| as default lower boundary. If
1323 % |\f@size| is smaller than the boundary we have to recurse.
1326 \ifdim \f@size \p@<\lower@bound
1329 % If both tests are passed we can try executing the size function.
1331 \set@simple@size@args#3<#4\@nnil
1332 \execute@size@function\sizefn@info
1334 % If the function was successful it should have left an external
1335 % font name in |\external@font|. We use this to see if we can stop
1336 % scanning. Otherwise we recurse.
1338 \ifx\external@font\@empty
1340 \let\reserved@f\@empty
1348 % \begin{macro}{\lower@bound}
1349 % \begin{macro}{\upper@bound}
1350 % We use two dimen registers |\lower@bound| and |\upper@bound|
1351 % to store the lower and upper endpoints of the range we found.
1353 \newdimen\lower@bound
1354 \newdimen\upper@bound
1360 % \begin{macro}{\check@single}
1361 % |\check@single| takes the size as parameter |#1|, size function
1362 % as |#2| and the size function's arguments as |#3|. We can assume
1363 % that there is always something in the pipeline since the very
1364 % last entry is a faked range (see above).
1366 \def\check@single#1>#2<#3\@nnil{%
1368 % We start by assuming that
1369 % we have to recurse. Note that we have to reinsert an |<| as it
1370 % was already removed by scanning.
1372 \def\reserved@f{\extract@rangefontinfo<#3\@nnil}%
1374 % Now we check the the size against |\f@size|. If it is not equal
1375 % |\f@size| it is no good and we have to recurse.
1377 \ifdim \f@size \p@=#1\p@
1379 % Otherwise if this test is passed we can try executing the size
1382 \set@simple@size@args#2<#3\@nnil
1383 \execute@size@function\sizefn@info
1385 % If the function was successful it should have left an external
1386 % font name in |\external@font|. We use this to see if we can stop
1387 % scanning. Otherwise we recurse.
1389 \ifx\external@font\@empty
1391 \let\reserved@f\@empty
1399 % \begin{macro}{\set@size@funct@args}
1400 % \begin{macro}{\set@size@funct@args@}
1401 % This macro sets the optional and mandatory arguments for a size
1402 % function. If the optional argument is not present it is set to
1403 % the empty token list. The mandatory argument is delimited by the
1406 \def\set@size@funct@args{\@ifnextchar[%
1407 \set@size@funct@args@{\set@size@funct@args@[]}}
1411 \def\set@size@funct@args@[#1]#2\@nil{%
1412 \def\mandatory@arg{#2}%
1413 \def\optional@arg{#1}}
1420 % \begin{macro}{\DeclareSizeFunction}
1421 % This function defines a new size function hiding the internal
1422 % from the designer. The body of the size function may use
1423 % |\optional@arg| and |\mandatory@arg| denoting the optional and
1424 % mandatory argument that may follow the size specification |<...>|.
1425 % \changes{v2.1c}{1993/03/18}{Added all args to avoid blanks problems}
1428 \def\DeclareSizeFunction#1#2{\@namedef{s@fct@#1}{#2}}
1429 \@onlypreamble\DeclareSizeFunction
1435 % \begin{macro}{\execute@size@function}
1436 % This macro is very simple. The only point worth noting
1437 % is that calling an undefined size function will do nothing
1438 % (actually execute a |\relax|).
1440 %<*2ekernel|package>
1441 \def\execute@size@function#1{%
1443 \@ifundefined{s@fct@#1}%
1444 {\errmessage{Undefined font size function #1}%
1446 {\csname s@fct@#1\endcsname}%
1448 %<-trace> \csname s@fct@#1\endcsname
1450 %</2ekernel|package>
1454 % \changes{v2.3j}{1994/05/23}{Removed def of \cs{f@warn@break}}
1457 % \begin{macro}{\try@size@range}
1458 % This macro tries to find a suitable range for requested size
1459 % (specified by |\f@size|) in |\font@info|. All the relevant
1460 % action is done in |\extract@rangefontinfo|. All that needs
1461 % to be done is to stuff in the token list in |\font@info| so
1462 % that |\extract@rangefontinfo| can inspect it.
1463 % Note the |<-*\@nil><| token at the end to stop scanning.
1464 % \changes{v2.0b}{1992/07/26}{}
1467 \def\try@size@range{%
1468 \expandafter\extract@rangefontinfo\font@info <-*>\@nil<\@nnil
1474 % \begin{macro}{\try@size@substitution}
1475 % \changes{v2.3k}{1994/11/06}{New implementation}
1476 % This is the last thing that can be tried. If the desired |\f@size|
1477 % is found neither among the simple size specifications nor in one
1478 % of the ranges the whole list of size specifications is searched for
1479 % a nearby simple size.
1481 \gdef\try@size@substitution{%
1483 % First we do some initializations. |\@tempdimb|
1484 % will hold the difference between the wanted size and the best
1485 % solution found so far, so we initialise it with |\maxdimen|.
1486 % The macro |\best@size| will hold the best size found, nothing
1487 % found is indicated by the empty value.
1489 \@tempdimb \maxdimen
1490 \let \best@size \@empty
1492 % Now we loop over the specification
1494 \expandafter \try@simples \font@info <\number\@M>\@nil<\@nnil
1500 % \begin{macro}{\font@submax}
1501 % \changes{v2.3d}{1994/04/18}{Changed dimen to macro}
1502 % \begin{macro}{\fontsubfuzz}
1503 % \changes{v2.3d}{1994/04/18}{Changed dimen to macro}
1504 % The macro |\font@submax| records the maximal deviation from the
1505 % desired size encountered so far. Its value is used in a warning
1506 % message at |\end{document}|. The macro
1507 % |\fontsubfuzz| contains the amount that will not cause terminal
1508 % warnings (warnings still go into the transcript file).
1510 \def\font@submax{0pt}
1511 \def\fontsubfuzz{.4pt}
1513 %<+package>\def\fontsubfuzz{0pt}
1520 % \begin{macro}{\try@simples}
1521 % \changes{v2.3k}{1994/11/06}{New implementation}
1522 % |\try@simples| goes through a font shape definition
1523 % in the input until it recognizes the tokens |<*\@nil><|.
1524 % It looks for simple sizes to determine the two closest sizes.
1525 % It is assumed that simple sizes are in increasing order.
1528 \gdef\try@simples#1<#2>{%
1529 \tryif@simple#2->\tryif@simple}
1533 % \begin{macro}{\tryis@simple}
1534 % \changes{v2.3k}{1994/11/06}{New implementation}
1535 % |\tryis@simple| is similar to |\is@range|. If it sees a simple size,
1536 % it checks it against the value of |\f@size| and sets
1537 % |\lower@font@size| or |\higher@font@size|. In the latter case, it
1538 % stops the iteration. By adding |<\number\@M>| at the end of the
1539 % line we always have an end point. This is a hack which probably
1540 % should be corrected.
1542 % First it checks whether it is finished already, then whether the
1543 % size specification in question is a simple one.
1545 \gdef\tryif@simple#1-#2\tryif@simple{%
1547 % Most common case for |\reserved@f| first:
1549 \let \reserved@f \try@simples
1552 % If so, it compares it to the value of |\f@size|. This is done using
1553 % a dimen register since there may be fractional numbers.
1556 \ifdim \dimen@<\@M\p@
1558 % If |\dimen@| is |\@M\p@| we have reached the end of the fontspec
1559 % (hopefully) otherwise we compare the value with |\f@size| and
1560 % compute in |\@tempdimc| the absolute value of the difference
1561 % between the two values.
1563 \ifdim \f@size\p@<\dimen@
1565 \advance\@tempdimc -\f@size\p@
1567 \@tempdimc \f@size\p@
1568 \advance\@tempdimc -\dimen@
1571 % The result is then compared with the smallest difference we have
1572 % encountered, if the new value (in |\@tempdimc| is smaller) we
1573 % have found a size which is a better approximation so we make it
1574 % the |\best@size| and adjust |\@tempdimb|.
1576 \ifdim \@tempdimc<\@tempdimb
1577 \@tempdimb \@tempdimc
1578 \def \best@size{#1}%
1581 % When we have reached the end of the fontspec we substitute the
1582 % best size found (if any). We code this inline to save macro
1583 % space; in the past this was done by a macro called |\subst@size|.
1589 % \begin{macro}{\subst@size}
1590 % This macro substitutes the size recorded in |\best@size| for
1591 % the unavailable size |\f@size|. |\font@submax| records the maximum
1592 % difference between desired size and selected size in the
1594 % \changes{v2.3d}{1994/04/18}{\cs{font@submax} and \cs{fontsubfuzz}
1597 % %\subst@size %% coded inline
1598 % %\def\subst@size{%
1599 \ifx \external@font\@empty
1600 \ifx \best@size\@empty
1602 \ifdim \@tempdimb>\font@submax \relax
1603 \xdef \font@submax {\the\@tempdimb}%
1605 \let \f@user@size \f@size
1606 \let \f@size \best@size
1607 \ifdim \@tempdimb>\fontsubfuzz\relax
1608 \@font@warning{Font\space shape\space
1609 `\curr@fontshape'\space in\space size\space
1610 <\f@user@size>\space not\space available\MessageBreak
1611 size\space <\f@size>\space substituted}%
1614 \do@subst@correction
1621 % This brings us back into the main part of |\tryif@simple|.
1622 % Finally we get rid of any rubbish left over on the input stack.
1624 % \changes{v3.0c}{1995/08/24}{}
1626 \let \reserved@f \remove@to@nnil
1630 % If it's a range iterate also.
1638 % \subsection{Sizefunctions}
1640 % In the following we define some useful size functions.
1643 % \begin{macro}{\s@fct@}
1644 % This is the default size function. Mandatory argument is an
1645 % external font name, optional argument a scale factor.
1646 % The font is scaled
1647 % to |\f@size| if no optional argument is present, and to
1648 % |\f@size| multiplied by the optional argument otherwise.
1649 % \changes{v2.0b}{1992/07/26}{}
1651 \DeclareSizeFunction{}{\empty@sfcnt\@font@warning}
1652 \DeclareSizeFunction{s}{\empty@sfcnt\@font@info}
1656 \def\empty@sfcnt#1{%
1657 \@tempdimb \f@size\p@
1658 \ifx\optional@arg\@empty
1660 \@tempdimb \optional@arg\@tempdimb
1661 #1{Font\space shape\space `\curr@fontshape'\space
1662 will\space be\MessageBreak
1663 scaled\space to\space size\space \the\@tempdimb}%
1665 \edef\external@font{\mandatory@arg\space at\the\@tempdimb}}
1671 % \begin{macro}{\s@fct@gen}
1672 % \begin{macro}{\s@fct@sgen}
1673 % This size function generates the external name from the mandatory
1674 % argument and the requested user size, and thus can be used for
1675 % external names where the size is encoded in the font name. The
1676 % optional argument a scale factor. The font is scaled to |\f@size|
1677 % if no optional argument is present, and to |\f@size| multiplied
1678 % by the optional argument otherwise.
1680 \DeclareSizeFunction{gen}{\gen@sfcnt\@font@warning}
1681 \DeclareSizeFunction{sgen}{\gen@sfcnt\@font@info}
1686 \edef\mandatory@arg{\mandatory@arg\f@size}%
1694 % \begin{macro}{\s@fct@genb}
1695 % \begin{macro}{\s@fct@sgenb}
1696 % This size function is similar to |gen|, but for fonts where the
1697 % size is encoded in the font name in centipoints, as in the DC
1698 % fonts version 1.2. The font is scaled to |\f@size|
1699 % if no optional argument is present, and to |\f@size| multiplied
1700 % by the optional argument otherwise.
1702 \DeclareSizeFunction{genb}{\genb@sfcnt\@font@warning}
1703 \DeclareSizeFunction{sgenb}{\genb@sfcnt\@font@info}
1708 \edef\mandatory@arg{\mandatory@arg\expandafter\genb@x\f@size..\@@}%
1715 % \begin{macro}{\genb@x}
1716 % \begin{macro}{\genb@y}
1717 % The auxiliary macros |\genb@x| and |\genb@y| are used to convert
1718 % the |\f@size| into centipoints.
1720 \def\genb@x#1.#2.#3\@@{\two@digits{#1}\genb@y#200\@@}
1721 \def\genb@y#1#2#3\@@{#1#2}
1728 % \begin{macro}{\s@fct@sub}
1729 % This size function handles font substitution.
1730 % The mandatory argument is a family/series/shape combination,
1731 % the optional argument (if present) is ignored. The font encoding
1732 % scheme cannot be changed. Therefore, the first thing we do is to
1733 % prepend the encoding scheme.
1734 % \changes{v2.0b}{1992/07/26}{}
1736 \DeclareSizeFunction{sub}{\sub@sfcnt\@font@warning}
1737 \DeclareSizeFunction{ssub}{\sub@sfcnt\@font@info}
1742 \edef\mandatory@arg{\f@encoding/\mandatory@arg}%
1744 % Next action is split the arg into its individual components and
1745 % allow for a late font shape load.
1748 \expandafter\split@name\mandatory@arg/\@nil
1752 % Then we record the current |\f@size| since it may get clobbered.
1754 \let\f@user@size\f@size
1756 % Then we check whether this new combination is defined and
1757 % give an error message if not. In this case we also switch to
1758 % |\error@fontshape|.
1761 \ifx\csname\mandatory@arg\endcsname\relax
1762 \errmessage{No\space declaration\space for\space
1763 shape\space \mandatory@arg}%
1767 % Otherwise we warn the user about the substitution taking place.
1769 #1{Font\space shape\space `\curr@fontshape'\space in\space
1770 size\space <\f@size>\space not\space available\MessageBreak
1771 Font\space shape\space `\mandatory@arg'\space tried\space
1773 \expandafter\split@name\mandatory@arg/\@nil
1776 % Then we restart the font specification scan by calling
1777 % |\get@external@font|.
1779 \edef\f@size{\f@user@size}%
1782 % Finally |\do@subst@correction| is called to get the font name
1785 \do@subst@correction
1791 % \begin{macro}{\s@fct@subf}
1792 % The |subf| size function allows substitution of another font. The
1793 % mandatory argument is the external name of the font to be
1794 % substituted, the optional argument a size scaling factor like
1795 % in the default size function.
1796 % The main difference to the default size function is the warning
1799 \DeclareSizeFunction{subf}{\subf@sfcnt\@font@warning}
1800 \DeclareSizeFunction{ssubf}{\subf@sfcnt\@font@info}
1805 #1{Font\space shape\space `\curr@fontshape'\space in\space
1806 size\space \f@size\space not\space available\MessageBreak
1807 external\space font\space `\mandatory@arg'\space used}%
1814 % \begin{macro}{\s@fct@fixed}
1815 % The |fixed| size function is for using a font at a different size
1816 % than requested. A warning message is printed, and the external
1817 % font to be used is taken from the mandatory argument.
1818 % If an optional argument is present it is used as the `at'
1819 % size for the font. Otherwise the font is loaded at its design size.
1821 \DeclareSizeFunction{fixed}{\fixed@sfcnt\@font@warning}
1822 \DeclareSizeFunction{sfixed}{\fixed@sfcnt\@font@info}
1826 \def\fixed@sfcnt#1{%
1827 \ifx\optional@arg\@empty
1828 \let\external@font\mandatory@arg
1830 \edef\external@font{\mandatory@arg\space at\optional@arg pt}%
1832 #1{External\space font\space `\external@font'\space loaded\space
1833 for\space size\MessageBreak
1841 %<+checkmem>\CHECKMEM