星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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