% \iffalse meta-comment
%
% Copyright (C) 1993 by LaTeX3 project.  All rights reserved.
% For additional copyright information see further down in this file.
% 
% This file is part of the LaTeX2e system (PRELIMINARY TEST RELEASE)
% ------------------------------------------------------------------
% 
%  This system is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
% 
% IMPORTANT NOTICE:
% 
% For error reports in case of UNCHANGED versions see readme files.
% 
% Please do not request updates from us directly.  Distribution is
% done through Mail-Servers and TeX organizations.
% 
% You are not allowed to change this file.
% 
% You are allowed to distribute this file under the condition that
% it is distributed together with all files mentioned in 00readme.l2e.
% 
% If you receive only some of these files from someone, complain!
% 
% You are NOT ALLOWED to distribute this file alone.  You are NOT
% ALLOWED to take money for the distribution or use of either this
% file or a changed version, except for a nominal charge for copying
% etc.
% \fi
\def\fileversion{v3.0b}
\def\filedate{1993/12/19}
\def\docdate {1993/12/19}

% \CheckSum{336}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \iffalse
% Copyright (C) 1993 Frank Mittelbach and Chris Rowley
% all rights reserved.
% \fi
% 
%
% \title{The \texttt{fontcmds} package  providing
%        NFSS2 font commands}
% \author{Frank Mittelbach \and Chris Rowley}
% \date{\filedate}
%
% \MakeShortVerb\|
%
% \def \ie {i.e.~}
% \def \eg {e.g.~}
% 
% \def \dst {{\normalfont\scshape docstrip}}
% \def \NFSS {\textsf{NFSS}}
% 
% \setcounter{StandardModuleDepth}{1}
%
% \changes{v2.0b}{1993/05/05}{Removed all LaTeX related cmds}
% \changes{v3.0a}{1993/12/11}{Complete reworking of all text commands,
% using just one creator function}
% \changes{v3.0a}{1993/12/11}{newfontswitch command corrected and changed}
% \changes{v3.0a}{1993/12/11}{newcommands replaced by defs}
% \changes{v3.0a}{1993/12/11}{italic correction now put in front of
% penalty before glue}
% \changes{v3.0b}{1993/12/19}{@pdef comand added}
% \changes{v3.0b}{1993/12/19}{Other tidying}
% \changes{3.0b}{1993/12/19}{Made `@newfontswitch produce an error if
%    the command already exists, and added `@renewfontswitch. ASAJ.}
% \changes{v3.0b}{1993/12/19}{Untidying added, so this is now a
%    TEMPORARY version.}
% \changes{v3.0b}{1993/12/19}{Some more tidying done.}
%
% \maketitle
%
% \begin{abstract}
%   The commands defined in this file \texttt{fontcmds} are
%   part of the kernel code for \LaTeXe/NFSS2. Therefore this package file
%   is needed only if you want to use them with some format that
%   does not run with NFSS2, e.g.\ with plain \TeX. However, in that
%   case some \LaTeX{} utility commands will also need to be defined.
%
%   It is also meant to serve as documentation for package writers since
%   it demonstrates how to define high-level font changing commands
%   using a small number of creator functions.
%
%   The high-level creation and setting commands probably need a
%   user-version of the form |\Declare...| or |\Set...|.
% \end{abstract}
%
% \section{Introduction}
%
% Font changes such as |\bfseries|, |\sffamily|, etc.\ are
% declarations; this means that their scope is delimited by the
% grouping structure, either by the next |\end| of some environment or
% by explicitly using a group, e.g., writing something like
% |{\bfseries...}| in the source. If you make the mistake of writing
% |\bfseries{...}| (thinking of |\bfseries| as a command with one
% argument) then the result is rather striking.
% 
% Font declarations are an artifact of the \TeX{} system and for
% several reasons it is better to avoid them on the user level
% whenever possible.  In \LaTeX3 they will probably all be
% replaced by environments and by font commands taking one argument.
% 
% This file defines a creator function for such declarative font switches.
% This function creates commands which can be used in both math and text.
% 
% This file also defines a number of high-level commands (all
% starting with |\text..|) that have one argument and typeset this
% argument in the requested way. Thus these commands are for
% typesetting short pieces of text in a specific family, series or
% shape.  These are all produced as examples of the use of a creator
% function which is itself also defined in this file.
% 
% Table~\ref{tab:fontcmds} shows all these high-level commands in action.
% A further advantage of using these commands is that they
% automatically take care of any necessary italic correction on either
% side of their argument.
% \begin{table}[t]
% \begin{center}
% \begin{tabular}{lll}
% \textit{Command} & \textit{Corresponds to }& \textit{Action} \\[4pt]
% |\textrm{..}| & |\rmfamily| &
%            Typeset argument in roman family  \\
% |\textsf{..}| & |\sffamily| &
%            Typeset argument in \textsf{sans serif} family  \\
% |\texttt{..}| & |\ttfamily| &
%            Typeset argument in \texttt{typewriter} family
%                                                            \\[2pt]
% |\textmd{..}| & |\mdseries| &
%             Typeset argument in medium series    \\
% |\textbf{..}| & |\bfseries| &
%             Typeset argument in \textbf{bold} series    \\[2pt]
% |\textup{..}| & |\upshape| &
%             Typeset argument in normal shape  \\
% |\textit{..}| & |\itshape| &
%             Typeset argument in \textit{italic} shape  \\
% |\textsl{..}| & |\slshape| &
%             Typeset argument in \textsl{slanted} shape  \\
% |\textsc{..}| & |\scshape| &
%             Typeset argument in \textsc{small caps} shape
%                                                            \\[2pt]
% |\emph{..}| & |\em| &
%              Typeset argument \emph{emphasized} 
% \end{tabular}
% \end{center}
% \caption{Font-change commands with arguments}
% \label{tab:fontcmds}
% \begin{quote}
% The font change commands provided with the package
% \texttt{fontcmds} all start with |\text..| to emphasize that they
% are for use in normal text and to be easily memorable. They
% automatically take care of any necessary italic correction on either
% side of the argument.
% \end{quote}
% \end{table}
% 
% Thus, when using such commands, one does not have to worry about
% forgetting the italic correction when changing fonts.  Only in very
% few situations is this additional space wrong but, for example, most
% typographers recommend omitting the italic correction if a small
% punctuation character, like a comma, directly follows the font
% change.  Since the amount of correction required is partly a matter
% of taste, you can define in what situations the italic correction
% should be suppressed. This is done by puttiing the characters that
% should cancel a preceding italic correction in the list
% |\nocorrlist|.\footnote{Any package that changes the
% \texttt{\string\catcode} of a character inside
% \texttt{\string\nocorrlist} must then explicitly reset the list.
% Otherwise the changed character will no longer be recognized
% by the suppression algorithm.}
% The default definition for this list is produced by the following. 
% \begin{verbatim}
% \def \nocorrlist {,.:;}
% \end{verbatim}
% It is best to declare the most often used characters first, because this
% will make the processing slightly faster.  For example,
% \begin{verbatim}
% \emph{When using the \NFSS{} high-level commands,
% the \emph{proper} use of italic corrections is
% automatically taken care of}. Only
% \emph{sometimes} one has to help \LaTeX{} by
% adding a \verb=\nocorr= command.
%\end{verbatim}
% which results in: 
% \begin{quote}
% \emph{When using the \NFSS{} high-level commands,
% the \emph{proper} use of italic corrections is
% automatically taken care of}. Only
% \emph{sometimes} one has to help \LaTeX{} by
% adding a \verb=\nocorr= command.
% \end{quote}
% 
% 
% In contrast, the use of the declaration forms is often more appropriate
% when you define your own commands or environments.
% \begin{verbatim}
% \newenvironment{bfitemize}{\begin{itemize}\normalfont\bfseries}
%                           {\end{itemize}}
% \begin{bfitemize}
% \item This environment produces boldface items.
% \item It is defined in terms of \LaTeX's
%   \texttt{itemize} environment and NFSS
%   declarations.
% \end{bfitemize}
% \end{verbatim}
% This gives:
% \begin{quote}
% \newenvironment{bfitemize}
%   {\begin{itemize}\normalfont\bfseries}
%   {\end{itemize}}
% \begin{bfitemize}
% \item This environment produces boldface items.
% \item It is defined in terms of \LaTeX's
%   \texttt{itemize} environment and NFSS
%   declarations.
% \end{bfitemize}
% \end{quote}
% 
% In addition to global customization of when to insert the italic
% correction, it is of course sometimes necessary to explicitly insert
% one with |\/|.
%
% It is also possible to suppress the italic correction
% in individual instances. For this, the command |\nocorr| is provided.
%
% It is usually best (and easiest) to put the |\nocorr| inside the
% argument of the |\text...| commands, at that end (left or right) of
% the text where you wish to suppress the italic correction.
%
% It will also often work if put in other sensible positions.
% However, care is needed when it is used in
% close conjunction with commands which inhibit line-breaking.
% The excact rules are somewhat mysterious%
% \footnote{This is because it is implemented using the primitive
% \TeX{} entity `kern' and these, when followed by glue, interact
% with the line-breaking mechanism in ways which are non-intuitive
% (if not totally weird), see page 96 of The \TeX book.}
% but one rule to remember is that it should never be put immediately
% after the line-breaking inhibition.
% If this is in danger of occuring, swap them around so that the
% |\nocorr| comes immediately before the line-breaking command.
%
% Thus the following will all prevent the italic correction being
% inserted.
% \begin{verbatim}
% Before \textsl{slanted\nocorr} after;
% before \textsl{slanted\nocorr\nolinebreak} after;
% before \textsl{slanted\nocorr}~after;
% before \textup{\nocorr non-slanted} after;
% before\nolinebreak\ \textup{\nocorr upright} after.
% before~\textup{\nocorr upright} after.
% \end{verbatim}
% But the following will not work, in the sense that the effect of the
% |\nolinebreak| will be negated and a linebreak may occur in
% an unwanted place.
% \begin{verbatim}
% Before \textsl{slanted\nolinebreak\nocorr} after.
% \end{verbatim}
% 
% It is worth pointing out here that inserting a |\/| in places where
% it can have no function (\ie anywhere except immediately after a
% slanted letter) is not an error---it will just be silently ignored. 
% 
% \StopEventually{}
%
% \section{The implementation}
%
% We start by writing to the VDU and the transcript file.
%    \begin{macrocode}
%<*code>
\wlog{Kernel code: `fontcmds'
  \fileversion\space <\filedate> (FMi,CRo)}
