• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Dec 28, 2009 Dec 28, 2009

Copy link to clipboard

Copied

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.

TOPICS
Programming

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 07, 2010 Jan 07, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 07, 2010 Jan 07, 2010

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 14, 2010 Jan 14, 2010

Copy link to clipboard

Copied

skip double post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 14, 2010 Jan 14, 2010

Copy link to clipboard

Copied

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 (          ) def

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

showpage

*

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 15, 2010 Jan 15, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines