showchar.ps 3.0 KB

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