-
1. Re: How Do I Get a Glyph's Bounding Box After a "glyphshow"?
abeddie Jan 7, 2010 12:47 PM (in response to Tom Browder2)For a string and a glyph:
Eddie
%!
/msg (Hello) def
/Courier 72 selectfont72 612 moveto
msg true charpath
pathbbox
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 y0 x1 x0 sub y1 y0 sub rectstroke
72 612 moveto
msg shownewpath
72 512 moveto
(H) true charpath
pathbbox
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 y0 x1 x0 sub y1 y0 sub rectstroke
72 512 moveto
/H glyphshowshowpage
-
2. Re: How Do I Get a Glyph's Bounding Box After a "glyphshow"?
Tom Browder2 Jan 7, 2010 1:22 PM (in response to abeddie)Thanks, but your solution is for standard encoding, how would it be done for a named glyph NOT in the encoding vector as in my original question?
-
3. Re: How Do I Get a Glyph's Bounding Box After a "glyphshow"?
abeddie Jan 14, 2010 10:13 AM (in response to Tom Browder2)skip double post
-
4. Re: How Do I Get a Glyph's Bounding Box After a "glyphshow"?
abeddie Jan 14, 2010 10:12 AM (in response to Tom Browder2)Here's an example that includes a defined font with a non-stardard character (newexlam) and re-encodes the font
to use charpath. Note, the setcachdevice args to newexclam are just a copy from exclam.
Eddie
%!
12 dict begin
/FontType 3 def
/FontMatrix [0.001 0 0 0.001 0 0 ] readonly def
/FontName /simple def
/FontBBox {-173 -218 1000 902 } readonly def
/PaintType 0 def/Encoding 256 array
0 1 255 { 1 index exch /.notdef put} for
dup 32/space put
dup 33/exclam put
readonly def/BuildChar { 1 index /Encoding get exch get 1 index /BuildGlyph get exec } bind def
/BuildGlyph { 2 copy exch /CharProcs get exch 2 copy known not { pop /.notdef} if get exch pop 0 exch exec pop pop fill} bind def
/CharProcs 8 dict def
CharProcs begin
/.notdef { 1000 0 0 0 0 0 setcachedevice } bind def
/space { 250 0 0 0 0 0 setcachedevice } bind def/exclam { 333 0 121 -13 244 670 setcachedevice
100 100 300 100 rectfill
100 300 300 500 rectfill
} bind def
/newexclam { 333 0 121 -13 244 670 setcachedevice
00 00 500 100 rectfill
00 200 500 500 rectfill
} bind def
end
currentdict end
/simple exch definefont pop/msg (!!!!!) def
/simple 72 selectfont
newpath
72 612 moveto
msg true charpath
pathbbox
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 y0 x1 x0 sub y1 y0 sub rectstroke
72 612 moveto
msg show/SecondEncoding StandardEncoding 256 array copy
dup 32/newexclam put
readonly def
/simple findfont
dup length dict begin
{ 1 index /FID ne {def} {pop pop} ifelse} forall
/Encoding SecondEncoding def
currentdict
end
/NewEncode exch definefont pop/NewEncode 72 selectfont
/msg ( ) defnewpath
72 512 moveto
msg true charpath
pathbbox
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 y0 x1 x0 sub y1 y0 sub rectstroke
72 512 moveto
msg showshowpage
*
-
5. Re: How Do I Get a Glyph's Bounding Box After a "glyphshow"?
Tom Browder2 Jan 15, 2010 3:36 AM (in response to abeddie)Thanks, Eddie, but that again is just a variation of character substitution into an encodong vector and then using the show operator or variant.
What I would like to do is be able to use the glyph name as is, with glyphshow, and somehow find the bounding box of the path so stroked.
Does clip work properly afterwards? Pathbbox?
I can't get them to show the bounding box.
-Tom

