%\filename{fontswitchmacros.tex}
%\edited{last by stolfi on Sat May 30 02:36:47 1987}

% Macros for switching between font sizes

\catcode`@=11 \endlinechar=-1

  % To be loaded after KernelMacros

  % This package does its best to simplify the switching between
  %
  %   three GROSS SIZES: big, normal, small;
  %   four MATH STYLES: text (non-math), base (math text + display),
  %                       script (sub + super), scriptscript; and
  %   many FONT STYLES: roman, math italic, symbols, text italic, bold, etc.

  % Note: specialized fonts (for titles, flowers, etc.) that aren't
  % supposed to change with the gross size or with the math style
  % should be defined elsewhere.  The only exception are the math
  % extension fonts, which have a special meaning to TeX.
  % See below.  
  
  % This package assumes the client will load the appropriate fonts for
  % all 3*4*n combinations of gross size, math style, and font style.
  % Their names should be of the form \xxYYzzfont, where
  %
  %   xxx is the gross size (big, nor, sma)
  %
  %   YY is the math style (TX, BA, SC, SS)
  %
  %   zz is the font style (rm, mi, sy, ti, bf, etc.)
  %
  % Fonts that are not available should be explicitly declared to be null,
  %     e.g.     \let\bigSStifont=\nullfont

  % To add anew font style zz, the client must create a separate file which
  %
  %      1. loads (or equates to \nullfont) the fonts \xxxYYzzfont,
  %
  %      2. Allocates a new family for style zz: \newfam\zzfam,
  %
  %      3. Defines the macro \zz,
  %
  %      4. Extends the macros \xxxsizeswitch appropriately,
  %
  % all this for xxx=(big, sma, nor) and YY=(TX, BA, SC, SS).
  % For the proper way to do steps 3 and 4, see ambf10fonts.tex
  % and bffontmacros.tex.

  % The most useful macros defined in this package are
  %   \bigsize, \normalsize, \smallsize: select gross size
  %   \bigger, \smaller: step up/down the current gross size

  % The math style is changed by entering/leaving math mode,
  % entering/leaving superscripts, or by the standard TeX macros
  % \displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle.  

  % Other macros (mostly for internal use) are
  %  * Affected by change in gross size:
  %   \cursize: defined to \bigsize, \normalsize, or \smallsize
  %   \resetlinesep: resets linesep, parsep, etc to values appropriate to
  %     the current gross size.
  %   For zz = rm, mi, sy, ti, bf, etc.:
  %     \zzfont=                 either \bigTXzzfont, norTXzzfont, smaTXzzfont
  %     \basefont\zzfam=         either \bigBAzzfont, norBAzzfont, smaBAzzfont
  %     \scriptfont\zzfam=       either \bigSCzzfont, norSCzzfont, smaSCzzfont
  %     \scriptscriptfont\zzfam= either \bigSSzzfont, norSSzzfont, smaSSzzfont
  %
  %  * Affected by change in font style:
  %     \curstyle: defined to be either \rm, \mi, \sy, \ti, \bf, etc.
  %     \fam: either \rmfam, \mifam, \syfam, \tifam, \bifam, etc.

  % A note on families:

  % If you say \fam=<number>, this will set the standard family for
  % math to <number> This will affect all characters whose math class
  % (first digit of mathcode) is 7, usually letters and digits.  
  % 
  % If \fam is not defined, TeX will use the character's default
  % family, that is the second digit of the character's mathcode.
  % Usually this is 0 (\rmfam) for digits, and 1 (\mifam) for
  % letters.  Note that \fam is reset to -1 (undefined) whenever math
  % mode is entered.  
  
  % The \zz macro defined in step 3 of the recipe above changes both
  % the current math family and the current text font.  Note that
  % \basefont\rmfam is almost required to be a standard TeX font., but
  % \rmfont may be different from \basefont\rmfam.  Same for other
  % styles.  Characters whose class is not 7 get always the family
  % specified in their mathcode, so they are not affected by the \zz
  % macros.

  % Family 3 has a special meaning for TeX: it is used to obtain
  % extension characters. Normally it uses the same font
  % for all gross sizes and math styles, so it doesn't enter in the
  % above font switching mechanisms.

% PARAMETERS TO BE DEFINED BY CLIENT

  %  (in addition to the fonts as explained above)

  \message{parameters ...}

  % Strut boxes

    \newbox\bigstrutbox
    \newbox\normalstrutbox
    \newbox\smallstrutbox

  % Interline glue parameters

    \newglue\bigbaselinesep
    \newglue\biglinesep % also normal \lineseplimit
    \newglue\bigparsep

    \newglue\normalbaselinesep
    \newglue\normallinesep % also normal \lineseplimit
    \newglue\normalparsep

    \newglue\smallbaselinesep
    \newglue\smalllinesep
    \newglue\smallparsep

% SIZE SWITCHING MACROS

  \message{size switching ...}

  % Big size

    \def\bigsizeswitch{} % This will be extended by each font package

    \def\bigsetlinesep{
      \baselinesep\bigbaselinesep
      \linesep\biglinesep
      \parsep\bigparsep
      \lineseplimit0.5\biglinesep
    }

    \def\bigsize{
      
      % Change fonts:
      
      \bigsizeswitch 
      
      % Change glue and dimension parameters:

      \setbox\strutbox=\copy\bigstrutbox
      \let\cursize=\bigsize
      \let\bigger=\undefined \let\smaller=\normalsize
      \let\resetlinesep=\bigsetlinesep
      \curstyle\resetlinesep
    }

  % Normal size

    \def\norsizeswitch{} % This will be extended by each font package

    \def\norsetlinesep{
      \baselinesep\normalbaselinesep
      \linesep\normallinesep
      \parsep\normalparsep
      \lineseplimit0.5\normallinesep
    }

    \def\normalsize{

      % Change fonts:

      \norsizeswitch

      % Change glue and dimension parameters:

      \setbox\strutbox=\copy\normalstrutbox
      \let\cursize=\normalsize
      \let\bigger=\bigsize \let\smaller=\smallsize
      \let\resetlinesep=\norsetlinesep
      \curstyle\resetlinesep
    }

  % Small size
    
    \def\smasizeswitch{} % This will be extended by each font package

    \def\smasetlinesep{
      \baselinesep\smallbaselinesep
      \linesep\smalllinesep
      \parsep\smallparsep
      \lineseplimit0.5\smalllinesep
    }

    \def\smallsize{

      % Change fonts:
      
      \smasizeswitch

      % Change glue and dimension parameters:

      \setbox\strutbox=\copy\smallstrutbox
      \let\cursize=\smallsize
      \let\bigger=\normalsize \let\smaller=\undefined
      \let\resetlinesep=\smasetlinesep
      \curstyle\resetlinesep
    }

% FONT LOADING MACROS

  %  (in addition to the fonts as explained above)

  % The call \loadfonts{zz} will load the macros that define all fonts
  % of style zz.  Before using it, be sure to define \designsize, the
  % basic design point size (e.g., 10 or 11) of the work, and
  % \fontpackage, the font package prefix ("am" for Almost Modern fonts,
  % "cm" for Computer Modern, "tr" for Times Roman, etc.

  \ifx\designsize\und@fined
    \def\designsize{10} % In case the client forgets
  \fi
  \ifx\fontpackage\und@fined
    \def\fontpackage{cm}
  \fi
 
  \def\loadfonts#1{
    \expandafter\ifx\csname norTX#1font\endcsname\relax
      \let\next=\fontpackage
      \input /home/staff/stolfi/tex/su/\next fonts/\next #1\designsize fonts
      \relax 
      \normalsize\rm
    \fi
  }

\catcode`@=12 \endlinechar=`\^^M

% END
