[cairo] Rounding bug in cairo_ft_font.c

Carl Worth cworth at cworth.org
Sat Jan 8 21:30:38 PST 2005


At Sat, 08 Jan 2005 20:40:44 -0800, Keith Packard wrote:
> > The convention that "all numbers crossing the API are in user-space[*]"
> 
> Except that we expose font space already with the font scaling and
> transformation mechanisms.  The reasoning for using 'font space' for
> metrics is partially because PostScript does, and partially because we'd
> have to report polygons instead of rectangles for the bounding boxes and
> vectors instead of scalars for advances.

I'm not sure I follow.

Consider cairo-demo/png/text.c, whose output with current cairo can be
seen here:

	http://cairographics.org/~cworth/images/text.png

There are obviously some bugs in the exact metrics, (notice some of
the glyphs extend beyond the boxes).

But notice the two rotated "hello, world" strings. The first is
rotated by means of the CTM, while the second is rotated by means of a
font transform. The code for these two examples looks like this:

	/* Rotate text with CTM */
	cairo_translate (cr, 10, height);
	cairo_rotate (cr, 10 * M_PI / 180.0);
	box_text (cr, "hello, world", 0, 0);
	
	/* ... */

	/* Rotate text with font transform */
	cairo_matrix_t *matrix = cairo_matrix_create ();
	cairo_matrix_rotate (matrix, 10 * M_PI / 180.0);
	cairo_transform_font (cr, matrix);
	cairo_matrix_destroy (matrix);
	box_text (cr, "hello, world", 10, height);

While the relevant portion of the box_text is as follows

	cairo_rectangle (cr,
			 x + extents.x_bearing - line_width,
			 y + extents.y_bearing - line_width,
			 extents.width  + 2 * line_width,
			 extents.height + 2 * line_width);
	cairo_stroke (cr);

	cairo_move_to (cr, x, y);
	cairo_show_text (cr, utf8);

So, in either case, the extents function returns a user-space box
that, (should, but currently doesn't quite), bound the text output.

This seems quite sane to me. Do we actually want something different?

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050109/e41159c1/attachment.pgp


More information about the cairo mailing list