[cairo] Re: METRICS_HINTING_OFF in win32 font backend

Behdad Esfahbod behdad at behdad.org
Mon Mar 12 22:46:28 PDT 2007


On Mon, 2007-03-12 at 23:07 -0400, Behdad Esfahbod wrote:
> Hi,
> 
> Seems like the win32 font backend returns hinted font-metrics no matter
> what font options are set.  This bug has code for testing:
> 
> 	http://bugzilla.gnome.org/show_bug.cgi?id=377795
> 
> I suspect the second branch in _cairo_win32_scaled_font_set_metrics() is
> enough to get the right metrics.  In that case, it's a one-line patch.
>
> Can someone familiar with the win32 backend test and fix please.

So, muntyan actually tested that and it works after fixing another,
really embarrassing bug in there.  That is:

@@ -723,7 +723,7 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
        _cairo_win32_scaled_font_done_unscaled_font (&scaled_font->base);
 
        extents.ascent = (double)metrics.tmAscent / scaled_font->em_square;
-       extents.descent = metrics.tmDescent * scaled_font->em_square;
+       extents.descent = (double)metrics.tmDescent / scaled_font->em_square;
        extents.height = (double)(metrics.tmHeight + metrics.tmExternalLeading) / scaled_font->em_square;
        extents.max_x_advance = (double)(metrics.tmMaxCharWidth) / scaled_font->em_square;
        extents.max_y_advance = 0;

And the original patch should look like:

--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -693,7 +693,7 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
     if (!hdc)
        return CAIRO_STATUS_NO_MEMORY;
 
-    if (scaled_font->preserve_axes) {
+    if (scaled_font->preserve_axes || scaled_font->options.hint_metrics == CAIRO_HINT_METRICS_OFF) {
        /* For 90-degree rotations (including 0), we get the metrics
         * from the GDI in logical space, then convert back to font space
         */

I'll go on and commit this unless someone comments or beats me to it.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list