% FontSampler.TeX --- Stolfi March 28, 1984 11:56:42 am PST
% Generates a font sampler sheet
% FONT SAMPLING MACROS
% Tick marks
\newbox\ltick \setbox\ltick\hbox to 0pt{\hss
\vrule width 3pt height0.1pt depth 0.1pt\kern 2pt}
\ht\ltick=0pt \dp\ltick=0pt
\newbox\laxis \setbox\laxis\hbox to 0pt{\hss
\vrule width 6pt height0.1pt depth 0.1pt\kern 6pt}
\ht\laxis=0pt \dp\laxis=0pt
\newbox\rtick \setbox\rtick\hbox to 0pt{\kern 2pt
\vrule width 3pt height0.1pt depth 0.1pt\hss}
\ht\rtick=0pt \dp\rtick=0pt
\newbox\raxis \setbox\raxis\hbox to 0pt{\kern 6pt
\vrule width 6pt height0.1pt depth 0.1pt\hss}
\ht\raxis=0pt \dp\raxis=0pt
\newbox\utick \setbox\utick\hbox to 0pt{\kern-0.1pt
\vrule height 5pt width0.2pt depth -2pt}
\ht\utick=0pt \dp\utick=0pt \wd\utick=0pt
\newbox\dtick \setbox\dtick\hbox to 0pt{\kern-0.1pt
\vrule height -2pt width0.2pt depth 5pt}
\ht\dtick=0pt \dp\dtick=0pt \wd\dtick=0pt
% Make character box with ticks and leave it in box 0
\def\charinbox#1{\setbox2\hbox{\zefont\char#1}\setbox4\vbox to 0pt
{\vskip-\ht2
\copy\ltick
\vskip\ht2
\copy\laxis
\vskip\dp2
\copy\ltick\copy\dtick\vskip-\dp2}\setbox6\vbox to 0pt
{\vskip0pt
\copy\raxis
\vskip\dp2
\copy\dtick
\vskip-\dp2}\setbox0\hbox{\box4\box2\box6}}
% Make font table
\newtoks\tbody
\newtoks\lbody
\newcount\rowix
\newcount\fcol
\newcount\lcol
\newcount\colix
\def\maketablebody[#1-#2,#3-#4]{
\global\tbody={}
\makeheaderline[#3-#4]
\global\tbody=\expandafter{\the\lbody}
\rowix=#1\relax
\loop\fcol=\rowix\advance\fcol by#3
\lcol=\rowix\advance\lcol by #4\relax
\maketableline
\edef\foobaz{\the\tbody\the\lbody}
\global\tbody=\expandafter{\foobaz}
\ifnum\rowix<#2
\advance\rowix by 8
\repeat
}
\def\makeheaderline[#1-#2]{{
\count0=#1\relax
\global\lbody={\omit\hfil}
\loop
\global\lbody=\expandafter{\the\lbody&\omit\hfil}
\expandafter\aplbody\number\count0\cr
\global\lbody=\expandafter{\the\lbody\hfil}
\ifnum\count0<#2
\advance\count0 by 1
\repeat
\global\lbody=\expandafter{\the\lbody\cr
\noalign{\vskip5pt\hrule}}}}
\def\aplbody#1\cr{\global\lbody=\expandafter{\the\lbody #1}}
\def\maketableline{{
\colix=\fcol
\global\lbody={}
\expandafter\aplbody\number\rowix\cr
\loop
\global\lbody=\expandafter{\the\lbody&}
\expandafter\aplbody\number\colix\cr
\ifnum\colix<\lcol
\advance\colix by 1
\repeat
\global\lbody=\expandafter{\the\lbody\cr\noalign{\hrule}}}}
\def\printfontsample[#1-#2,#3-#4]{
\maketablebody[#1-#2,#3-#4]
{\offinterlineskip\tabskip=0pt
\halign{\vrule width0.5pt\quad\rq {\count0=## \octalll}
\quad\vrule width0.5pt&&\kern14pt
\vrule width0pt height25pt depth15pt
\charinbox{##}\hfil\ifdim 1\wd0>24pt\box0
\else\kern 12pt\kern-0.5\wd0\box0\kern-0.5\wd0\kern12pt\fi
\hfil\kern 14pt\vrule width0.5pt\cr\the\tbody}}}
\newif\ifsampletext
\def\samplefont#1{
\font\zefont=#1\relax
\headline={\hbox to 6.5truein{\hss\bigfont #1\hss}}

\null\vskip40pt\printfontsample['000-'070,0-7]
\ifsampletext\vskip30pt\penalty-300
{\zefont\baselineskip2.5ex \lineskip0.1ex\parskip 0.3ex

\leavevmode\sampletext\par}\fi \vfill\eject
\null\vskip40pt\printfontsample['100-'170,0-7] \vfill\eject
\null\vskip40pt\printfontsample['200-'270,0-7] \vfill\eject
\null\vskip40pt\printfontsample['300-'370,0-7] \vfill\eject}
\def\octalll{{\count2=\count0\divide\count0 by 8
\octall
\multiply\count0 by 8 \advance\count2 by -\count0
\number\count2}}
\def\octall{{\count2=\count0\divide\count0 by 8
\number\count0
\multiply\count0 by 8 \advance\count2 by -\count0
\number\count2}}
\def\sampletext{English words like `technology' stem from a Greek root beginning with the letters $\tau\epsilon\chi\ldots;$ and this same Greek word means art as well as technology. Hence the name \TeX, which is an uppercase form of $\tau\epsilon\chi.$\par
Insiders pronounce the $\chi$ of \TeX\ as a Greek chi, not as an `x', so that \TeX\ rhymes with the word blecchhh. It is the `ch' sound in Scottish words like `loch' or German words like `ach'; it's a Spanish `j' and a russian `kh'. When you say it correctly to your computer, the terminal may become slightly moist.}
% LOADS THE FONT
\font\bigfont=timesroman at 14truebp
\font\twelvei=ammi10 scaled \magstep1\relax
\textfont1=\twelvei
\message{\^^M Enter font specification:}
\read-1 to\fontspec
\sampletexttrue
\samplefont\fontspec
\par\vfill\bye