% make a (fairly large) font chart

\newlinechar=`@
\message{@Name of the font to chart = }
\read-1 to \fontname

\font\f=\fontname at .75in
\f

% Here's the best way I know to discover character height and depth
% when they are possibly negative.
\fontdimen5\f=-10000pt % a new (rather small) xheight
\textfont0=\f
\newdimen\h \newdimen\d % will be set to the character's height, depth
\def\htdp#1{\setbox0=\hbox{\char#1}\h=-\ht0
 \setbox0=\hbox{\accent#1\char#1}\advance\h\ht0 \advance\h-10000pt
 \setbox0=\null \wd0=-10000pt % in case the character has a charlist!
 \setbox0=\hbox{$\mathaccent#1{\box0}$}%
 \d=\ht0 \advance\d-10000pt \advance\d-\h}

% (By the way, my previous best was this:
% \textfont15=\f % use family "F
% \fontdimen8\tenex=0pt % set defaultrulethickness zero
% \setbox1=\null \ht1=-10000pt \setbox2=\null \dp3=-10000pt
% \newdimen\d \newdimen\h \newcount\n
% \n=#1 \advance\n"F00
% \setbox0=\hbox{$\radical\n{\copy1}$}
% \d=\dp0 \advance\d-5000pt \advance\d\d %\showthe\d
% \setbox0=\hbox{$\radical\n{\copy2}$}
% \h=\ht0 \advance\h-5000pt \advance\h-.5\d
% \ifdim\h>0pt \h=.5\h \fi
% ....very tricky! But it works only when height+depth is positive.)

\tracinglostchars=0
\nopagenumbers

\def\testrow#1#2{\setbox0=\hbox{\penalty1\def\\{\char'#1#2}%
 \\0\\1\\2\\3\\4\\5\\6\\7\global\chardef\p=\lastpenalty}} % p=1 if none there

\raggedbottom
\baselineskip=1in
\topskip=.75in
\newdimen\w \w=.75in
\headline={\vtop{\hbox{\tt\fontname\unskip, page \folio\hfil}
  \kern-.75in\unitsdigits}\hss}
\footline={\unitsdigits\hss}
\def\unitsdigits{\hbox{\kern.3in \tt
 \hbox to\w{\ \ 0\hss}%
 \hbox to\w{\ \ 1\hss}%
 \hbox to\w{\ \ 2\hss}%
 \hbox to\w{\ \ 3\hss}%
 \hbox to\w{\ \ 4\hss}%
 \hbox to\w{\ \ 5\hss}%
 \hbox to\w{\ \ 6\hss}%
 \hbox to\w{\ \ 7\hss}}}

\def\row#1#2{\testrow#1#2%
\ifnum\p=0\hbox{\hbox to.3in{\tt#1#2\hfil}%
 \mod#1#20\mod#1#21\mod#1#22\mod#1#23\mod#1#24\mod#1#25\mod#1#26\mod#1#27%
 \hbox to.3in{\tt\hfil#1#2}}\fi}

\newdimen\pixel \pixel=.00333333in
\def\mod#1#2#3{\chardef\c='#1#2#3 \htdp\c
 \setbox0=\hbox{\penalty1\c\global\chardef\p=\lastpenalty}%
 \ifnum\p=1 \hbox to\w{}\else
 \setbox2=\hbox{\c\/}%
 \hbox to\w{\kern-\pixel \vrule width\pixel height\h depth\d
  \copy\leftbox\copy0\copy\rightbox
  \vrule width\pixel height\h depth\d \kern-\pixel \kern-\wd0
  \raise\h\vbox{\hrule height\pixel width\wd0}\kern-\wd0
  \lower\d\vbox{\hrule height0pt depth\pixel width\wd0}\kern-\wd0
  \ifdim\wd2>\wd0 \kern\wd2\raise\h\copy\icbox \fi
  \hss}\fi}

\newbox\leftbox % marking the baseline at the left
\setbox\leftbox=\hbox{\kern-\pixel\vrule width\pixel height4pt
  \vrule height0pt depth\pixel width4pt \kern-4pt}
\newbox\rightbox % marking the baseline at the right
\setbox\rightbox=\hbox{\kern-4pt\vrule height0pt depth\pixel width4pt
  \vrule width\pixel height4pt \kern-\pixel}
\newbox\icbox % the mark of an italic correction
\setbox\icbox=\hbox{\kern-4pt\vrule height\pixel width4pt depth0pt
  \vrule width\pixel depth4pt}

\row00 \row01 \row02 \row03 \row04 \row05 \row06 \row07
\row10 \row11 \row12 \row13 \row14 \row15 \row16 \row17
\row20 \row21 \row22 \row23 \row24 \row25 \row26 \row27
\row30 \row31 \row32 \row33 \row34 \row35 \row36 \row37
\bye
