% 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