How-To Use Postscript Type 1 fonts with GROFF?

~draft 1.1 as of 18-DEC-2002~

This small How-To describes how to use Postscript Type 1 fonts with the UNIX textformatting program groff and its helper applications. I will describe my own setup, which works for me and as always, your mileage may vary.

What do I need?

Assuming you have a Postscript Type 1 font file on your Apple Macintosh, you may wish to copy it on a netatalk volume, so you can access it easily on the UNIX side of life. Netatalk provides file server capabilites for Apple Macintosh computers. The data and the resource fork are stored separately on the UNIX side, where the resource fork is found in a hidden subdirectory called .AppleDouble.

The following utilities are used in this process:

utilitypackagepurposedownload location
t1unmact1utilsto generate PFA files from a Type 1 resource forkdownload
pfa2afmto generate probably missing AFM files from PFA filesdownload
afmtoditgroffto generate GROFF compatible font file out of the above filesdownload

What should I do?

First we change our current working directory to groff’s prefix and step further into the font/devps directory, where all files for the poscript device reside:

cd ${groff_prefix}/font/devps

which for example means on my system

cd /usr/share/groff/1.18.1/font/devps

Garamand Condensed (a type by SWFTE is used in this example)

t1unmac --appledouble --pfa \
    /MacVol_01/Fonts/.AppleDouble/GaramConSWPla GaramConSWPla.pfa
pfa2afm GaramConSWPla.pfa

We choose to make the type named “Garamand Condensed” available als “GCP” in groff:

afmtodit -d DESC -e text.enc \
    GaramConSWPla.afm generate/textmap GCP

Now the type is ready to be used in groff, but if we want to print it on a postscript printer, we have to tell it that this font is downloadable. This is easily achieved by adding a line to the file “download”. We need to add a reference from the groff’s internal file name to the downloadable PFA font file:

echo -e "`grep "internalname" GCP | awk '{print $2}'`\tGaramConSWPla.pfa" \
    >> download

How do I use it?

You can reference the new font by “GCP” in groff, e.g. by using

.ft GCP
This is Garamand Condensed

What problems are likely to occur?

Sometimes Macintosh font files are stored with ^M as their “line switching” character, especially if you have ready-to-use AFM files (adobe font metrics) enclosed with your Type 1 font files. If one of the programs above doesn’t produce a suitable output, you need to convert its input file by converting the “line switching” character. This is done by using tr (“translate”):

cat inputfile | tr '\015' '\012' > outfile