home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gs333ini / gs3.33 / prfont.ps < prev    next >
Text File  |  1995-12-09  |  4KB  |  140 lines

  1. %!
  2. %%Creator: Eric Gisin <egisin@waterloo.csnet>
  3. %%Title: Print font catalog
  4. % Copyright (c) 1986 Eric Gisin
  5. % Copyright (C) 1992 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  6. %   Modified to print all 256 encoded characters.
  7. % Copyright (C) 1993 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  8. %   Modified to print unencoded characters.
  9. % Copyright (C) 1994 Aladdin Enterprises, Menlo Park, CA (ghost@aladdin.com)
  10. %   Modified to always create 256-element Encoding vectors.
  11.  
  12. % Example usages at bottom of file
  13.  
  14. /#copies 1 def
  15. /min { 2 copy gt { exch } if pop } bind def
  16.  
  17. /T6 /Times-Roman findfont 6 scalefont def
  18. /Temp 64 string def
  19. /Inch {72 mul} def
  20. /Base 16 def    % char code output base
  21. /TempEncoding [ 256 { /.notdef } repeat ] def
  22.  
  23. % do single character of page
  24. % output to rectangle ll=(0,-24) ur=(36,24)
  25. /DoChar {
  26.   /C exch def
  27.   /S (_) dup 0 C put def
  28.   /N F /Encoding get C get def
  29.  
  30.   % print code name, width and char name
  31.   /W F setfont S stringwidth pop def
  32.   T6 setfont
  33.   N /.notdef ne {0 -20 moveto N Temp cvs show} if
  34.   0 -12 moveto C Base Temp cvrs show (  ) show
  35.   W 0.0005 add Temp cvs 0 5 getinterval show
  36.  
  37.   % print char with reference lines
  38.   N /.notdef ne {
  39.     3 0 translate
  40.     0 0 moveto F24 setfont S show
  41.     /W S stringwidth pop def
  42.     0 -6 moveto 0 24 lineto
  43.     W -6 moveto W 24 lineto
  44.     -3 0 moveto W 3 add 0 lineto
  45.     0 setlinewidth stroke
  46.   } if
  47. } def
  48.  
  49. % print page title
  50. /DoTitle {
  51.   /Times-Roman findfont 18 scalefont setfont
  52.   18 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  53. } def
  54.  
  55. % print one block of characters
  56. /DoBlock {    % firstcode lastcode
  57.   /FirstCode 2 index def
  58.   1 exch {
  59.     /I exch def
  60.     /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  61.     gsave
  62.     Xn 36 mul 9 add Yn -56 mul 9.5 Inch add translate
  63.     I DoChar
  64.     grestore
  65.   } for
  66. } def
  67.  
  68. % print a line of character
  69. /DoLine {    % firstcode lastcode
  70.   1 exch { (_) dup 0 3 index put show pop } for
  71. } def
  72.  
  73. % print font sample page
  74. /DoFont {
  75.   /FName exch def    % font name
  76.   /F FName findfont def
  77.   /F24 F 24 scalefont def
  78.   /Line0 96 string def
  79.   /Line1 96 string def
  80.  
  81.     % Display the first 128 encoded characters.
  82.  
  83.   DoTitle (, characters 0-127) show
  84.   0 127 DoBlock
  85.   F 10 scalefont setfont
  86.   18 2.0 Inch moveto 0 63 DoLine
  87.   18 1.5 Inch moveto 64 127 DoLine
  88.   showpage
  89.  
  90.     % Display the second 128 encoded characters.
  91.  
  92.   DoTitle (, characters 128-255) show
  93.   128 255 DoBlock
  94.   F 10 scalefont setfont
  95.   18 2.0 Inch moveto 128 191 DoLine
  96.   18 1.5 Inch moveto 192 255 DoLine
  97.   showpage
  98.  
  99.   F /FontType get 1 eq
  100.    {
  101.         % Find and display the unencoded characters.
  102.         % Currently we can't handle more than 128.
  103.  
  104.     /Encoded F /Encoding get length dict def
  105.     F /Encoding get { true Encoded 3 1 roll put } forall
  106.     /Unencoded [ F /CharStrings get
  107.      { pop dup Encoded exch known { pop } if }
  108.     forall
  109.     counttomark 128 gt { counttomark 128 sub { pop } repeat } if
  110.     ] def
  111.     /Count Unencoded length def
  112.     Unencoded TempEncoding copy pop
  113.     F length dict F
  114.      { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  115.     forall dup /Encoding TempEncoding put
  116.     /* exch definefont
  117.     /F exch def
  118.     /F24 F 24 scalefont def
  119.  
  120.     DoTitle (, unencoded characters) show
  121.     0 Count 1 sub 127 min DoBlock
  122.     F 10 scalefont setfont
  123.     18 2.0 Inch moveto 0 Count 64 min 1 sub DoLine
  124.     Count 64 gt
  125.      { 18 1.5 Inch moveto 64 Count 128 min 1 sub DoLine
  126.      }
  127.     if
  128.     showpage
  129.    }
  130.   if
  131.  
  132. } def
  133.  
  134. % Do font samples
  135. % /Times-Roman DoFont            % Test (less than a minute)
  136. % /Hershey-Gothic-English DoFont    % Test (8 minutes)
  137.  
  138. % Do a complete catalog
  139. % FontDirectory {pop DoFont} forall    % All fonts (quite a long time)
  140.