groff wouldn't be as much fun if we were stuck with just the few fonts that are part of the standard package. Fortunately, if you are using a PostScript device, groff makes it simple to install any Type 1 font. groff also comes with the machinery to automatically include fonts in a PostScript output file, so you don't need to take any extra steps to download them to your printer.
To begin a font installation, find the devps directory where the groff PostScript device files are located. On a Linux system, this will be somewhere like:
/usr/share/groff/font/devpsWorking from within this directory, font installation is basically a three-step process. We will sketch the steps below with an example of installing the Roman typeface of the Optima family. Here the internal PostScript font name is “Optima”, and groff will be set up to access this font as OptimaR. (We would follow this setup with the complete family as OptimaI, OptimaB and OptimaBI for the italic, bold and bold italic variants of the Optima family.)
Step 1. Create the groff metric file from the type1 afm file:
<command:> afmtodit.pl -e text.enc op______.afm textmap OptimaRStep 2. Convert the .pfb file to .pfa format:
<command:> pfbtops op______.pfb >op______.pfaStep 3. Edit the file named download in the devps directory and add a line with the following entry:
Optima op______.pfaStep one uses the afmtodit.pl utility that ships with groff to convert the font's PostScript metric file from afm format (for “adobe metric file”) to dit format (for “device independent troff”). In the example, we use the -e option to re-encode the font with the text.enc encoding file that comes with groff, to access to many more characters than are usually available with the standard encoding. The next three arguments are required and are the font's .afm file, groff's textmap file and the name by which we want to refer to this font from groff.
The second step uses the pfbtops utility to convert the Type 1 font from binary format to “ASCII” format. Most Type 1 fonts are distributed in a compact binary format, recognized by a .pfb extension. groff's automatic download mechanism, however, needs the ASCII version of a Type 1 font, generally recognized by a .pfa extension.
The third step registers the font with groff's automatic download mechanism. The file named download in the /devps directory is a simple ASCII file with two space-delimited fields per line. The first field has the internal PostScript name for the font, and the second field gives the location of the .pfa file to download for this font.
That's it. Repeat for the italic, bold and bold italic variants, following the same pattern as above. Then, the Optima fonts are available on request from within your document:
.ALIAS FONT ftIn the sample text above, we have shown the use of aliased groff requests to change the font. Of course, the main article should give you some ideas on how to design and export an improved user interface for the selection of fonts using groff macros.
.ALIAS FONTFAM fam .FONT OptimaR .<p> #The text here will appear in Optima Roman. .FONTFAM Optima .<p> #The text here will also appear in Optima Roman. The .fam request is a groff extension that makes it easier to work with typeface families. .<p> It is also possible to change fonts with \f[OptimaI]inline\fP escape sequences. Since the groff family mechanism is in use, we can also change \fIinline\fP with the abbreviated escape sequence to get the italic variant of the current family.
One large and complete set of freely available Type 1 fonts is the Computer Modern collection—originating with Donald Knuth's TEX/Metafont system—converted into PostScript format and made freely available by Blue Sky Research. These work well with the groff typesetter and provide the full set of f ligatures. One modification with respect to ligatures is required in the above procedure. Since groff recognizes only f ligatures, you will need to edit the dit file created in step one above. Find the line beginning with the word “ligatures” near the top of the file, and delete any entries that are not fi, ff, fl, ffi or ffl.
A similar procedure is required for fonts such as those in the Bitstream 500 and Corel collections. Most of these fonts do have fi and fl ligature characters, but the afmtodit.pl utility doesn't “find” them. In this case, simply edit the dit file created in step one above. Insert the single line that follows near the top of the file, immediately before the line beginning with the word kernpairs:
ligatures fi fl 0Now, groff will be able to access these ligatures and automatically insert them in the printed output. This is one of the many small details that gives documents typeset by groff their refined and professional quality.