[cairo] Rotated glyph inked area problem
britten at caris.com
Thu Sep 9 13:13:51 PDT 2010
My goal is to get the device-unit extent of some rendered text.
(by getting the user-unit extent and converting it back to device).
Currently I'm using using Cairo 1.8.8 on 64-bit Linux, and drawing
glyphs from the stock Arial TT font, loaded through FT (2.3.9),
with FT_LOAD_NO_HINTING. I'm drawing to an image surface
(Although I'll eventually be drawing to a PDF surface too)
For my first attempt to get the inked-area, I was using
cairo_glyph_extents(), but I seem to have run into something odd.
When getting the extent of a *rotated* glyph, the returned
width/height in the cairo_text_extents_t structure doesn't seem to
be the for the "inked area" (As documented). Instead, it seems
that the code might be computing the upright cover of the glyph,
rotating the box, and then returning the width/height of the
rotated *box*, not the width/height of the (rotated) glyph. This
results in width/height values that are too big.
-> Is this a bug, or a documentation shortcoming?
As a workaround, I tried using a combination of cairo_glyph_path()
and cairo_fill_extents(). Note this this seems to be returning
slightly different results, even for upright glyphs.
(eg: Approximately 0.02 pixels difference in both the width and
the height). It's pretty close, but enough to fail tests.
Note that with this approach, the results for a rotated glyph
looked correct (Better than what cairo_glyph_extents() returned).
-> Should cairo_glyph_extents() return *exactly* the same results
-> If not, what's the difference, and which one is preferable?
So, should I pursue either of these issues (Bugzilla?), or are
they known issues?
Thanks for any info!
More information about the cairo