% \begin{meta-comment}
%
% $Id: mdwfonts.dtx,v 1.1 1996/11/19 22:02:15 mdw Exp mdw $
%
% PostScript fonts for more excitement
%
% (c) 1996 Mark Wooding
%
%----- Revision history -----------------------------------------------------
%
% $Log: mdwfonts.dtx,v $
% Revision 1.1  1996/11/19 22:02:15  mdw
% Initial revision
%
%
% \end{meta-comment}
%
% \begin{meta-comment} <general public licence>
%%
%% mdwtools common declarations
%% Copyright (c) 1996 Mark Wooding
%%
%% This program is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation; either version 2 of the License, or
%% (at your option) any later version.
%%
%% This program 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.  See the
%% GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public License
%% along with this program; if not, write to the Free Software
%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%%
% \end{meta-comment}
%
% \begin{meta-comment} <file preamble>
%<+sty>\NeedsTeXFormat{LaTeX2e}
%<+sty>\ProvidesPackage{mdwfonts}
%<+mttpcr>\ProvidesFile{mTTpcr.fd}
%<*fontinst>
\ifx\ProvidesFile\mdwundefined
  \def\ProvidesFile#1[#2]{\wlog{File: #1 #2}}
\fi
\ProvidesFile{mdwfonts.tex}
%</fontinst>
                [1997/01/11 1.2 PostScript fonts for my documents]
