From: Travis Moore firstname.lastname@example.org Date: Wed, 13 Dec 2017 13:07:30 +1300 Subject: Re: [9front] WANTED: instructions for adding fonts to troff
I’d like to expand the font options for troff in my installation. How might this be accomplished?
I’ve kept your mail in my inbox for nearly a year because I’d been meaning to look into this. I finally got around to it and figured out a method of sorts:
Obtain postscript versions of the font. The file with the font data has the extension .pfa or .pfb The file with the font metrics has the extension .afm I tested on the following materials:
http://mirrors.ctan.org/fonts/urw/garamond.zip https://www.math.utah.edu/~beebe/fonts/urwfonts-1.0.zip https://www.math.utah.edu/~beebe/fonts/utopia-1.0.zip https://www.math.utah.edu/~beebe/fonts/charter-1.0.zip
Apparently there are tools to convert from other formats.
Convert the font metrics to a troff font description. The attached awk script is something I hacked up to do this:
convpsfont ugmr8a.afm GA # URW Garamond
This creates a file GA which should look something like this:
name GA fontname GaramondNo8-Reg spacewidth 26 charset ! 26 2 33 " 42 2 34 &c...
Choose a name not in conflict with those in /sys/lib/troff/font/devutf/ Check the contents of this file makes sense; I haven’t tested many fonts and my script may need adjustment or the output may need to be tweaked by hand. The troff font format is described in: /sys/doc/troff.ps!32 The .afm format can be found at: http://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5004.AFM_Spec.pdf
Put the resulting file GA in /sys/lib/troff/font/devutf/ or else use troff’s -F flag to point to the dir that holds it.
You can now rm the .afm file or else keep it with its .pfa/.pfb
Let postscript see the font. Put the font (.pfa/.pfb) in /sys/lib/postscript/font/ I put mine in a subdir called useradded. Add an entry at the bottom of /sys/lib/postscript/font/fontmap:
% fonts added by user GaramondNo8-Reg useradded/ugmr8a.pfb
Create a file called /sys/lib/postscript/troff/GA:
0x0000 0x00ff GaramondNo8-Reg 0x2010 0x2044 GaramondNo8-Reg 0xfb00 0xfb06 GaramondNo8-Reg
You can use other fonts for ranges missing from your font.
Let ghostscript see the font.
cd /sys/lib/ghostscript/font && mk
Test. echo ‘.sp 1i .ft GA .ps 14 Pack my box with five dozen liquor jugs. ø ß á ä à æ ¼ ½ ¾ © ¶ §’ | troff | page
ps2pdf will embed the font and make it printable everywhere.
Hope this is useful to someone,