markhint.ps 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. % Copyright (C) 1994, 1995, 1996 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: markhint.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % markhint.ps
  19. % Draw the hints for a Type 1 font.
  20. (type1ops.ps) runlibfile
  21. /mhsetup % <matrix> <print> mhsetup -
  22. { /mhprint exch def
  23. /mhmx exch def
  24. /mhdash 0 9 gsave initmatrix dtransform grestore idtransform add abs def
  25. gsave
  26. clippath pathbbox
  27. 2 index sub /bbh exch def
  28. 2 index sub /bbw exch def
  29. /bby exch def
  30. /bbx exch def
  31. grestore
  32. } def
  33. /markfonthints % <matrix> <print> markfonthints -
  34. { mhsetup
  35. } def
  36. /hmark % <y> hmark -
  37. { bbx exch moveto bbw 0 rlineto stroke
  38. } def
  39. /hsmark % <y0> <dy> hsmark -
  40. { 1 index add exch gsave
  41. [mhdash] 0 setdash 0 exch mhmx transform exch pop hmark
  42. [mhdash 2 div dup 2 mul] 0 setdash 0 exch mhmx transform exch pop hmark
  43. grestore
  44. } def
  45. /vmark % <x> vmark -
  46. { bby moveto 0 bbh rlineto stroke
  47. } def
  48. /vsmark % <x0> <dx> vsmark -
  49. { 1 index add exch gsave
  50. [mhdash] mhdash setdash 0 mhmx transform pop vmark
  51. [mhdash 2 div dup 2 mul] 0 setdash 0 mhmx transform pop vmark
  52. grestore
  53. } def
  54. /pmark % <x> <y> pmark -
  55. { newpath 0 4.5 gsave initmatrix dtransform grestore idtransform add abs
  56. 0 360 arc stroke
  57. } def
  58. /mchdict mark
  59. /hsbw { pop 0 mhmx transform translate 0 0 pmark }
  60. /sbw { pop pop mhmx transform translate 0 0 pmark }
  61. /hstem
  62. { mhprint { (hstem ) print 2 copy 2 packedarray == } if
  63. hsmark
  64. }
  65. /vstem
  66. { mhprint { (vstem ) print 2 copy 2 packedarray == } if
  67. vsmark
  68. }
  69. /hstem3
  70. { mhprint { (hstem3 ) print 6 copy 6 packedarray == } if
  71. 3 { hsmark } repeat
  72. }
  73. /vstem3
  74. { mhprint { (vstem3 ) print 6 copy 6 packedarray == } if
  75. 3 { vsmark } repeat
  76. }
  77. /div
  78. { div
  79. }
  80. /callothersubr
  81. { 3 eq
  82. { pop
  83. mhprint { (replace) = } if
  84. % We're replacing hints; lighten the color.
  85. currentrgbcolor 3 { 2 mul 3 div 3 1 roll } repeat setrgbcolor
  86. }
  87. { { pop } repeat
  88. } ifelse
  89. }
  90. /callsubr
  91. { Private /Subrs get exch get mchinterp
  92. }
  93. /pop
  94. {
  95. }
  96. /return
  97. {
  98. }
  99. .dicttomark def
  100. /mchinterp % <charstring> mchinterp -
  101. { 4330 exch dup length string .type1decrypt exch pop
  102. dup length lenIV sub lenIV exch getinterval
  103. 0 () /SubFileDecode filter
  104. mark exch charstack_read ]
  105. { dup type /nametype eq
  106. { mchdict exch .knownget { exec } { cleartomark mark } ifelse
  107. }
  108. if
  109. }
  110. forall
  111. } def
  112. /markcharhints % <charname> <matrix> <print> markcharhints -
  113. { mhsetup
  114. gsave mark
  115. /Private currentfont /Private get def
  116. Private rcheck % make sure we won't get an access error
  117. { /lenIV Private /lenIV .knownget not { 4 } if def
  118. currentfont /CharStrings get 3 -1 roll get mchinterp
  119. }
  120. { (Sorry, this font is protected; I can't show the hints.\n) print flush
  121. exch
  122. }
  123. ifelse
  124. cleartomark grestore
  125. } def