1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
% Draw all glyphs from the AFM
%
% expects AFM to be the file for the font
%
% For example:
%
% gswin32c -q -c "/AFM (/artifex/urwfonts_new/z003034l.afm) (r) file def" -f drawafm.ps
%
% --------------------------------------------------------------------
%
/S 1000 string def % scratch string
/FONTSIZE 350 def
%
% /name searchtoken (remainder of line)
/searchtoken {
/SearchToken exch def
{
AFM S readline not { (OOPS couldn't find ) print SearchToken = flush quit } if
token {
SearchToken eq { exit } { pop } ifelse
} if % ignore 'false' return from 'token' to skip blank lines.
} loop
} bind def
% string count skiptokens substring true
% () false (if not enough tokens in string)
/skiptokens {
true 3 1 roll
{ token { pop } { not () exit } ifelse } repeat
exch
} bind def
% --------------------------------------------------------------------
% Find the /FontName line and load that font
/FontName searchtoken
token not {
(OOPS: /FontName line didn't have a name following) = flush quit
} if
exch pop
findfont FONTSIZE scalefont setfont
% Now find the 'StartCharMetrics' line
/StartCharMetrics searchtoken pop
% Now process lines starting with 'C ' tokens (until EndCharMetrics)
% They look like:
% C 36 ; WX 440 ; N dollar ; B 60 -144 461 675 ;
{
AFM S readline not { (EOF before EndCharMetrics line) = flush quit } if
token {
dup /EndCharMetrics eq { pop exit } if
/C eq {
3 skiptokens not {
(OOPS: Bad format C line before GlyphWidth) = flush quit
} if
token not {
(OOPS: C line missing GlyphWidth) = flush quit
} if
/GlyphWidth exch def
2 skiptokens not {
(OOPS: Bad format C line before GlyphName) = flush quit
} if
token not {
(OOPS: C line missing GlyphName) = flush quit
} if
/GlyphName exch def
2 skiptokens not {
(OOPS: Bad format C line before Metrics values) = flush quit
} if
[ exch
4 {
token not {
(OOPS: C line missing Metrics value) = flush quit
} if
exch
} repeat
pop % discard remaining paramters
] /Metrics exch def
(Drawing Glyph: ) print /GlyphName load =print
(, Width: ) print GlyphWidth =print ( ) print flush
clippath .8 setgray fill
gsave 100 150 translate FONTSIZE 1000 div dup scale
Metrics aload pop 2 index sub exch 3 index sub exch 1 setgray
rectfill
grestore
0 setgray
100 Metrics 0 get FONTSIZE mul 1000 div add 0 moveto 0 700 rlineto stroke
100 Metrics 2 get FONTSIZE mul 1000 div add 0 moveto 0 700 rlineto stroke
100 GlyphWidth 1000 div FONTSIZE mul add
100 150 moveto /GlyphName load glyphshow
showpage
} {
(Unexpected line before EndCharMetrics, tail: ) print = flush exit
} ifelse
} if % skip blank lines
} loop
(done.) = flush quit
|