2 # showchar: show character with information
4 # showchar Font-Name Char-Name | lpr -Pprinter
7 echo "Usage: `basename $0` Font-Name Char-Name" >&2
13 % Get character metrics and bounding box for $1
17 /fn fname findfont 1000 scalefont def
21 /sn { ns cvs show } def
22 /sc { (\()show exch sn (,)show sn (\))show } def
24 /Times-Roman findfont 10 scalefont setfont
26 72 242 translate % one inch in, 3 1/2 inch up
28 gsave % print character name
30 ($2 from font $1 displayed on `date` by `basename $0` 1.00 (C) AJCD 1991)
35 thin setlinewidth % cross hairs
36 -9 0 rmoveto 18 0 rlineto
37 -9 -9 rmoveto 0 18 rlineto
38 stroke % position info
39 -9 -9 moveto ((0,0)) stringwidth pop neg 0 rmoveto
43 % create encoding with a single character at all positions
44 /MyEncoding 256 array def
46 0 1 255 { % fill out with notdefs
47 MyEncoding exch cname put
50 fn dup length dict begin
51 {1 index /FID ne {def} {pop pop} ifelse} forall
52 /Encoding MyEncoding def
54 end /newfont exch definefont
58 gsave % draw character (enlarged)
60 fn 1 reduction div scalefont setfont
66 dup fn /Metrics get exch get
67 dup type /arraytype eq {
69 {1 get 0} {dup 2 get exch 3 get} ifelse
75 fn setfont (\000) stringwidth round exch round exch
81 reduction div exch reduction div exch rlineto
85 -4 -3 rlineto 0 6 rmoveto 4 -3 rlineto
90 gsave % get bounding box
92 (\000) true charpath flattenpath pathbbox
95 3 index reduction div % put coords on top of stack
99 3 index 3 index moveto
101 0 -9 rmoveto 7 index 7 index sc
103 1 index 3 index lineto
105 0 -9 rmoveto 5 index 7 index sc
107 1 index 1 index lineto
109 0 9 rmoveto 5 index 5 index sc
111 3 index 1 index lineto
113 0 9 rmoveto 7 index 5 index sc