星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

prfont.ps 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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
  6. % Modified to print all 256 encoded characters.
  7. % Copyright (C) 1993 Aladdin Enterprises, Menlo Park, CA
  8. % Modified to print unencoded characters.
  9. % Copyright (C) 1994 Aladdin Enterprises, Menlo Park, CA
  10. % Modified to always create 256-element Encoding vectors.
  11. % Copyright (C) 1995 Aladdin Enterprises, Menlo Park, CA
  12. % Modified to print more than 128 unencoded characters.
  13. % Copyright (C) 1996 Aladdin Enterprises, Menlo Park, CA
  14. % Modified to leave a slightly wider left margin, because many H-P
  15. % printers can't print in the leftmost 1/4" of the page.
  16. % Modified to print unencoded characters in any font that has CharStrings.
  17. % Copyright (C) 1999 Aladdin Enterprises, Menlo Park, CA
  18. % Modified to sort unencoded characters.
  19. % Copyright (C) 2000 Aladdin Enterprises, Menlo Park, CA
  20. % Modified to print CIDFonts as well as fonts.
  21. % O(N^2) sorting replaced with O(N log N).
  22. % Copyright transferred 2000/09/15 to Artifex Software, Inc. Send any questions to
  23. % bug-gs@ghostscript.com.
  24. % $Id: prfont.ps 8022 2007-06-05 22:23:38Z giles $
  25. % Example usages at bottom of file
  26. /#copies 1 def
  27. /min { 2 copy gt { exch } if pop } bind def
  28. /T6 /Times-Roman findfont 6 scalefont def
  29. /Temp 64 string def
  30. /Inch {72 mul} def
  31. /Base 16 def % char code output base
  32. /TempEncoding [ 256 { /.notdef } repeat ] def
  33. % Sort an array. Code used by permission of the author, Aladdin Enterprises.
  34. /sort { % <array> <lt-proc> sort <array>
  35. % Heapsort (algorithm 5.2.3H, Knuth vol. 2, p. 146),
  36. % modified for 0-origin indexing. */
  37. 10 dict begin
  38. /LT exch def
  39. /recs exch def
  40. /N recs length def
  41. N 1 gt {
  42. /l N 2 idiv def
  43. /r N 1 sub def {
  44. l 0 gt {
  45. /l l 1 sub def
  46. /R recs l get def
  47. } {
  48. /R recs r get def
  49. recs r recs 0 get put
  50. /r r 1 sub def
  51. r 0 eq { recs 0 R put exit } if
  52. } ifelse
  53. /j l def {
  54. /i j def
  55. /j j dup add 1 add def
  56. j r lt {
  57. recs j get recs j 1 add get LT { /j j 1 add def } if
  58. } if
  59. j r gt { recs i R put exit } if
  60. R recs j get LT not { recs i R put exit } if
  61. recs i recs j get put
  62. } loop
  63. } loop
  64. } if recs end
  65. } def
  66. % do single character of page
  67. % output to rectangle ll=(0,-24) ur=(36,24)
  68. /DoGlyph { % C, N, W set
  69. % print code name, width and char name
  70. T6 setfont
  71. N /.notdef ne {0 -20 moveto N Temp cvs show} if
  72. 0 -12 moveto C Base Temp cvrs show ( ) show
  73. W 0.0005 add Temp cvs 0 5 getinterval show
  74. % print char with reference lines
  75. N /.notdef ne {
  76. 3 0 translate
  77. 0 0 moveto F24 setfont N glyphshow
  78. /W W 24 mul def
  79. 0 -6 moveto 0 24 lineto
  80. W -6 moveto W 24 lineto
  81. -3 0 moveto W 3 add 0 lineto
  82. 0 setlinewidth stroke
  83. } if
  84. } def
  85. /DoChar {
  86. /C exch def
  87. /N F /Encoding get C get def
  88. /S (_) dup 0 C put def
  89. /W F setfont S stringwidth pop def
  90. DoGlyph
  91. } def
  92. /CIDTemp 20 string def
  93. /DoCID {
  94. /N exch def
  95. /C N def
  96. /W F setfont gsave
  97. matrix currentmatrix nulldevice setmatrix
  98. 0 0 moveto N glyphshow currentpoint pop
  99. grestore def
  100. DoGlyph
  101. } def
  102. % print page title
  103. /DoTitle {
  104. /Times-Roman findfont 18 scalefont setfont
  105. 36 10.5 Inch moveto FName Temp cvs show ( ) show ((24 point)) show
  106. } def
  107. % print one block of characters
  108. /DoBlock { % firstcode lastcode
  109. /FirstCode 2 index def
  110. 1 exch {
  111. /I exch def
  112. /Xn I FirstCode sub 16 mod def /Yn I FirstCode sub 16 idiv def
  113. gsave
  114. Xn 35 mul 24 add Yn -56 mul 9.5 Inch add translate
  115. I DoCode
  116. grestore
  117. } for
  118. } def
  119. % print a line of character
  120. /DoCharLine { % firstcode lastcode
  121. 1 exch { (_) dup 0 3 index put show pop } for
  122. } def
  123. /DoCIDLine { % firstcode lastcode
  124. 1 exch { glyphshow } for
  125. } def
  126. % initialize variables
  127. /InitDoFont { % fontname font
  128. /F exch def % font
  129. /FName exch def % font name
  130. /F24 F 24 scalefont def
  131. /Line0 96 string def
  132. /Line1 96 string def
  133. /Namestring1 128 string def
  134. /Namestring2 128 string def
  135. } def
  136. % print pages of unencoded characters
  137. /DoUnencoded { % glyphs
  138. /Unencoded exch def
  139. /Count Unencoded length def
  140. % Print the unencoded characters in blocks of 128.
  141. 0 128 Unencoded length 1 sub
  142. { /BlockStart 1 index def
  143. dup 128 add Unencoded length .min 1 index sub
  144. Unencoded 3 1 roll getinterval TempEncoding copy
  145. /BlockEncoding exch def
  146. /BlockCount BlockEncoding length def
  147. save
  148. F /Encoding known {
  149. F length dict F
  150. { 1 index /FID eq { pop pop } { 2 index 3 1 roll put } ifelse }
  151. forall dup /Encoding TempEncoding put
  152. /* exch definefont
  153. /F exch def
  154. /F24 F 24 scalefont def
  155. /BlockStart 0 def
  156. } if
  157. DoTitle (, unencoded characters) show
  158. BlockStart dup BlockCount 1 sub add DoBlock
  159. F 10 scalefont setfont
  160. 36 2.4 Inch moveto
  161. 0 32 BlockCount 1 sub {
  162. 0 -0.4 Inch rmoveto gsave
  163. dup 31 add BlockCount 1 sub .min
  164. exch BlockStart add exch BlockStart add DoLine
  165. grestore
  166. } for
  167. showpage
  168. restore
  169. } for
  170. } def
  171. % print font sample pages
  172. /DoFont {
  173. dup findfont InitDoFont
  174. /DoCode {DoChar} def
  175. /DoLine {DoCharLine} def
  176. % Display the first 128 encoded characters.
  177. DoTitle (, characters 0-127) show
  178. 0 127 DoBlock
  179. F 10 scalefont setfont
  180. 36 2.0 Inch moveto 0 31 DoLine
  181. 36 1.6 Inch moveto 32 63 DoLine
  182. 36 1.2 Inch moveto 64 95 DoLine
  183. 36 0.8 Inch moveto 96 127 DoLine
  184. showpage
  185. % Display the second 128 encoded characters.
  186. DoTitle (, characters 128-255) show
  187. 128 255 DoBlock
  188. F 10 scalefont setfont
  189. 36 2.0 Inch moveto 128 159 DoLine
  190. 36 1.6 Inch moveto 160 191 DoLine
  191. 36 1.2 Inch moveto 192 223 DoLine
  192. 36 0.8 Inch moveto 224 255 DoLine
  193. showpage
  194. F /CharStrings known
  195. {
  196. % Find and display the unencoded characters.
  197. /Encoded F /Encoding get length dict def
  198. F /Encoding get { true Encoded 3 1 roll put } forall
  199. [ F /CharStrings get
  200. { pop dup Encoded exch known { pop } if }
  201. forall ] {
  202. exch Namestring1 cvs exch Namestring2 cvs lt
  203. } sort DoUnencoded
  204. }
  205. if
  206. } def
  207. % print CIDFont sample pages
  208. /DoCIDFont {
  209. dup /CIDFont findresource InitDoFont
  210. /DoCode {DoCID} def
  211. /DoLine {DoCIDLine} def
  212. [ 0 1 F /CIDCount get 1 sub { } for ] DoUnencoded
  213. } def
  214. % Do font samples
  215. % /Times-Roman DoFont % Test (less than a minute)
  216. % /Hershey-Gothic-English DoFont % Test (8 minutes)
  217. % Do a complete catalog
  218. % FontDirectory {pop DoFont} forall % All fonts (quite a long time)