1
0

pcharstr.ps 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. % Copyright (C) 1990, 1992, 1997, 1999 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: pcharstr.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  16. % pcharstr.ps
  17. % Print the CharStrings and Subrs (if present) from a Type 1 font,
  18. % in either a PostScript-like or a C-compatible form,
  19. % depending on whether CSFormat is defined as /PS or /C.
  20. % Load the Type 1 utilities.
  21. (type1ops.ps) runlibfile
  22. % Define the printing procedures for PostScript-like output.
  23. /pcs_ps_dict mark
  24. /, {( ) print}
  25. /charname {==only}
  26. /csbegin {}
  27. /beginchars {(%---------------- CharStrings\n) print}
  28. /charbegin {==only}
  29. /char1 {( ) print ==only}
  30. /endchars {}
  31. /beginsubrs {(%---------------- Subrs\n) print}
  32. /subrbegin {=only}
  33. /endsubrs {}
  34. /beginboxes {(%---------------- Encoding & metrics\n) print}
  35. /notdefbox {}
  36. /boxbegin {=only ( ) print}
  37. /boxend {(\n) print}
  38. /endboxes {(%----------------\n) print}
  39. .dicttomark readonly def
  40. % Define the printing procedures for C-like output.
  41. /pcs_c_dict mark
  42. /, {(, ) print}
  43. /charname {(") print =only (") print}
  44. /csbegin {counttomark =only ,}
  45. /beginchars {(\nconstdata int CSCharData[] = {\n) print}
  46. /charbegin {pop}
  47. /char1 {=only ,}
  48. /endchars {
  49. (-1\n};\nconstdata char *CSCharNames[] = {\n) print
  50. CharStrings {pop charname ,} forall (0\n};\n) print
  51. }
  52. /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
  53. /subrbegin {pop}
  54. /endsubrs {(-1\n};\n) print}
  55. /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
  56. /notdefbox {( {""},\n) print}
  57. /boxbegin {pop ( {) print}
  58. /boxend {(},) =}
  59. /endboxes {( {0}\n};\n) print}
  60. .dicttomark readonly def
  61. /printcs
  62. { dup type /stringtype eq
  63. { printcs1 (\n) print }
  64. { ( ) print == }
  65. ifelse
  66. } bind def
  67. /printcs1
  68. { save exch
  69. lenIV 0 ge {
  70. 4330 exch dup length string .type1decrypt exch pop
  71. dup length lenIV sub lenIV exch getinterval
  72. } if
  73. 0 () /SubFileDecode filter
  74. mark exch charstack_read csbegin
  75. counttomark 1 sub -1 0 { index char1 } for
  76. cleartomark restore
  77. } bind def
  78. /printfont
  79. { pcs_ps_dict
  80. /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
  81. begin
  82. currentfont begin Private begin 10 dict begin
  83. % Print the CharStrings and Subrs
  84. beginchars
  85. CharStrings { exch charbegin printcs } forall
  86. endchars
  87. /Subrs where
  88. { pop % the dictionary
  89. beginsubrs
  90. 0 1 Subrs length 1 sub
  91. { dup subrbegin
  92. Subrs exch get printcs
  93. } for
  94. endsubrs
  95. } if
  96. % Print the bounding boxes
  97. gsave nulldevice FontMatrix matrix invertmatrix concat
  98. beginboxes
  99. 0 1 Encoding length 1 sub
  100. { dup Encoding exch get dup /.notdef eq
  101. { pop pop notdefbox
  102. }
  103. { 1 index boxbegin charname ,
  104. ( ) dup 0 4 -1 roll put
  105. newpath 0 0 moveto false charpath
  106. pathbbox ({) print 4 -1 roll =only ,
  107. 3 -1 roll =only , exch =only , =only (}) print
  108. boxend
  109. }
  110. ifelse
  111. } for
  112. endboxes
  113. grestore
  114. end end end end
  115. } bind def