home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / PSUTILS / SHOWCHAR.CMD < prev   
OS/2 REXX Batch file  |  1994-01-13  |  3KB  |  122 lines

  1. extproc sh d:/bin/showchar.cmd 
  2. #!/bin/sh
  3. # showchar: show character with information
  4. # usage:
  5. #       showchar Font-Name Char-Name | lpr -Pprinter
  6.  
  7. shift 
  8.  
  9. if [ $# != 2 ]; then
  10.         echo "Usage: `basename $0` Font-Name Char-Name" >&2
  11.         exit 1
  12. fi
  13.  
  14. cat <<EOF
  15. %!
  16. % Get character metrics and bounding box for $1
  17. /ns 30 string def
  18. /fname /$1 def
  19. /cname /$2 def
  20. /fn fname findfont 1000 scalefont def
  21. /thin 0.7 def
  22. /reduction 2.0 def
  23.  
  24. /sn { ns cvs show } def
  25. /sc { (\()show exch sn (,)show sn (\))show } def
  26.  
  27. /Times-Roman findfont 10 scalefont setfont
  28.  
  29. 72 242 translate % one inch in, 3 1/2 inch up
  30. newpath 0 0 moveto
  31. gsave   % print character name
  32.    0 468 rmoveto
  33.    ($2 from font $1 displayed on `date` by `basename $0` 1.00 (C) AJCD 1991)
  34.    show 
  35. grestore
  36.  
  37. gsave
  38.    thin setlinewidth  % cross hairs
  39.    -9 0 rmoveto 18 0 rlineto
  40.    -9 -9 rmoveto 0 18 rlineto
  41.    stroke  % position info
  42.    -9 -9 moveto ((0,0)) stringwidth pop neg 0 rmoveto
  43.    ((0,0)) show
  44. grestore
  45.  
  46. % create encoding with a single character at all positions
  47. /MyEncoding 256 array def
  48.  
  49. 0 1 255 { % fill out with notdefs
  50.    MyEncoding exch cname put
  51. } for
  52.  
  53. fn dup length dict begin
  54.   {1 index /FID ne {def} {pop pop} ifelse} forall
  55.   /Encoding MyEncoding def
  56.   currentdict
  57. end /newfont exch definefont
  58. /fn exch def
  59. /en MyEncoding def
  60.  
  61. gsave  % draw character (enlarged)
  62.   .75 setgray
  63.   fn 1 reduction div scalefont setfont
  64.   (\000) show
  65. grestore
  66.  
  67. % show character info
  68. fn /Metrics known {
  69.    dup fn /Metrics get exch get 
  70.    dup type /arraytype eq {
  71.       dup length 2 eq
  72.       {1 get 0} {dup 2 get exch 3 get} ifelse
  73.    } {
  74.       round 0
  75.    } ifelse
  76. } {
  77.    gsave
  78.       fn setfont (\000) stringwidth round exch round exch
  79.    grestore
  80. } ifelse
  81. gsave   % show width
  82.    thin setlinewidth
  83.    2 copy
  84.    reduction div exch reduction div exch rlineto
  85.    gsave
  86.       1 1 rmoveto sc
  87.    grestore
  88.    -4 -3 rlineto 0 6 rmoveto 4 -3 rlineto
  89.    stroke
  90. grestore
  91.  
  92. gsave
  93.    gsave  % get bounding box
  94.       fn setfont
  95.       (\000) true charpath flattenpath pathbbox
  96.    grestore
  97.    thin setlinewidth
  98.    3 index reduction div  % put coords on top of stack
  99.    3 index reduction div
  100.    3 index reduction div
  101.    3 index reduction div
  102.    3 index 3 index moveto
  103.    gsave  % llx lly
  104.       0 -9 rmoveto 7 index 7 index sc
  105.    grestore
  106.    1 index 3 index lineto
  107.    gsave  % urx lly
  108.       0 -9 rmoveto 5 index 7 index sc
  109.    grestore
  110.    1 index 1 index lineto
  111.    gsave  % urx ury
  112.       0 9 rmoveto 5 index 5 index sc
  113.    grestore
  114.    3 index 1 index lineto
  115.    gsave  % llx ury
  116.       0 9 rmoveto 7 index 5 index sc
  117.    grestore
  118.    closepath stroke
  119. grestore
  120. showpage
  121. EOF
  122.