[cairo] PATCH #4 - text extents

Carl Worth cworth at east.isi.edu
Thu Dec 11 05:59:55 PST 2003


On Dec 9, John Ellson wrote:
 > I'm sorry for the churn on this.

No worries. Thanks for all the work. I'm now testing the patch out and
hope to be able to commit something soon.

 > < #define FONT_UNIT_TO_DEV(x) ((double)(x) / (double)(ft->face->units_per_EM))
 > ---
 > >     extents->ascent =        DOUBLE_FROM_26_6(face->ascender);
 > >     extents->descent =       DOUBLE_FROM_26_6(face->descender);
 > >     extents->height =        DOUBLE_FROM_26_6(face->height);
 > >     extents->max_x_advance = DOUBLE_FROM_26_6(face->max_advance_width);
 > >     extents->max_y_advance = DOUBLE_FROM_26_6(face->max_advance_height);
 > 376,381c376
 > <     extents->ascent = FONT_UNIT_TO_DEV(ft->face->ascender) * scale_y;
 > <     extents->descent = FONT_UNIT_TO_DEV(ft->face->descender) * scale_y;
 > <     extents->height = FONT_UNIT_TO_DEV(ft->face->height) * scale_y;
 > <     extents->max_x_advance = FONT_UNIT_TO_DEV(ft->face->max_advance_width) * scale_x;
 > <     extents->max_y_advance = FONT_UNIT_TO_DEV(ft->face->max_advance_height) * scale_y;
 > <     return status;
 > ---
 > >     return CAIRO_STATUS_SUCCESS;

 > Index: src/cairo_gstate.c
 > ===================================================================
 > RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
 > retrieving revision 1.33
 > diff -r1.33 cairo_gstate.c
 > 1595a1610
 > >     double scale_x, scale_y;
 > 1602a1618,1625
 > > 
 > >     _get_scale_factors(&gstate->ctm, &scale_x, &scale_y);
 > >     extents->max_x_advance /= scale_x;
 > >     extents->max_y_advance /= scale_y;
 > >     extents->ascent /= scale_y;
 > >     extents->descent /= scale_y;
 > >     extents->height /= scale_y;

The changes above looks suspicious. From my testing, with this change
the font extents returned are independent of any value passed to
cairo_scale_font. The original code seems to work fine.

So, when I commit the rest, I plan to revert this, unless there's a
better suggestion.

 > >     extents->left_side_bearing  = DOUBLE_FROM_26_6(overall_Left);
 > >     extents->right_side_bearing = DOUBLE_FROM_26_6(overall_Right);
 > >     extents->ascent             = DOUBLE_FROM_26_6(overall_Top);
 > >     extents->descent            = DOUBLE_FROM_26_6(overall_Bottom);
 > >     extents->x_advance          = DOUBLE_FROM_26_6(X);
 > >     extents->y_advance          = DOUBLE_FROM_26_6(Y);

I still want to rename these fields as discussed earlier. But I'll do
that in a separate commit afterwards.

-Carl




More information about the cairo mailing list