* src/cairo-ft-font.c (_cairo_ft_scaled_font_create): Hint the metrics. (_cairo_ft_scaled_glyph_init): Hint the metrics regardless of whether the glyph is hinted. Also Hint with more care. Index: src/cairo-ft-font.c =================================================================== RCS file: /cvs/cairo/cairo/src/cairo-ft-font.c,v retrieving revision 1.115 diff -u -r1.115 cairo-ft-font.c --- src/cairo-ft-font.c 21 Dec 2005 16:19:47 -0000 1.115 +++ src/cairo-ft-font.c 11 Feb 2006 08:33:11 -0000 @@ -1433,6 +1433,7 @@ * user space */ if (scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF) { + FT_Pos rounded; double x_factor, y_factor; if (unscaled->x_scale == 0) @@ -1445,10 +1446,17 @@ else y_factor = 1 / unscaled->y_scale; - fs_metrics.ascent = DOUBLE_FROM_26_6(metrics->ascender) * y_factor; - fs_metrics.descent = DOUBLE_FROM_26_6(- metrics->descender) * y_factor; - fs_metrics.height = DOUBLE_FROM_26_6(metrics->height) * y_factor; - fs_metrics.max_x_advance = DOUBLE_FROM_26_6(metrics->max_advance) * x_factor; + rounded = (metrics->ascender + 63) & -64; + fs_metrics.ascent = DOUBLE_FROM_26_6(rounded) * y_factor; + + rounded = metrics->descender & -64; + fs_metrics.descent = DOUBLE_FROM_26_6(-rounded) * y_factor; + + rounded = (metrics->height + 32) & -64; + fs_metrics.height = DOUBLE_FROM_26_6(rounded) * y_factor; + + rounded = (metrics->max_advance + 32) & -64; + fs_metrics.max_x_advance = DOUBLE_FROM_26_6(rounded) * x_factor; } else { double scale = face->units_per_EM; @@ -1768,24 +1776,26 @@ * * Scale metrics back to glyph space from the scaled glyph space returned * by FreeType - * - * If we want hinted metrics but aren't asking for hinted glyphs from - * FreeType, then we need to do the metric hinting ourselves. */ - if ((scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF) && - (load_flags & FT_LOAD_NO_HINTING)) + if (scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF) { FT_Pos x1, x2; FT_Pos y1, y2; FT_Pos advance; + int adj = 1; - x1 = (metrics->horiBearingX) & -64; + if (metrics->horiBearingX + metrics->width > metrics->horiAdvance) + adj = 0; + x2 = (metrics->horiBearingX + metrics->width + 63) & -64; - y1 = (-metrics->horiBearingY) & -64; + x1 = (metrics->horiBearingX) & -64; y2 = (-metrics->horiBearingY + metrics->height + 63) & -64; + y1 = (-metrics->horiBearingY) & -64; advance = ((metrics->horiAdvance + 32) & -64); + if (adj && advance < x2) + advance = x2; fs_metrics.x_bearing = DOUBLE_FROM_26_6 (x1) * x_factor; fs_metrics.y_bearing = DOUBLE_FROM_26_6 (y1) * y_factor;