pcharstr.ps 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. % Copyright (C) 1990, 1992, 1997, 1999 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: pcharstr.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % pcharstr.ps
  19. % Print the CharStrings and Subrs (if present) from a Type 1 font,
  20. % in either a PostScript-like or a C-compatible form,
  21. % depending on whether CSFormat is defined as /PS or /C.
  22. % Load the Type 1 utilities.
  23. (type1ops.ps) runlibfile
  24. % Define the printing procedures for PostScript-like output.
  25. /pcs_ps_dict mark
  26. /, {( ) print}
  27. /charname {==only}
  28. /csbegin {}
  29. /beginchars {(%---------------- CharStrings\n) print}
  30. /charbegin {==only}
  31. /char1 {( ) print ==only}
  32. /endchars {}
  33. /beginsubrs {(%---------------- Subrs\n) print}
  34. /subrbegin {=only}
  35. /endsubrs {}
  36. /beginboxes {(%---------------- Encoding & metrics\n) print}
  37. /notdefbox {}
  38. /boxbegin {=only ( ) print}
  39. /boxend {(\n) print}
  40. /endboxes {(%----------------\n) print}
  41. .dicttomark readonly def
  42. % Define the printing procedures for C-like output.
  43. /pcs_c_dict mark
  44. /, {(, ) print}
  45. /charname {(") print =only (") print}
  46. /csbegin {counttomark =only ,}
  47. /beginchars {(\nconstdata int CSCharData[] = {\n) print}
  48. /charbegin {pop}
  49. /char1 {=only ,}
  50. /endchars {
  51. (-1\n};\nconstdata char *CSCharNames[] = {\n) print
  52. CharStrings {pop charname ,} forall (0\n};\n) print
  53. }
  54. /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
  55. /subrbegin {pop}
  56. /endsubrs {(-1\n};\n) print}
  57. /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
  58. /notdefbox {( {""},\n) print}
  59. /boxbegin {pop ( {) print}
  60. /boxend {(},) =}
  61. /endboxes {( {0}\n};\n) print}
  62. .dicttomark readonly def
  63. /printcs
  64. { dup type /stringtype eq
  65. { printcs1 (\n) print }
  66. { ( ) print == }
  67. ifelse
  68. } bind def
  69. /printcs1
  70. { save exch
  71. lenIV 0 ge {
  72. 4330 exch dup length string .type1decrypt exch pop
  73. dup length lenIV sub lenIV exch getinterval
  74. } if
  75. 0 () /SubFileDecode filter
  76. mark exch charstack_read csbegin
  77. counttomark 1 sub -1 0 { index char1 } for
  78. cleartomark restore
  79. } bind def
  80. /printfont
  81. { pcs_ps_dict
  82. /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
  83. begin
  84. currentfont begin Private begin 10 dict begin
  85. % Print the CharStrings and Subrs
  86. beginchars
  87. CharStrings { exch charbegin printcs } forall
  88. endchars
  89. /Subrs where
  90. { pop % the dictionary
  91. beginsubrs
  92. 0 1 Subrs length 1 sub
  93. { dup subrbegin
  94. Subrs exch get printcs
  95. } for
  96. endsubrs
  97. } if
  98. % Print the bounding boxes
  99. gsave nulldevice FontMatrix matrix invertmatrix concat
  100. beginboxes
  101. 0 1 Encoding length 1 sub
  102. { dup Encoding exch get dup /.notdef eq
  103. { pop pop notdefbox
  104. }
  105. { 1 index boxbegin charname ,
  106. ( ) dup 0 4 -1 roll put
  107. newpath 0 0 moveto false charpath
  108. pathbbox ({) print 4 -1 roll =only ,
  109. 3 -1 roll =only , exch =only , =only (}) print
  110. boxend
  111. }
  112. ifelse
  113. } for
  114. endboxes
  115. grestore
  116. end end end end
  117. } bind def