[cairo] _cairo_lround (and effects on positioning of text)

Daniel Amelang daniel.amelang at gmail.com
Tue Nov 21 18:23:04 PST 2006


On 11/21/06, Carl Worth <cworth at cworth.org> wrote:
> On Tue, 21 Nov 2006 17:37:02 -0800, Carl Worth wrote:
> > So, do we care that this patch might move some text around by a pixel
> > compared to where it was drawn before?
>
> Phrased another way, how do we want to document the behavior of the
> values passed to cairo_show_glyphs? We're accepting floating-point
> values, but then rounding them. Do we really want to specify banker's
> rounding for this? That feels so wrong.

Good point. It think that if the user is asking us to "draw this glyph
exactly halfway between these two pixels" (i.e. 1.5), and we don't
support sub-pixel text rendering, it's hard to do anything that feels
"right".

I'm admittedly biased towards the patch, as it is the result of my
blood sweat and tears, so I should probably stay clear of the
discussion.

> Maybe we really should have just provided an integer-only API for
> positioning text glyphs. (If so, one option would be to document that
> the API really should be used with only integers for now, and that the
> rounding mode is undefined for any non-integer value.) I'd at least
> feel more comfortable specifying undefined rounding behavior than
> banker's rounding for this.

Sounds reasonable. Or just have it be undefined for the edge case (x.5
values). I have cooking a _cairo_lround that has no FP ops (meant for
embedded devices) that uses arithmetic rounding (not really by
choice), which, if incorporated into cairo, would mean that the
rounding mode would differ per platform. Yuck! That "undefined for
non-integer values" or "undefined for x.5 values" sounds pretty good
right now.

Dan


More information about the cairo mailing list