sl/plan9 OK, uriel.

From: Travis Moore 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:

  1. 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:

    Apparently there are tools to convert from other formats.

  2. 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
    !	26	2	33
    "	42	2	34

    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/!32 The .afm format can be found at:

    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

  3. 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.

  4. Let ghostscript see the font.

    cd /sys/lib/ghostscript/font && mk
  5. 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,