Next Previous Contents

9. TeX / LaTeX

9.1 A Quick Primer on LaTeX/TeX fonts

Adding fonts to TeX and LaTeX is a somewhat complex procedure. However, like a lot of things, it's easy if you know how to do it. Some fonts are distributed in metafont format, and some in Type1 format. Usually, the Type1 formats are more easily available. However, metafont fonts have the distinct advantage that they can adjust their shape at different sizes, while Type1 and TrueType fonts at different point sizes are simply magnified or reduced versions of precisely the same shape. The main reason why this feature is desirable is that ideally, fonts should be ( relatively ) wider at smaller sizes and narrower at larger sizes.

For this discussion, we focus on Type1 fonts, since they are more widely available, and more problematic to install.

Here's a quick primer on LaTeX fonts. LaTeX uses the following types of font files for handling Type1 fonts:

It's good to know your way around the TeX directory structure. Here are the main directories you'll need to know about:

9.2 Adding Type1 fonts

Naming the fonts

First, you need to appropriately name your fonts. See the fontinst documentation on your system for instructions on how to name fonts ( it should be fontinst subdirectory of the directory containing your tetex documentation ). To make a long story very short, the naming scheme is FNW{V}E{n} where:

For example, the font Adobe Garamond demibold is pgad8a.

Creating the virtual fonts and tex font metrics

Now you can run fontinst as follows:

        latex `kpsewhich fontinst.sty`
        
then you type at the prompt:
        \latinfamily{font_name}{}\bye
        
where font_name is the first three letters of your font file name ( for example, pad for adobe garamond ). Now fontinst will generate a number of files -- font description files, property list files and virtual property list files. It also generates a lot of .mtx files. These are created by fontinst, but you don't need to use them. You need to convert the property lists and virtual property lists to metrics and virtual fonts. This is done using the utilities vptovf and pltotf.
        for X in *.pl; do pltotf $X; done
        for X in *.vpl; do vptovf $X; done
        
Then remove the old vpl, pl and mtx files.

Configure dvips

You will need to edit your dvips config file, psfonts.map. The best way to explain the format of the file is to give an example.

        
     marr8r          ArialMT <8r.enc <farr8a.pfa
     marbi8r         Arial_BoldItalicMT <8r.enc <farbi8a.pfa
     marb8r          Arial_BoldMT <8r.enc <farb8a.pfa
     marri8r         Arial_ItalicMT <8r.enc <farri8a.pfa
     marr8rn         Arial_Narrow <8r.enc <farr8an.pfa
        
The 8r.enc is simply there to inform dvips of the encoding scheme used ( in all our examples, it's 8r, because of the way fontinst constructs the virtual fonts ). The leftmost column is the font name TeX uses. The second column is the real name of the font, which is hardcoded into the font file ( this name can be deduced by opening the afm file in a text editor, and looking for the FontName directive ). The last column is the filename of the shape file corresponding with the font. It is not necessary to provide a directory path -- tex knows where to look.

Test the font

Try running latex on a document like this:

\documentclass{article}
\begin{document}
        \usefont{T1}{pga}{m}{n}\selectfont
        \huge
        Testing a new font \dots the quick red fox jumped over the lazy brown dogs
\end{document} 
         
where you replace pga with the outline of your font. If this works, you are almost done. All you have to do now is put all the files in the right directories ( as explained in the primer ), then run
         texconfig rehash
         
so that tex can update the directory lists.

Create a .sty file

You may want to create a .sty file so that you can more easily use fonts. Use the files in $TEXMF/tex/latex/psnfss as a template.


Next Previous Contents