showchar.ps 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. % Copyright (C) 1993, 1994, 1996 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: showchar.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  16. % showchar.ps
  17. % Show the outline and rasterized forms of a character.
  18. /F where { pop } { /F /Times-Roman def } ifelse
  19. /P where { pop } { /P 16 def } ifelse
  20. /Rx where { pop } { /Rx 100 def } ifelse
  21. /Ry where { pop } { /Ry 100 def } ifelse
  22. /Cs where { pop } { /Cs (M) def } ifelse
  23. /Pr where { pop } { /Pr false def } ifelse
  24. /Delay where { pop } { /Delay 0 def } ifelse
  25. 0 setgray
  26. (markpath.ps) runlibfile
  27. (markhint.ps) runlibfile
  28. /mmx [1 0 0 1 0 0] def
  29. /getpath % - getpath <pathproc>
  30. { [
  31. { /moveto cvx } { /lineto cvx } { /curveto cvx } { /closepath cvx }
  32. pathforall
  33. ] cvx
  34. } def
  35. /bitselectfont % <fontname> <scale> bitselectfont -
  36. { exch findfont exch scalefont setfont
  37. % Compute the bounding box in device coordinates.
  38. gsave [Rx 72 div 0 0 Ry 72 div 0 0] setmatrix
  39. currentfont /FontMatrix get concat
  40. currentfont /FontBBox get aload pop
  41. transform ceiling cvi /ury exch def ceiling cvi /urx exch def
  42. transform floor cvi /lly exch def floor cvi /llx exch def
  43. /bbx urx llx sub def /bby ury lly sub def
  44. grestore
  45. } def
  46. /bitshow % <string> bitshow -
  47. { /S exch def gsave
  48. /W bbx 8 add 7 or 1 add def
  49. /H bby 8 add def
  50. /buf W 8 idiv string def
  51. /M [Rx 72 div 0 0 Ry -72 div 4 llx sub H 4 sub] def
  52. M W H <ff 00> makeimagedevice
  53. /dev exch def
  54. gsave dev setdevice
  55. newpath 0 lly idtransform moveto
  56. 0 setgray
  57. gsave
  58. /hpath S false charpath getpath def
  59. grestore
  60. S show grestore
  61. 20 20 translate
  62. 50000 Rx Ry .max P mul div dup scale
  63. 0.7 setgray
  64. 0 W H true M
  65. { dup 1 add exch dev exch buf copyscanlines
  66. } imagemask pop
  67. 0 setlinewidth
  68. gsave 0.5 1 0.5 setrgbcolor hpath exec mmx markpath grestore
  69. 0 0.5 1 setrgbcolor hpath exec stroke
  70. % Show the hints for Type 1 fonts also.
  71. currentfont /FontType get 1 eq
  72. { gsave 1 0 0 setrgbcolor
  73. 0 lly M idtransform translate
  74. currentfont /FontMatrix get
  75. dup Pr markfonthints
  76. currentfont /Encoding get S 0 get get exch Pr markcharhints
  77. grestore
  78. }
  79. if
  80. } def
  81. F P bitselectfont
  82. /S1 1 string def
  83. Cs
  84. { /C exch def
  85. currentfont /Encoding get C get /.notdef ne
  86. { save S1 0 C put S1 bitshow
  87. showpage restore
  88. } if
  89. } forall
  90. quit