Post by v***@gmail.comI'm currently working with a Type 2 font, and need to retrieve bounding
boxes for glyphs.
Thinking about this further since my reply to your first post...
For what purpose do you need the bounding box of a glyph ? You can't get
that from a type 1 program either you know, except by processing a
setcachedevice operation.
Notice that the type 1 spec says 'It executes a setcachedevice
operation, using a bounding box it computes directly from the character
outline' That is, it actually renders the glyph, and then tells the
cache how big it is, the glyph is (obviously) rendered at the correct
point size and resolution.
Post by v***@gmail.comI am looking through the Type 2 charstring spec
(which is fairly similar to Type 1 charstrings) and don't see any
'bounding box' operator or something similar -
I don't think there's anything like that in the type 1 spec either. The
setcachedevice operator is executed by the font interpreter, which
calculates the bounding box by rendering the glyph outline.
('rendering' in this case doesn't mean actually laying down pixels, just
calculating where they would lie)
Post by v***@gmail.comway to get a bounding box is to manually step through the glyph path
and keep track of the bounds by hand? (Assuming there is no bounding
box field in the top dict)
Even if there were a bounding box in the top dict (which there isn't as
far as I'm aware) analogous to the /FontBBox, all that would tell you is
the maximum bounding box, not the bounds of each glyph.
Post by v***@gmail.comIf so, is there a quick way to do so (without doing hint/flex, subrs,
etc lookups)?
No, that's what the font interpreter is for. As you note, the bounding
box of the glyph (in device space) will depend on the font size and the
resolution of the device. You can probably ignore flex, and hinting,
unless you need a pixel perfect result. If you do need a pixel perfect
result then you have several problems:
1) The only way to figure this out is to do the entire job of a font
interpreter. Its a lot of work.
2) Even if you do that, your code will undoubtedly not match any real-
world implementation, so getting pixel-perfect results is defeated
anyway, unless you are doing the rendering yourself, in which case you
need a full font interpreter (round and round and round we go ;-)
So it isn't clear to me what you want, exactly, or why you want it, and
what you intend to do with it once you have it :-)
Perhaps if you could give a little background ?
Ken