Skip to main content
Participant
December 28, 2009
Question

How Do I Get a Glyph's Bounding Box After a "glyphshow"?

  • December 28, 2009
  • 1 reply
  • 1880 views

I am trying to capture the bounding box from painting a character using glyphshow, but the result seems not to be the actual bounding box.  Here is a snippet of PS code that I am trying:

% begin snippet

/BickhamScriptPro-Bold 70 selectfont

0 0 moveto

newpath

/glyphname glyphshow pathbbox

/ury exch def

/urx exch def

/lly exch def

/llx exch dev

% end snippet

I use the result to center the glyph like so:

% begin snippet

/hw llx urx add .5 mul def

0 hw sub 0 moveto /glyphname glyphshow

% end snippet

For the glyph I'm using the result is not centered ("d.begin", font: Adobe Bickham Script Bold).  Note the glyph is a very slanted cursive 'd' with the upper right part extending well over adjacent characters to its right.

What am I doing wrong?

Thanks.

This topic has been closed for replies.

1 reply

Participating Frequently
January 7, 2010

For a string and a glyph:

Eddie

%!
/msg (Hello) def
/Courier 72 selectfont

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

newpath
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 glyphshow

showpage

Participant
January 7, 2010

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?

Participating Frequently
January 14, 2010

skip double post