forked from latex3/latex2e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathltfsstrc.dtx
1845 lines (1842 loc) · 64.3 KB
/
ltfsstrc.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% Copyright 1993-2016
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
%
% \iffalse
%%% From File: ltfsstrc.dtx
%% Copyright (C) 1989-97 by Frank Mittelbach and Rainer Sch\"opf.
%% Copyright (C) 1994-97 by LaTeX3 project. All rights reserved.
%
%<package>\NeedsTeXFormat{LaTeX2e}[1995/05/16]
%<package>\ProvidesPackage{tracefnt}
%<package> [2015/02/21 v3.0k Standard LaTeX package (font tracing)]
% \fi
% \ProvidesFile{ltfsstrc.dtx}
% [2015/02/21 v3.0k LaTeX Kernel (NFSS tracing)]
%
% \iffalse
%<+checkmem>\CHECKMEM
% \fi
%
%
%
%
% \changes{v3.0g}{1995/11/28}
% {documentation fixes}
% \changes{v3.0f}{1995/10/22}{Added `genb' and `sgenb' size functions
% to support new DC font naming scheme.}
% \changes{v3.0e}{1995/10/20}
% {(DPC) Modify autoload code}
% \changes{v3.0d}{1995/10/04}
% {(DPC) Modify autoload code}
% \changes{v3.0b}{1995/05/24}
% {(DPC) Fix \cs{ProvidesFile} usage}
% \changes{v3.0a}{1995/05/24}
% {(DPC) Make file from previous file, tracefnt 1995/05/16 v2.3o}
% \changes{v3.0k}{2015/02/21}
% {Removed autoload code}
%
% \changes{v2.3m}{1994/11/18}
% {\cs{next} to \cs{reserved@f}}
% \changes{v2.3l}{1994/11/17}
% {\cs{@tempa} to \cs{reserved@a}}
% \changes{v2.3i}{1994/05/20}{Use new error command names}
% \changes{v2.3g}{1994/05/13}{Removed typeouts as
% \cs{ProvidesPackage} writes to log.}
% \changes{v2.3e}{1994/04/27}{Corrected item that was forgotten
% in last change.}
% \changes{v2.3d}{1994/04/18}{Changed to new error/warning scheme}
% \changes{v2.3a}{1994/01/17}{New math font setup}
% \changes{v2.2a}{1993/11/11}{Option concept added for LaTeX2e}
% \changes{v2.1j}{1993/09/15}{Corrected spelling of \cs{noxpand}.}
% \changes{v2.1i}{1993/09/02}{Corrected name of sgen size function.}
% \changes{v2.1h}{1993/07/16}{Changed layout of info messages}
% \changes{v2.1b}{1993/03/18}
% {Changed all \cs{@tempdimb} in \cs{@tempdimx}
% to avoid killing \cs{numberline}}
% \changes{v2.1b}{1993/03/18}
% {Changed all \cs{@tempdima} in \cs{@tempdimb}
% to avoid killing \cs{numberline}}
% \changes{v1.0l}{1990/04/01}{Part of code moved to fam.dtx.}
% \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
% \changes{v1.0h}{1990/01/18}{\cs{tracingfonts} meaning changed.}
%
% \newcommand\module[1]{\texttt{#1}}
% \providecommand{\dst}{\textsc{DocStrip}}
% \newcommand\Loption[1]{\texttt{#1}}
%
% \GetFileInfo{ltfsstrc.dtx}
% \title{The \texttt{tracefnt} package\thanks
% {This file has version number \fileversion, dated
% \filedate.} \\
% for use with the new font selection scheme}
% \author{Frank Mittelbach \and Rainer Sch\"opf}
%
%
% \MaintainedByLaTeXTeam{latex}
% \maketitle
%
% \section{Introduction}
%
% This package contains the code for tracing font loading and font
% changes. It basically overlays some of the low-level functions of
% NFSS with additional code used for tracing.
%
% The package accepts the following options:
% \begin{description}
% \item[errorshow] Write all information about font changes etc.\
% only to the transcript file unless an error happens. This means
% that information about font substitution will not be shown on the
% terminal.
%
% \item[warningshow] Show all NFSS warnings on the terminal. This
% setting corresponds to the default behaviour of NFSS if the
% \texttt{tracefnt} package is \emph{not} loaded!
%
% \item[infoshow] Show all NFSS warning and all NFSS info
% messages (that are normally only written to the transcript file)
% also on the terminal. This is the default if the \texttt{tracefnt}
% package is loaded.
%
% \item[debugshow] In addition to \texttt{infoshow} show also
% changing of math fonts as far as possible (this option can produce a
% large amount of output.
%
% \item[loading] Show the name of external fonts when they are
% loaded. This option shows only ``newly'' loaded fonts not those
% already preloaded in the format or the class file before the
% \texttt{tracefnt} package became active.
%
% \item[pausing]
% Turn all font warnings into errors so that \LaTeX{} will stop.
%
% \end{description}
%
%
% \StopEventually{}
%
% \section{A driver for this document}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you
% are currently reading. It will be extracted from this file by the
% \dst{} program.
%
% When this file is processed directly by \LaTeX{} this will
% produce the documentation as well.
%
% \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
%\OnlyDescription % comment out for implementation details
\begin{document}
\DocInput{ltfsstrc.dtx}
\end{document}
%</driver>
% \end{macrocode}
%
%
% \section{The Implementation}
%
% \begin{quote}
% \textbf{Warning:} Read the macro documentation with a grain of
% salt. It is still basically the documentation from the first NFSS
% release and therefore in some cases probably not completely
% accurate.
% \end{quote}
%
% If we are making a package file it is a good idea to test whether
% we are running under 2e.
% This code is actually placed at the very beginning of this file
% for easier maintenance, thus commented out here.
% \begin{macrocode}
%<*package>
%\NeedsTeXFormat{LaTeX2e}
%\ProvidesPackage{tracefnt}[??/??/?? v?.??
% Standard LaTeX package (font tracing)]
%</package>
% \end{macrocode}
%
%
% The \texttt{debug} module makes use of commands contained in a
% special package file named \texttt{trace.sty}.\footnote{This package
% is not in distribution at the moment (and probably doesn't any
% longer work). Think of this part of the code as being historical
% artefacts.}
% \begin{macrocode}
%<+debug> \input trace.sty
% \end{macrocode}
%
%
% \section{Handling Options}
%
% \begin{macro}{\tracingfonts}
% Here is the definition of the integer register for the font
% trace. As a default in a package file we use $1$ to give error
% messages if fonts are substituted. If this code is used for
% debugging or tracing reasons in the format file (i.e.\ in
% \texttt{fam.dtx}) we use $0$ as the default. But if no font
% trace is used we build a definition that will produce a warning
% message.
% \changes{v1.0l}{1990/04/01}
% {Check if \cs{tracingfonts} already defined.}
% \changes{v1.0o}{1990/04/01}
% {Check if \cs{tracingfonts} defined removed again.}
% \begin{macrocode}
%<*2ekernel>
\def\tracingfonts{%
\@font@warning{Command \noexpand\tracingfonts
not provided.\MessageBreak
Use the `tracefnt' package.\MessageBreak Command found:}%
\count@}
%</2ekernel>
% \end{macrocode}
% The |\count@| in the line above will remove the number after
% |\tracingfonts|. Note that this definition will be overwritten be
% the next line if one of these modules are included.
% \begin{macrocode}
%<*package,trace,debug>
\newcount\tracingfonts
\tracingfonts=0
%</package,trace,debug>
% \end{macrocode}
% \end{macro}
%
%
% The option \Loption{errorshow} turns off all warnings so that only
% real errors are shown. \Loption{warningshow} corresponds to the
% NFSS default (when \texttt{tracefnt} is not loaded).
% \Loption{infoshow} is the default for this package here; and
% \Loption{debugshow}, \Loption{loading}, and
% \Loption{pausing} extend the amount of information even further.
% \changes{v2.3o}{1995/05/13}
% {Use single hash mark in \cs{DeclareOption}}
% \begin{macrocode}
%<*package>
\DeclareOption{errorshow}{%
\def\@font@info#1{%
\GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Info: \space\space\space#1}}%
\def\@font@warning#1{%
\GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Warning: #1}}%
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareOption{warningshow}{%
\def\@font@info#1{%
\GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Info: \space\space\space#1}}%
\def\@font@warning#1{%
\GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Warning: #1}}%
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareOption{infoshow}{%
\def\@font@info#1{%
\GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Info: \space\space\space#1}}%
\def\@font@warning#1{%
\GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Warning: #1}}%
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareOption{loading}{%
\tracingfonts\tw@
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareOption{debugshow}{%
\ExecuteOptions{infoshow}%
\tracingfonts\thr@@
}
% \end{macrocode}
%
% \changes{v3.0j}{1997/05/29}{Replaced \texttt{\symbol{92}\symbol{92}}
% by \cs{MessageBreak}, as suggested by Donald Arseneau.}
% \begin{macrocode}
\DeclareOption{pausing}{%
\def\@font@warning#1{%
\GenericError
{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Warning: #1}%
{See the LaTeX Companion for details.}%
{I'll stop for every LaTeX Font Warning because
you requested\MessageBreak the `pausing' option
to the tracefnt package.}}%
}
% \end{macrocode}
% We make |infoshow| the default, which in turn defines
% |\font@warning| and |\font@info|.
% \begin{macrocode}
\ExecuteOptions{infoshow}
\ProcessOptions
%</package>
% \end{macrocode}
%
% We also need a default definition inside the kernel:
% \begin{macrocode}
%<*2ekernel>
\def\@font@info#1{%
\GenericInfo{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Info: \space\space\space#1}}%
\def\@font@warning#1{%
\GenericWarning{(Font)\@spaces\@spaces\@spaces\space\space}%
{LaTeX Font Warning: #1}}%
%</2ekernel>
% \end{macrocode}
%
%
% \section{Macros common to \texttt{fam.tex} and \texttt{tracefnt.sty}}
%
% In the first versions of \texttt{tracefnt.dtx} some macros of
% \texttt{fam.dtx}\footnote{This file is currently not distributed in
% documented form. Its code is part of \texttt{ltfss.dtx}.}
% were redefined to included the extra tracing
% information. Now these macros are all defined in this file (i.e.\
% removed from \texttt{fam.dtx}) and different production versions can
% be obtained simply by specifying a different set of modules to
% include when generating \texttt{ltfss.dtx}.
%
%
%
% \subsection{General font loading}
%
%
% \begin{macro}{\extract@font}
%
% This macro organizes the font loading.
% It first calls |\get@external@font|
% which will return in |\external@font| the name of the external
% font file (the \texttt{.tfm}) as it was determined by the NFSS
% tables.
% \begin{macrocode}
%<*2ekernel|package>
\def\extract@font{%
\get@external@font
% \end{macrocode}
% Then the external font is loaded and assigned to the font
% identifier stored inside |\font@name|
% (for this reason we need |\expandafter|).
% \begin{macrocode}
\global\expandafter\font\font@name\external@font\relax
% \end{macrocode}
% When tracing we typeout the internal and external font name.
% \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
% \begin{macrocode}
%<*trace>
\ifnum \tracingfonts >\@ne
\@font@info{External font `\external@font'
loaded as\MessageBreak \font@name}\fi
%</trace>
% \end{macrocode}
% Finally we call the corresponding ``loading action'' macros to
% finish things. First the font is locally selected to allow the
% use of |\font| inside the loading action macros.
% \begin{macrocode}
\font@name \relax
% \end{macrocode}
% The next two lines execute the ``loading actions'' for the
% family and then for the individual font shape.
% \begin{macrocode}
\csname \f@encoding+\f@family\endcsname
\csname\curr@fontshape\endcsname
\relax
}
%</2ekernel|package>
% \end{macrocode}
% The |\relax| at the end needs to be explained.
% This is inserted to prevent \TeX{} from scanning too far
% when it is executing the replacement text of the loading
% code macros.
% \end{macro}
%
%
% \begin{macro}{\get@external@font}
% This function tries to find an external font name. It will place
% the name into the macro
% |\external@font|. If no font is found it will return the one
% that was defined via |\DeclareErrorFont|.
% \begin{macrocode}
%<*2ekernel>
\def\get@external@font{%
% \end{macrocode}
% We don't know the external font name at the beginning.
% \begin{macrocode}
\let\external@font\@empty
\edef\font@info{\expandafter\expandafter\expandafter\string
\csname \curr@fontshape \endcsname}%
\try@size@range
% \end{macrocode}
% If this failed, we'll try to substitute another size of the same
% font. This is done by the |\try@size@substitution| macro. It
% ``knows about'' |\do@extract@font|, |\font@name|, |\f@size|, and
% so on.
% \begin{macrocode}
\ifx\external@font\@empty
\try@size@substitution
\ifx\external@font\@empty
\@latex@error{Font \expandafter \string\font@name\space
not found}\@eha
\error@fontshape
\get@external@font
\fi\fi
}
%</2ekernel>
% \end{macrocode}
% \end{macro}
%
%
% \changes{v1.0j}{1990/02/18}
% {Redefine unprotected version \cs{p@selectfont}
% instead of \cs{selectfont}.}
%
%
% \begin{macro}{\selectfont}
% \changes{v1.1a}{1989/12/16}{Changed order of calls.}
% \changes{v2.3f}{1994/05/12}{Use \cs{DeclareRobustCommand}}
% The macro |\selectfont| is called whenever a font change must
% take place.
% \begin{macrocode}
%<*2ekernel|package>
\DeclareRobustCommand\selectfont
{%
% \end{macrocode}
% When \module{debug} is specified we actually want something like
% `undebug'. The font selection is now stable so that using
% |\tracingall| on some other macros will show us a lot of unwanted
% information about font loading. Therefore we disable tracing during
% font loading as long as |\tracingfonts| is less than $4$.
% \changes{v1.0m}{1990/04/05}
% {Call \cs{tracingon} only if \cs{tracingfonts} greater than 3.}
% \changes{v1.0n}{1990/05/05}{\cs{tracingon} with new syntax.}
% \begin{macrocode}
%<+debug> \pushtracing
%<+debug> \ifnum\tracingfonts<4 \tracingoff
%<+debug> \else \tracingon\p@selectfont \fi
% \end{macrocode}
% If |\baselinestretch| was redefined by the user it will not
% longer match its internal counterpart |\f@linespread|. If so we
% call |\set@fontsize| to prepare |\size@update|.
% \begin{macrocode}
\ifx\f@linespread\baselinestretch \else
\set@fontsize\baselinestretch\f@size\f@baselineskip \fi
% \end{macrocode}
% Then we generate the internal name of the font
% by concatenating {\em family}, {\em series},
% {\em shape}, and current {\em size},
% with slashes as delimiters between them.
% This is much more readable than standard
% \LaTeX's |\twfbf|, etc.
% We define |\font@name| globally, as always.
% The reason for this is explained later on.
% \changes{v2.0b}{1992/07/26}{}
% \begin{macrocode}
\xdef\font@name{%
\csname\curr@fontshape/\f@size\endcsname}%
% \end{macrocode}
% We call the macro |\pickup@font| which will load the font if
% necessary.
% \begin{macrocode}
\pickup@font
% \end{macrocode}
% Then we select the font.
% \begin{macrocode}
\font@name
% \end{macrocode}
% If |\tracingfonts| is
% greater than 2 we also show the font switch.
% We do this before |\glb@settings| is called since this
% macro might redefine |\font@name|.
% \changes{v1.0k}{1990/03/14}{Added code for TeX3.}
% \changes{v1.0i}{1990/02/16}{Changed \cs{f@size} to \cs{lcl@currsize}
% (see fam file).}
% \begin{macrocode}
%<*trace>
\ifnum \tracingfonts>\tw@
\@font@info{Switching to \font@name}\fi
%</trace>
% \end{macrocode}
% Finally we call |\size@update|. This macro is normally empty but
% will contain actions (like setting the |\baselineskip|) that have
% to be carried out when the font size, the base |\baselineskip| or
% the |\baselinestretch| have changed.
% \begin{macrocode}
\size@update
% \end{macrocode}
% A similar function is called to handle anything related to
% encoding updates. This one is changed from |\relax| by
% |\fontencoding|.
% \changes{v2.3h}{1994/05/14}{Added \cs{enc@update}}
% \begin{macrocode}
\enc@update
% \end{macrocode}
% Just before ending this macro we have to pop the tracing stack
% if it was pushed before.
% \begin{macrocode}
%<+debug> \poptracing
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\set@fontsize}
% The macro |\set@fontsize| does the actual work. First it assigns
% new values to |\f@size|, |\f@baselineskip| and |\f@linespread|.
% \begin{macrocode}
\def\set@fontsize#1#2#3{%
\@defaultunits\@tempdimb#2pt\relax\@nnil
\edef\f@size{\strip@pt\@tempdimb}%
\@defaultunits\@tempskipa#3pt\relax\@nnil
\edef\f@baselineskip{\the\@tempskipa}%
\edef\f@linespread{#1}%
% \end{macrocode}
% For backward compatibility and for later testing within
% |\selectfont| the internal value of |\f@linespread| is passed
% back to |\baselinestretch|.
% \begin{macrocode}
\let\baselinestretch\f@linespread
% \end{macrocode}
% Additional processing will happen within |\selectfont|. For this
% reason the macro |\size@update| (which will be called in
% |\selectfont|) will be defined to be:
% \begin{macrocode}
\def\size@update{%
% \end{macrocode}
% First calculate the new |\baselineskip| and also store it in
% |normalbaselineskip|
% \begin{macrocode}
\baselineskip\f@baselineskip\relax
\baselineskip\f@linespread\baselineskip
\normalbaselineskip\baselineskip
% \end{macrocode}
% then to set up a new |\strutbox|
% \begin{macrocode}
\setbox\strutbox\hbox{%
\vrule\@height.7\baselineskip
\@depth.3\baselineskip
\@width\z@}%
% \end{macrocode}
% We end with a bit of tracing information.
% \begin{macrocode}
%<*trace>
\ifnum \tracingfonts>\tw@
\ifx\f@linespread\@empty
\let\reserved@a\@empty
\else
\def\reserved@a{\f@linespread x}%
\fi
\@font@info{Changing size to \f@size/\reserved@a
\f@baselineskip}%
\aftergroup\type@restoreinfo \fi
%</trace>
% \end{macrocode}
% When all this is processed |\size@update| redefines itself to
% |\relax| so that in later calls of |\selectfont| no extra code
% will be executed.
% \begin{macrocode}
\let\size@update\relax}%
}
% \end{macrocode}
% Instead of defining this macro internally we might speed things
% up by placing the code into a separate macro and use |\let|!
% \end{macro}
%
%
% \begin{macro}{\size@update}
% Normally this macro does nothing; it will be redefined by
% |\set@fontsize| to initiate an update.
% \begin{macrocode}
\let\size@update\relax
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\type@restoreinfo}
% This macro produces some info when a font size and/or baseline
% change will get restored.
% \changes{1.0r}{1990/08/27}{Some extra tracing info.}
% \begin{macrocode}
%<*trace>
\def\type@restoreinfo{%
\ifx\f@linespread\@empty
\let\reserved@a\@empty
\else
\def\reserved@a{\f@linespread x}%
\fi
\@font@info{Restoring size to
\f@size/\reserved@a\f@baselineskip}}
%</trace>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\glb@settings}
% \begin{macro}{\glb@currsize}
% \changes{v2.3a}{1994/01/17}{New math font setup}
% \changes{v2.3k}{1994/11/06}{New implementation}
% The macro |\glb@settings| globally selects
% all math fonts for the current size if necessary.
% \begin{macrocode}
\def\glb@settings{%
% \end{macrocode}
% When |\glb@settings| gains control a size
% change was requested and all previous font assignments need to
% be replaced.
% Therefore the old values of the fonts are no longer needed.
% For every {\em math group\/} the new assignments are appended to
% |\math@fonts|.
% But this happens only if the |math@fonts| switch
% is set to true.
% However, we always set up the correct math sizes for script and
% scriptscript fonts since they may be needed even if we don't set
% up the whole math machinery.
%
% Here we set the math size, script size and scriptscript size.
% If the |S@|\ldots{} macro is not defined we have to first
% calculate the three sizes.
% \begin{macrocode}
\expandafter\ifx\csname S@\f@size\endcsname\relax
\calculate@math@sizes
\fi
% \end{macrocode}
% The effect of this is that |\calculate@math@sizes|
% may or may not define the |S@|\ldots{} macro. In the
% first case the next time the same size is requested
% this macro is used, otherwise |\calculate@math@sizes| is
% called again.
% This also sets the |math@fonts| switch.
% If it is true we must switch the math fonts.
% \begin{macrocode}
\csname S@\f@size\endcsname
\ifmath@fonts
%<*trace>
\ifnum \tracingfonts>\tw@
\@font@info{Setting up math fonts for
\f@size/\f@baselineskip}\fi
%</trace>
% \end{macrocode}
% Inside a group we execute the macro for the current math {\em
% version}. This sets |\math@fonts| to a list of
% |\textfont|\dots{} assignments. |\getanddefine@fonts| (which may
% be called at this point) needs the |\escapechar| parameter to be
% set to $-1$.
% \begin{macrocode}
\begingroup
\escapechar\m@ne
\csname mv@\math@version \endcsname
% \end{macrocode}
% Then we set |\globaldefs| to 1 so that all following changes are
% done globally. The math font assignments recorded in
% |\math@fonts| are executed and |\glb@currsize| is set equal to
% |\f@size|. This signals that the fonts for math in this size are
% set up.
% \begin{macrocode}
\globaldefs\@ne
\math@fonts
\let \glb@currsize \f@size
\endgroup
% \end{macrocode}
% Finally we execute any code that is supposed to happen
% whenever the math font setup changes. This register will
% be executed in local mode which means that everything that is
% supposed to have any effect should be done globally inside.
% We can't execute it within |\globaldefs\@ne| as we don't know
% what ends up inside this register, e.g., it might contain
% calculations which use some local registers to calculate the
% final (global) value.
% \begin{macrocode}
\the\every@math@size
% \end{macrocode}
% Otherwise we announce that the math fonts are not set up for this
% size.
% \begin{macrocode}
%<*trace>
\else
\ifnum \tracingfonts>\tw@
\@font@info{No math setup for
\f@size/\f@baselineskip}\fi
%</trace>
\fi
}
%</2ekernel|package>
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\baselinestretch}
% \changes{v1.0o}{1990/06/24}{Moved to tracefnt.dtx.}
% In |\selectfont| we used |\baselinestretch| as
% a factor when assigning a value to |\baselineskip|.
% We use 1 as a default (i.e.\ no stretch).
% \begin{macrocode}
%<*2ekernel>
\def\baselinestretch{1}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\every@math@size}
% \changes{v1.0u fam.dtx}{1989/12/05}{Hook \cs{every@size} added.}
% \changes{v23.k}{1994/10/23}{Renamed to \cs{every@math@size}}
% We must still define the hook |\every@math@size| we used in
% |\glb@settings|. We initialize it to nothing. It is important to
% remember that everything that goes into this hook should to global
% updates, local changes will have weird effects.
% \begin{macrocode}
\newtoks\every@math@size
\every@math@size={}
%</2ekernel>
% \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Math fonts setup}
%
%
% \subsubsection{Outline of algorithm for math font sizes}
%
% \TeX{} uses the the math fonts that are current when the end of a
% formula is reached. If we don't want to keep font setups local to
% every formula (which would result in an enormous overhead, we have
% to be careful not to end up with the wrong setup in case formulas
% are nested, e.g., we need to be able to handle
% \begin{verbatim}
% $ a=b+c \mbox{ \small for all $b$ and $c\in Z$}$
%\end{verbatim}
% Here the inner formulae |b| and |c\in Z| are typeset in |\small| but
% we have to return to |\normalsize| before we reach the closing |$|
% of the outer formula.
%
% This is handled in the following way:
% \begin{enumerate}
% \item At any point in the document the global variable
% |\gbl@currsize| contains the point size for which the math fonts
% currently are set up.
%
% \item \label{it:everymath} Whenever we start a formula we compare
% its value with the local variable |\f@size| that describes the
% current text font size.
%
% \item If both are the same we assume that we can use the current
% math font setup without adjustment.
%
% \item \label{it:everymathend} If they differ we call |\gbl@settings|
% which changes the math font setup and updates |\gbl@currsize|.
% \begin{enumerate}
% \item If we are recursively inside another formula (|\if@inmath|) we
% ensure that |\gbl@settings| is executed again in the outer
% formula, so that the old setup is automatically restored.
% \item Otherwise, we set the switch |@inmath| locally to |true| so
% that all nested formulae will be able to detect that they are
% nested in some outer formula.
% \end{enumerate}
% \end{enumerate}
%
%
% The above algorithm has the following features:
% \begin{itemize}
% \item For sizes which are not containing any formula no math setup
% is done. Compared to the original algorithm of NFSS this results
% in the following savings:
% \begin{itemize}
% \item No unnecessary loading of math fonts for sizes that are not
% used to typeset any math formulae (explicit or implicit ones).
% \item No time overhead due to unnecessary changes of the math font
% setup on entrance and exit of the text font size.
% \end{itemize}
%
% \item Math font setup changes for top-level formulae will survive
% (there is no restoration after the formula) thus any following
% formula in the same size will be directly typesetable. Compared to
% original implementation in NFSS2
% the new algorithm has the overhead of one test per formula
% to see if the current math setup is valid (in the original
% algorithm the setup was always valid, thus no test was necessary).
%
% \item In nested formulae the math font setup is restored in the
% outer formula by a series of |\aftergroup| commands and checks.
% Compared to the original algorithm this involves additional checks
% ($2 \times \langle\mbox{non-math levels}\rangle$ per inner
% formula).
% \end{itemize}
%
% \subsubsection{Code for math font size setting}
%
% \begin{macro}{\check@mathfonts}
% \changes{v2.3a}{1994/01/17}{New math font setup}
% \changes{v2.3c}{1994/01/26}{Correct trace info placement}
% In the |\check@mathfonts| macros we implement the steps
% \ref{it:everymath} to \ref{it:everymathend} except that instead
% of a switch the macro |\init@restore@glb@settings| is used.
% \begin{macrocode}
%<*2ekernel|package>
\def\check@mathfonts{%
\ifx \glb@currsize \f@size
%<*trace>
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: no change \f@size\space
curr/global (\curr@math@size/\glb@currsize)}\fi
%</trace>
\else
%<*trace>
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: setting up \f@size\space
curr/global (\curr@math@size/\glb@currsize)}\fi
%</trace>
\glb@settings
\init@restore@glb@settings
\fi
\let\curr@math@size\f@size
\def\init@restore@glb@settings{\aftergroup\restglb@settings}%
}
% \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\init@restore@glb@settings}
% \changes{v3.0i}{1996/07/26}{macro added replacing \cs{if@inmath} switch}
% This macros does by default nothing but get redefined inside
% |\check@mathfonts| to initiate fontsize restoring in nested
% formulas.
% \begin{macrocode}
%<-trace>\let\init@restore@glb@settings\relax
%<*trace>
\def\init@restore@glb@settings{%
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: no resetting (not in
nested math)}\fi
}
%</trace>
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\restglb@settings}
% \changes{v2.3a}{1994/01/17}{New math font setup}
% \changes{v2.3c}{1994/01/26}{Correct trace info placement}
% This macro will be executed the first time after the current
% formula.
% \begin{macrocode}
\def\restglb@settings{%
%<*trace>
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: restoring}\fi
%</trace>
\begingroup
\let\f@size\curr@math@size
\ifx\glb@currsize \f@size
%<*trace>
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: ... already okay (\f@size)}\fi
%</trace>
\else
%<*trace>
\ifnum \tracingfonts>\thr@@
\@font@info{*** MATH: ... to \f@size}\fi
%</trace>
\glb@settings
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Other code for math}
%
%
% \begin{macro}{\use@mathgroup}
% \changes{v1.2b}{1990/01/21}{Macro added to allow cleaner interface.}
% \changes{v1.2h}{1990/03/30}{Third argument removed (see
% \cs{math@egroup}).}
% The |\use@mathgroup| macro should be used in user
% macros to select a math group. Depending on whether or not the
% \texttt{margid} option is in force it has two or three arguments.
% For this reason it should be called as the last macro.
%
% First we test if we are inside math mode since we don't want to
% apply a useless definition.
% \changes{v1.1a}{1989/12/16}{Usage of `\quotechar=' macro added.}
% \changes{v1.1a}{1989/12/16}{Redefinition of alphabet now simpler.}
% \begin{macrocode}
\def\use@mathgroup#1#2{\relax\ifmmode
% \end{macrocode}
% \changes{v1.0o}{1990/06/24}{Tracing code added.}
% \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
% \begin{macrocode}
%<*trace>
\ifnum \tracingfonts>\tw@
\count@#2\relax
\@font@info{Using \noexpand\mathgroup
(\the\count@) #2}\fi
%</trace>
% \end{macrocode}
% If so we first call the `=' macro (i.e.\ argument three) to set
% up special things for the selected math group. Then we call
% |\mathgroup| to select the group given by argument two and
% finally we place |#1| (i.e.\ the argument of the \meta{math
% alphabet identifier} at the end. This part of the code is
% surrounded by two commands which behave like |\begingroup|
% and |\endgroup| if we want \meta{math alphabet identifier}s
% but will expand into |\@empty| if we want simply switches to
% a new math group.
% \changes{v1.0p}{1990/06/30}{Added \cs{relax} after math group number.}
% Since argument number $2$ may be a digit instead of a control
% sequence we add a |\relax|.
% Otherwise something like |\mit{1}| would switch to math group
% $11$ (and back) instead of printing an oldstyle $\mit {1}$.
% \changes{v2.0b}{1992/07/26}{}
% \begin{macrocode}
\math@bgroup
\expandafter\ifx\csname M@\f@encoding\endcsname#1\else
#1\fi
\mathgroup#2\relax
% \end{macrocode}
% Before we reinsert the swallowed token (arg.\ three) into the
% input stream, in the case that the \meta{math alphabet
% identifier} isn't called in math mode, we remove the |\fi|
% with the |\expandafter| trick. This is necessary if the
% token is actually an macro with arguments. In such a case the
% |\fi| will be misinterpreted as the first argument which
% would be disastrous.
% \changes{v1.0f}{1989/12/13}
% {\cs{expandafter} added before final \cs{fi}.}
% \begin{macrocode}
\expandafter\math@egroup\fi}%
% \end{macrocode}
% The surrounding macros equal |\begingroup| and |\endgroup|. But
% using internal names makes it possible to overwrite their meaning
% in certain cases. This is for example used in \AmSTeX{} macros
% for placing accents.
% \end{macro}
%
% \begin{macro}{\math@egroup}
% \changes{v1.0q}{1990/07/07}{Tracing code added.} If the
% \texttt{margid} option is in force (which can be tested by
% looking at the definition of |\math@bgroup| we change the
% |\math@egroup| command a bit to display the current \meta{math
% group number} after it closes the scope of \meta{math alphabet}
% with |\endgroup|.
% \changes{v3.0h}{1996/05/08}{Use \cs{bgroup} instead of \cs{begingroup}
% to match a kernel change made in 1994!!!!}
% \begin{macrocode}
%<*trace>
\ifx\math@bgroup\bgroup
\def\math@egroup#1{#1\egroup
\ifnum \tracingfonts>\tw@
\@font@info{Restoring \noexpand\mathgroup
(\ifnum\mathgroup=\m@ne default\else \the\mathgroup \fi)%
}\fi}
\fi
%</trace>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\getanddefine@fonts}
% \changes{v1.0o}{1990/06/24}{\cs{Macro} moved from fam.dtx.}
% |\getanddefine@fonts| has two arguments: the \meta{math
% group number} and the {\em family/series/shape\/} name as a
% control sequence.
% \begin{macrocode}
\def\getanddefine@fonts#1#2{%
% \end{macrocode}
% First we turn of tracing when |\tracingfonts| is less than $4$.
% \changes{v1.0o}{1990/06/24}{Adding debug code.}
% \changes{v1.0r}{1990/08/27}
% {Correcting missing name after \cs{tracingon}.}
% \begin{macrocode}
%<+debug> \pushtracing
%<+debug> \ifnum\tracingfonts<4 \tracingoff
%<+debug> \else \tracingon\getanddefine@fonts \fi
% \end{macrocode}
% \changes{v1.0o}{1990/06/24}{\cs{Adding} tracing code.}
% \changes{v1.0q}{1990/07/07}{Group number added to tracing.}
% \changes{v2.1a}{1992/09/22}{Introduced \cs{tf@size} for math size.}
% \begin{macrocode}
%<*trace>
\ifnum \tracingfonts>\tw@
\count@#1\relax
\@font@info{\noexpand\mathgroup (\the\count@) #1 :=\MessageBreak
\string#2 \tf@size/\sf@size/\ssf@size}\fi
%</trace>
% \end{macrocode}