% fntproof.tex
%
% Copyright 2010 by Daniel H. Luecking. Placed in the public domain.
% If you make any changes, please remove or modify this copyright notice
% before distributing your version, preferably with a different name.
%
% This is a noninteractive version of testfont.tex. Instead of prompting
% for font names and commands, the user supplies them on the command
% line, or in a file.
%
%
% Original testfont.tex comment:
% A testbed for font evaluation (see The METAFONTbook, Appendix H)
%
% (Most code changes from testfont.tex are explained in comments preceded
% by "%DHL:")
%
\def\fntproofversion{1.0}
\immediate\write16{This is fntproof.tex, version \fntproofversion.}
\tracinglostchars=0
\tolerance=1000
\raggedbottom
\parindent=0pt
\hyphenpenalty=200
\doublehyphendemerits=30000
\hyphenation{prom-i-nent}%
%
\newcount\m \newcount\n \newcount\p \newdimen\dim
\chardef\other=12
%
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}%
\def\hours{\n=\time \divide\n 60
  \m=-\n \multiply\m 60 \advance\m \time
  \twodigits\n\twodigits\m}%
\def\twodigits#1{\ifnum #1<10 0\fi \number#1}%
%
%DHL: These are used to sanitize the fontname.
%  Odd capitals to avoid overwriting other's macros (Knuth's own 
%  overwriting notwithstanding :)
\def\sTripprefix#1>{}%
\def\sAnitize#1{\edef#1{\expandafter\sTripprefix\meaning#1}}
\def\gobble#1{}%
\def\firstofone#1{#1}%
%
% Modified from ifmtarg.sty, works around certain errors.
\begingroup
  \catcode`\Q=3
  \long\gdef\xifmtarg#1#2Q#3#4#5\relax{#4}%
  \long\gdef\ifnotempty#1{\xifmtarg#1QQ\firstofone\gobble\relax}%
\endgroup
%
%DHL: For debug purposes: a command to read and show the file name.
% This to test whether TeX special characters in the font name are
% properly handled.
%\def\showfont{%
%  \begingroup
%    \def\do##1{\catcode`##1=\other}\dospecials
%    \catcode`\ =10\relax\xshowfont
%}%
%\def\xshowfont#1 {%
%    \newlinechar`\^^J%
%    \message{^^J --> Font name #1 read from command line. <--^^J}%
%  \endgroup
%}%
%
%DHL: \init will not prompt, but just read up to the next space.
% We allow anything but whitespace in a filename. The filename argument
% (of \xinit) is delimited by the next space. Alternatively, an
% initial left brace is assumed to be grouping around the full font 
% name. In that case, \yinit reads the whole group
\def\init{\futurelet\next\doinit}% to see if a brace follows
\def\doinit{%
  \begingroup
    \def\do##1{\catcode`##1=\other}\dospecials\catcode`\ =10\relax
    \ifx\next\bgroup
       \catcode`\{=1 \catcode`\}=2
       \expandafter\yinit
    \else
      \expandafter\xinit
    \fi}
\def\yinit #1{\fininit{#1}}%
\def\xinit#1 {\fininit{#1}}%
\def\fininit#1{%
  \def\thisfont{#1}\sAnitize\thisfont\global\let\thisfont\thisfont
  \endgroup
  \par\everypar{}%
  \startfont
}%
%
%DHL:
% This defines \everypar so that the first fontname triggers \init,
% a lot like mproof.tex.
\def\Init{\par\everypar{{\setbox0\lastbox}\everypar{}\init}}%
%
%DHL: \startfont is identical to the one in testfont.tex, except I've 
% added a \filbreak between fonts and a conditional to turn off the
% header.
\def\startfont{\font\testfont=\thisfont \spaceskip=0pt
  \filbreak
  \ifheaders \par
  \leftline{\sevenrm Test of \thisfont\unskip\ on \today\ at \hours}%
  \fi
  \medskip
  \testfont \setbaselineskip
  \ifdim\fontdimen6\testfont<10pt \rightskip=0pt plus 20pt
  \else\rightskip=0pt plus 2em \fi
  \spaceskip=\fontdimen2\testfont % space between words (\raggedright)
  \xspaceskip=\fontdimen2\testfont \advance\xspaceskip by\fontdimen7\testfont}%
%
\newif\ifheaders \headerstrue
%DHL:
% \getthisfont defines \thisfont to be the \fontname of the current 
% font. Unlike \init it does not sanitize \thisfont as \fontname returns 
% category 12 characters. 
% 
% \initcurrentfont performs the functions of \init on the current font, 
% including defining \thisfont.
% 
% \theheader prints the header even when \headersfalse was issued. It 
% requires a definition for \thisfont.
\def\getthisfont{\edef\thisfont{\fontname\font}}%
\def\initcurrentfont{\noinit\getthisfont\startfont}%
\def\theheader{%
  \leftline{\sevenrm Test of \thisfont\ on \today\ at \hours}}%
