4 echo "usage: $0 font-name | gsnd - >font-name.afm" >&2
11 % (c) 1993 by Robert Joop <rj@rainbow.in-berlin.de>
12 % inspired by two other versions of this theme which are
13 % getafm 1.00 (c) AJCD
14 % and getafm.ps by an unknown author,
15 % modified by J. Daniel Smith <dsmith@mailhost.aa.cad.slb.com>
17 % Metrics dictionary code added by AJCD, 7/6/93
19 /getafmdict 100 dict dup begin
24 /prany % dict dictname printname -> dict
26 2 index 2 index cvn known
30 1 index exch cvn get =
33 (Comment /FontInfo contains no /) print
42 (, therefore no ) print
65 (ItalicAngle)dup prany
66 (isFixedPitch)(IsFixedPitch) prany
67 (UnderlinePosition)dup prany
68 (UnderlineThickness)dup prany
69 (Version)(version) prany
74 (Comment Font lacks a /FontInfo!)=
80 /prbbox % llx lly urx ury -> -
82 4 1 roll 3 1 roll exch % swap top 4 elements
83 4 { ( ) print buf cvs print } repeat
87 /getbbox % fontdict chardict character -> fontdict chardict llx lly urx ury
90 2 index setfont 0 0 moveto
91 false charpath flattenpath pathbbox
101 dup /FontBBox get aload pop prbbox ()=
104 (Comment missing required /FontBBox)=
113 dup /looksRoman exch def
117 ceiling cvi = pop pop pop
120 ceiling cvi = pop pop pop
123 ceiling cvi = pop pop pop
126 pop pop floor cvi = pop
129 (Comment font doesn't contain H, x, d and p; therefore no CapHeight, XHeight, Ascender and Descender)=
135 [ (ISOLatin1Encoding) /ISOLatin1Encoding ]
136 [ (AdobeStandardEncoding) /StandardEncoding ]
143 (EncodingScheme ) print
163 % chardictname fontdict charnamedict encoding charindex charname
165 4 index dup length dict dup begin exch
171 1 index /Encoding eq { 256 array copy } if
179 dup /Encoding get 32 3 index put
184 1 index buf cvs print
187 % Metrics entries are:
188 % 1 number: which is the character width
189 % an array of 2 numbers: which are the left sidebearing and width
190 % an array of 4 numbers: x & y left sidebearing, width and height
191 dup 5 index % /charname fontdict
193 /Metrics get exch 2 copy known {
194 get dup type /arraytype eq {
196 {1 get} {2 get} ifelse
198 round cvi buf cvs print
200 pop pop ( ) stringwidth pop round cvi buf cvs print
203 pop pop ( ) stringwidth pop round cvi buf cvs print
212 ( ) true charpath flattenpath pathbbox
214 2 { ceiling cvi 4 1 roll } repeat
215 2 { floor cvi 4 1 roll } repeat
225 aload pop 1 index 3 index eq
230 1 index buf2 cvs dup length
235 3 -1 roll getinterval
270 (StartCharMetrics ) print
271 2 copy exch get length 1 sub buf cvs =
274 1 index /Encoding get
278 % chardictname fontdict charnamedict
279 1 index /Encoding get
284 dup /.notdef eq { pop } { printcharmetric } ifelse
295 % chardictname fontdict charnamedict encoding charindex charname
296 dup 4 index exch known
304 % charnamedict encoding index
313 (StartFontMetrics 3.0)=
314 (Comment Produced by getafm 3.0 (which is by rj@rainbow.in-berlin.de))=
331 findfont 1000 scalefont
334 [ /CharDefs /CharData /CharProcs /CharStrings ]
336 2 index 1 index known { exch } if
342 (can't find dictionary with character data!)=
346 exch % dictname fontdict