pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: Visual bounding box for type 3 font glyphs?
Date Fri, 05 Feb 2016 17:26:24 GMT

> On 5 Feb 2016, at 05:05, Branden Visser <mrvisser@gmail.com> wrote:
> 
> Hi all,
> 
> I'm trying to get the visual bounds of a type 3 font. I've had success
> getting that information from many fonts using `getPath`, but it
> appears it's not supported for Type3. Is there a reliable way to
> understand drawing information for those?

Some Type 3 glyphs begin with the “d1” operator which specifies both
the logical width and the bounding box of the glyph. However, many
begin with “d0” which simply specifies the logical width, which isn’t
what you want.

In theory a Type 3 glyph can contain arbitrary PDF drawing commands
but in practice they are used only for bitmap fonts which contain a single
“BI” operator to draw a masked image. This means it’s actually fairly
easy to extract this image (and then combine its size with the bbox from
d1 and the font matrix to get the glyph’s visual bounding rect). All you
need is a custom PDFStreamEngine which handles only those operators.
We actually have one in preflight, called PreflightType3Stream, which you
can use as starting point.

— John

> Thanks,
> Branden
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message