[cairo] Rotated glyph inked area problem
Behdad Esfahbod
behdad at behdad.org
Thu Sep 9 16:40:03 PDT 2010
On 09/09/10 16:13, Ian Britten wrote:
> Hi all,
> 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?
A bug. Not very easy to fix though.
> 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.
0.02 pixels is peanuts as far as rounding and other errors are involved. My
long-term plans for cairo will fix this one too.
> 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
> as cairo_glyph_path()+cairo_fill_extents()?
Ideally, yes. In fact, my long term plan is for cairo to get the glyph
outline from FreeType and do everything (rasterization, extent calculations,
etc) all within cairo itself since FreeType has proved to be very
low-precision at those.
> So, should I pursue either of these issues (Bugzilla?), or are
> they known issues?
Known issues. Here's what I wrote previously:
http://lists.freedesktop.org/archives/cairo/2008-May/014146.html
behdad
> Thanks for any info!
> Ian
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list