\documentstyle[twocolumn]{article} \title{Building virtual fonts with {\tt fontinst}} \author{Alan Jeffrey} \date{9 January 1994} \def\fontinst{{\tt fontinst}} \def\vptovf{{\tt vptovf}} \def\afmtotfm{{\tt afm2tfm}} \def\psnfss{{\tt psnfss}} \def\pltotf{{\tt pltotf}} \def\LaTeXe{\LaTeX\hskip.15em$2_{\textstyle\varepsilon}$} \newcount\slot \newcount\p \def\fonttable#1{{% \font\foo=#1 \foo \global\slot=0 \global\p=0 \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow \fontrow }} \def\fontrow{% \global\p=0 \setbox0\hbox{} \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \fontcell \ifnum\p<16 \leavevmode\box0\par \fi } \def\fontcell{% \setbox0\hbox{% \unhbox0 \hbox to 10pt{% \hss \penalty1 \char\slot \global\advance\p by \lastpenalty \hss }% }% \global\advance\slot by 1 } \begin{document} \maketitle \section{Introduction} This document gives a brief overview of the \fontinst{} package. The \fontinst{} package is used to build {\em virtual fonts\/} ({\em VF\/}s) which allow PostScript fonts to be used as drop-in replacements for the Computer Modern fonts in \TeX. Below, I'll describe VFs briefly, and describe how they can be built using the \fontinst{} package. \section{A problem with fonts} One of the biggest problems about using fonts in \TeX{} is {\em encodings}, that is the order the characters come in the font. For example, the default encoding for Adobe's Times-Roman font is the `Adobe Standard encoding': \begin{center} \fonttable{ptmr0} \end{center} The default encoding for \TeX, however, is the `\TeX\ text encoding'. The Adobe Times-Roman font in the `\TeX\ text encoding' is:\footnote{% The \TeX nically minded may note that the glyphs `\l' and `\L' are not normally in the `\TeX\ text encoding'. This is because Computer Modern has a special `\l-slash' glyph for building `\l' and `\L', which Adobe Times-Roman does not have. Its place is therefore taken by a black square, and there are liguatures with `l' and `L' to produce `\l' and `\L'. Thus this font is drop-in compatible with Computer Modern, despite the lack of an `\l-slash' glyph. } \begin{center} \fonttable{ptmr} \end{center} There are many other competing encodings: `ISO Latin-1', `\TeX\ extended text' (or `Cork'), `Macintosh', the list is seemingly endless. In addition, different encodings contain different glyphs. The \TeX\ text encoding is supposed to contain a dotless `j' character, and a slash for building `\l' and `\L', but very few fonts contain these characters, and their places are taken by black squares above. The problem of incompatible font encodings is addressed in \TeX{} by {\em virtual fonts}. \section{A solution: virtual fonts} As far as \TeX{} is concerned a virtual font (VF) is a font like any other. It has a \TeX{} font metric file, which contains the dimensions of each character, together with ligatures, kerning, and other typographical information. However, a VF does not have an associated bitmap, Type~1 font, TrueType font, or other information about what the font should look like. Instead, a VF has an associated {\tt vf} file, which contains a small fragment of {\tt dvi} file for each character in the font. This {\tt dvi} fragment may contain characters from other fonts, rules or \verb|\specials|. For example, the `Adobe Standard' encoded Times-Roman font above is a `raw' Type~1 font, but the `\TeX{} text' encoded Times-Roman font is a virtual font. \begin{itemize} \item The `ff', `ffi' and `ffl' ligatures are faked by putting an `f' next to an `f', `fi' or `fl'. \item The missing `dotless j' and `\l-slash' are rules, together with a `Warning: missing glyph' \verb|\special|. \item The Greek upper case come from the Symbol Type~1 font. \item The other characters come from the Times-Roman Type~1 font. \end{itemize} Any {\tt dvi} driver which understands VFs and can use Type~1 fonts can use the \TeX\ text Times-Roman VF as a drop-in replacement for Computer Modern. \section{A problem with virtual fonts} One stumbling block about using VFs is that they are not very easy to generate. Despite having been in existence for four years, there are very few tools for creating VFs. The most important tool is Knuth's \vptovf, which converts {\em Virtual Property Lists\/} ({\em VPL\/}s) into VFs. Unfortunately, the VPL language is rather opaque, for example the VPL code for the Adobe Times character `ff' is: \begin{verbatim} (CHARACTER D 11 (CHARWD R 6.47998) (CHARHT R 6.81995) (CHARDP R 0.0) (MAP (SELECTFONT D 1) (SETCHAR D 102) (MOVERIGHT R -0.17993) (SETCHAR D 102) ) ) \end{verbatim} Editing VPL files by hand is something of a black art, and there are few tools for manipulating them. The main tool for generating VPLs is Rockiki's \afmtotfm, which converts the {\em Adobe Font Metric\/} ({\em AFM\/}) files which come with every PostScript font into VPLs. Unfortunately, \afmtotfm{} cannot produce fonts with more than one raw font (for example the `\TeX{} text' encoded Times-Roman uses Symbol for the upper case Greek) and had problems with math fonts. \begin{table*}[t] % Hacks ahoy! \def\next{% \p=\catcode`\% \begin{verbatim}% \catcode`\%=\p \input{fonttime.tex}% } \next\end{verbatim} \caption{The file {\tt fonttime.tex}} \label{Tab:times} \end{table*} \section{A solution: the \fontinst{} package} The \fontinst{} package is designed to read AFMs and produce VPLs. It: \begin{itemize} \item Is written in \TeX, for maximum portabilty (at the cost of speed). \item Supports the \TeX\ text, \TeX\ math, and extended \TeX\ text encoding. \item Allows fonts to be generated in an arbitrary encoding, with arbitrary `fake' characters---for example the `ff' character can be faked if necessary by putting an `f' next to a `f'. \item Allows caps and small caps fonts with letter spacing and kerning. \item Allows kerning to be shared between characters, for example `\AA' can be kerned as if it were an `A'. This is useful, since many PostScript fonts only include kerning information for characters without accents. \item Allows the generation of math fonts. \item Allows more than one PostScript font to contribute to a \TeX\ font, for example the `ff' ligature can be taken from the Expert encoding, if you have it. \item Automatically generates an \verb|fd| file for use with \LaTeXe. \end{itemize} The \fontinst{} package is available as freeware from the CTAN archives, along with a selection of VFs which have been generated with \fontinst{}. Version 0.19 of \fontinst{} is described in the proceedings of the Aston TUG~AGM ({\em TUGboat\/} 14(3)). This description is now largely out of date. The VFs generated by \fontinst{} will be the standard VFs for use with Sebastian Rahtz's \psnfss{} package for \LaTeXe. \section{Using the \fontinst{} package} The \fontinst{} package comes with full documentation in the file {\tt fontinst.tex}. The simplest way to start to use \fontinst{} is to edit the file {\tt fonttime.tex}, shown in Table~\ref{Tab:times}. This tells \TeX\ to create the Adobe Times Roman fonts in the `\TeX\ extended text' (T1) encoding, using the files: \begin{itemize} \item {\tt ptmr0.afm}, {\tt ptmri0.afm}, {\tt ptmb0.afm} and {\tt ptmbi0.afm}, the Times-Roman AFM files. \item {\tt latin.mtx}, the {\em \TeX\ metric\/} file containing the default Latin characters. \item {\tt T1.etx} and {\tt T1c.etx}, the {\em \TeX\ encoding\/} files containing the `\TeX\ extended text' and `\TeX\ extended tex caps \& small caps' encodings. \end{itemize} This produces a number of PL and VPL fonts, which can be converted into \TeX\ fonts using \pltotf{} and \vptovf. For example by replacing every occurrence of {\tt ptm} by {\tt ppl} you can install the Adobe Palatino fonts. If you generate any fonts with \fontinst{} which you think other people might want to use, please send them to me, and if I like them, I'll include them in the \fontinst\ contributors directory. \end{document}