From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from asquith.prosimetrum.com ([125.236.209.157]) by ur; Tue Dec 12 19:07:01 EST 2017 Message-ID: From: Travis Moore Date: Wed, 13 Dec 2017 13:07:30 +1300 To: 9front@9front.org Subject: Re: [9front] WANTED: instructions for adding fonts to troff In-Reply-To: 97f3adc8cb28033b37822d83f6adf2b9@pav1.example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-zakvstiflqgmazogzglbvtspyl" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: lossless strategy injection HTML lifecycle software browser-oriented optimizer This is a multi-part message in MIME format. --upas-zakvstiflqgmazogzglbvtspyl Content-Disposition: inline Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit > 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: 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. 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 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 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, Travis --upas-zakvstiflqgmazogzglbvtspyl Content-Disposition: attachment; filename=convpsfont Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit #!/bin/awk -f # convert postscript font metrics to font description for troff # usage: convpsfont font.afm TFONT BEGIN { name = ARGV[2] ARGV[2] = "" print "name", name > name tolerance = 75 # 0021-00ff (Latin), 2010-2044 (punctuation), fb00-fb06 (ligatures) # if you want more characters add them from adobe's glyph list codetab["exclam"] = 33 codetab["quotedbl"] = 34 codetab["numbersign"] = 35 codetab["dollar"] = 36 codetab["percent"] = 37 codetab["ampersand"] = 38 codetab["quotesingle"] = 39 codetab["parenleft"] = 40 codetab["parenright"] = 41 codetab["asterisk"] = 42 codetab["plus"] = 43 codetab["comma"] = 44 codetab["hyphen"] = 45 codetab["period"] = 46 codetab["slash"] = 47 codetab["zero"] = 48 codetab["one"] = 49 codetab["two"] = 50 codetab["three"] = 51 codetab["four"] = 52 codetab["five"] = 53 codetab["six"] = 54 codetab["seven"] = 55 codetab["eight"] = 56 codetab["nine"] = 57 codetab["colon"] = 58 codetab["semicolon"] = 59 codetab["less"] = 60 codetab["equal"] = 61 codetab["greater"] = 62 codetab["question"] = 63 codetab["at"] = 64 codetab["A"] = 65 codetab["B"] = 66 codetab["C"] = 67 codetab["D"] = 68 codetab["E"] = 69 codetab["F"] = 70 codetab["G"] = 71 codetab["H"] = 72 codetab["I"] = 73 codetab["J"] = 74 codetab["K"] = 75 codetab["L"] = 76 codetab["M"] = 77 codetab["N"] = 78 codetab["O"] = 79 codetab["P"] = 80 codetab["Q"] = 81 codetab["R"] = 82 codetab["S"] = 83 codetab["T"] = 84 codetab["U"] = 85 codetab["V"] = 86 codetab["W"] = 87 codetab["X"] = 88 codetab["Y"] = 89 codetab["Z"] = 90 codetab["bracketleft"] = 91 codetab["backslash"] = 92 codetab["bracketright"] = 93 codetab["asciicircum"] = 94 codetab["underscore"] = 95 codetab["grave"] = 96 codetab["a"] = 97 codetab["b"] = 98 codetab["c"] = 99 codetab["d"] = 100 codetab["e"] = 101 codetab["f"] = 102 codetab["g"] = 103 codetab["h"] = 104 codetab["i"] = 105 codetab["j"] = 106 codetab["k"] = 107 codetab["l"] = 108 codetab["m"] = 109 codetab["n"] = 110 codetab["o"] = 111 codetab["p"] = 112 codetab["q"] = 113 codetab["r"] = 114 codetab["s"] = 115 codetab["t"] = 116 codetab["u"] = 117 codetab["v"] = 118 codetab["w"] = 119 codetab["x"] = 120 codetab["y"] = 121 codetab["z"] = 122 codetab["braceleft"] = 123 codetab["bar"] = 124 codetab["verticalbar"] = 124 codetab["braceright"] = 125 codetab["asciitilde"] = 126 codetab["exclamdown"] = 161 codetab["cent"] = 162 codetab["sterling"] = 163 codetab["currency"] = 164 codetab["yen"] = 165 codetab["brokenbar"] = 166 codetab["section"] = 167 codetab["dieresis"] = 168 codetab["copyright"] = 169 codetab["ordfeminine"] = 170 codetab["guillemotleft"] = 171 codetab["logicalnot"] = 172 codetab["sfthyphen"] = 173 codetab["softhyphen"] = 173 codetab["registered"] = 174 codetab["macron"] = 175 codetab["overscore"] = 175 codetab["degree"] = 176 codetab["plusminus"] = 177 codetab["twosuperior"] = 178 codetab["threesuperior"] = 179 codetab["acute"] = 180 codetab["mu"] = 181 codetab["mu1"] = 181 codetab["paragraph"] = 182 codetab["middot"] = 183 codetab["periodcentered"] = 183 codetab["cedilla"] = 184 codetab["onesuperior"] = 185 codetab["ordmasculine"] = 186 codetab["guillemotright"] = 187 codetab["onequarter"] = 188 codetab["onehalf"] = 189 codetab["threequarters"] = 190 codetab["questiondown"] = 191 codetab["Agrave"] = 192 codetab["Aacute"] = 193 codetab["Acircumflex"] = 194 codetab["Atilde"] = 195 codetab["Adieresis"] = 196 codetab["Aring"] = 197 codetab["AE"] = 198 codetab["Ccedilla"] = 199 codetab["Egrave"] = 200 codetab["Eacute"] = 201 codetab["Ecircumflex"] = 202 codetab["Edieresis"] = 203 codetab["Igrave"] = 204 codetab["Iacute"] = 205 codetab["Icircumflex"] = 206 codetab["Idieresis"] = 207 codetab["Eth"] = 208 codetab["Ntilde"] = 209 codetab["Ograve"] = 210 codetab["Oacute"] = 211 codetab["Ocircumflex"] = 212 codetab["Otilde"] = 213 codetab["Odieresis"] = 214 codetab["multiply"] = 215 codetab["Oslash"] = 216 codetab["Ugrave"] = 217 codetab["Uacute"] = 218 codetab["Ucircumflex"] = 219 codetab["Udieresis"] = 220 codetab["Yacute"] = 221 codetab["Thorn"] = 222 codetab["germandbls"] = 223 codetab["agrave"] = 224 codetab["aacute"] = 225 codetab["acircumflex"] = 226 codetab["atilde"] = 227 codetab["adieresis"] = 228 codetab["aring"] = 229 codetab["ae"] = 230 codetab["ccedilla"] = 231 codetab["egrave"] = 232 codetab["eacute"] = 233 codetab["ecircumflex"] = 234 codetab["edieresis"] = 235 codetab["igrave"] = 236 codetab["iacute"] = 237 codetab["icircumflex"] = 238 codetab["idieresis"] = 239 codetab["eth"] = 240 codetab["ntilde"] = 241 codetab["ograve"] = 242 codetab["oacute"] = 243 codetab["ocircumflex"] = 244 codetab["otilde"] = 245 codetab["odieresis"] = 246 codetab["divide"] = 247 codetab["oslash"] = 248 codetab["ugrave"] = 249 codetab["uacute"] = 250 codetab["ucircumflex"] = 251 codetab["udieresis"] = 252 codetab["yacute"] = 253 codetab["thorn"] = 254 codetab["ydieresis"] = 255 codetab["hyphentwo"] = 8208 codetab["figuredash"] = 8210 codetab["endash"] = 8211 codetab["emdash"] = 8212 codetab["horizontalbar"] = 8213 codetab["dblverticalbar"] = 8214 codetab["dbllowline"] = 8215 codetab["underscoredbl"] = 8215 codetab["quoteleft"] = 8216 codetab["quoteright"] = 8217 codetab["quotesinglbase"] = 8218 codetab["quoteleftreversed"] = 8219 codetab["quotereversed"] = 8219 codetab["quotedblleft"] = 8220 codetab["quotedblright"] = 8221 codetab["quotedblbase"] = 8222 codetab["dagger"] = 8224 codetab["daggerdbl"] = 8225 codetab["bullet"] = 8226 codetab["onedotenleader"] = 8228 codetab["twodotenleader"] = 8229 codetab["twodotleader"] = 8229 codetab["ellipsis"] = 8230 codetab["perthousand"] = 8240 codetab["minute"] = 8242 codetab["second"] = 8243 codetab["primereversed"] = 8245 codetab["guilsinglleft"] = 8249 codetab["guilsinglright"] = 8250 codetab["referencemark"] = 8251 codetab["exclamdbl"] = 8252 codetab["overline"] = 8254 codetab["asterism"] = 8258 codetab["fraction"] = 8260 codetab["ff"] = 64256 codetab["fi"] = 64257 codetab["fl"] = 64258 codetab["ffi"] = 64259 codetab["ffl"] = 64260 codetab["ft"] = 64261 codetab["st"] = 64262 chartab["exclam"] = "!" chartab["quotedbl"] = "\"" chartab["numbersign"] = "#" chartab["dollar"] = "$" chartab["percent"] = "%" chartab["ampersand"] = "&" chartab["quotesingle"] = "'" chartab["parenleft"] = "(" chartab["parenright"] = ")" chartab["asterisk"] = "*" chartab["plus"] = "+" chartab["comma"] = "," chartab["hyphen"] = "-" chartab["period"] = "." chartab["slash"] = "/" chartab["zero"] = "0" chartab["one"] = "1" chartab["two"] = "2" chartab["three"] = "3" chartab["four"] = "4" chartab["five"] = "5" chartab["six"] = "6" chartab["seven"] = "7" chartab["eight"] = "8" chartab["nine"] = "9" chartab["colon"] = ":" chartab["semicolon"] = ";" chartab["less"] = "<" chartab["equal"] = "=" chartab["greater"] = ">" chartab["question"] = "?" chartab["at"] = "@" chartab["A"] = "A" chartab["B"] = "B" chartab["C"] = "C" chartab["D"] = "D" chartab["E"] = "E" chartab["F"] = "F" chartab["G"] = "G" chartab["H"] = "H" chartab["I"] = "I" chartab["J"] = "J" chartab["K"] = "K" chartab["L"] = "L" chartab["M"] = "M" chartab["N"] = "N" chartab["O"] = "O" chartab["P"] = "P" chartab["Q"] = "Q" chartab["R"] = "R" chartab["S"] = "S" chartab["T"] = "T" chartab["U"] = "U" chartab["V"] = "V" chartab["W"] = "W" chartab["X"] = "X" chartab["Y"] = "Y" chartab["Z"] = "Z" chartab["bracketleft"] = "[" chartab["backslash"] = "\\" chartab["bracketright"] = "]" chartab["asciicircum"] = "^" chartab["underscore"] = "_" chartab["grave"] = "`" chartab["a"] = "a" chartab["b"] = "b" chartab["c"] = "c" chartab["d"] = "d" chartab["e"] = "e" chartab["f"] = "f" chartab["g"] = "g" chartab["h"] = "h" chartab["i"] = "i" chartab["j"] = "j" chartab["k"] = "k" chartab["l"] = "l" chartab["m"] = "m" chartab["n"] = "n" chartab["o"] = "o" chartab["p"] = "p" chartab["q"] = "q" chartab["r"] = "r" chartab["s"] = "s" chartab["t"] = "t" chartab["u"] = "u" chartab["v"] = "v" chartab["w"] = "w" chartab["x"] = "x" chartab["y"] = "y" chartab["z"] = "z" chartab["braceleft"] = "{" chartab["bar"] = "|" chartab["verticalbar"] = "|" chartab["braceright"] = "}" chartab["asciitilde"] = "~" chartab["exclamdown"] = "¡" chartab["cent"] = "¢" chartab["sterling"] = "£" chartab["currency"] = "¤" chartab["yen"] = "¥" chartab["brokenbar"] = "¦" chartab["section"] = "§" chartab["dieresis"] = "¨" chartab["copyright"] = "©" chartab["ordfeminine"] = "ª" chartab["guillemotleft"] = "«" chartab["logicalnot"] = "¬" chartab["sfthyphen"] = "­" chartab["softhyphen"] = "­" chartab["registered"] = "®" chartab["macron"] = "¯" chartab["overscore"] = "¯" chartab["degree"] = "°" chartab["plusminus"] = "±" chartab["twosuperior"] = "²" chartab["threesuperior"] = "³" chartab["acute"] = "´" chartab["mu"] = "µ" chartab["mu1"] = "µ" chartab["paragraph"] = "¶" chartab["middot"] = "·" chartab["periodcentered"] = "·" chartab["cedilla"] = "¸" chartab["onesuperior"] = "¹" chartab["ordmasculine"] = "º" chartab["guillemotright"] = "»" chartab["onequarter"] = "¼" chartab["onehalf"] = "½" chartab["threequarters"] = "¾" chartab["questiondown"] = "¿" chartab["Agrave"] = "À" chartab["Aacute"] = "Á" chartab["Acircumflex"] = "Â" chartab["Atilde"] = "Ã" chartab["Adieresis"] = "Ä" chartab["Aring"] = "Å" chartab["AE"] = "Æ" chartab["Ccedilla"] = "Ç" chartab["Egrave"] = "È" chartab["Eacute"] = "É" chartab["Ecircumflex"] = "Ê" chartab["Edieresis"] = "Ë" chartab["Igrave"] = "Ì" chartab["Iacute"] = "Í" chartab["Icircumflex"] = "Î" chartab["Idieresis"] = "Ï" chartab["Eth"] = "Ð" chartab["Ntilde"] = "Ñ" chartab["Ograve"] = "Ò" chartab["Oacute"] = "Ó" chartab["Ocircumflex"] = "Ô" chartab["Otilde"] = "Õ" chartab["Odieresis"] = "Ö" chartab["multiply"] = "×" chartab["Oslash"] = "Ø" chartab["Ugrave"] = "Ù" chartab["Uacute"] = "Ú" chartab["Ucircumflex"] = "Û" chartab["Udieresis"] = "Ü" chartab["Yacute"] = "Ý" chartab["Thorn"] = "Þ" chartab["germandbls"] = "ß" chartab["agrave"] = "à" chartab["aacute"] = "á" chartab["acircumflex"] = "â" chartab["atilde"] = "ã" chartab["adieresis"] = "ä" chartab["aring"] = "å" chartab["ae"] = "æ" chartab["ccedilla"] = "ç" chartab["egrave"] = "è" chartab["eacute"] = "é" chartab["ecircumflex"] = "ê" chartab["edieresis"] = "ë" chartab["igrave"] = "ì" chartab["iacute"] = "í" chartab["icircumflex"] = "î" chartab["idieresis"] = "ï" chartab["eth"] = "ð" chartab["ntilde"] = "ñ" chartab["ograve"] = "ò" chartab["oacute"] = "ó" chartab["ocircumflex"] = "ô" chartab["otilde"] = "õ" chartab["odieresis"] = "ö" chartab["divide"] = "÷" chartab["oslash"] = "ø" chartab["ugrave"] = "ù" chartab["uacute"] = "ú" chartab["ucircumflex"] = "û" chartab["udieresis"] = "ü" chartab["yacute"] = "ý" chartab["thorn"] = "þ" chartab["ydieresis"] = "ÿ" chartab["hyphentwo"] = "‐" chartab["figuredash"] = "‒" chartab["endash"] = "–" chartab["emdash"] = "—" chartab["horizontalbar"] = "―" chartab["dblverticalbar"] = "‖" chartab["dbllowline"] = "‗" chartab["underscoredbl"] = "‗" chartab["quoteleft"] = "‘" chartab["quoteright"] = "’" chartab["quotesinglbase"] = "‚" chartab["quoteleftreversed"] = "‛" chartab["quotereversed"] = "‛" chartab["quotedblleft"] = "“" chartab["quotedblright"] = "”" chartab["quotedblbase"] = "„" chartab["dagger"] = "†" chartab["daggerdbl"] = "‡" chartab["bullet"] = "•" chartab["onedotenleader"] = "․" chartab["twodotenleader"] = "‥" chartab["twodotleader"] = "‥" chartab["ellipsis"] = "…" chartab["perthousand"] = "‰" chartab["minute"] = "′" chartab["second"] = "″" chartab["primereversed"] = "‵" chartab["guilsinglleft"] = "‹" chartab["guilsinglright"] = "›" chartab["referencemark"] = "※" chartab["exclamdbl"] = "‼" chartab["overline"] = "‾" chartab["asterism"] = "⁂" chartab["fraction"] = "⁄" chartab["ff"] = "ff" chartab["fi"] = "fi" chartab["fl"] = "fl" chartab["ffi"] = "ffi" chartab["ffl"] = "ffl" chartab["ft"] = "ſt" chartab["st"] = "st" } /^FontName /{print "fontname", $2 >> name} /^XHeight /{xheight = $2} # The following assumes character data looks like: # C 33 ; WX 258 ; N exclam ; B 67 -10 194 688 ; /^C 32 ;/{ print "spacewidth", int(($5+5)/10) >> name print "charset" >> name next } /^C /{ if(chartab[$8] == "") next printf "%s\t", chartab[$8] >> name printf "%d\t", int(($5+5)/10) >> name ascdesc = 0 if($12 < -tolerance) ascdesc++ if($14 > xheight+tolerance) ascdesc += 2 printf "%d\t", ascdesc >> name printf "%d\n", codetab[$8] >> name } --upas-zakvstiflqgmazogzglbvtspyl--