commit e082d7ce221a3aba3a461a12f226d11743727afe Author: Brian Ewins Date: Wed Mar 7 00:42:46 2007 +0000 [quartz] correct text scaling (#10067) The quartz surface calculates advances in user units, when it needs them in device units. Correct this by using the advances already calculated in the scaled glyph extents. diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index bcd688c..6432026 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1244,6 +1244,7 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface, int num_glyphs, cairo_scaled_font_t *scaled_font) { + cairo_scaled_glyph_t *scaled_glyph; cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; cairo_quartz_action_t action; @@ -1308,19 +1309,18 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface, cg_advances = (CGSize*) malloc(sizeof(CGSize) * num_glyphs); } - double xprev = glyphs[0].x; - double yprev = glyphs[0].y; - - cg_glyphs[0] = glyphs[0].index; - cg_advances[0].width = 0; - cg_advances[0].height = 0; - - for (i = 1; i < num_glyphs; i++) { - cg_glyphs[i] = glyphs[i].index; - cg_advances[i-1].width = glyphs[i].x - xprev; - cg_advances[i-1].height = glyphs[i].y - yprev; - xprev = glyphs[i].x; - yprev = glyphs[i].y; + _cairo_scaled_font_freeze_cache (scaled_font); + for (i = 0; i < num_glyphs; i++) { + rv = _cairo_scaled_glyph_lookup (scaled_font, + glyphs[i].index, + CAIRO_SCALED_GLYPH_INFO_METRICS, + &scaled_glyph); + if (rv) + goto BAIL; + + cg_glyphs[i] = glyphs[i].index; + cg_advances[i].width = scaled_glyph->metrics.x_advance; + cg_advances[i].height = scaled_glyph->metrics.y_advance; } #if 0 @@ -1342,6 +1342,9 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface, if (action == DO_SHADING) CGContextDrawShading (surface->cgContext, surface->sourceShading); + BAIL: + _cairo_scaled_font_thaw_cache (scaled_font); + _cairo_quartz_teardown_source (surface, source); CGContextRestoreGState (surface->cgContext);