%%% I need to be able to specify the width for text. I would like to %%% use the largest size (subject to a user specified maximum and %%% minimum). If the constraints mean that I cannot fill the width %%% then the text should be centered at the largest specified size. %%% %%% Phil Taylor January 1993 \catcode `\@ = 11 \newcount \r@mainder \newcount \m@gstepcount \newcount \m@gsteplimit \newcount \m@gstepvalue \newdimen \m@gstepdimen \def \magsteps {\afterassignment \m@gsteps \m@gsteplimit = } \def \m@gsteps {\let \@r = \or \def \or {\noexpand \or}% \m@gstepdimen = 0.166667 \maxdimen \m@gstepvalue = 1000 \m@gstepcount = 0 \def \magstep {}% \loop \ifnum \m@gstepcount < \m@gsteplimit \advance \m@gstepcount by 1 \ifnum \m@gstepvalue > \m@gstepdimen \advance \m@gstepcount by -1 \message {Sorry --- integer overflow would occur if I went any further; stopped at \the \m@gstepcount.} \m@gsteplimit = \m@gstepcount \else \multiply \m@gstepvalue by 12 \multiply \r@mainder by 12 \divide \r@mainder by 10 \advance \m@gstepvalue by \r@mainder \r@mainder = \m@gstepvalue \divide \m@gstepvalue by 10 \multiply \m@gstepvalue by 10 \advance \r@mainder by -\m@gstepvalue \divide \m@gstepvalue by 10 \ifnum \r@mainder < 5 \edef \magstep {\magstep \or \the \m@gstepvalue}% \else \advance \m@gstepvalue by 1 \edef \magstep {\magstep \or \the \m@gstepvalue}% \advance \m@gstepvalue by -1 \fi \fi \repeat \edef \magstep ##1% {\noexpand \ifcase ##1 1000\magstep \noexpand \else 0% \noexpand \message {Sorry --- \string \magstep \space ##1 is not in range 0 .. \the \m@gsteplimit}% \noexpand \fi \noexpand \relax }% \let \or = \@r } \catcode `\@ = 12 \magsteps 63 \newcount \loopcount \newdimen \thewidth \def \set #1 \in #2 \to %%% see example at end {\def \thetext {#1}% \def \thefont {#2 }% \afterassignment \settowidth \thewidth = } \def \settowidth {\loopcount = 0 \loop \message {Trying \noexpand \magstep \the \loopcount...}% \setbox 0 = \hbox {\font \tempfont = \thefont scaled \magstep \loopcount \tempfont \thetext }% \ifdim \wd 0 < \thewidth \advance \loopcount by 1 \repeat \advance \loopcount by -1 \message {The calculated font is \thefont \space scaled \noexpand \magstep \the \loopcount}% \hbox to \thewidth {\font \tempfont = \thefont scaled \magstep \loopcount \hss \tempfont \thetext \hss}% } \set Now is the time for \in cmr10 \to 50 cm