Debian Codegraph @

texmf-dist/tex/plain/knuth-lib/testfont.tex

raw
1 % A testbed for font evaluation (see The METAFONTbook, Appendix H)
2
3 \tracinglostchars=0
4 \tolerance=1000
5 \raggedbottom
6 \nopagenumbers
7 \parindent=0pt
8 \newlinechar=`@
9 \hyphenpenalty=200
10 \doublehyphendemerits=30000
11 \hyphenation{prom-i-nent}
12
13 \newcount\m \newcount\n \newcount\p \newdimen\dim
14 \chardef\other=12
15
16 \def\today{\ifcase\month\or
17 January\or February\or March\or April\or May\or June\or
18 July\or August\or September\or October\or November\or December\fi
19 \space\number\day, \number\year}
20 \def\hours{\n=\time \divide\n 60
21 \m=-\n \multiply\m 60 \advance\m \time
22 \twodigits\n\twodigits\m}
23 \def\twodigits#1{\ifnum #1<10 0\fi \number#1}
24
25 \def\init{\message{@Name of the font to test = }
26 \read-1 to\fontname \startfont
27 \message{Now type a test command (\string\help\space for help):}}
28 \def\startfont{\font\testfont=\fontname \spaceskip=0pt
29 \leftline{\sevenrm Test of \fontname\unskip\ on \today\ at \hours}
30 \medskip
31 \testfont \setbaselineskip
32 \ifdim\fontdimen6\testfont<10pt \rightskip=0pt plus 20pt
33 \else\rightskip=0pt plus 2em \fi
34 \spaceskip=\fontdimen2\testfont % space between words (\raggedright)
35 \xspaceskip=\fontdimen2\testfont \advance\xspaceskip by\fontdimen7\testfont}
36
37 {\catcode`\|=0 \catcode`\\=\other
38 |gdef|help{|message{%
39 \init switches to another font;@%
40 \end or \bye finishes the run;@%
41 \table prints the font layout in tabular format;@%
42 \text prints a sample text, assuming TeX text font conventions;@%
43 \sample combines \table and \text;@%
44 \mixture mixes a background character with a series of others;@%
45 \alternation interleaves a background character with a series;@%
46 \alphabet prints all lowercase letters within a given background;@%
47 \ALPHABET prints all uppercase letters within a given background;@%
48 \series prints a series of letters within a given background;@%
49 \lowers prints a comprehensive test of lowercase;@%
50 \uppers prints a comprehensive test of uppercase;@%
51 \digits prints a comprehensive test of numerals;@%
52 \math prints a comprehensive test of TeX math italic;@%
53 \names prints a text that mixes upper and lower case;@%
54 \punct prints a punctuation test;@%
55 \bigtest combines many of the above routines;@%
56 \help repeats this message;@%
57 and you can use ordinary TeX commands (e.g., to \input a file).}}}
58
59 \def\setbaselineskip{\setbox0=\hbox{\n=0
60 \loop\char\n \ifnum \n<255 \advance\n 1 \repeat}
61 \baselineskip=6pt \advance\baselineskip\ht0 \advance\baselineskip\dp0 }
62
63 \def\setchar#1{{\escapechar-1\message{\string#1 character = }%
64 \def\do##1{\catcode`##1=\other}\dospecials
65 \read-1 to\next
66 \expandafter\finsetchar\next\next#1}}
67 \def\finsetchar#1#2\next#3{\global\chardef#3=`#1
68 \ifnum #3=`\# \global\chardef#3=#2 \fi}
69 \def\promptthree{\setchar\background
70 \setchar\starting \setchar\ending}
71
72 \def\mixture{\promptthree \domix\mixpattern}
73 \def\alternation{\promptthree \domix\altpattern}
74 \def\mixpattern{\0\1\0\0\1\1\0\0\0\1\1\1\0\1}
75 \def\altpattern{\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0}
76 \def\domix#1{\par\chardef\0=\background \n=\starting
77 \loop \chardef\1=\n #1\endgraf
78 \ifnum \n<\ending \advance\n 1 \repeat}
79
80 \def\!{\discretionary{\background}{\background}{\background}}
81 \def\series{\promptthree \!\doseries\starting\ending\par}
82 \def\doseries#1#2{\n=#1\loop\char\n\!\ifnum\n<#2\advance\n 1 \repeat}
83 \def\complower{\!\doseries{`a}{`z}\doseries{'31}{'34}\par}
84 \def\compupper{\!\doseries{`A}{`Z}\doseries{'35}{'37}\par}
85 \def\compdigs{\!\doseries{`0}{`9}\par}
86 \def\alphabet{\setchar\background\complower}
87 \def\ALPHABET{\setchar\background\compupper}
88
89 \def\lowers{\docomprehensive\complower{`a}{`z}{'31}{'34}}
90 \def\uppers{\docomprehensive\compupper{`A}{`Z}{'35}{'37}}
91 \def\digits{\docomprehensive\compdigs{`0}{`4}{`5}{`9}}
92 \def\docomprehensive#1#2#3#4#5{\par\chardef\background=#2
93 \loop{#1} \ifnum\background<#3\m=\background\advance\m 1
94 \chardef\background=\m \repeat \chardef\background=#4
95 \loop{#1} \ifnum\background<#5\m=\background\advance\m 1
96 \chardef\background=\m \repeat}
97
98 \def\names{ {\AA}ngel\aa\ Beatrice Claire
99 Diana \'Erica Fran\c{c}oise Ginette H\'el\`ene Iris
100 Jackie K\=aren {\L}au\.ra Mar{\'\i}a N\H{a}ta{\l}{\u\i}e {\O}ctave
101 Pauline Qu\^eneau Roxanne Sabine T\~a{\'\j}a Ur\v{s}ula
102 Vivian Wendy Xanthippe Yv{\o}nne Z\"azilie\par}
103 \def\punct{\par\dopunct{min}\dopunct{pig}\dopunct{hid}
104 \dopunct{HIE}\dopunct{TIP}\dopunct{fluff}
105 \$1,234.56 + 7/8 = 9\% @ \#0\par}
106 \def\dopunct#1{#1,\ #1:\ #1;\ `#1'\ ?`#1?\ !`#1!\ (#1)\ [#1]\ #1*\ #1.\par}
107
108 \def\bigtest{\sample
109 hamburgefonstiv HAMBURGEFONSTIV\par
110 \names \punct \lowers \uppers \digits}
111
112 \def\math{\textfont1=\testfont \skewchar\testfont=\skewtrial
113 \mathchardef\Gamma="100 \mathchardef\Delta="101
114 \mathchardef\Theta="102 \mathchardef\Lambda="103 \mathchardef\Xi="104
115 \mathchardef\Pi="105 \mathchardef\Sigma="106 \mathchardef\Upsilon="107
116 \mathchardef\Phi="108 \mathchardef\Psi="109 \mathchardef\Omega="10A
117 \def\ii{i} \def\jj{j}
118 \def\\##1{|##1|+}\mathtrial
119 \def\\##1{##1_2+}\mathtrial
120 \def\\##1{##1^2+}\mathtrial
121 \def\\##1{##1/2+}\mathtrial
122 \def\\##1{2/##1+}\mathtrial
123 \def\\##1{##1,{}+}\mathtrial
124 \def\\##1{d##1+}\mathtrial
125 \let\ii=\imath \let\jj=\jmath \def\\##1{\hat##1+}\mathtrial}
126 \newcount\skewtrial \skewtrial='177
127 \def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L \\M \\N \\O
128 \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z \\a \\b \\c \\d \\e \\f \\g
129 \\h \\\ii \\\jj \\k \\l \\m \\n \\o \\p \\q \\r \\s \\t \\u \\v \\w \\x \\y
130 \\z \\\alpha \\\beta \\\gamma \\\delta \\\epsilon \\\zeta \\\eta \\\theta
131 \\\iota \\\kappa \\\lambda \\\mu \\\nu \\\xi \\\pi \\\rho \\\sigma \\\tau
132 \\\upsilon \\\phi \\\chi \\\psi \\\omega \\\vartheta \\\varpi \\\varphi
133 \\\Gamma \\\Delta \\\Theta \\\Lambda \\\Xi \\\Pi \\\Sigma \\\Upsilon
134 \\\Phi \\\Psi \\\Omega \\\partial \\\ell \\\wp$\par}
135 \def\mathsy{\begingroup\skewtrial='060 % for math symbol font tests
136 \def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L
137 \\M \\N \\O \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z$\par}
138 \math\endgroup}
139
140 \def\oct#1{\hbox{\rm\'{}\kern-.2em\it#1\/\kern.05em}} % octal constant
141 \def\hex#1{\hbox{\rm\H{}\tt#1}} % hexadecimal constant
142 \def\setdigs#1"#2{\gdef\h{#2}% \h=hex prefix; \0\1=corresponding octal
143 \m=\n \divide\m by 64 \xdef\0{\the\m}%
144 \multiply\m by-64 \advance\m by\n \divide\m by 8 \xdef\1{\the\m}}
145 \def\testrow{\setbox0=\hbox{\penalty 1\def\\{\char"\h}%
146 \\0\\1\\2\\3\\4\\5\\6\\7\\8\\9\\A\\B\\C\\D\\E\\F%
147 \global\p=\lastpenalty}} % \p=1 if none of the characters exist
148 \def\oddline{\cr
149 \noalign{\nointerlineskip}
150 \multispan{19}\hrulefill&
151 \setbox0=\hbox{\lower 2.3pt\hbox{\hex{\h x}}}\smash{\box0}\cr
152 \noalign{\nointerlineskip}}
153 \newif\ifskipping
154 \def\evenline{\loop\skippingfalse
155 \ifnum\n<256 \m=\n \divide\m 16 \chardef\next=\m
156 \expandafter\setdigs\meaning\next \testrow
157 \ifnum\p=1 \skippingtrue \fi\fi
158 \ifskipping \global\advance\n 16 \repeat
159 \ifnum\n=256 \let\next=\endchart\else\let\next=\morechart\fi
160 \next}
161 \def\morechart{\cr\noalign{\hrule\penalty5000}
162 \chartline \oddline \m=\1 \advance\m 1 \xdef\1{\the\m}
163 \chartline \evenline}
164 \def\chartline{&\oct{\0\1x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&}
165 \def\chartstrut{\lower4.5pt\vbox to14pt{}}
166 \def\table{$$\global\n=0
167 \halign to\hsize\bgroup
168 \chartstrut##\tabskip0pt plus10pt&
169 &\hfil##\hfil&\vrule##\cr
170 \lower6.5pt\null
171 &&&\oct0&&\oct1&&\oct2&&\oct3&&\oct4&&\oct5&&\oct6&&\oct7&\evenline}
172 \def\endchart{\cr\noalign{\hrule}
173 \raise11.5pt\null&&&\hex 8&&\hex 9&&\hex A&&\hex B&
174 &\hex C&&\hex D&&\hex E&&\hex F&\cr\egroup$$\par}
175 \def\:{\setbox0=\hbox{\noboundary\char\n\noboundary}%
176 \ifdim\ht0>7.5pt\reposition
177 \else\ifdim\dp0>2.5pt\reposition\fi\fi
178 \box0\global\advance\n 1 }
179 \def\reposition{\setbox0=\vbox{\kern2pt\box0}\dim=\dp0
180 \advance\dim 2pt \dp0=\dim}
181 \def\centerlargechars{
182 \def\reposition{\setbox0=\hbox{$\vcenter{\kern2pt\box0\kern2pt}$}}}
183
184 \def\text{{\advance\baselineskip-4pt
185 \setbox0=\hbox{abcdefghijklmnopqrstuvwxyz}
186 \ifdim\hsize>2\wd0 \ifdim 15pc>2\wd0 \hsize=15pc \else \hsize=2\wd0 \fi\fi
187 On November 14, 1885, Senator \& Mrs.~Leland Stanford called
188 together at their San Francisco mansion the 24~prominent men who had
189 been chosen as the first trustees of The Leland Stanford Junior University.
190 They handed to the board the Founding Grant of the University, which they
191 had executed three days before. This document---with various amendments,
192 legislative acts, and court decrees---remains as the University's charter.
193 In bold, sweeping language it stipulates that the objectives of the University
194 are ``to qualify students for personal success and direct usefulness in life;
195 and to promote the publick welfare by exercising an influence in behalf of
196 humanity and civilization, teaching the blessings of liberty regulated by
197 law, and inculcating love and reverence for the great principles of
198 government as derived from the inalienable rights of man to life, liberty,
199 and the pursuit of happiness.'' \moretext
200 (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)\par}}
201 \def\moretext{?`But aren't Kafka's Schlo{\ss} and {\AE}sop's {\OE}uvres
202 often na{\"\i}ve vis-\`a-vis the d{\ae}monic ph{\oe}nix's official r\^ole
203 in fluffy souffl\'es? }
204 \def\omitaccents{\let\moretext=\relax}
205
206 \def\sample{\table\text}
207
208 \ifx\noinit!\else\init\fi