\wlog{English Documentation
  \space\space\space\space\space
  \space\space\space\space <\docdate> (FMi,Cr0)}
%    \end{macrocode}
%    
%  \begin{macro}{\@pdef}
% \changes{v3.0b}{1993/12/19}{Command added}
%    This is a command for easily producing and redefining commands
%    with self-protection built in: these are used especially for
%    font-changing commands.  The syntax for its use is precisely as
%    if |\pfoo| were being defined directly, arguments and all.
%    It may perhaps have more general applicablility, in
%    which case it should be moved from this file to somewhere more
%    appropriate.
%
%    Usage: |\@pdef|\meta{foo}\meta{parameters}|{|\meta{def}|}|
%
%    It defines |\foo| to expand to |\pfoo| which in turn expands to
%    \meta{def} with parameters etc specified  as normal.
%    It produces warnings if either |\foo| or |\pfoo| is already defined.  
%    \begin{macrocode}
\def \@pdef #1{%
  \def \@tempa {\expandafter \@gobble \string #1}%
  \@ifundefined {\@tempa}%
     {}{\@warning{\string#1\space has been redefined}}%
  \@ifundefined {p\@tempa}%
     {}{\@warning{\expandafter \string \csname p\@tempa \endcsname
                           \space has been redefined}}%
  \let \protect \relax
%    \end{macrocode}
%    Frank thinks that this first |\noexpand| is a wise precaution.
%    \begin{macrocode}
  \edef #1{\noexpand\protect \expandafter \noexpand
                                  \csname p\@tempa\endcsname}%
  \@namedef{p\@tempa}%
}
%    \end{macrocode}
%  \end{macro}
%  
%  \begin{macro}{\@newtextcmd}
% \changes{v3.0a}{1993/12/11}{Macro changed}
%    This is the creator function for |\text..| commands.
%    It is not used exclusively for making a `new command' but I think
%    that the name is OK.
%    Frank thinks that it should be made more restrictive by using
%    |\@ifdefinable|.
%    Chris thinks that it should just give a warning if |\foo| or
%    |\pfoo| is already defined, so it does: maybe the warnings should
%    be combined somehow?
% \changes{v3.0b}{1993/12/19}{Corrected and tidied}
%    \begin{macrocode}
\def \@newtextcmd #1#2{%
  \@pdef #1##1{\ifmmode
                 \expandafter\nfss@text
               \else
                 \leavevmode
               \fi
               {#2\maybe@ic ##1}\maybe@ic
               }%
}
%    \end{macrocode}
%  \end{macro}
%  
%  \begin{macro}{\textrm}
%  \begin{macro}{\textsf}
%  \begin{macro}{\texttt}
%  \begin{macro}{\textnormal}
%    Now we define the |\text|\meta{family} commands in terms of the
%    above; |\texttt| does not look very nice!
%    \begin{macrocode}
\@newtextcmd{\textrm}{\rmfamily} 
\@newtextcmd{\textsf}{\sffamily}
\@newtextcmd{\texttt}{\ttfamily}
\@newtextcmd{\textnormal}{\normalfont}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\textbf}
%  \begin{macro}{\textmd}
%    For the series attribute:
%    \begin{macrocode}
\@newtextcmd{\textbf}{\bfseries}
\@newtextcmd{\textmd}{\mdseries}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  
%  \begin{macro}{\textit}
%  \begin{macro}{\textsl}
%  \begin{macro}{\textsc}
%  \begin{macro}{\textup}
% \changes{v3.0a}{1993/12/11}{Macros changed}
%    And for the shapes:
%    \begin{macrocode}
\@newtextcmd{\textit}{\itshape}
\@newtextcmd{\textsl}{\slshape}
\@newtextcmd{\textsc}{\scshape}
\@newtextcmd{\textup}{\upshape}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
% 
%  \begin{macro}{\emph}
% \changes{v3.0a}{1993/12/11}{Macro changed}
%    Finally we have the |\em| font change declaration of \LaTeX. The
%    corresponding definition with argument is
%    \begin{macrocode}
\@newtextcmd{\emph}{\em}
%    \end{macrocode}
%  \end{macro}
%  
%  \begin{macro}{\nocorr}
%  We prevent an italic correction from having any effect by putting
%  in a kern; care is needed that this does not produce any new
%  breakpoints. 
%    \begin{macrocode}
\def \nocorr {\kern\z@}
%    \end{macrocode}
%    To ensure this the zero here could be replaced by a sentinal value
%    like $-1$sp; then in some cases this value could be detected and
%    the kern removed.  However, since the recommended (and easiest)
%    methods of using it rarely produce such problems this has not
%    been done. 
%  \end{macro}
%
%  \begin{macro}{\maybe@ic}
% \changes{v3.0a}{1993/12/11}{Macro name changed}
%  \begin{macro}{\maybe@ic@}
% \changes{v3.0a}{1993/12/11}{Macro and name changed}
%    These macros implement the italic correction.
%    \begin{macrocode}
\def \maybe@ic {\futurelet\next\maybe@ic@}
\def \maybe@ic@ {%
%    \end{macrocode}
%    We first check to see if the outer font is also sloped.
%    (But do not forget the message Rainer sent about an upright font
%    with non-zero slope!)
%    \begin{macrocode}
  \ifdim \fontdimen\@ne\font>\z@ 
  \else 
    \@tempswatrue
%    \end{macrocode}
%    It would be possible, but probably not worthwhile, to continue the
%    forward scan beyond any closing braces.
%
%    The list we check through contains the chars specified in
%    |\nocorrlist| plus the two individual commands |\nocorr| and
%    |\kern|. The |\kern| can happen if the command was used in a
%    moving argument and the |\nocorr| was expanded. Actually we
%    would need to check for |\kern\z@| in that case but we leave this
%    out since an explici kern here is not likely.
%    \begin{macrocode}
    \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=%
        \nocorrlist\nocorr\kern
%    \end{macrocode}
%    We have to hide the |\next| in the macro |\test@next| rather
%    than testing it directly in the loop since it might be |\let|
%    to a |\fi| or |\else|, which would result in chaos.
% \changes{v2.1a}{1993/11/24}{Use `test@next}
%    \begin{macrocode}
    \do \test@next
