1
0

printfont.ps 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. %
  2. % Formatted font dump. Assumes all fonts include valid FontBBox arrays.
  3. %
  4. /#copies 1 store
  5. /aspectratio 1 def
  6. /landscape false def
  7. /magnification 1 def
  8. /margin 10 def
  9. /orientation 0 def
  10. /rotation 1 def
  11. /xoffset 0 def
  12. /yoffset 0 def
  13. /axescount 0 def
  14. /charwidth false def
  15. /graynotdef 0.85 def
  16. /hireslinewidth 0.2 def
  17. /longnames false def
  18. /maxsize 6.0 def
  19. /minsize 4.5 def
  20. /numbercell true def
  21. /radix 16 def
  22. /labelfont /Helvetica def
  23. /labelspace 36 def
  24. /zerocell 0 def
  25. /roundpage true def
  26. /useclippath true def
  27. /pagebbox [0 0 612 792] def
  28. /inch {72 mul} def
  29. /min {2 copy gt {exch} if pop} def
  30. /max {2 copy lt {exch} if pop} def
  31. /LLx {0 get} bind def
  32. /LLy {1 get} bind def
  33. /URx {2 get} bind def
  34. /URy {3 get} bind def
  35. /BBoxHeight {dup URy exch LLy sub} bind def
  36. /BBoxWidth {dup URx exch LLx sub} bind def
  37. /setup {
  38. /graylevels [1 0 0] def
  39. /scratchstring 512 string def
  40. /Product statusdict begin /product where {pop product}{(Unknown)} ifelse end def
  41. /Resolution 0 72 dtransform dup mul exch dup mul add sqrt cvi def
  42. /Version /version where {pop version}{(???)} ifelse def
  43. landscape {/orientation 90 orientation add def} if
  44. pagedimensions
  45. xcenter ycenter translate
  46. orientation rotation mul rotate
  47. width 2 div neg height 2 div translate
  48. xoffset inch yoffset inch neg translate
  49. margin dup neg translate
  50. 0 labelspace .75 mul neg translate
  51. magnification dup aspectratio mul scale
  52. 0 0 transform round exch round exch itransform translate
  53. currentdict /linewidth known not {
  54. /linewidth Resolution 400 le {0}{hireslinewidth} ifelse def
  55. } if
  56. } def
  57. /pagedimensions {
  58. useclippath {
  59. /pagebbox [clippath pathbbox newpath] def
  60. roundpage currentdict /roundpagebbox known and {roundpagebbox} if
  61. } if
  62. pagebbox aload pop
  63. 4 -1 roll exch 4 1 roll 4 copy
  64. landscape {4 2 roll} if
  65. sub /width exch def
  66. sub /height exch def
  67. add 2 div /xcenter exch def
  68. add 2 div /ycenter exch def
  69. } def
  70. /CharSetup {
  71. /chcode exch def
  72. /chname Encoding chcode get def
  73. /chstring ( ) dup 0 chcode put def
  74. /chknown true def
  75. graylevels 0 1 put % initial cell fill
  76. graylevels 1 0 put % cell text
  77. graylevels 2 0 put % cell border
  78. FontDict /CharStrings known {
  79. FontDict /CharStrings get chname known not {
  80. /chknown false def
  81. graylevels 0 0 put
  82. graylevels 1 1 put
  83. } if
  84. } if
  85. chname /.notdef eq {
  86. /chknown false def
  87. graylevels 0 graynotdef put
  88. graylevels 1 graynotdef put
  89. } if
  90. /chwid chknown
  91. {FontDict 1 scalefont setfont chstring stringwidth pop}
  92. {0}
  93. ifelse def
  94. } bind def
  95. /CellSetup {
  96. /gridwidth width margin 2 mul sub def
  97. /gridheight height labelspace sub margin 2 mul sub def
  98. /cellwidth gridwidth radix div def
  99. /cellheight gridheight Entries radix div ceiling div def
  100. cellwidth cellheight dtransform truncate exch truncate exch idtransform
  101. /cellheight exch def
  102. /cellwidth exch def
  103. labelfont findfont 1 scalefont setfont
  104. /LabelBBox currentfont /FontBBox get TransformBBox def
  105. LabelBBox 2 0 Encoding {
  106. scratchstring cvs stringwidth pop
  107. 2 copy lt {exch} if
  108. pop
  109. } forall put
  110. /CellLabelSize
  111. cellheight .20 mul cellwidth .90 mul LabelBBox BestFit
  112. minsize max
  113. maxsize min
  114. def
  115. zerocell CellOrigin cellheight add neg exch neg exch translate
  116. } bind def
  117. /FontSetup {
  118. FontName findfont 1 scalefont setfont
  119. /BBox currentfont /FontBBox get TransformBBox def
  120. /PointSize cellheight .5 mul cellwidth .8 mul BBox BestFit def
  121. BBox {PointSize mul} forall BBox astore pop
  122. /xorigin cellwidth BBox BBoxWidth sub 2 div BBox LLx sub def
  123. /yorigin cellheight BBox BBoxHeight sub 2 div BBox LLy sub def
  124. } bind def
  125. /BestFit {
  126. /bbox exch def
  127. bbox BBoxWidth div exch
  128. bbox BBoxHeight div min
  129. } bind def
  130. /TransformBBox { % font bbox to user space
  131. aload pop
  132. currentfont /FontMatrix get dtransform 4 2 roll
  133. currentfont /FontMatrix get dtransform 4 2 roll
  134. 4 array astore % should build user space bbox if all zeros
  135. } bind def
  136. /CellOrigin {
  137. dup
  138. exch radix mod cellwidth mul
  139. exch radix idiv 1 add neg cellheight mul
  140. } bind def
  141. /CellOutline {
  142. newpath
  143. CellOrigin moveto
  144. cellwidth 0 rlineto
  145. 0 cellheight rlineto
  146. cellwidth neg 0 rlineto
  147. closepath
  148. } bind def
  149. /LabelCell {
  150. gsave
  151. chcode CellOrigin translate
  152. linewidth .5 mul setlinewidth
  153. labelfont findfont CellLabelSize scalefont setfont
  154. numbercell {
  155. cellwidth .025 mul cellheight .05 mul moveto
  156. chcode radix scratchstring cvrs show
  157. } if
  158. charwidth chknown and {
  159. /wid chwid 0.0005 add scratchstring cvs 0 5 getinterval def
  160. cellwidth wid stringwidth pop 1.10 mul sub cellheight .05 mul moveto
  161. wid show
  162. } if
  163. longnames chknown not or {
  164. cellwidth .025 mul
  165. cellheight LabelBBox URy CellLabelSize mul sub .05 sub moveto
  166. Encoding chcode get scratchstring cvs show
  167. } if
  168. axescount 1 ge chknown and { % gsave/grestore if not last
  169. newpath
  170. xorigin yorigin translate
  171. BBox LLx 0 moveto % baseline
  172. BBox URx 0 lineto stroke
  173. axescount 2 ge { % vertical through current origin
  174. 0 BBox LLy moveto
  175. 0 BBox URy lineto stroke
  176. } if
  177. axescount 3 ge { % vertical through next origin
  178. chwid PointSize mul BBox LLy
  179. dtransform round exch round exch idtransform moveto
  180. 0 BBox BBoxHeight rlineto stroke
  181. %chwid PointSize mul BBox URy lineto stroke
  182. } if
  183. } if
  184. grestore
  185. } bind def
  186. /PlaceChar {
  187. FontName findfont PointSize scalefont setfont
  188. chcode CellOrigin moveto
  189. xorigin yorigin rmoveto
  190. ( ) dup 0 chcode put show
  191. } bind def
  192. /LabelPage {
  193. labelfont findfont labelspace .75 mul .75 mul 18 min scalefont setfont
  194. 0 labelspace .75 mul .25 mul moveto
  195. FontName scratchstring cvs show
  196. labelfont findfont labelspace .25 mul .75 mul 9 min scalefont setfont
  197. 0 gridheight neg moveto
  198. 0 labelspace .25 mul .75 mul neg rmoveto
  199. Product show ( Version ) show Version show
  200. ( \() show Resolution scratchstring cvs show (dpi\)) show
  201. gridwidth gridheight neg moveto
  202. 0 labelspace .25 mul .75 mul neg rmoveto
  203. (size=, ) stringwidth pop neg 0 rmoveto
  204. PointSize cvi scratchstring cvs stringwidth pop neg 0 rmoveto
  205. (gray=, ) stringwidth pop neg 0 rmoveto
  206. graynotdef scratchstring cvs stringwidth pop neg 0 rmoveto
  207. (linewidth=) stringwidth pop neg 0 rmoveto
  208. linewidth scratchstring cvs stringwidth pop neg 0 rmoveto
  209. (size=) show PointSize cvi scratchstring cvs show (, ) show
  210. (gray=) show graynotdef scratchstring cvs show (, ) show
  211. (linewidth=) show linewidth scratchstring cvs show
  212. } bind def
  213. %
  214. % Formatted dump of the encoded characters in a single font.
  215. %
  216. /PrintFont {
  217. /saveobj save def
  218. /FontName exch def
  219. /FontDict FontName findfont def
  220. /Encoding FontDict /Encoding get def
  221. /Entries Encoding length def
  222. CellSetup
  223. FontSetup
  224. LabelPage
  225. zerocell 1 Entries 1 sub {
  226. CharSetup
  227. graylevels 0 get setgray
  228. chcode CellOutline fill
  229. graylevels 1 get setgray
  230. LabelCell
  231. PlaceChar
  232. graylevels 2 get setgray
  233. linewidth setlinewidth
  234. chcode CellOutline stroke
  235. } for
  236. showpage
  237. saveobj restore
  238. } bind def
  239. %
  240. % Dump of all ROM and disk fonts - in alphabetical order.
  241. %
  242. /AllFonts {
  243. /AllFontNames FontDirectory maxlength array def
  244. AllFontNames 0 0 put
  245. FontDirectory {pop AllFontNames Insert} forall
  246. /filenameforall where {
  247. pop
  248. (fonts/*)
  249. {(fonts/) search pop pop pop AllFontNames Insert}
  250. 200 string
  251. filenameforall
  252. } if
  253. 1 1 AllFontNames 0 get {
  254. AllFontNames exch get cvn PrintFont
  255. } for
  256. } bind def
  257. /Insert { % name in a sorted list
  258. /List exch def
  259. /Name exch 128 string cvs def
  260. /Slot 1 def
  261. List 0 get {
  262. Name List Slot get le {exit} if
  263. /Slot Slot 1 add def
  264. } repeat
  265. List 0 get -1 Slot {
  266. dup List exch get
  267. List 3 1 roll exch 1 add exch put
  268. } for
  269. List Slot Name put
  270. List 0 List 0 get 1 add put
  271. } bind def