% \end{meta-comment}
%
% \CheckSum{562}
%% \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         \~}
%%
%
% \begin{meta-comment}
%
%<*driver>
\input{mdwtools}
\usepackage{mflogo}
\describespackage{mdwfonts}
\mdwdoc
%</driver>
%
% \end{meta-comment}
%
% 
%^^A-------------------------------------------------------------------------
% \section{Overview}
%
% This suite of \LaTeX\ bits is intended to provide some configurability
% for the fonts used by documents.  It lets users define their favourite
% collection of fonts, and any documents using this package will
% automatically honour those design decisions.
%
% It goes a little beyond this brief, however, by supplying some missing
% PostScript fonts which may be useful.  (Well, the author uses them a lot.)
% In particular:
% \begin{itemize}
% \item The `squashed' Courier from David Carlisle's \package{pslatex}
%   package is included, and extended to cover the other known variants of
%   Courier (e.g., bold and oblique).
% \item A maths symbol font for Palatino has been added.  It works in a
%   similar way to the \package{mathptm} package's support for Times (i.e.,
%   it grabs glyphs from the normal Palatino font, and from the Computer
%   Modern symbols).
% \end{itemize}
%
%
% \section{Installing \package{mdwfonts}}
%
% The package comes with a large number of miscellaneous font files.  They
% ought to be placed in appropriate directories where \TeX and/or other
% programs can find them.  Exactly where this will be depends heavily on your
% installation: try looking for the other fonts and put these with them.
% The various extensions for the font files are:
% \begin{description}
% \item [.tfm] is a \TeX\ Font Metric file, needed by \TeX.
% \item [.vf] is a virtual font description file, needed by DVI-drivers.
% \item [.fd] is a font description file, required by \LaTeX.
% \end{description}
%
% You'll also need to put |mdwfonts.sty| somewhere where \LaTeX\ will find
% it.  What you do with the documentation file is up to you.
%
% The files |mTTpcr.fd| and |mdwfonts.sty| may not have been included in
% your distribution.  If you don't have them, run \LaTeX\ on |mdwfonts.ins|
% to build them.  I'm explicitly not giving instructions for building all
% the other font files, because I'd much prefer it if they were distributed
% as they are, please -- building them is a fiddly business, and I'd rather
% that only I had to do it.
%
% Once you've done all that, you must tell \textit{dvips} about your new
% fonts, so add the following lines to the |psfonts.map| file, unless they're
% already there:
% \begin{listing}
%pcrb8rn Courier-Bold ".85 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <pcrb8a.pfb
%pcrbo8rn Courier-BoldOblique ".85 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <pcrbo8a.pfb
%pcrr8rn Courier ".85 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <pcrr8a.pfb
%pcrro8rn Courier-Oblique ".85 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <pcrro8a.pfb
% \end{listing}
% The |pcrr8rn| line will already be in the file if you've installed the
% \package{pslatex} package, so don't bother putting it in again.
%
%
% \section{Using \package{mdwfonts}}
%
% \subsection{Defining fonts to use}
%
% The font faces you can use, with their names as used by this package,
% currently are:
% \begin{itemize}
% \item Computer Modern Roman (|cmr|)
% \item Computer Modern Sans (|cmss|)
% \item Times Roman (|times|)
% \item Helvetica (|helvetica|)
% \item Palatino (|palatino|)
% \item Computer Modern Typewriter (|cmtt|)
% \item Courier (condensed version) (|courier|)
% \end{itemize}
% Only Computer Modern Roman, Times Roman and Palatino may be used as a maths
% family.
%
% The \package{mdwfonts} package knows about five font families which
% documents probably want to use.  The available families you can set, with
% their names as used by this package, are:
% \begin{description}
% \item [The body text family] (|body|) is the main font your document uses.
%   The default body family is Computer Modern Roman.
% \item [The maths family] (|maths|) is the font used for mathematics.
%   The default maths family is the same as the body family.
% \item [The sans serif family] (|sans|) is used for sans serif text.
%   The default sans serif family is Computer Modern Sans.
% \item [The headings family] (|head|) is used for headings, if your
%   document class supports this.\footnote{
%     The \texttt{\char`\\headfam} command is configured to change to the
%     chosen headings family.  Co-operating document classes should use this
%     hook when typesetting chapter and section headings, etc.}
%   Most document classes don't support this, but \package{mdwfonts} patches
%   the standard \LaTeX\ classes so that they work.  The default headings
%   family is Computer Modern Roman.
% \item [The typewriter family] (|tt|) is used for monospaced text.  The
%    default typewriter family is Computer Modern Typewriter.
% \end{description}
% American users not used to spelling \lit{maths} correctly may use the
% alternative spelling \lit{math} instead.  If only the rest of \LaTeX\ were
% this considerate.
%
%
% \subsection{Assigning faces to families}
%
% \DescribeMacro\mdwfont
% This is fairly simple, really.  The |\mdwfont| will attach a typeface to a
% given family.  The syntax is as follows:
% \begin{syntdiag}
% "\\mdwfont" "{" \< <family-name> "=" <face-name> \\ "," \> "}"
% \end{syntdiag}
% For example, saying
% \begin{listing}
%\mdwfont{body=palatino, maths=palatino,
%         sans=helvetica, head=helvetica
%         tt=courier}
% \end{listing}
% uses Palatino for the main body text, and for maths, Helvetica for sans
% serif text, and for headings (again, only if your document class supports
% this).
%
% The \package{mdwfonts} package also supports a collection of options which
% may be passed to the package.  The syntax of the package invocation is:
% \begin{syntdiag}
% "\\usepackage"
% \[ "["
%   \< \( <face-name> \\ <family-name> "=" <face-name> \) \\ "," \>
% "]" \]
% \\
% "{" "mdwfonts" "}"
% \end{syntdiag}
%
% A face name on its own configures families sensibly to use that face.
% The actual behaviour is as follows:
% \begin{description}
% \item [times] Set body and maths families to Times Roman.
% \item [palatino] Set body and maths families to Palatino.
% \item [cmr] Set body, headings and maths families to Computer Modern Roman.
% \item [helvetica] Set sans serif and headings families to Helvetica.
% \item [cmss] Set sans serif family to Computer Modern Sans.
% \item [courier] Set typewriter family to Courier.
% \item [cmtt] Set typewriter family to Computer Modern Typewriter.
% \end{description}
% Astute readers will be able to deduce the author's personal preferences
% for assigning typefaces to families from the above rules.  However, they
% should suffice for most simple configurations.  Moreover, the direct
% assignment of faces to families is supported in case the above aren't
% expressive enough.
%
% When \package{mdwfonts} starts up, it reads a file called |mdwfonts.cfg|,
% if it exists.  This file should set up defaults for the various families
% according to the user's preferences.  The decisions made by the
% configuration file may be overridden by the document, however, since
% package options are processed after running |mdwfonts.cfg|.
%
%
% \implementation
%
% \section{The package}
%
%    \begin{macrocode}
%<*sty>
%    \end{macrocode}
%
%
% \subsection{Options handing}
%
% There are several font choices to be made.  These can be made from the
% package options or the configuration file; the former takes precedence over
% the latter.
%
% I'll use David Carlisle's rather good \package{keyval} package to handle
% this lot because it saves a lot of hassle in the long run.
%
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}
%
% Now to define how all this actually works.  Maintain a variable for each
% family that I understand, and a list of which fonts people have expressed
% an interest in.
%
%    \begin{macrocode}
\def\mdwf@bodyfont{\mdwf@cmr}
\def\mdwf@mathsfont{\mdwf@bodyfont}
\def\mdwf@sansfont{\mdwf@cmss}
\def\mdwf@headfont{\mdwf@cmr}
\def\mdwf@ttfont{\mdwf@cmtt}
%    \end{macrocode}
%
% Now to define the keys and values which I'll accept.
%
%    \begin{macrocode}
\def\mdwf@set#1#2{\edef#1{\expandafter\noexpand\csname mdwf@#2\endcsname}}
\define@key{mdwf}{body}{\mdwf@set\mdwf@bodyfont{#1}}
\define@key{mdwf}{maths}{\mdwf@set\mdwf@mathsfont{#1}}
\define@key{mdwf}{math}{\mdwf@set\mdwf@mathsfont{#1}}
\define@key{mdwf}{sans}{\mdwf@set\mdwf@sansfont{#1}}
\define@key{mdwf}{head}{\mdwf@set\mdwf@headfont{#1}}
\define@key{mdwf}{tt}{\mdwf@set\mdwf@ttfont{#1}}
%    \end{macrocode}
%
% Now input the configuration file.
%
%    \begin{macrocode}
\def\mdwfont{\setkeys{mdwf}}
\@input{mdwfonts.cfg}
%    \end{macrocode}
%
% Set up some package options which handle the common cases.  Then add
% a catch-all option which just gets bundled to \package{keyval}.
%
%    \begin{macrocode}
\DeclareOption{times}{\mdwfont{body=times, maths=times}}
\DeclareOption{palatino}{\mdwfont{body=palatino, maths=palatino}}
\DeclareOption{cmr}{\mdwfont{body=cmr, maths=cmr, head=cmr}}
\DeclareOption{helvetica}{\mdwfont{sans=helvetica, head=helvetica}}
\DeclareOption{cmss}{\mdwfont{sans=cmss}}
\DeclareOption{courier}{\mdwfont{tt=courier}}
\DeclareOption{cmtt}{\mdwfont{tt=cmtt}}
\DeclareOption*{\expandafter\mdwfont\expandafter{\CurrentOption}}
\ProcessOptions*
%    \end{macrocode}
%
% Now, if a client wants a really odd setup not provided by the above
% interface, it can define |\mdwfonts| to declare its decision.
%
%    \begin{macrocode}
\ifx\mdwfonts\@@undefined\else
  \def\@tempa#1\@@{\mdwfont{#1}}
  \expandafter\@tempa\mdwfonts\@@
\fi
%    \end{macrocode}
%
%
% \subsection{Setting up the actual fonts}
%
% \begin{macro}{\mdwf@iffont}
%
% I need to check whether a font's been used.  This macro will help.
%
% First, I'll define some numeric values for various fonts.
%
%    \begin{macrocode}
\count@\z@
\def\@tempa#1{%
  \expandafter\chardef\csname mdwf@#1\endcsname\count@%
  \advance\count@\@ne%
}
\@tempa{cmr}\@tempa{cmss}\@tempa{cmtt}
\@tempa{times}\@tempa{palatino}\@tempa{helvetica}\@tempa{courier}
%    \end{macrocode}
%
% And now to check whether a font is being used.  This is rather horrible.
%
%    \begin{macrocode}
\def\mdwf@iffont#1{\if1%
  \ifnum\mdwf@bodyfont=#11\else%
  \ifnum\mdwf@headfont=#11\else%
  \ifnum\mdwf@sansfont=#11\else%
  \ifnum\mdwf@ttfont=#11\else0%
  \fi\fi\fi\fi%
}
%    \end{macrocode}
%
% \end{macro}
%
% \subsubsection{Text fonts}
%
% \paragraph{Courier}
% The courier family is redefined in its entirety here.  I use the condensed
% courier provided by David Carlisle's \package{pslatex} package, although
% I've extended it to cover all the shapes and not just medium roman.
%    \begin{macrocode}
\mdwf@iffont\mdwf@courier
\DeclareFontFamily{OT1}{pcr}{\hyphenchar\font=-1}
\DeclareFontShape{OT1}{pcr}{b}{n}{<-> pcrb7tn}{}
\DeclareFontShape{OT1}{pcr}{b}{sc}{<-> pcrbc7tn}{}
\DeclareFontShape{OT1}{pcr}{b}{sl}{<-> pcrbo7tn}{}
\DeclareFontShape{OT1}{pcr}{m}{n}{<-> pcrr7tn}{}
\DeclareFontShape{OT1}{pcr}{m}{sc}{<-> pcrrc7tn}{}
\DeclareFontShape{OT1}{pcr}{m}{sl}{<-> pcrro7tn}{}
\DeclareFontShape{OT1}{pcr}{bx}{n}{<->ssub * pcr/b/n}{}
\DeclareFontShape{OT1}{pcr}{bx}{sc}{<->ssub * pcr/b/sc}{}
\DeclareFontShape{OT1}{pcr}{bx}{sl}{<->ssub * pcr/b/sl}{}
\DeclareFontShape{OT1}{pcr}{b}{it}{<->ssub * pcr/b/sl}{}
\DeclareFontShape{OT1}{pcr}{bx}{it}{<->ssub * pcr/b/it}{}
\DeclareFontShape{OT1}{pcr}{m}{it}{<->ssub * pcr/m/sl}{}
\DeclareFontFamily{T1}{pcr}{\hyphenchar\font=-1}
\DeclareFontShape{T1}{pcr}{b}{n}{<-> pcrb8tn}{}
\DeclareFontShape{T1}{pcr}{b}{sc}{<-> pcrbc8tn}{}
\DeclareFontShape{T1}{pcr}{b}{sl}{<-> pcrbo8tn}{}
\DeclareFontShape{T1}{pcr}{m}{n}{<-> pcrr8tn}{}
\DeclareFontShape{T1}{pcr}{m}{sc}{<-> pcrrc8tn}{}
\DeclareFontShape{T1}{pcr}{m}{sl}{<-> pcrro8tn}{}
\DeclareFontShape{T1}{pcr}{bx}{n}{<->ssub * pcr/b/n}{}
\DeclareFontShape{T1}{pcr}{bx}{sc}{<->ssub * pcr/b/sc}{}
\DeclareFontShape{T1}{pcr}{bx}{sl}{<->ssub * pcr/b/sl}{}
\DeclareFontShape{T1}{pcr}{b}{it}{<->ssub * pcr/b/sl}{}
\DeclareFontShape{T1}{pcr}{bx}{it}{<->ssub * pcr/b/it}{}
\DeclareFontShape{T1}{pcr}{m}{it}{<->ssub * pcr/m/sl}{}
\fi
%    \end{macrocode}
%
% \paragraph{Helvetica}
% Again the whole of helvetica is defined here, this time so that the font
% can be scaled a little.
%    \begin{macrocode}
\mdwf@iffont\mdwf@helvetica
\DeclareFontFamily{OT1}{phv}{}
\DeclareFontShape{OT1}{phv}{b}{n}{<-> s * [.9] phvb7t}{}
\DeclareFontShape{OT1}{phv}{b}{sc}{<-> s * [.9] phvbc7t}{}
\DeclareFontShape{OT1}{phv}{b}{sl}{<-> s * [.9] phvbo7t}{}
\DeclareFontShape{OT1}{phv}{bc}{n}{<-> s * [.9] phvbrn7t}{}
\DeclareFontShape{OT1}{phv}{bc}{sc}{<-> s * [.9] phvbcn7t}{}
\DeclareFontShape{OT1}{phv}{bc}{sl}{<-> s * [.9] phvbon7t}{}
\DeclareFontShape{OT1}{phv}{m}{n}{<-> s * [.9] phvr7t}{}
\DeclareFontShape{OT1}{phv}{m}{sc}{<-> s * [.9] phvrc7t}{}
\DeclareFontShape{OT1}{phv}{m}{sl}{<-> s * [.9] phvro7t}{}
\DeclareFontShape{OT1}{phv}{mc}{n}{<-> s * [.9] phvrrn7t}{}
\DeclareFontShape{OT1}{phv}{mc}{sc}{<-> s * [.9] phvrcn7t}{}
\DeclareFontShape{OT1}{phv}{mc}{sl}{<-> s * [.9] phvron7t}{}
\DeclareFontShape{OT1}{phv}{bx}{n}{<->ssub * phv/b/n}{}
\DeclareFontShape{OT1}{phv}{bx}{sc}{<->ssub * phv/b/sc}{}
\DeclareFontShape{OT1}{phv}{bx}{sl}{<->ssub * phv/b/sl}{}
\DeclareFontShape{OT1}{phv}{b}{it}{<->ssub * phv/b/sl}{}
\DeclareFontShape{OT1}{phv}{bx}{it}{<->ssub * phv/b/it}{}
\DeclareFontShape{OT1}{phv}{bc}{it}{<->ssub * phv/bc/sl}{}
\DeclareFontShape{OT1}{phv}{m}{it}{<->ssub * phv/m/sl}{}
\DeclareFontShape{OT1}{phv}{mc}{it}{<->ssub * phv/mc/sl}{}
\DeclareFontFamily{T1}{phv}{}
\DeclareFontShape{T1}{phv}{b}{n}{<-> s * [.9] phvb8t}{}
\DeclareFontShape{T1}{phv}{b}{sc}{<-> s * [.9] phvbc8t}{}
\DeclareFontShape{T1}{phv}{b}{sl}{<-> s * [.9] phvbo8t}{}
\DeclareFontShape{T1}{phv}{bc}{n}{<-> s * [.9] phvbrn8t}{}
\DeclareFontShape{T1}{phv}{bc}{sc}{<-> s * [.9] phvbcn8t}{}
\DeclareFontShape{T1}{phv}{bc}{sl}{<-> s * [.9] phvbon8t}{}
\DeclareFontShape{T1}{phv}{m}{n}{<-> s * [.9] phvr8t}{}
\DeclareFontShape{T1}{phv}{m}{sc}{<-> s * [.9] phvrc8t}{}
\DeclareFontShape{T1}{phv}{m}{sl}{<-> s * [.9] phvro8t}{}
\DeclareFontShape{T1}{phv}{mc}{n}{<-> s * [.9] phvrrn8t}{}
\DeclareFontShape{T1}{phv}{mc}{sc}{<-> s * [.9] phvrcn8t}{}
\DeclareFontShape{T1}{phv}{mc}{sl}{<-> s * [.9] phvron8t}{}
\DeclareFontShape{T1}{phv}{bx}{n}{<->ssub * phv/b/n}{}
\DeclareFontShape{T1}{phv}{bx}{sc}{<->ssub * phv/b/sc}{}
\DeclareFontShape{T1}{phv}{bx}{sl}{<->ssub * phv/b/sl}{}
\DeclareFontShape{T1}{phv}{b}{it}{<->ssub * phv/b/sl}{}
\DeclareFontShape{T1}{phv}{bx}{it}{<->ssub * phv/b/it}{}
\DeclareFontShape{T1}{phv}{bc}{it}{<->ssub * phv/bc/sl}{}
\DeclareFontShape{T1}{phv}{m}{it}{<->ssub * phv/m/sl}{}
\DeclareFontShape{T1}{phv}{mc}{it}{<->ssub * phv/mc/sl}{}
\fi
%    \end{macrocode}
%
% \paragraph{Palatino}
% Might as well define palatino too, for completeness' sake.
%    \begin{macrocode}
\mdwf@iffont\mdwf@palatino
\DeclareFontFamily{OT1}{ppl}{}
\DeclareFontShape{OT1}{ppl}{b}{n}{<-> pplb7t}{}
\DeclareFontShape{OT1}{ppl}{b}{sc}{<-> pplbc7t}{}
\DeclareFontShape{OT1}{ppl}{b}{sl}{<-> pplbo7t}{}
\DeclareFontShape{OT1}{ppl}{b}{it}{<-> pplbi7t}{}
\DeclareFontShape{OT1}{ppl}{m}{n}{<-> pplr7t}{}
\DeclareFontShape{OT1}{ppl}{m}{sc}{<-> pplrc7t}{}
\DeclareFontShape{OT1}{ppl}{m}{sl}{<-> pplro7t}{}
\DeclareFontShape{OT1}{ppl}{m}{it}{<-> pplri7t}{}
\DeclareFontShape{OT1}{ppl}{bx}{n}{<->ssub * ppl/b/n}{}
\DeclareFontShape{OT1}{ppl}{bx}{sc}{<->ssub * ppl/b/sc}{}
\DeclareFontShape{OT1}{ppl}{bx}{sl}{<->ssub * ppl/b/sl}{}
\DeclareFontShape{OT1}{ppl}{bx}{it}{<->ssub * ppl/b/it}{}
\DeclareFontShape{OT1}{ppl}{l}{n}{<->ssub * ppl/m/n}{}
\DeclareFontShape{OT1}{ppl}{l}{sc}{<->ssub * ppl/m/sc}{}
\DeclareFontShape{OT1}{ppl}{l}{sl}{<->ssub * ppl/m/sl}{}
\DeclareFontShape{OT1}{ppl}{l}{it}{<->ssub * ppl/m/it}{}
\DeclareFontFamily{T1}{ppl}{}
\DeclareFontShape{T1}{ppl}{b}{n}{<-> pplb8t}{}
\DeclareFontShape{T1}{ppl}{b}{sc}{<-> pplbc8t}{}
\DeclareFontShape{T1}{ppl}{b}{sl}{<-> pplbo8t}{}
\DeclareFontShape{T1}{ppl}{b}{it}{<-> pplbi8t}{}
\DeclareFontShape{T1}{ppl}{m}{n}{<-> pplr8t}{}
\DeclareFontShape{T1}{ppl}{m}{sc}{<-> pplrc8t}{}
\DeclareFontShape{T1}{ppl}{m}{sl}{<-> pplro8t}{}
\DeclareFontShape{T1}{ppl}{m}{it}{<-> pplri8t}{}
\DeclareFontShape{T1}{ppl}{bx}{n}{<->ssub * ppl/b/n}{}
\DeclareFontShape{T1}{ppl}{bx}{sc}{<->ssub * ppl/b/sc}{}
\DeclareFontShape{T1}{ppl}{bx}{sl}{<->ssub * ppl/b/sl}{}
\DeclareFontShape{T1}{ppl}{bx}{it}{<->ssub * ppl/b/it}{}
\DeclareFontShape{T1}{ppl}{l}{n}{<->ssub * ppl/m/n}{}
\DeclareFontShape{T1}{ppl}{l}{sc}{<->ssub * ppl/m/sc}{}
\DeclareFontShape{T1}{ppl}{l}{sl}{<->ssub * ppl/m/sl}{}
\DeclareFontShape{T1}{ppl}{l}{it}{<->ssub * ppl/m/it}{}
\fi
%    \end{macrocode}
%
% \paragraph{Times}
% Finally, times, for those who like it\dots
%    \begin{macrocode}
\mdwf@iffont\mdwf@times
\DeclareFontFamily{OT1}{ptm}{}
\DeclareFontShape{OT1}{ptm}{b}{n}{<-> ptmb7t}{}
\DeclareFontShape{OT1}{ptm}{b}{sc}{<-> ptmbc7t}{}
\DeclareFontShape{OT1}{ptm}{b}{sl}{<-> ptmbo7t}{}
\DeclareFontShape{OT1}{ptm}{b}{it}{<-> ptmbi7t}{}
\DeclareFontShape{OT1}{ptm}{m}{n}{<-> ptmr7t}{}
\DeclareFontShape{OT1}{ptm}{m}{sc}{<-> ptmrc7t}{}
\DeclareFontShape{OT1}{ptm}{m}{sl}{<-> ptmro7t}{}
\DeclareFontShape{OT1}{ptm}{m}{it}{<-> ptmri7t}{}
\DeclareFontShape{OT1}{ptm}{bx}{n}{<->ssub * ptm/b/n}{}
\DeclareFontShape{OT1}{ptm}{bx}{sc}{<->ssub * ptm/b/sc}{}
\DeclareFontShape{OT1}{ptm}{bx}{sl}{<->ssub * ptm/b/sl}{}
\DeclareFontShape{OT1}{ptm}{bx}{it}{<->ssub * ptm/b/it}{}
\DeclareFontShape{OT1}{ptm}{l}{n}{<->ssub * ptm/m/n}{}
\DeclareFontShape{OT1}{ptm}{l}{sc}{<->ssub * ptm/m/sc}{}
\DeclareFontShape{OT1}{ptm}{l}{sl}{<->ssub * ptm/m/sl}{}
\DeclareFontShape{OT1}{ptm}{l}{it}{<->ssub * ptm/m/it}{}
\DeclareFontFamily{T1}{ptm}{}
\DeclareFontShape{T1}{ptm}{b}{n}{<-> ptmb8t}{}
\DeclareFontShape{T1}{ptm}{b}{sc}{<-> ptmbc8t}{}
\DeclareFontShape{T1}{ptm}{b}{sl}{<-> ptmbo8t}{}
\DeclareFontShape{T1}{ptm}{b}{it}{<-> ptmbi8t}{}
\DeclareFontShape{T1}{ptm}{m}{n}{<-> ptmr8t}{}
\DeclareFontShape{T1}{ptm}{m}{sc}{<-> ptmrc8t}{}
\DeclareFontShape{T1}{ptm}{m}{sl}{<-> ptmro8t}{}
\DeclareFontShape{T1}{ptm}{m}{it}{<-> ptmri8t}{}
\DeclareFontShape{T1}{ptm}{bx}{n}{<->ssub * ptm/b/n}{}
\DeclareFontShape{T1}{ptm}{bx}{sc}{<->ssub * ptm/b/sc}{}
\DeclareFontShape{T1}{ptm}{bx}{sl}{<->ssub * ptm/b/sl}{}
\DeclareFontShape{T1}{ptm}{bx}{it}{<->ssub * ptm/b/it}{}
\DeclareFontShape{T1}{ptm}{l}{n}{<->ssub * ptm/m/n}{}
\DeclareFontShape{T1}{ptm}{l}{sc}{<->ssub * ptm/m/sc}{}
\DeclareFontShape{T1}{ptm}{l}{sl}{<->ssub * ptm/m/sl}{}
\DeclareFontShape{T1}{ptm}{l}{it}{<->ssub * ppl/m/it}{}
\fi
%    \end{macrocode}
%
% \subsubsection{Maths fonts}
%
% \paragraph{Palatino}
% Easy stuff.
%    \begin{macrocode}
\ifnum\mdwf@mathsfont=\mdwf@palatino
\DeclareSymbolFont{operators}   {OT1}{pplcm}{m}{n}
\DeclareSymbolFont{letters}     {OML}{pplcm}{m}{it}
\DeclareSymbolFont{bold}        {OT1}{ppl}{bx}{n}
\DeclareSymbolFont{italic}      {OT1}{ppl}{m}{it}
\fi
%    \end{macrocode}
%
% \paragraph{Times}
% Also easy.
%    \begin{macrocode}
\ifnum\mdwf@mathsfont=\mdwf@times
\DeclareSymbolFont{operators}   {OT1}{ptmcm}{m}{n}
\DeclareSymbolFont{letters}     {OML}{ptmcm}{m}{it}
\DeclareSymbolFont{bold}        {OT1}{ptm}{bx}{n}
\DeclareSymbolFont{italic}      {OT1}{ptm}{m}{it}
\fi
%    \end{macrocode}
%
% \paragraph{General PostScript things}
% Set up the symbols and large symbols fonts.  This lot is all from
% \package{mathptm}.
%    \begin{macrocode}
\if1\ifnum\mdwf@mathsfont=\mdwf@times1\else
    \ifnum\mdwf@mathsfont=\mdwf@palatino1\else0\fi\fi
\DeclareSymbolFont{symbols}     {OMS}{pzccm}{m}{n}
\DeclareSymbolFont{largesymbols}{OMX}{psycm}{m}{n}
%    \end{macrocode}
% Adjust the spacing around operators and things to fit PostScript fonts
% better.
%    \begin{macrocode}
\thinmuskip=2mu
\medmuskip=2.5mu plus 1mu minus 1mu
\thickmuskip=4mu plus 1.5mu minus 1mu
%    \end{macrocode}
% There isn't a bold symbol font.
%    \begin{macrocode}
\def\boldmath{%
   \@warning{there is no bold Symbol font}%
   \global\let\boldmath=\relax
}
%    \end{macrocode}
% Provide an |\omicron| character.  No idea why\dots
%    \begin{macrocode}
\DeclareMathSymbol{\omicron}{0}{operators}{`\o}
%    \end{macrocode}
% Make scripts a bit bigger.
%    \begin{macrocode}
\DeclareMathSizes{5}{5}{5}{5}
\DeclareMathSizes{6}{6}{5}{5}
\DeclareMathSizes{7}{7}{5}{5}
\DeclareMathSizes{8}{8}{6}{5}
\DeclareMathSizes{9}{9}{7}{5}
\DeclareMathSizes{10}{10}{7.4}{6}
\DeclareMathSizes{10.95}{10.95}{8}{6}
\DeclareMathSizes{12}{12}{9}{7}
\DeclareMathSizes{14.4}{14.4}{10.95}{8}
\DeclareMathSizes{17.28}{17.28}{12}{10}
\DeclareMathSizes{20.74}{20.74}{14.4}{12}
\DeclareMathSizes{24.88}{24.88}{17.28}{14.4}
%    \end{macrocode}
% Redefine the standard font for the symbols encoding.
%    \begin{macrocode}
\DeclareFontSubstitution{OMS}{pzccm}{m}{n}
\fi
%    \end{macrocode}
%
%
% \subsection{Setting the font families}
%
% First, define the family names for everything.
%
%    \begin{macrocode}
\def\mdwf@cmr{cmr}
\def\mdwf@cmss{cmss}
\def\mdwf@cmtt{cmtt}
\def\mdwf@times{ptm}
\def\mdwf@palatino{ppl}
\def\mdwf@helvetica{phv}
\def\mdwf@courier{pcr}
%    \end{macrocode}
%
% Now assign families to the various variables.
%
%    \begin{macrocode}
\edef\rmdefault{\mdwf@bodyfont}
\edef\sfdefault{\mdwf@sansfont}
\edef\ttdefault{\mdwf@ttfont}
\edef\headdefault{\mdwf@headfont}
%    \end{macrocode}
%
% Set various maths families.
%
%    \begin{macrocode}
\def\mdwf@mathsfam#1#2#3{%
  \edef\@tempa{\noexpand\DeclareMathAlphabet{\noexpand#1}{#2}{#3}}%
  \@tempa%
}
\mdwf@mathsfam{\mathit}{OT1}{\rmdefault}{m}{it}
\mdwf@mathsfam{\mathbf}{OT1}{\rmdefault}{bx}{n}
\mdwf@mathsfam{\mathsf}{OT1}{\sfdefault}{m}{n}
\mdwf@mathsfam{\mathtt}{OT1}{\ttdefault}{m}{n}
%    \end{macrocode}
%
% Finally, set |\headfam| nicely.
%
%    \begin{macrocode}
\def\headfam{\fontfamily\headdefault\selectfont}
%    \end{macrocode}
%
% \subsection{Clobber standard packages}
%
% Now, if I recognise this document class, patch it until it accepts
% |\headfam| correctly.  This stuff isn't terribly pleasant, but I don't
% care about that.
%
% First see if I'm in familiar territory.
%
%    \begin{macrocode}
\begingroup
\catcode`\.11
\if1\ifx\ver@article.cls\@@undefined
    \ifx\ver@report.cls\@@undefined
    \ifx\ver@book.cls\@@undefined
    \ifx\ver@amsart.cls\@@undefined
    \ifx\ver@amsproc.cls\@@undefined
    \ifx\ver@amsbook.cls\@@undefined0%
    \else1\fi
    \else1\fi
    \else1\fi
    \else1\fi
    \else1\fi
    \else1\fi
%    \end{macrocode}
%
% Looks like it.  Now to patch the |\@startsection|-based commands.  I'll
% redefine |\@startsection| to do the atching for me, and then just run
% all the commands which want patching.
%
%    \begin{macrocode}
  \def\@startsection#1#2#3#4#5#6#7{%
    \gdef#7{\@startsection{#1}{#2}{#3}{#4}{#5}{#6\headfam}}%
  }
  \section\section
  \subsection\subsection
  \subsubsection\subsubsection
  \paragraph\paragraph
  \subparagraph\subparagraph
  \if1\ifx\ver@amsart.cls\@@undefined\ifx\ver@amsproc.cls\@@undefined0%
      \else1\fi\else1\fi
    \part\part
  \fi
%    \end{macrocode}
%
% Now for the difficult bits.  Firstly, deal with part headings for normal
% \LaTeX\ classes.
%
%    \begin{macrocode}
  \long\def\mdwf@grab#1{\expandafter\mdwf@grab@i#1\@@delim}
  \long\def\mdwf@grab@i#1\@@delim#2{#2{#1}}
  \def\mdwf@patch@opt#1{\mdwf@grab{#1[##1]{##2}}\mdwf@patch@opt@i#1}
  \long\def\mdwf@patch@opt@i#1#2{\gdef#2[##1]##2{%
    \let\mdwf@@bfseries\bfseries\def\bfseries{\headfam\mdwf@@bfseries}%
    #1%
    \let\bfseries\mdwf@@bfseries%
  }}%
  \def\mdwf@patch#1{\mdwf@grab{#1{##1}}\mdwf@patch@i#1}
  \long\def\mdwf@patch@i#1#2{\gdef#2##1{%
    \let\mdwf@@bfseries\bfseries\def\bfseries{\headfam\mdwf@@bfseries}%
    #1%
    \let\bfseries\mdwf@@bfseries%
  }}%
  \if0\ifx\ver@amsart.cls\@@undefined\ifx\ver@amsproc.cls\@@undefined0%
      \else1\fi\else1\fi
    \mdwf@patch@opt\@part
    \mdwf@patch\@spart
  \fi
  \ifx\@makechapterhead\@@undefined\else
    \mdwf@patch\@makechapterhead
    \mdwf@patch\@makeschapterhead
  \fi
\fi
\endgroup
%    \end{macrocode}
%
% Wasn't that fun?
%
%
% That's it for the package.
%
%    \begin{macrocode}
%</sty>
%    \end{macrocode}
%
%
% \section{Font installation script}
%
% If you're lucky you'll never need to use this.
%
%    \begin{macrocode}
%<*fontinst>
\input fontinst.sty
%    \end{macrocode}
%
% Firstly, some code for building squashed courier fonts.
%
%    \begin{macrocode}
\def\squashcourier#1{%
  \transformfont{pcr#18rn}{%
  \xscalefont{850}{%
    \reencodefont{8r}{\fromafm{pcr#18a}}}}}
\squashcourier{b}
\squashcourier{bo}
\squashcourier{r}
\squashcourier{ro}
%    \end{macrocode}
%
% Now start installing fonts.
%
%    \begin{macrocode}
\installfonts
%    \end{macrocode}
%
% Start with the courier ones.
%
%    \begin{macrocode}
\installfont{pcrb7tn}{pcrb8rn,psyr,latin}{OT1tt}{OT1}{pcr}{b}{n}{}
\installfont{pcrb8tn}{pcrb8rn,psyr,latin}{T1}{T1}{pcr}{b}{n}{}
\installfont{pcrbc7tn}{pcrb8rn,psyr,latin}{OT1ctt}{OT1}{pcr}{b}{sc}{}
\installfont{pcrbc8tn}{pcrb8rn,psyr,latin}{T1c}{T1}{pcr}{b}{sc}{}
\installfont{pcrbo7tn}{pcrbo8rn,psyr,latin}{OT1tt}{OT1}{pcr}{b}{sl}{}
\installfont{pcrbo8tn}{pcrbo8rn,psyr,latin}{T1}{T1}{pcr}{b}{sl}{}
\installfont{pcrr7tn}{pcrr8rn,psyr,latin}{OT1tt}{OT1}{pcr}{m}{n}{}
\installfont{pcrr8tn}{pcrr8rn,psyr,latin}{T1}{T1}{pcr}{m}{n}{}
\installfont{pcrrc7tn}{pcrr8rn,psyr,latin}{OT1ctt}{OT1}{pcr}{m}{sc}{}
\installfont{pcrrc8tn}{pcrr8rn,psyr,latin}{T1c}{T1}{pcr}{m}{sc}{}
\installfont{pcrro7tn}{pcrro8rn,psyr,latin}{OT1tt}{OT1}{pcr}{m}{sl}{}
\installfont{pcrro8tn}{pcrro8rn,psyr,latin}{T1}{T1}{pcr}{m}{sl}{}
%    \end{macrocode}
%
% Now build palatino-based maths fonts.  This lot seems to work.  It's based
% on \package{mathptm}, and hacked a bit.
%
%    \begin{macrocode}
\installfamily{OT1}{pplcm}{}
\installfamily{OML}{pplcm}{\skewchar\font=127}
\installfamily{OMS}{pzccm}{}
\installfamily{OMX}{psycm}{}
\installfont{zpplcmr}
   {pplr8r,psyr,latin,zrhax,kernoff,cmr10}
   {OT1}{OT1}{pplcm}{m}{n}{}
\installfont{zpplcmrm}
   {kernoff,cmmi10,kernon,unsetalf,unsethum,pplri8r,psyr,mathit,zrmhax}
   {OML}{OML}{pplcm}{m}{it}{}
\installfont{zpzccmry}
   {cmsy10,unsethum,psyr,pplr8r,unsetalf,pzcmi8r scaled 1124,mathsy}
   {OMS}{OMS}{pzccm}{m}{n}{}
\installfont{zpsycmrv}
   {cmex10,psyr,zrvhax,cmex9 scaled 900}
   {OMX}{OMX}{psycm}{m}{n}{}
%    \end{macrocode}
%
% Done.
%
%    \begin{macrocode}
\endinstallfonts
\end
%</fontinst>
%    \end{macrocode}
%
%
% \section{Description file for courier}
%
% Here's a short |.fd| file for the squashed courier font which makes it
% work in my `|mTT|' encoding.
%
%    \begin{macrocode}
%<*mttpcr>
\DeclareFontFamily{mTT}{pcr}{\hyphenchar\font=-1}
\DeclareFontShape{mTT}{pcr}{b}{n}{<-> pcrb7tn}{}
\DeclareFontShape{mTT}{pcr}{b}{sc}{<-> pcrbc7tn}{}
\DeclareFontShape{mTT}{pcr}{b}{sl}{<-> pcrbo7tn}{}
\DeclareFontShape{mTT}{pcr}{m}{n}{<-> pcrr7tn}{}
\DeclareFontShape{mTT}{pcr}{m}{sc}{<-> pcrrc7tn}{}
\DeclareFontShape{mTT}{pcr}{m}{sl}{<-> pcrro7tn}{}
\DeclareFontShape{mTT}{pcr}{bx}{n}{<->ssub * pcr/b/n}{}%
\DeclareFontShape{mTT}{pcr}{bx}{sc}{<->ssub * pcr/b/sc}{}%
\DeclareFontShape{mTT}{pcr}{bx}{sl}{<->ssub * pcr/b/sl}{}%
\DeclareFontShape{mTT}{pcr}{b}{it}{<->ssub * pcr/b/sl}{}%
\DeclareFontShape{mTT}{pcr}{bx}{it}{<->ssub * pcr/b/it}{}%
\DeclareFontShape{mTT}{pcr}{m}{it}{<->ssub * pcr/m/sl}{}%
%</mttpcr>
%    \end{macrocode}
%
% 
% Done.
%
% \hfill Mark Wooding, \today
%
% \Finale
%
\endinput
