home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / fonts / print_glyphs.ps < prev    next >
Encoding:
Text File  |  2001-07-04  |  3.1 KB  |  129 lines  |  [TEXT/LMAN]

  1. %!PS-Adobe
  2. % print_glyphs.ps
  3. % Copyright (C) Thomas Merz 1994-2001
  4. %
  5. % This PostScript program prints all glyphs in a font along
  6. % with their names in alphabetical ordering.
  7. % It requires a PostScript Level 2 or PostScript 3 interpreter.
  8. %
  9. % Usage:
  10. % - The font must either be resident in the printer, or be
  11. %   downloaded ahead of this program (as a single job).
  12. % - At the end of this file, enter a line with the font name, e.g.:
  13. %   /Times-Roman ShowGlyphs
  14. %   (Omit the percent character, but leave the leading slash '/')
  15.  
  16.  
  17. /$sort 20 dict def
  18.  
  19. /Insert { % node string ==> -
  20.     exch dup 0 get type (nulltype) eq { % ifelse
  21.         exch [ exch 1 array 1 array ] 0 exch put
  22.     }{ % else
  23.         aload pop aload pop 4 2 roll 2 copy gt { % ifelse
  24.             pop 3 -1 roll pop Insert
  25.         }{ %else
  26.             pop exch pop Insert
  27.         } ifelse
  28.     } ifelse
  29. } def
  30.  
  31. /PrefixWalk {
  32.     $sort begin
  33.     cvx /!bt exch def bpwalk 
  34.     end
  35. } def
  36.  
  37. $sort begin
  38. /bpwalk {
  39.     dup 0 get type /nulltype eq { pop }{ % ifelse
  40.     aload pop aload pop exch bpwalk exch !bt bpwalk
  41.     } ifelse
  42. } bind def
  43.     
  44. end % $sort
  45.  
  46. /DictSort {    % dict ==> array
  47.     dup length array /a exch def
  48.     $sort begin
  49.     /tree 1 array def
  50.     { pop 50 string cvs tree exch Insert } forall
  51.     /ndx 0 def
  52.     tree { a ndx 3 -1 roll put /ndx ndx 1 add def } PrefixWalk
  53.     a
  54. } bind def
  55.  
  56. /ShowGlyphs {                     % font name ==> -
  57.     /buffer 100 string def
  58.     /FontName 100 string def
  59.     /fs 20 def                     % font size
  60.     /ts 7 def                     % font size of caption
  61.     /ls fs 1.75 mul def             % line spacing
  62.  
  63.     dup FontName cvs pop
  64.     findfont fs scalefont /F exch def
  65.  
  66.     clippath pathbbox
  67.     20 sub /top exch def
  68.     20 sub /right exch def
  69.     20 add /bottom exch def
  70.     40 add /left exch def
  71.  
  72.     /textfont /Helvetica-Narrow findfont ts scalefont def
  73.     /x left def
  74.     /y top fs sub def
  75.  
  76.     /Helvetica-Bold findfont fs scalefont setfont
  77.     x y moveto
  78.     /y y ls sub def 
  79.  
  80.     % Check the interpreter's language level...
  81.     /languagelevel where { pop languagelevel }{ 1 } ifelse
  82.  
  83.     % ...and quit if Level 1
  84.     2 lt {
  85.     (Error: this program doesn't work on PostScript Level 1 printers!)show
  86.     showpage
  87.     stop
  88. } if
  89.  
  90.     FontName show        % print font name
  91.  
  92.     % Try to find the dictionary with the character names
  93.     F /CharStrings known {
  94.         F /CharStrings get
  95.     }{
  96.     (: Couldn't find character names (CharStrings dictionary)!) show
  97.     showpage
  98.     quit
  99.     } ifelse
  100.  
  101.     DictSort                % sort the character names
  102.  
  103.     { % forall
  104.     /GlyphName exch def        % remember the character name
  105.  
  106.     x y moveto F setfont    % the actual character...
  107.     GlyphName cvn glyphshow
  108.  
  109.     x y ts 2 mul sub moveto    % ...and its glyph name
  110.     textfont setfont GlyphName buffer cvs show
  111.  
  112.     /x x fs 2 mul add def
  113.     x right gt { /x left def /y y fs 2 mul sub def } if 
  114.     y bottom lt {
  115.         /y top fs sub def /x left def
  116.         showpage
  117.         x y moveto
  118.         /y y ls sub def 
  119.         /Helvetica-Bold findfont fs scalefont setfont
  120.         FontName show        % print font name
  121.     } if
  122.     } forall
  123.     y top ls sub ne x left ne or { showpage } if
  124.  
  125. } bind def
  126.  
  127. % Example:
  128. %/Times-Roman ShowGlyphs
  129.