home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / inne / gs300ini / prfont.ps < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.1 KB  |  125 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.  
  10. % Example usages at bottom of file
  11.  
  12. /#copies 1 def
  13.  
  14. /T6 /Times-Roman findfont 6 scalefont def
  15. /Temp 64 string def
  16. /Inch {72 mul} def
  17. /Base 16 def    % char code output base
  18.  
  19. % do single character of page
  20. % output to rectangle ll=(0,-24) ur=(36,24)
  21. /DoChar {
  22.   /C exch def
  23.   /S (_) dup 0 C put def
  24.   /N F /Encoding get C get def
  25.  
  26.   % print code name, width and char name
  27.   /W F setfont S stringwidth pop def
  28.   T6 setfont
  29.   N /.notdef ne {0 -20 moveto N Temp cvs show} if
  30.   0 -12 moveto C Base Temp cvrs show (  ) show
  31.   W 0.0005 add Temp cvs 0 5 getinterval show
  32.  
  33.   % print char with reference lines
  34.   N /.notdef ne {
  35.     3 0 translate
  36.     0 0 moveto F24 setfont S show
  37.     /W S stringwidth pop def
  38.     0 -6 moveto 0 24 lineto
  39.     W -6 moveto W 24 lineto
  40.     -3 0 moveto W 3 add 0 lineto
  41.     0 setlinewidth stroke
  42.   } if
  43. } def
  44.  
  45. % print page title
  46. /DoTitle {
  47.   /Times-Roman findfont 18 scalefont setfont
  48.   18 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  49. } def
  50.  
  51. % print one block of characters
  52. /DoBlock {    % firstcode lastcode
  53.   /FirstCode 2 index def
  54.   1 exch {
  55.     /I exch def
  56.     /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  57.     gsave
  58.     Xn 36 mul 9 add Yn -56 mul 9.5 Inch add translate
  59.     I DoChar
  60.     grestore
  61.   } for
  62. } def
  63.  
  64. % print a line of character
  65. /DoLine {    % firstcode lastcode
  66.   1 exch { (_) dup 0 3 index put show pop } for
  67. } def
  68.  
  69. % print font sample page
  70. /DoFont {
  71.   /FName exch def    % font name
  72.   /F FName findfont def
  73.   /F24 F 24 scalefont def
  74.   /Line0 96 string def
  75.   /Line1 96 string def
  76.  
  77.   DoTitle (, characters 0-127) show
  78.   0 127 DoBlock
  79.   F 10 scalefont setfont
  80.   18 2.0 Inch moveto 0 63 DoLine
  81.   18 1.5 Inch moveto 64 127 DoLine
  82.   showpage
  83.  
  84.   DoTitle (, characters 128-255) show
  85.   128 255 DoBlock
  86.   F 10 scalefont setfont
  87.   18 2.0 Inch moveto 128 191 DoLine
  88.   18 1.5 Inch moveto 192 255 DoLine
  89.   showpage
  90.  
  91.   F /FontType get 1 eq
  92.    {    /Encoded F /Encoding get length dict def
  93.     F /Encoding get { true Encoded 3 1 roll put } forall
  94.     [ F /CharStrings get
  95.      { pop dup Encoded exch known { pop } if }
  96.     forall ]
  97.       dup length /Count exch def
  98.     F length dict F
  99.      { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  100.     forall dup /Encoding 4 -1 roll put
  101.     /* exch definefont
  102.     /F exch def
  103.     /F24 F 24 scalefont def
  104.  
  105.     DoTitle (, unencoded characters) show
  106.     0 Count 1 sub 127 min DoBlock
  107.     F 10 scalefont setfont
  108.     18 2.0 Inch moveto 0 Count 64 min 1 sub DoLine
  109.     Count 64 gt
  110.      { 18 1.5 Inch moveto 64 Count 128 min 1 sub DoLine
  111.      }
  112.     if
  113.     showpage
  114.    }
  115.   if
  116.  
  117. } def
  118.  
  119. % Do font samples
  120. % /Times-Roman DoFont            % Test (less than a minute)
  121. % /Hershey-Gothic-English DoFont    % Test (8 minutes)
  122.  
  123. % Do a complete catalog
  124. % FontDirectory {pop DoFont} forall    % All fonts (quite a long time)
  125.