%    \end{macrocode}
%    Frank thinks that the next bit it is inefficient if done after
%    the second change.  Chris thinks that most all of this is
%    inefficient for the commonest cases: but that is the price of a
%    cleverer algorithm.  It is certainly needed to deal with the use
%    of |\nolinebreak|.
%    
%    \begin{macrocode}
    \if@tempswa \sw@slant \fi
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  
%  \begin{macro}{\sw@slant}
% \changes{v3.0a}{1993/12/11}{Macro changed}
%  \begin{macro}{\fix@penalty}
% \changes{v3.0a}{1993/12/11}{Macro added}
%    The definition of the mysterious |\sw@slant| command is as follows.
%    \begin{macrocode}
\def \sw@slant {%
%    \end{macrocode}
%    It is surely correct to put in an italic correction when there
%    is no skip.  If the last thing on the list is actually a zero
%    skip (including things whose dimension part is zero, such as
%    |\hfill|), or anything other than a sloped character, then the
%    italic correction will have no effect.
%
%    In order to work correctly with unbreakable spaces from |~|
%    (and other common forms of line-breaking control) we also move
%    back across a penalty before the glue.
%    \begin{macrocode}
  \ifdim \lastskip=\z@
    \fix@penalty
  \else
    \skip@ \lastskip
    \unskip
    \fix@penalty
    \hskip \skip@
  \fi
}
%    \end{macrocode}
%    The above code means: ``If there is a non-zero space just before
%    the current position (|\ifdim...|) save the amount of that space
%    (|\skip@\lastskip|), remove it (|\unskip|), then do a similar
%    thing if there is a penalty just before the skip,
%    and finally put the space back in.''
%
%    Since zero glue cannot be distinguished in this context from no glue,
%    we dare not put in an |\hskip| in this case as this may produce
%    an unwanted breakpoint.  This is not satisfactory.
%
%    The penalty before the glue is handled similarly, with the same
%    caveats concerning the zero case.   Is this the first recorded
%    use of |\unpenalty| in standard |\LaTeX| code? 
%    \begin{macrocode}
\def \fix@penalty {%
  \ifnum \lastpenalty=\z@
    \/%
  \else
    \count@ \lastpenalty
    \unpenalty
    \/%
    \penalty \count@
  \fi
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  
%  \begin{macro}{\test@next}
% \changes{v2.1a}{1993/11/24}{Macro added}
%    The next token in the input stream is stored in |\next| via a
%    |\let|, the current token from |\nocorrlist| is stored via |\def|
%    in |\@tempa|. To compare them we have to fiddle around a bit.
%    \begin{macrocode}
\def \test@next {%
  \expandafter\let\expandafter\@tempb\expandafter=\@tempa\relax
  \ifx\@tempb\next
%    \end{macrocode}
%    If they are the same we jump out of the loop.
%    \begin{macrocode}
    \@tempswafalse
    \let\@nextwhile\@fornoop
    \expandafter\@gobblefour
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\nocorrlist}
%    This holds the list of characters that should prevent italic
%    correction.  They should be ordered by decreasing frequency of
%    use. If any such character is made active later on one needs
%    to redefine the list so that the active character becomes part
%    of it.
%    \begin{macrocode}
\def \nocorrlist {.,;:}
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\nfss@text}
%    This command will by default behave like a \LaTeX{} |\mbox| but
%    may be redefined by packages such as |amstext.sty| to be a bit
%    cleverer.
%    \begin{macrocode}
\ifx \nfss@text\undefined 
  \def \nfss@text {\leavevmode\hbox}