%
%DHL:
% One change to \help is use of "^^J" instead of "@" as \newlinechar.
% Since no other command needs this, I have made it a local assignment.
% I've added some delimiting lines as well.
\begingroup
\catcode`\|=0 \catcode`\\=\other
|gdef|help{{|newlinechar`^^J|message{^^J%
===  Main commands  ==============^^J%
\init switches to another font;^^J%
\end or \bye finishes the run;^^J%
\table prints the font layout in tabular format;^^J%
\fonttable must be used instead of \table in LaTeX;^^J
\text prints a sample text, assuming TeX text font conventions;^^J%
\sample combines \table and \text;^^J%
\mixture mixes a background character with a series of others;^^J%
\alternation interleaves a background character with a series;^^J%
\alphabet prints all lowercase letters within a given background;^^J%
\ALPHABET prints all uppercase letters within a given background;^^J%
\series prints a series of letters within a given background;^^J%
\lowers prints a comprehensive test of lowercase;^^J%
\uppers prints a comprehensive test of uppercase;^^J%
\digits prints a comprehensive test of numerals;^^J%
\math prints a comprehensive test of TeX math italic;^^J%
\names prints a text that mixes upper and lower case;^^J%
\punct prints a punctuation test;^^J%
\bigtest combines many of the above routines;^^J%
\help repeats this message;^^J%
and you can use ordinary TeX commands (e.g., to \input a file).^^J%
===  More commands  ==============^^J%
\noinit turns off automatic initialization of the first word as a font;^^J%
\headersfalse \headerstrue turn off/resume printing of header text;^^J%
\theheader print the header text;^^J%
\thisfont print the name of font specified by \init;^^J%
\getthisfont define \thisfont to be the current font;^^J%
==================================^^J^^J}}}%
|endgroup
%
\def\setbaselineskip{\setbox0=\hbox{\n=0
\loop\char\n \ifnum \n<255 \advance\n 1 \repeat}
\baselineskip=6pt \advance\baselineskip\ht0 \advance\baselineskip\dp0 }%
%
%DHL: This is used just before reading character arguments.
\def\beginspecial{%
  \begingroup
  \def\do##1{\catcode`##1=\other}\dospecials
  \catcode`\{=1\catcode`\}=2\catcode`\\=0\catcode`\ =10
}%
\let\endspecial\endgroup
%
%DHL:
% We delay reading anything until the \catcode changes in \beginspecial.
\long\def\setchar{\beginspecial\Xsetchar}%
%
%DHL:
% #1 is the character name (\background, \starting or \ending)
% #2 is the command to be run after the characters are "set".
% #3 is the actual character.
% Calls \dosetchar, then ends group and issues saved command
\long\def\Xsetchar#1#2#3{\dosetchar#1{#3}\endspecial#2}%
%
%DHL:
% #1 as in \Xsetchar
% #2 actual character
% Inserts character as a delimited parameter for \finsetchar
% We could do all this in \Xsetchar, but I needed to isolate
% this part for use in \getthree.
\def\dosetchar#1#2{%
  \def\next{#2}\expandafter\finsetchar\next\next#1}%
%
%DHL:
% #1 is first token of character, #2 is the rest, possibly empty
% #3 is the character command (same as #1 in \setchar).
% If the first part is #, and the rest is not empty, assume the rest is
% a number.
\def\finsetchar#1#2\next#3{\global\chardef#3=`#1
  \ifnum #3=`\#\relax \ifnotempty{#2}{\global\chardef#3=#2\relax}\fi}%
%
%DHL:
% As \setchar no longer prompts for input, \promptthree is
% changed to \getthree.
\def\getthree{%
  \beginspecial
    \dogetthree
}%
\long\def\dogetthree#1#2#3#4{%
    \dosetchar\background{#2}%
    \dosetchar\starting{#3}%
    \dosetchar\ending{#4}%
  \endspecial#1%
}%
%DHL: The commands themselves. Very few changes at from here
% to the end.
%
%DHL:
% Extra braces in \mixture and \alternation because \getthree takes
% the code to run as an argument. This is so it can get at the character
% arguments that follow.
\def\mixture{\getthree{\domix\mixpattern}}%
\def\alternation{\getthree{\domix\altpattern}}%
\def\mixpattern{\0\1\0\0\1\1\0\0\0\1\1\1\0\1}%
\def\altpattern{\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0}%
\def\domix#1{\par\chardef\0=\background \n=\starting
  \loop \chardef\1=\n #1\endgraf
  \ifnum \n<\ending \advance\n 1 \repeat}%
%
\def\!{\discretionary{\background}{\background}{\background}}%
%DHL: Extra braces in \series also. Same reason as above.
\def\series{\getthree{\!\doseries\starting\ending\par}}%
\def\doseries#1#2{\n=#1\loop\char\n\!\ifnum\n<#2\advance\n 1 \repeat}%
\def\complower{\!\doseries{`a}{`z}\doseries{'31}{'34}\par}%
\def\compupper{\!\doseries{`A}{`Z}\doseries{'35}{'37}\par}%
\def\compdigs{\!\doseries{`0}{`9}\par}%
\def\alphabet{\setchar\background\complower}%
\def\ALPHABET{\setchar\background\compupper}%
%
\def\lowers{\docomprehensive\complower{`a}{`z}{'31}{'34}}%
\def\uppers{\docomprehensive\compupper{`A}{`Z}{'35}{'37}}%
\def\digits{\docomprehensive\compdigs{`0}{`4}{`5}{`9}}%
\def\docomprehensive#1#2#3#4#5{\par\chardef\background=#2
  \loop{#1} \ifnum\background<#3\m=\background\advance\m 1
  \chardef\background=\m \repeat \chardef\background=#4
  \loop{#1} \ifnum\background<#5\m=\background\advance\m 1
  \chardef\background=\m \repeat}%
%
\def\names{ {\AA}ngel\aa\ Beatrice Claire
  Diana \'Erica Fran\c{c}oise Ginette H\'el\`ene Iris
  Jackie K\=aren {\L}au\.ra Mar{\'\i}a N\H{a}ta{\l}{\u\i}e {\O}ctave
  Pauline Qu\^eneau Roxanne Sabine T\~a{\'\j}a Ur\v{s}ula
  Vivian Wendy Xanthippe Yv{\o}nne Z\"azilie\par}%
\def\punct{\par\dopunct{min}\dopunct{pig}\dopunct{hid}%
  \dopunct{HIE}\dopunct{TIP}\dopunct{fluff}%
  \$1,234.56 + 7/8 = 9\% @ \#0\par}%
\def\dopunct#1{#1,\ #1:\ #1;\ `#1'\ ?`#1?\ !`#1!\ (#1)\ [#1]\ #1*\ #1.\par}%
%
\def\bigtest{\sample
  hamburgefonstiv HAMBURGEFONSTIV\par
  \names \punct \lowers \uppers \digits}%
%
\def\math{\textfont1=\testfont \skewchar\testfont=\skewtrial
 \mathchardef\Gamma="100 \mathchardef\Delta="101
 \mathchardef\Theta="102 \mathchardef\Lambda="103 \mathchardef\Xi="104
 \mathchardef\Pi="105 \mathchardef\Sigma="106 \mathchardef\Upsilon="107
 \mathchardef\Phi="108 \mathchardef\Psi="109 \mathchardef\Omega="10A
 \def\ii{i} \def\jj{j}
 \def\\##1{|##1|+}\mathtrial
 \def\\##1{##1_2+}\mathtrial
 \def\\##1{##1^2+}\mathtrial
 \def\\##1{##1/2+}\mathtrial
 \def\\##1{2/##1+}\mathtrial
 \def\\##1{##1,{}+}\mathtrial
 \def\\##1{d##1+}\mathtrial
 \let\ii=\imath \let\jj=\jmath \def\\##1{\hat##1+}\mathtrial}%
\newcount\skewtrial \skewtrial='177
\def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L \\M \\N \\O
 \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z \\a \\b \\c \\d \\e \\f \\g
 \\h \\\ii \\\jj \\k \\l \\m \\n \\o \\p \\q \\r \\s \\t \\u \\v \\w \\x \\y
 \\z \\\alpha \\\beta \\\gamma \\\delta \\\epsilon \\\zeta \\\eta \\\theta
 \\\iota \\\kappa \\\lambda \\\mu \\\nu \\\xi \\\pi \\\rho \\\sigma \\\tau
 \\\upsilon \\\phi \\\chi \\\psi \\\omega \\\vartheta \\\varpi \\\varphi
 \\\Gamma \\\Delta \\\Theta \\\Lambda \\\Xi \\\Pi \\\Sigma \\\Upsilon
 \\\Phi \\\Psi \\\Omega \\\partial \\\ell \\\wp$\par}%
\def\mathsy{\begingroup\skewtrial='060 % for math symbol font tests
 \def\mathtrial{$\\A \\B \\C \\D \\E \\F \\G \\H \\I \\J \\K \\L
  \\M \\N \\O \\P \\Q \\R \\S \\T \\U \\V \\W \\X \\Y \\Z$\par}
 \math\endgroup}%
%
\def\oct#1{\hbox{\rm\'{}\kern-.2em\it#1\/\kern.05em}}% octal constant
\def\hex#1{\hbox{\rm\H{}\tt#1}}% hexadecimal constant
\def\setdigs#1"#2{\gdef\h{#2}% \h=hex prefix; \0\1=corresponding octal
 \m=\n \divide\m by 64 \xdef\0{\the\m}%
 \multiply\m by-64 \advance\m by\n \divide\m by 8 \xdef\1{\the\m}}%
\def\testrow{\setbox0=\hbox{\penalty 1\def\\{\char"\h}%
 \\0\\1\\2\\3\\4\\5\\6\\7\\8\\9\\A\\B\\C\\D\\E\\F%
 \global\p=\lastpenalty}}% \p=1 if none of the characters exist
\def\oddline{\cr
  \noalign{\nointerlineskip}
  \multispan{19}\hrulefill&
  \setbox0=\hbox{\lower 2.3pt\hbox{\hex{\h x}}}\smash{\box0}\cr
  \noalign{\nointerlineskip}}%
\newif\ifskipping
\def\evenline{\loop\skippingfalse
 \ifnum\n<256 \m=\n \divide\m 16 \chardef\next=\m
 \expandafter\setdigs\meaning\next \testrow
 \ifnum\p=1 \skippingtrue \fi\fi
 \ifskipping \global\advance\n 16 \repeat
 \ifnum\n=256 \let\next=\endchart\else\let\next=\morechart\fi
 \next}%
\def\morechart{\cr\noalign{\hrule\penalty5000}
 \chartline \oddline \m=\1 \advance\m 1 \xdef\1{\the\m}
 \chartline \evenline}%
\def\chartline{&\oct{\0\1x}&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&\:&&}%
\def\chartstrut{\lower4.5pt\vbox to14pt{}}%
\def\fonttable{$$\global\n=0
  \halign to\hsize\bgroup
    \chartstrut##\tabskip0pt plus10pt&
    &\hfil##\hfil&\vrule##\cr
    \lower6.5pt\null
    &&&\oct0&&\oct1&&\oct2&&\oct3&&\oct4&&\oct5&&\oct6&&\oct7&\evenline}%
\def\endchart{\cr\noalign{\hrule}
  \raise11.5pt\null&&&\hex 8&&\hex 9&&\hex A&&\hex B&
  &\hex C&&\hex D&&\hex E&&\hex F&\cr\egroup$$\par}%
\def\:{\setbox0=\hbox{\noboundary\char\n\noboundary}%
  \ifdim\ht0>7.5pt\reposition
  \else\ifdim\dp0>2.5pt\reposition\fi\fi
  \box0\global\advance\n 1 }%
\def\reposition{\setbox0=\vbox{\kern2pt\box0}\dim=\dp0
  \advance\dim 2pt \dp0=\dim}%
\def\centerlargechars{
  \def\reposition{\setbox0=\hbox{$\vcenter{\kern2pt\box0\kern2pt}$}}}%
%
\def\text{{\advance\baselineskip-4pt
\setbox0=\hbox{abcdefghijklmnopqrstuvwxyz}
\ifdim\hsize>2\wd0 \ifdim 15pc>2\wd0 \hsize=15pc \else \hsize=2\wd0 \fi\fi
On November 14, 1885, Senator \& Mrs.~Leland Stanford called
together at their San Francisco mansion the 24~prominent men who had
been chosen as the first trustees of The Leland Stanford Junior University.
They handed to the board the Founding Grant of the University, which they
had executed three days before. This document---with various amendments,
legislative acts, and court decrees---remains as the University's charter.
In bold, sweeping language it stipulates that the objectives of the University
are ``to qualify students for personal success and direct usefulness in life;
and to promote the publick welfare by exercising an influence in behalf of
humanity and civilization, teaching the blessings of liberty regulated by
law, and inculcating love and reverence for the great principles of
government as derived from the inalienable rights of man to life, liberty,
and the pursuit of happiness.'' \moretext
(!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)\par}}%
\def\moretext{?`But aren't Kafka's Schlo{\ss} and {\AE}sop's {\OE}uvres
often na{\"\i}ve  vis-\`a-vis the d{\ae}monic ph{\oe}nix's official r\^ole
in fluffy souffl\'es? }%
\def\omitaccents{\let\moretext=\relax}%
%
\def\sample{\fonttable\text}%
%DHL: Adjustments for LaTeX:
\ifx\AtBeginDocument\UndEfInEd
  \let\table\fonttable
\else
  \ifx\sevenrm\UndEfInEd
    \def\sevenrm{\normalfont\fontfamily{cmr}\fontsize{7}{9}\selectfont}%
  \fi
\fi
%
%DHL:
% \Init causes first fontname to auto-\init itself. For this purpose, the
% fontname must begin with a character with category 11 or 12. As in
% testfont.tex, this can be turned off by \let\noinit! before this file is
% input. With fntproof, we  have the alternative of using the command
% \noinit *after* it is input.
\ifx\noinit!\else\Init\fi \def\noinit{\everypar{}}%
