\def\VPL{\textsc{vpl}} \title{Building virtual fonts with `fontinst'} \author[Alan Jeffrey]{Alan Jeffrey\\\texttt{alanje@cogs.susx.ac.uk}} \begin{Article} \def\vptovf{\texttt{vptovf{}}} \def\afmtotfm{\texttt{afm2tfm}} \def\psnfss{\texttt{psnfss}} \def\pltotf{\texttt{pltotf}} \newcount\slot \newcount\p \def\fonttable#1{{% \font\foo=#1 at12pt \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 } \section{Introduction} This document gives a brief overview of the \fontinst{} package. The \fontinst{} package is used to build \emph{virtual fonts} (\emph{\VF{}}s) which allow PostScript fonts to be used as drop-in replacements for the Computer Modern fonts in \TeX. Below, I'll describe \VF{}s 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 \emph{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{ptmrraw} \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 ligatures 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-mn} \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 \emph{ 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 \texttt{.vf} file, which contains a small fragment of \DVI{} file for each character in the font. This \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 \DVI{} driver which understands \VF{}s 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 \VF{}s is that they are not very easy to generate. Despite having been in existence for four years, there are very few tools for creating \VF{}s. The most important tool is Knuth's \vptovf{}, which converts \emph{Virtual Property Lists} (\VPL{}s) into \VF{}s. 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 \VPL{}s is Rokicki's \afmtotfm, which converts the \emph{Adobe Font Metric} (\emph{AFM}) files which come with every PostScript font into \VPL{}s. 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. \section{A solution: the `fontinst' package} The \fontinst{} package is designed to read AFMs and produce \VPL{}s. 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 \VF{}s which have been generated with \fontinst{}. Version 0.19 of \fontinst{} is described in the proceedings of the Aston TUG~AGM (\emph{TUGboat} 14(3)). This description is now largely out of date. The \VF{}s generated by \fontinst{} will be the standard \VF{}s 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 \texttt{ fontinst.tex}. The simplest way to start to use \fontinst{} is to edit the file \texttt{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 \texttt{ptmr0.afm}, \texttt{ptmri0.afm}, \texttt{ptmb0.afm} and \texttt{ ptmbi0.afm}, the Times-Roman \textsc{afm} files. \item \texttt{latin.mtx}, the \emph{\TeX\ metric} file containing the default Latin characters. \item \texttt{T1.etx} and \texttt{T1c.etx}, the \emph{\TeX\ encoding} files containing the `\TeX\ extended text' and `\TeX\ extended tex caps \& small caps' encodings. \end{itemize} This produces a number of \textsc{PL} and \VPL{} fonts, which can be converted into \TeX\ fonts using \pltotf{} and \vptovf{}. For example by replacing every occurrence of \texttt{ptm} by \texttt{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{Article} \vfill \begin{table*}[!h] \begin{verbatim} \input fontinst.sty \needsfontinstversion{1.303} \installfonts \installfamily{T1}{ptm}{} \installfont{ptmrq}{ptmr0,latin}{T1}{T1}{ptm}{m}{n}{} \installfont{ptmrcq}{ptmr0,latin}{T1c}{T1}{ptm}{m}{sc}{} \installfont{ptmriq}{ptmri0,latin}{T1}{T1}{ptm}{m}{it}{} \installfont{ptmbq}{ptmb0,latin}{T1}{T1}{ptm}{bx}{n}{} \installfont{ptmbcq}{ptmb0,latin}{T1c}{T1}{ptm}{bx}{sc}{} \installfont{ptmbiq}{ptmbi0,latin}{T1}{T1}{ptm}{bx}{it}{} \endinstallfonts \bye \end{verbatim} \caption{The file \texttt{fonttime.tex}} \label{Tab:times} \end{table*} \newpage \endinput