[cairo] Wrong extents when rendering glyphs to non-integer positions
psychon at znc.in
Thu Oct 21 05:26:18 PDT 2010
attached is a diff between current master and my try at this. I got this split
up into multiple commits at . I hope this works roughly like you wanted it to
I only enable this for the image and xcb backends, because this is where I know
that it fixes test suite failures. Other backends could do the same if needed.
Am 21.10.2010 02:24, Behdad Esfahbod wrote:
> Long term, there's a LOT to be fixed (including, first defining what the
> extents really mean in raster backend), but for now a hack shall be used.
> Your's misses a few corner cases (analysis surface targeting raster surface,
> recording surface targeting raster, etc).
> I suggest instead you add a private font-options member and set it to ON/OFF
> in different surface types like we already do for hinting.
> On 10/19/10 06:02, Uli Schlachter wrote:
>> thanks to a bug in the XCB backend, I noticed that
>> _cairo_composite_rectangles_init_for_glyphs returns a wrong extent for
>> non-integer-aligned glyphs (see the result of xcb's overlapping-glyphs test).
>> The problem is that the xcb and image backends (and others?) round the pixel
>> coordinates before drawing, e.g. cairo-image-surface.c, line 3977:
>> x = _cairo_lround (info->glyphs[i].x -
>> y = _cairo_lround (info->glyphs[i].y -
>> However, the function that does all the extents-work
>> (_cairo_scaled_font_glyph_device_extents) doesn't do this rounding. Instead, it
>> generates a cairo_box_t with the exact bounding rectangle and then rounds this
>> via _cairo_box_round_to_rectangle to a cairo_rectangle_int_t.
>> I did a quick-and-dirty hack that makes _cairo_scaled_font_glyph_device_extents
>> use _cairo_lround. The test suite then said that this fixed text-rotate in
>> the test suite (and only broke Xlib's clip-text due to a wrong text postion).
>> Andrea Canciani suggested that this change might break hinting. Looking at the
>> font face code, I need someone else to confirm this. ;)
>> Could somehow who has a better understanding of cairo's glyph rendering take a
>> look at this and perhaps come up with a nice(r) fix? IMHO, all backends that can
>> only draw glyphs to integer positions and thus use _cairo_lround might be
>> affected by this problem in one way or another.
>> Uli Schlachter
- Buck, when, exactly, did you lose your mind?
- Three months ago. I woke up one morning married to a pineapple.
An ugly pineapple... But I loved her
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7024 bytes
Desc: not available
More information about the cairo