4 echo "usage: $0 font-name | gsnd -q - >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 % modified by Joachim H. Kaiser <jhk@cmpnetmail.com>:
18 % - suggest a quiet gs run in usage
19 % - get font version info (from 'version', not 'Version')
20 % - add copyright field to output
22 % Metrics dictionary code added by AJCD, 7/6/93
24 /getafmdict 100 dict dup begin
29 /prany % dict dictname printname -> dict
31 2 index 2 index cvn known
35 1 index exch cvn get =
38 (Comment /FontInfo contains no /) print
47 (, therefore no ) print
70 (ItalicAngle)dup prany
71 (isFixedPitch)(IsFixedPitch) prany
72 (UnderlinePosition)dup prany
73 (UnderlineThickness)dup prany
74 (version)(Version) prany
80 (Comment Font lacks a /FontInfo!)=
86 /prbbox % llx lly urx ury -> -
88 4 1 roll 3 1 roll exch % swap top 4 elements
89 4 { ( ) print buf cvs print } repeat
93 /getbbox % fontdict chardict character -> fontdict chardict llx lly urx ury
96 2 index setfont 0 0 moveto
97 false charpath flattenpath pathbbox
107 dup /FontBBox get aload pop prbbox ()=
110 (Comment missing required /FontBBox)=
119 dup /looksRoman exch def
123 ceiling cvi = pop pop pop
126 ceiling cvi = pop pop pop
129 ceiling cvi = pop pop pop
132 pop pop floor cvi = pop
135 (Comment font doesn't contain H, x, d and p; therefore no CapHeight, XHeight, Ascender and Descender)=
141 [ (ISOLatin1Encoding) /ISOLatin1Encoding ]
142 [ (AdobeStandardEncoding) /StandardEncoding ]
149 (EncodingScheme ) print
169 % chardictname fontdict charnamedict encoding charindex charname
171 4 index dup length dict dup begin exch
177 1 index /Encoding eq { 256 array copy } if
185 dup /Encoding get 32 3 index put
190 1 index buf cvs print
193 % Metrics entries are:
194 % 1 number: which is the character width
195 % an array of 2 numbers: which are the left sidebearing and width
196 % an array of 4 numbers: x & y left sidebearing, width and height
197 dup 5 index % /charname fontdict
199 /Metrics get exch 2 copy known {
200 get dup type /arraytype eq {
202 {1 get} {2 get} ifelse
204 round cvi buf cvs print
206 pop pop ( ) stringwidth pop round cvi buf cvs print
209 pop pop ( ) stringwidth pop round cvi buf cvs print
218 ( ) true charpath flattenpath pathbbox
220 2 { ceiling cvi 4 1 roll } repeat
221 2 { floor cvi 4 1 roll } repeat
231 aload pop 1 index 3 index eq
236 1 index buf2 cvs dup length
241 3 -1 roll getinterval
276 (StartCharMetrics ) print
277 2 copy exch get length 1 sub buf cvs =
280 1 index /Encoding get
284 % chardictname fontdict charnamedict
285 1 index /Encoding get
290 dup /.notdef eq { pop } { printcharmetric } ifelse
301 % chardictname fontdict charnamedict encoding charindex charname
302 dup 4 index exch known
310 % charnamedict encoding index
319 (StartFontMetrics 3.0)=
320 (Comment Produced by getafm 3.0 (which is by rj@rainbow.in-berlin.de))=
337 findfont 1000 scalefont
340 [ /CharDefs /CharData /CharProcs /CharStrings ]
342 2 index 1 index known { exch } if
348 (can't find dictionary with character data!)=
352 exch % dictname fontdict