tex ramblings 3: from tex to typography (a tutorial on using postscript
typefaces with latex)
So now that you have it installed and can process documents, you find yourself getting
impatient. After all, you are a typographer, no? Computer Modern,
which is Knuth’s interpretation of Monotype Modern No. 8a, is
beautiful and versatile, but it only takes you so far. Simply put,
you want to use other fonts. Specifically, you want to see the PostScript
typefaces for which you shelled out hard-earned cash come to life
within TeX.
Well, you can, and the purpose of this entry is to show you how. I’ll focus
on LaTeX, actually, and I’ll begin with the PostScript faces
freely available with TeX. Then, I’ll take you through an easy
installation of Adobe Garamond (with the expert set) using pre-built
files. Finally, I’ll show how the same face can be installed
“from scratch” and how text numerals can be used.
Before launching in, however, I should say that the best print references
for using PostScript fonts with TeX are (1) Goosens, Rahtz, and Mittelbach,
The LaTeX Graphics Companion; and (2) Hoenig, TeX Unbound;
this post is no substitute. I’ll add that everything below applies
to TeX (MiKTeX) running under Microsoft Windows.
Part 1
Using the standard PostScript typefaces
There is a wonderful command for loading LaTeX
packages, whether they be packages that call typefaces, specify leading
or character spacing, or load graphics. It is called
\usepackage,
and it is placed somewhere between
\documentclass{...}
and \begin{document}.
Open the file called sample2e.tex and
place the command \usepackage{times}
on the line above \begin{document}.
Process, and view the result using YAP (Yet Another Previewer), GSView,
or Acrobat Reader. See what happened? The typeface, with the exception of
the mathematics, was changed from Computer Modern to Times Roman.
Times is one of “the 35 PostScript fonts” you may have heard about. These
fonts were distributed with the Apple LaserWriter Plus in the mid-1980’s
and are standard issue with TeX. Eight typefaces comprise these 35
variants, which are: Times Roman, Palatino, New Century Schoolbook,
AvantGarde, Bookman, Helvetica, Courier, and Zapf Chancery.
Now try Palatino; voila, you get Palatino. This seems easy; let’s try New Century
Schoolbook. What? “LaTeX Error: File ‘NewCenturySchoolbook.sty’
not found.”
Well, sometimes the font name is abbreviated. But abbreviated to what? How would you
know? Take a look in /tex/latex/psnfss; you find times.sty. Scrolling
back to the n section, you find newcent.sty; and sure enough,
\usepackage{newcent}
works! But you look deeper, and you find .sty files for a wide variety
of typefaces: Apollo, Imprint, and Octavian, just to name a few. In
fact, you find .sty files for many more than the 35 basic fonts.
A confession: When I was new to TeX, and before I knew anything about type, I tried
for hours in vain to get the face Apollo to appear in my document.
I hadn’t yet realized that the distribution was helpful in providing
some of the architecture to make Apollo work, but not so helpful that
it would hand over the actual typeface for me. I had to license typefaces
to get them to work. Who knew?
Now, these 35 PostScript fonts are resident, and by specifying the typefaces that
comprise them with the \usepackage command, you will call them whether
you process your file with YAP, dvips, or pdfLaTeX. But when you wish
to reach beyond these fonts – and you will – things become
more complicated, albeit not much more so. Let’s install Adobe
Garamond, replete with expert characters, using the files and formats
already supplied for us, and let’s make it work such that you
can view the output with GSView and Acrobat Reader.
Part 2
Using other PostScript typefaces with LaTeX: Pre-assembled files
So what does the call to \usepackage actually do? In order to answer this question,
you’ll have to start looking at some files. Let’s begin
with xagaramon.sty; it may be found within tex/latex/psnfss. And if
not, you’ll get it shortly. There’s really not much to
this file: four lines that specify something called “padx”
as the default roman face. Yes, to make matters a bit confusing, PostScript
faces are not called by their real names. Rather, they are given three-
or sometimes four-letter abbreviations. The first letter represents
the supplier; p is Adobe’s designation. The following two letters
denote the typeface: ad is Adobe’s version of Garamond. And
the x stands for expert.
But how do you get from padx to the actual font file to output in Adobe Garamond?
Well, by the time you call xagaramon in your LaTeX file, you have
to make sure that all the supporting files – as well as the
fonts themselves – are in their correct places. Let’s
begin with the fonts that constitute Adobe Garamond; take a look at
the names of your font binary (.pfb) files. Three, four, or five letters,
followed by some underscores, to make a total of eight characters.
Unfortunately, these names just won’t do where LaTeX is concerned.
You’ll have to change them; go to /fontname/adobe.map. Scroll
down to faces 100 and 101; these numbers refer to the basic and the
expert sets, respectively. You’ll notice that the first entry
is AGaramond-Bold; this is Adobe’s font name. And whereas its
Windows name is gdb_____, its TeX name is padb8a. Select this section
and print it, and then proceed to copy all of your Adobe Garamond
.pfb files to /fonts/type1/adobe and place in a folder called xagaramon.
Now, rename them (e.g., change gdb_____.pfb to padb8a and so on).
You’re actually much of the way there! But there are several more files you need to
have in place before you’re good to go. The first of these is
a font definition (.fd) file, which links the font name to the encoding
to the style (roman, italic, etc.). Then there are the virtual font
(.vf) files, which are read by the driver and often contain information
on remapping characters in a font, as well as the TeX font metric
(.tfm) files, which specify each character’s dimensions. Finally,
there is the .map file, with which you’ve already dealt. Not
only do you need this for renaming your .pfb files, but you need to
make sure that the section of the .map file pertaining to your typeface
– in this case, Adobe Garamond – is present in the driver
files.
Fortunately, all of these files have been pre-assembled for Adobe Garamond as well
as for fonts from several other vendors and are freely available via
the CTAN page (or one of its mirrors) on the Internet. Go to http://ctan.tug.org
and then navigate to /fonts/psfonts/xadobe/agaramon/. The x in xadobe
denotes “expert” (note that most of the TeX files for
Adobe faces are found in the plain adobe directory). You will see
four subdirectories: dvips, tex, tfm, and vf. Copy the .fd and .sty
files from the tex subdirectory to your psnfss folder (under /tex/latex).
Next, copy all of the .tfm files from the tfm subdirectory to /fonts/tfm/adobe/xagaramon
(you will have to create the new folder, xagaramon). Similarly, copy
all of the .vf files from the vf subdirectory to /fonts/vf/adobe/xagaramon.
Finally, in order to process your file using dvips as well as pdfLaTeX,
copy the text from the .map file, which is in the dvips subdirectory,
anywhere into /dvips/config/ psfonts.map as well as into /pdftex/config/ psfonts.map,
if this text is not already there. You will notice that some of the
.map code specifies a SlantFont option; if used, a slanted, upright
form of the face is printed. Why in God’s name anyone would
want to do this is beyond me, although Knuth makes substantial use
of slanted Computer Modern. So, to summarize, perform the following
operations to use Adobe Garamond with LaTeX:
1. Copy .pfb files to type1 folder; rename
2. Copy .fd files and the .sty file to the psnfss folder
3. Copy .tfm files to tfm folder
4. Copy .vf files to vf folder
5. Copy applicable section of .map file to psfonts.map folders
Be sure to refresh your filename database, and then run LaTeX on sample2e.tex,
with \usepackage{xagaramon}.
Then, process using dvips and view with GSView, or process using pdfLaTeX
and view with Acrobat Reader. You should see your text in Adobe Garamond.
Although the math remains in Computer Modern, the ligatures are there,
and if you set off a word or phrase in small caps,
using \textsc{...},
you have small caps. Life is good!
But wait, what’s that – all lining figures? There must be an easy way to switch
to text or oldstyle numerals – some simple command, right? Wrong.
You can access the text figure, seven, for example, by calling the
package textcomp (available on CTAN) and then by using the command
\textsevenoldstyle. But using text numerals by default requires a
different set of LaTeX files. These are not supplied; you must generate
them anew, and this is the topic of the next section.
Part 3
Using other PostScript typefaces with LaTeX: Generating your own LaTeX files
This is a bit more laborious, but oh-so-gratifying, once you see the final
result. You will use a program called fontinst, along with two others,
pltotf and vptovf, to generate the .fd, .tfm, and .vf files. If the
fontinst directory is not part of your LaTeX package, copy it to /tex/latex.
To make things easier, copy the pltotf and vptovf executables from
/bin to /tex/latex/ fontinst/inputs/ tex. To generate the TeX font
metric information yourself, you will need to use Adobe Garamond’s
.afm files. Copy these also to /tex/latex/ fontinst/inputs/tex. Just
as you changed the names of your .pfb files, you will have to change
the designators of the .afm files to make them LaTeX-readable. Thus,
gdb_____.afm becomes padb8a.afm and so on.
Now comes the file generation part. Copy fontinst.sty and fontinst.ini to the same
folder and then run LaTeX on fontinst.sty. At the asterisk prompt,
type \latinfamily{padj}{} \bye.
The \latinfamily command is a simple
way to turn .afm files into the required LaTeX files; the j appended
to pad specifies text figures. The program runs for more than a few
seconds, and after completing, you’ll notice that you now have
a collection of .fd, .mtx, .pl, and .vpl files. The .pl and .vpl files
are simply the .tfm and .vf files in readable form. You will use the
programs pltotf and vptovf to convert the .pl and .vpl files into
binary format. Running these programs in a DOS window, you will type,
for example, pltotf padb9c.pl padb9c.tfm
for one of the .pl to .tfm
conversions and vptovf padb9c.vpl padb9c.vf padb9c.tfm for one of
the .vpl to .vf conversions. Yes, you will run this on each of the
.pl and .vpl files, one by one! I know that this operation can be
batch processed in other systems, and I’m sure it can be in
Windows; I just don’t know how.
When you’ve finished the conversions, move the newly-created .tfm and .vf files
to their respective folders in the fonts directory; move the .fd files
to the psnfss folder as well. You may delete the .pl, .vpl, and .mtx
files. Create a new .sty file by saving xagaramon.sty as xagaramonj.sty
and changing the contents to read {padj} instead of {padx}. Again,
refresh the filename database, and run LaTeX on sample2e.tex, this
time using your xagaramonj package. You should now see text figures
as default.
It will not be as straightforward as described; some tinkering will undoubtedly
be necessary. It helps to know a TeX-pert, too. I am not one, myself;
I have come this far only through much trial and error, and with a
great deal of banging my head against the wall. But I hope that this
short tutorial will be of some use to those of you who want to try
to use your PostScript typefaces with LaTeX; the journey may be arduous,
but the reward is great!
12-November 2002