Debian Codegraph @

texmf-dist/source/latex/base/nfssfont.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 \def\nfssfontfileversion{v2.2f}
30 \def\nfssfontfiledate{2023/11/07}
31
32 %
33 % \iffalse
34 % Copyright (C) 1994 Donald E. Knuth
35 % Copyright (C) 1994-2019 Frank Mittelbach,
36 % all rights reserved.
37 % \fi
38 %
39 %
40 % \title{The program \texttt{nfssfont}}
41 % \author{Frank Mittelbach\thanks{Adapted from code written
42 % by Donald E.~Knuth}}
43 % \date{\nfssfontfiledate}
44 %
45 %
46 % \def\dst{{\normalfont\scshape docstrip}}
47 % \def\NFSS{\textsf{NFSS}}
48 % \setcounter{StandardModuleDepth}{1}
49 %
50 %
51 % \MaintainedByLaTeXTeam{latex}
52 % \maketitle
53 %
54 % \section{Introduction}
55 %
56 % Within the \NFSS{} distribution there is a \LaTeX{} file
57 % \texttt{nfssfont.tex} which can be used to test new fonts, produce
58 % font tables showing all characters, etc. This is an adaption of a
59 % program originally written by Don Knuth.
60
61 % When you run this file through \LaTeX{} you will be asked to enter
62 % the name of the font to test. Your answer should be the external
63 % font name without any extension, e.g.\ \texttt{cmr10} (Computer
64 % Modern Roman 10pt) or \texttt{yinit} (Yannis Haralambous' Initial
65 % font).
66 %
67 % Alternatively (since version 2.1), you can press \meta{return} at
68 % this point. In that case a dialog is started that asks you for the
69 % font characteristics in \NFSS{} notation, i.e., first for the
70 % encoding scheme (default \texttt{T1}), then for the family name
71 % (default \texttt{cmr}), then for the series (default \texttt{m}),
72 % then for the shape (default \texttt{n}), and finally for the size
73 % (default \texttt{10pt}).
74 %
75 % You are then requested to enter a command. Probably the most
76 % important one is |\table|, which will produce a font chart. To
77 % switch to a new test font, type |\init|; to finish the test, type
78 % |\bye|; and to learn about all the other possible tests type
79 % |\help|.
80 %
81 % This is at
82 % the moment only a crude adaption of the test program for the
83 % Computer Modern fonts by Donald Knuth.
84 %
85 % \MaybeStop{}
86 %
87 % \section{A driver for this document}
88 %
89 % The next bit of code contains the documentation driver file for
90 % \TeX{}, i.e., the file that will produce the documentation you are
91 % currently reading. It will be extracted from this file by the
92 % \dst{} program.
93 % \begin{macrocode}
94 %<*driver>
95 \documentclass{ltxdoc}
96 % \OnlyDescription % comment out for implementation details
97 \begin{document}
98 \DocInput{nfssfont.dtx}
99 \end{document}
100 %</driver>
101 % \end{macrocode}
102 %
103 % \section{The code}
104 %
105 % A testbed for font evaluation (see The METAFONTbook, Appendix H)
106 % changed for \LaTeX{} with \NFSS.
107 %
108 % This program should get a complete rewrite some day or at least some
109 % code documentation. Any volunteers?
110 % \begin{macrocode}
111 %<*code>
112 \documentclass{article}
113 \nofiles
114 \setlength\textwidth{470pt}
115 \setlength\oddsidemargin{0pt}
116 \addtolength\textheight{7\baselineskip}
117 \addtolength\topmargin{-3\baselineskip}
118
119 \def\sevenrm{\fontencoding{OT1}\fontsize{7}{9pt}\rmfamily}
120
121 \typeout{**********************************************}
122 \typeout{* NFSS font test program version <\nfssfontfileversion>}
123 \typeout{*}
124 \typeout{* Follow the instructions}
125 \typeout{**********************************************}
126 \typeout{}
127
128 \tracinglostchars=0
129 \tolerance=1000
130 \raggedbottom
131 \parindent=0pt
132 %\newlinechar=`@ %FMi
133 \hyphenpenalty=200
134 \doublehyphendemerits=30000
135 % \end{macrocode}
136 %
137 % \begin{macrocode}
138 \newcount\m \newcount\n \newcount\p \newdimen\dim
139 \chardef\other=12
140
141 \def\today{\ifcase\month\or
142 January\or February\or March\or April\or May\or June\or
143 July\or August\or September\or October\or November\or December\fi
144 \space\number\day, \number\year}
145 \def\hours{\n=\time \divide\n 60
146 \m=-\n \multiply\m 60 \advance\m \time
147 \twodigits\n\twodigits\m}
148 \def\twodigits#1{\ifnum #1<10 0\fi \number#1}
149 % \end{macrocode}
150 %
151 % We first ask for a real external font name\ldots
152 % \begin{macrocode}
153 \def\init{%
154 \typein[\currfontname]%
155 {Input external font name, e.g., cmr10^^J%
156 (or <enter> for NFSS classification of font):}%
157 % \end{macrocode}
158 % If the answer is a real font name (like ``cmr10'') then we have no idea
159 % what the encoding of this font is, so in this case we record the word
160 % ``unknown'' and internally assume |T1| encoding. Commands other than
161 % |\table| are then most likely going to fail, unless that assumption was
162 % correct.
163 % \begin{macrocode}
164 \def\encoding{unknown}%
165 \fontencoding{T1}\selectfont
166 % \end{macrocode}
167 % If the user answers with ``return'' we ask for the \NFSS{}
168 % classification of the font in form of encoding, family, series,
169 % shape, and size offering a default each time.
170 % \begin{macrocode}
171 \ifx\currfontname\empty
172 \typein[\encoding]{^^J^^J*** NFSS classification
173 ***^^J^^JFont encoding [T1]:}%
174 \ifx\encoding\empty
175 \fontencoding{T1}%
176 \def\encoding{T1}%
177 \else
178 % \end{macrocode}
179 % Depending on the chosen encoding we have the problem, that the encoding
180 % support information may not be available (only for |T1| and |OT1| this is
181 % preloaded in the kernel, all other encodings normally need a declaration in
182 % the preamble). So here we attempt to load this support file even though
183 % it is actually already too late for this.
184 % \begin{macrocode}
185 \edef\next{%
186 \lowercase{\def\noexpand\next{\encoding enc.def}}}%
187 \next
188 \makeatletter
189 \InputIfFileExists\next
190 {}%
191 % \end{macrocode}
192 % If the encoding support file is not found this may indicate an error, eg
193 % something misspelled. However, it may equally mean that we dealing
194 % with a math font encoding for which no encoding support is
195 % available.
196 % \begin{macrocode}
197 {\PackageWarningNoLine{nfssfont}%
198 {Encoding file `\next' not found.%
199 \MessageBreak
200 You might have misspelled the name of the encoding
201 \MessageBreak
202 or perhaps this encoding is not a text encoding,
203 \MessageBreak
204 in which case you will probably only be able to
205 \MessageBreak
206 run the \noexpand\table command successfully}%
207 % \end{macrocode}
208 % But actually the situation is even worse, as some math
209 % encodings do have such support files. So for them we need to make the encoding
210 % known to NFSS in some other way, otherwise we could not even find the
211 % external font name, let alone typesetting a |\table|.
212 % \begin{macrocode}
213 \expandafter\let\csname T@\encoding\endcsname\empty
214 }%
215 \makeatother
216 \let\next\relax
217 \fontencoding\encoding
218 \fi
219 \typein[\family]{Font family [cmr]:}%
220 \relax
221 \ifx\family\empty
222 \fontfamily{cmr}%
223 \else
224 \fontfamily\family
225 \fi
226 \typein[\series]{Font series [m]:}%
227 \ifx\series\empty
228 \fontseries{m}%
229 \else
230 \fontseries\series
231 \fi
232 \typein[\shape]{Font shape [n]:}%
233 \ifx\shape\empty
234 \fontshape{n}%
235 \else
236 \fontshape\shape
237 \fi
238 \typein[\size]{Font size [10pt]:}%
239 \ifx\size\empty
240 \fontsize{10}{10}%
241 \else
242 \fontsize\size\size
243 \fi
244 % \end{macrocode}
245 % Then select the font and assign it to |\currfontname|.
246 % \begin{macrocode}
247 \selectfont\edef\currfontname{\fontname\font}%
248 \fi
249 \startfont
250 % \end{macrocode}
251 % Finally we ask for some ``action'' and offer |\table\bye| as
252 % default---basically I got tired of having to type that in each
253 % time.
254 % If some other action is given you end with a |*| prompt and have
255 % to finish the run with |\bye| yourself eventually.
256 % \begin{macrocode}
257 \typein[\action]{Now type a test command or
258 \string\help\space for help [ \string\table\space\string\bye\space]:}%
259 \ifx\action\empty
260 \expandafter\table\expandafter\bye
261 \else
262 \expandafter\action
263 \fi
264 }
265 % \end{macrocode}
266 %
267 % \begin{macrocode}
268 \def\startfont{\font\testfont=\currfontname
269 \leftline{\sevenrm Test of font \currfontname\unskip\ (encoding
270 \encoding\unskip) on \today\ at \hours}
271 \medskip
272 \testfont \setbaselineskip
273 \ifdim\fontdimen6\testfont<10pt \rightskip=0pt plus 20pt
274 \else\rightskip=0pt plus 2em \fi
275 \spaceskip=\fontdimen2\testfont % space between words (\raggedright)
276 \xspaceskip=\fontdimen2\testfont \advance\xspaceskip
277 by\fontdimen7\testfont}
278 % \end{macrocode}
279 %
280 % \begin{macrocode}
281 {\catcode`\|=0 \catcode`\\=\other
282 |gdef|help{|message{%
283 \init switches to another font;^^J%
284 \stop or \bye finishes the run;^^J%
285 \table prints the font layout in tabular format;^^J%
286 \text prints a sample text, assuming TeX text font conventions;^^J%
287 \sample combines \table and \text;^^J%
288 \mixture mixes a background character with a series of others;^^J%
289 \alternation interleaves a background character with a series;^^J%
290 \alphabet prints all lowercase letters within a given background;^^J%
291 \ALPHABET prints all uppercase letters within a given background;^^J%
292 \series prints a series of letters within a given background;^^J%
293 \lowers prints a comprehensive test of lowercase;^^J%
294 \uppers prints a comprehensive test of uppercase;^^J%
295 \digits prints a comprehensive test of numerals;^^J%
296 \math prints a comprehensive test of TeX math italic;^^J%
297 \names prints a text that mixes upper and lower case;^^J%
298 \punct prints a punctuation test;^^J%
299 \bigtest combines many of the above routines;^^J%
300 \help repeats this message;^^J%
301 and you can use ordinary TeX commands (e.g., to \input a file).}}}
302
303 \def\setbaselineskip{\setbox0=\hbox{\n=0
304 \loop\char\n \ifnum \n<255 \advance\n 1 \repeat}
305 \baselineskip=6pt \advance\baselineskip\ht0 \advance\baselineskip\dp0 }
306 % \end{macrocode}
307 %
308 % \begin{macrocode}
309 \def\setchar#1{{\escapechar-1\message{\string#1 character = }%
310 \def\do##1{\catcode`##1=\other}\dospecials
311 \read-1 to\next
312 \expandafter\finsetchar\next\next#1}}
313 \def\finsetchar#1#2\next#3{\global\chardef#3=`#1
314 \ifnum #3=`\# \global\chardef#3=#2 \fi}
315 \def\promptthree{\setchar\background
316 \setchar\starting \setchar\ending}
317
318 \def\mixture{\promptthree \domix\mixpattern}
319 \def\alternation{\promptthree \domix\altpattern}
320 \def\mixpattern{\0\1\0\0\1\1\0\0\0\1\1\1\0\1}
321 \def\altpattern{\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0}
322 \def\domix#1{\par\chardef\0=\background \n=\starting
323 \loop \chardef\1=\n #1\endgraf
324 \ifnum \n<\ending \advance\n 1 \repeat}
325
326 \def\!{\discretionary{\background}{\background}{\background}}
327 \def\series{\promptthree \!\doseries\starting\ending\par}
328 \def\doseries#1#2{\n=#1\loop\char\n\!\ifnum\n<#2\advance\n 1 \repeat}
329 \def\complower{\!\doseries{`a}{`z}\doseries{'31}{'34}\par}
330 \def\compupper{\!\doseries{`A}{`Z}\doseries{'35}{'37}\par}
331 \def\compdigs{\!\doseries{`0}{`9}\par}
332 \def\alphabet{\setchar\background\complower}
333 \def\ALPHABET{\setchar\background\compupper}
334
335 \def\lowers{\docomprehensive\complower{`a}{`z}{'31}{'34}}
336 \def\uppers{\docomprehensive\compupper{`A}{`Z}{'35}{'37}}
337 \def\digits{\docomprehensive\compdigs{`0}{`4}{`5}{`9}}
338 \def\docomprehensive#1#2#3#4#5{\par\chardef\background=#2
339 \loop{#1} \ifnum\background<#3\m=\background\advance\m 1
340 \chardef\background=\m \repeat \chardef\background=#4
341 \loop{#1} \ifnum\background<#5\m=\background\advance\m 1
342 \chardef\background=\m \repeat}
343 % \end{macrocode}
344 %
345 % \begin{macrocode}
346 \def\names{ {\AA}ngel\aa\ Beatrice Claire
347 Diana \'Erica Fran\c{c}oise Ginette H\'el\`ene Iris
348 Jackie K\=aren {\L}au\.ra Mar{\'\i}a N\H{a}ta{\l}{\u\i}e {\O}ctave
349 Pauline Qu\^eneau Roxanne Sabine T\~a{\'\j}a Ur\v{s}ula
350 Vivian Wendy Xanthippe Yv{\o}nne Z\"azilie\par}
351 \def\punct{\par\dopunct{min}\dopunct{pig}\dopunct{hid}
352 \dopunct{HIE}\dopunct{TIP}\dopunct{fluff}
353 \$1,234.56 + 7/8 = 9\% @ \#0\par}
354 \def\dopunct#1{#1,\ #1:\ #1;\ `#1'\ ?`#1?\ !`#1!\ (#1)\ [#1]\
355 #1*\ #1.\par}
356
357 \def\bigtest{\sample
358 hamburgefonstiv HAMBURGEFONSTIV\par
359 \names \punct \lowers \uppers \digits}
360
361 \def\math{\textfont1=\testfont \skewchar\testfont=\skewtrial
362 \mathchardef\Gamma="100 \mathchardef\Delta="101
363 \mathchardef\Theta="102 \mathchardef\Lambda="103 \mathchardef\Xi="104
364 \mathchardef\Pi="105 \mathchardef\Sigma="106 \mathchardef\Upsilon="107
365 \mathchardef\Phi="108 \mathchardef\Psi="109 \mathchardef\Omega="10A
366 \def\ii{i} \def\jj{j}
367 \def\\##1{|##1|+}\mathtrial
368 \def\\##1{##1_2+}\mathtrial
369 \def\\##1{##1^2+}\mathtrial
370 \def\\##1{##1/2+}\mathtrial
371 \def\\##1{2/##1+}\mathtrial
372 \def\\##1{##1,{}+}\mathtrial
373 \def\\##1{d##1+}\mathtrial
374 \let\ii=\imath \let\jj=\jmath \def\\##1{\hat##1+}\mathtrial}
375 \newcount\skewtrial \skewtrial='177
376 \def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L \\M \\N
377 \\O \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z \\a \\b \\c \\d \\e \\f
378 \\g \\h \\\ii \\\jj \\k \\l \\m \\n \\o \\p \\q \\r \\s \\t \\u \\v \\w
379 \\x \\y \\z \\\alpha \\\beta \\\gamma \\\delta \\\epsilon \\\zeta
380 \\\eta \\\theta \\\iota \\\kappa \\\lambda \\\mu \\\nu \\\xi \\\pi
381 \\\rho \\\sigma \\\tau \\\upsilon \\\phi \\\chi \\\psi \\\omega
382 \\\vartheta \\\varpi \\\varphi \\\Gamma \\\Delta \\\Theta \\\Lambda
383 \\\Xi \\\Pi \\\Sigma \\\Upsilon \\\Phi \\\Psi \\\Omega \\\partial
384 \\\ell \\\wp$\par}
385 \def\mathsy{\begingroup\skewtrial='060 % for math symbol font tests
386 \def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L
387 \\M \\N \\O \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z$\par}
388 \math\endgroup}
389 % \end{macrocode}
390 % Here we have to ensure that we use a suitable encoding otherwise our
391 % octal and hexadecimal constants will appear in whatever encoding the
392 % current font is.
393 % \begin{macrocode}
394 \def\oct#1{\hbox{\fontencoding{OT1}\rmfamily\'{}\kern-.2em\itshape
395 #1\/\kern.05em}}% octal constant
396 \def\hex#1{\hbox{\fontencoding{OT1}\rmfamily
397 \H{}\ttfamily#1}}% hexadecimal constant
398 \def\setdigs#1"#2{\gdef\h{#2}% \h=hex prefix; \0\1=corresponding octal
399 \m=\n \divide\m by 64 \xdef\0{\the\m}%
400 \multiply\m by-64 \advance\m by\n \divide\m by 8 \xdef\1{\the\m}}
401 \def\testrow{\setbox0=\hbox{\penalty 1\def\\{\char"\h}%
402 \\0\\1\\2\\3\\4\\5\\6\\7\\8\\9\\A\\B\\C\\D\\E\\F%
403 \global\p=\lastpenalty}} % \p=1 if none of the characters exist
404 \def\oddline{\cr
405 \noalign{\nointerlineskip}
406 \multispan{19}\hrulefill&
407 \setbox0=\hbox{\lower 2.3pt\hbox{\hex{\h x}}}\smash{\box0}\cr
408 \noalign{\nointerlineskip}}
409 \newif\ifskipping
410 \def\evenline{\loop\skippingfalse
411 \ifnum\n<256 \m=\n \divide\m 16 \chardef\next=\m
412 \expandafter\setdigs\meaning\next \testrow
413 \ifnum\p=1 \skippingtrue \fi\fi
414 \ifskipping \global\advance\n 16 \repeat
415 \ifnum\n=256 \let\next=\endchart\else\let\next=\morechart\fi
416 \next}
417 \def\morechart{\cr\noalign{\hrule\penalty5000}
418 \chartline \oddline \m=\1 \advance\m 1 \xdef\1{\the\m}
419 \chartline \evenline}
420 \def\chartline{&\oct{\0\1x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&}
421 \def\chartstrut{\lower4.5pt\vbox to14pt{}}
422 \def\table{$$\global\n=0
423 \halign to\hsize\bgroup
424 \chartstrut##\tabskip0pt plus10pt&
425 &\hfil##\hfil&\vrule##\cr
426 \lower6.5pt\null
427 &&&\oct0&&\oct1&&\oct2&&\oct3&&\oct4&&\oct5&&\oct6&&\oct7&\evenline}
428 \def\endchart{\cr\noalign{\hrule}
429 \raise11.5pt\null&&&\hex 8&&\hex 9&&\hex A&&\hex B&
430 &\hex C&&\hex D&&\hex E&&\hex F&\cr\egroup$$\par}
431 \def\:{\setbox0=\hbox{\noboundary\char\n\noboundary}%
432 \ifdim\ht0>7.5pt\reposition
433 \else\ifdim\dp0>2.5pt\reposition\fi\fi
434 \box0\global\advance\n 1 }
435 \def\reposition{\setbox0=\vbox{\kern2pt\box0}\dim=\dp0
436 \advance\dim 2pt \dp0=\dim}
437 \def\centerlargechars{
438 \def\reposition{\setbox0=\hbox{$\vcenter{\kern2pt\box0\kern2pt}$}}}
439 % \end{macrocode}
440 %
441 % \begin{macrocode}
442 \def\text{{\advance\baselineskip-4pt
443 \setbox0=\hbox{abcdefghijklmnopqrstuvwxyz}
444 \ifdim\hsize>2\wd0
445 \ifdim 15pc>2\wd0 \hsize=15pc \else \hsize=2\wd0 \fi
446 \fi
447 On November 14, 1885, Senator \& Mrs.~Leland Stanford called together
448 at their San Francisco mansion the 24~prominent men who had been
449 chosen as the first trustees of The Leland Stanford Junior University.
450 They handed to the board the Founding Grant of the University, which
451 they had executed three days before. This document---with various
452 amendments, legislative acts, and court decrees---remains as the
453 University's charter. In bold, sweeping language it stipulates that
454 the objectives of the University are ``to qualify students for
455 personal success and direct usefulness in life; and to promote the
456 publick welfare by exercising an influence in behalf of humanity and
457 civilization, teaching the blessings of liberty regulated by law, and
458 inculcating love and reverence for the great principles of government
459 as derived from the inalienable rights of man to life, liberty, and
460 the pursuit of happiness.'' \moretext
461 (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)\par}}
462 \def\moretext{?`But aren't Kafka's Schlo\ss{} and \AE sop's
463 \OE uvres often na\"\i ve vis-\`a-vis the d\ae monic ph\oe nix's
464 official r\^ole in fluffy souffl\'es? }
465 \def\omitaccents{\let\moretext=\relax}
466
467 \def\sample{\table\text}
468 % \end{macrocode}
469 %
470 % \begin{macrocode}
471 \def\bye{\end{document}}
472 % \end{macrocode}
473 %
474 % The redefinition of |\typeout| around the |\begin{document}|
475 % prevents \LaTeX{} from reporting that there is no |.aux| file.
476 % This is a bad hack, I agree :-)
477 % \begin{macrocode}
478 \let\oldtypeout\typeout
479 \def\typeout#1{}
480 % \end{macrocode}
481 % And another bad hack: to be able to load an encoding definition file
482 % after |\begin{document}| I disable the preamble only setting.
483 % \begin{macrocode}
484 \makeatletter
485 \let\@preamblecmds\@empty
486 \makeatother
487
488 \begin{document}
489 \let\typeout\oldtypeout
490
491 \ifx\noinit!\else\expandafter\init\fi
492 %</code>
493 % \end{macrocode}
494 %
495 %
496 % \DeleteShortVerb{\|}
497 % \Finale
498 %
499 \endinput