\fi
%    \end{macrocode}
%  \end{macro}
%
%
%  \begin{macro}{\@setfontswitch}
%    This is the function used to create declarative font-chnaging
%    commands that can also be used to change alphabets in math-mode.
%    
%    Usage: |\@setfontswitch \fn{|\meta{font-change decls}|}|
%                                        \meta{math-alphabet}
%
%    Here |\fn| is the font-declaration command being defined,
%    \meta{font-change decls} are the declaration it will expand to in
%    text-mode, and \meta{math-alphabet} is the (single) math alphabet
%    specifier which is to be used in math-mode.
%
%    Here are some typical examples of its use in conjunction with
%    more basic NFSS2 font commands.    
%    \begin{verbatim}
%    \@setfontswitch{\rm}{\normalfont\rmfamily}{\mathrm}
%    \@setfontswitch{\sf}{\normalfont\sffamily}{\mathsf}
%    \@setfontswitch{\tt}{\normalfont\ttfamily}{\mathtt}
%    \end{verbatim}
%    
%    Frank thinks that this should be made more restrictive by using
%    |\@ifdefinable|.
%    Chris thinks that it should just give a warning if |\foo| or
%    |\pfoo| is already defined, so it does: maybe the warnings should
%    be combined somehow?
% \changes{v3.0b}{1993/12/19}{Corrected and tidied}
%    \begin{macrocode}
\def \@setfontswitch #1#2#3{%
  \@pdef #1{\@fontswitch {#2}{#3}}%
}
%    \end{macrocode}
%  \end{macro}
%  
%  \begin{macro}{\@newfontswitch}
%  \begin{macro}{\@renewfontswitch}
%    Alan agrees with Frank, so he introduced a form which uses
%    |\@ifdefinable|.
%    He also added |\@renewfontswitch|, so users should have the best
%    of both worlds.
%    Chris then incorporated these commands, which do not check very much,
%    into his latest version.  This is temporary, and a mess.
%    \changes{3.0b}{1993/12/18}{Put `@ifdefinable into old version of
%       `@newfontswitch, and added `@renewfontswitch.}
%    \begin{macrocode}
\def \@newfontswitch #1#2#3{%
   \@ifdefinable{#1}{%
      \let \protect \relax
      \def \@tempa {\expandafter \@gobble \string #1}%
      \edef #1{%
         \noexpand\protect
         \expandafter\noexpand
         \csname p\@tempa\endcsname
      }%
      \@namedef{p\@tempa}{\@fontswitch{#2}{#3}}%
   }%
}
\def\@renewfontswitch#1{%
  {\escapechar\m@ne\xdef\@gtempa{{\string#1}}}%
  \expandafter\@ifundefined\@gtempa
     {\@latexerr{\string#1\space undefined}\@ehc}%
     {}%
  \let\@ifdefinable\@rc@ifdefinable
  \@newfontswitch#1%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  
%  \begin{macro}{\@fontswitch}
%  \begin{macro}{\@@math@egroup}
%    These two commands actually do the necessary tests and
%    declarative \mbox{font-} or alphabet-changing.
%  
%    \begin{macrocode}
\def \@fontswitch #1#2{%
  \ifmmode
     \let \math@bgroup \relax
     \def \math@egroup {\let\math@bgroup\relax
                        \let\math@egroup\@@math@egroup}%
     #2%
  \else
     #1%
  \fi
}
\def \@@math@egroup #1{#1\endgroup}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \changes{2.1b}{1993/12/08}{Macros `rm, `bf and `sf moved to
%                            classes.dtx} 
%
%    These font functions are available only in the preamble.
%    \begin{macrocode}
\@onlypreamble \@newtextcmd
\@onlypreamble \@newfontswitch
\@onlypreamble \@renewfontswitch
%    \end{macrocode}
%
% \section{Initialization}
% \changes{3.0b}{1993/12/19}{Added by ASAJ.}
% \changes{3.0b}{1993/12/19}{Wording changes by CAR.}
% 
% We initialize all of the standard font-changing commands
% to produce an error.
% \begin{macro}{\@undefinedfonterror}
%    This is the error produced by a 
%    font-changing command not defined by the class.
%    \begin{macrocode}
\def \@undefinedfonterror #1#2{%
  \@latexerr {The font #1 command \string#2
              is not defined.}\@eha
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rm}
% \begin{macro}{\tt}
% \begin{macro}{\sf}
% \begin{macro}{\bf}
% \begin{macro}{\sl}
% \begin{macro}{\it}
% \begin{macro}{\sc}
% \begin{macro}{\Huge}
% \begin{macro}{\huge}
% \begin{macro}{\LARGE}
% \begin{macro}{\Large}
% \begin{macro}{\large}
% \begin{macro}{\normalsize}
% \begin{macro}{\@normalsize}
% \begin{macro}{\small}
% \begin{macro}{\footnotesize}
% \begin{macro}{\scriptsize}
% \begin{macro}{\tiny}
%    All the standard font-changing commands produce errors.
%    \begin{macrocode}
\def\rm{\@undefinedfonterror{family}\rm}
\def\tt{\@undefinedfonterror{family}\tt}
\def\sf{\@undefinedfonterror{family}\sf}
\def\bf{\@undefinedfonterror{series}\bf}
\def\sl{\@undefinedfonterror{shape}\sl}
\def\it{\@undefinedfonterror{shape}\it}
\def\sc{\@undefinedfonterror{shape}\sc}
\def\Huge{\@undefinedfonterror{size}\Huge}
\def\huge{\@undefinedfonterror{size}\huge}
\def\LARGE{\@undefinedfonterror{size}\LARGE}
\def\Large{\@undefinedfonterror{size}\Large}
\def\large{\@undefinedfonterror{size}\large}
\def\normalsize{\@undefinedfonterror{size}\normalsize}
\def\@normalsize{\@undefinedfonterror{size}\normalsize}
\def\small{\@undefinedfonterror{size}\small}
\def\footnotesize{\@undefinedfonterror{size}\footnotesize}
\def\scriptsize{\@undefinedfonterror{size}\scriptsize}
\def\tiny{\@undefinedfonterror{size}\tiny}
%</code>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{A driver for this document}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the 
% \dst{} program.
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}

\DisableCrossrefs

%\CodelineIndex     % Index code by line number

%\OnlyDescription  % comment out for implementation details

\begin{document}
   \DocInput{fontcmds.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% 
% \DeleteShortVerb{\|}
% \Finale
%
%
\endinput
