home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / inne / gs300ini / printafm.ps < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.0 KB  |  139 lines

  1. %!
  2. % $Header: /usr/jjc/dvitops/RCS/printafm.ps,v 1.1 89/02/01 09:19:41 jjc Rel $
  3. % written by James Clark <jjc@jclark.uucp>
  4. % print an afm file on the standard output
  5. % usage is `fontname printafm' eg `/Times-Roman printafm'
  6.  
  7. % From the `dvitops' distribution, which included this notice:
  8. % dvitops is not copyrighted; you can do with it exactly as you please.
  9. % I would, however, ask that if you make improvements or modifications,
  10. % you ask me before distributing them to others.
  11.  
  12. % Altered by d.love@dl.ac.uk to produce input for Rokicki's afm2tfm,
  13. % which groks the format of the Adobe AFMs.
  14.  
  15. % Modified by L. Peter Deutsch 9/14/93:
  16. %   uses Ghostscript's =only procedure to replace 'buf cvs print'.
  17.  
  18. /onechar 1 string def
  19.  
  20. % c toupper - c
  21. /toupper {
  22.     dup dup 8#141 ge exch 8#172 le and { 
  23.         8#40 sub
  24.     } if
  25. } bind def
  26.  
  27. % printcharmetrics -
  28.  
  29. /printcharmetrics {
  30.     (StartCharMetrics ) print
  31.     currentfont /CharStrings get dup length exch /.notdef known { 1 sub } if =
  32.     currentfont 1000 scalefont setfont 0 0 moveto
  33.     /e currentfont /Encoding get def
  34.     0 1 255 {
  35.         dup e exch get
  36.         dup /.notdef ne {
  37.             exch dup printmetric
  38.         } {
  39.             pop pop
  40.         } ifelse
  41.     } for
  42.     % s contains an entry for each name in the original encoding vector
  43.     /s 256 dict def
  44.     e {
  45.         s exch true put
  46.     } forall
  47.     % v is the new encoding vector
  48.     /v 256 array def
  49.     0 1 255 {
  50.         v exch /.notdef put
  51.     } for
  52.     % fill up v with names in CharStrings
  53.     /i 0 def
  54.     currentfont /CharStrings get {
  55.         pop
  56.         i 255 le {
  57.             v i 3 -1 roll put
  58.             /i i 1 add def
  59.         } {
  60.             pop
  61.         } ifelse
  62.     } forall
  63.     % define a new font with v as its encoding vector
  64.     currentfont maxlength dict /f exch def
  65.     currentfont {
  66.         exch dup dup /FID ne exch /Encoding ne and { 
  67.             exch f 3 1 roll put
  68.         } { 
  69.             pop pop 
  70.         } ifelse
  71.     } forall
  72.     f /Encoding v put
  73.     f /FontName /temp put
  74.     % make this new font the current font
  75.     /temp f definefont setfont
  76.     % print a entry for each character not in old vector
  77.     /e currentfont /Encoding get def
  78.     0 1 255 {
  79.         dup e exch get
  80.         dup dup /.notdef ne exch s exch known not and { 
  81.             exch -1 printmetric
  82.         } { 
  83.             pop pop
  84.         } ifelse
  85.     } for
  86.     (EndCharMetrics) =
  87. } bind def
  88.  
  89. % name actual_code normal_code printmetric -
  90.  
  91. /printmetric {
  92.     /saved save def
  93.     (C ) print =only
  94.     ( ; WX ) print
  95.     onechar 0 3 -1 roll put
  96.     onechar stringwidth pop round cvi =only
  97.     ( ; N ) print =only
  98.     ( ; B ) print
  99.     onechar false charpath flattenpath mark pathbbox counttomark {
  100.         counttomark -1 roll
  101.         round cvi =only
  102.         ( ) print
  103.     } repeat pop
  104.     (;) =
  105.     saved restore
  106. } bind def
  107.  
  108. % fontname printafm -
  109.  
  110. /printafm {
  111.     findfont gsave setfont
  112.     (StartFontMetrics 2.0) =
  113.     (FontName ) print currentfont /FontName get =
  114.  
  115.         % Print the FontInfo
  116.  
  117.     currentfont /FontInfo get {
  118.         exch
  119.         =string cvs dup dup 0 get 0 exch toupper put print
  120.         ( ) print =
  121.     } forall
  122.  
  123.         % Print the FontBBox
  124.  
  125.     (FontBBox) print
  126.     currentfont /FontBBox get {
  127.         ( ) print round cvi =only
  128.     } forall
  129.     (\n) print
  130.  
  131.     printcharmetrics
  132.     (EndFontMetrics) =
  133.     grestore
  134. } bind def
  135.  
  136.  
  137.  
  138. /Times-Roman printafm
  139.