
% csfontsm.tex, October 2012,    Petr Olsak (Ol\v s\'ak)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file is a part of csplain used during format generation.
%
% Usage: \def\sizespec{at14pt}\resizefont\tenrm
% after this, the \tenrm font selector switches to csr10 at14pt
%
% The \resizefont macro takes the font selector declared by \font, uses the
% same font but re-sets this selector to (probably) new font size declared
% in the \sizespec macro. You can \def\sizespec{at<dimen>} or
% \def\sizespec{magstep<number>}. The \resizefont's setting is done
% locally, it means that you can do (for instance):
%
% {\def\sizespec{scaled\magstep3}\resizefont\tenbf \tenbf Title text}
%
% The \resizeall macro resizes the \tentt, \tenrm, \tenit, \tenbf, \tenbi
% font selectors by currently defined \sizespec.
% The \regfont adds a new `registered' font-selector to the \resizeall macro
% The font-loading macros can register their fonts by \regfont.

\def\sizespec{}  % by default: fonts are loaded in their implicit sizes

\def\resizefont #1{\expandafter
  \font\expandafter#1\expandafter\resizefontskipat\fontname#1 \relax}
\def\resizefontskipat#1 #2\relax{#1 \sizespec\relax}

\font\tenbi=csbxti10  % it may be usable to have 
                      % the quartet \rm \it \bf \bi preloaded
\def\bi{\tenbi}       % math \fam\bifam is not preloaded now

\def\regfont#1{\expandafter\def\expandafter\resizeall\expandafter{%
  \resizeall \resizefont#1}}

\def\resizeall{}

\regfont\tenrm \regfont\tenit \regfont\tenbf \regfont\tenbi
\regfont\tentt

% You can use: \letfont \titlefont = \tenbf at15pt

\def\letfont #1{%
  \def\tmp##1 {\let\tmp\sizespec \def\sizespec{##1}\resizefont#1\let\sizespec\tmp}%
  \afterassignment\tmp \let#1}

\endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The notice about resizing the current font.

You can't use \expandafer \resizefont \the\font because \the\font expands to
the token with internal meaning: ``current font'' and with external
representation \fontselector where \fontselector is the control sequence
used by primitive \font as a parameter. The internal meaning has a
precedence and the token \the\font is inaccesible. You can make an accesible
control sequence by re-packing it by \csname...\endcsname. Thus the macro
\currsize{<size>} which sets the typesetting of the current font to the
desired <size> may be:

\def\currsize#1{%
  {\escapechar=-1\xdef\tmp{\csname\expandafter\string\the\font\endcsname}}%
  \def\sizespec{at#1}\expandafter\resizefont\tmp \tmp}

or:

\def\currsize#1{%
  \expandafter\let \expandafter\tmp \the\font
  \def\sizespec{at#1}\resizefont\tmp \tmp}


% end of csfontsm.tex

