diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c index 5ca5653..19ec806 100644 --- a/src/cairo-win32-font.c +++ b/src/cairo-win32-font.c @@ -739,7 +739,7 @@ _cairo_win32_scaled_font_init_glyph_metr if (!hdc) return CAIRO_STATUS_NO_MEMORY; - if (scaled_font->preserve_axes) { + if (scaled_font->preserve_axes && scaled_font->base.options.hint_style != CAIRO_HINT_METRICS_OFF) { /* If we aren't rotating / skewing the axes, then we get the metrics * from the GDI in device space and convert to font space. */ @@ -1079,7 +1079,7 @@ _compute_a8_mask (cairo_win32_surface_t return &image8->base; } -static cairo_status_t +static cairo_int_status_t _cairo_win32_scaled_font_glyph_init (void *abstract_font, cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_glyph_info_t info) @@ -1248,9 +1248,13 @@ _cairo_win32_scaled_font_load_truetype_t } static cairo_fixed_t -_cairo_fixed_from_FIXED (FIXED f) +_cairo_scaled_fixed_from_FIXED (FIXED f, double scale) { - return *((cairo_fixed_t *)&f); + double d; + + d = _cairo_fixed_to_double (*((cairo_fixed_t *)&f)); + d *= scale; + return _cairo_fixed_from_double (d); } static cairo_status_t @@ -1264,6 +1268,7 @@ _cairo_win32_scaled_font_init_glyph_path DWORD bytesGlyph; unsigned char *buffer, *ptr; cairo_path_fixed_t *path; + double x_scale, y_scale; hdc = _get_global_font_dc (); if (!hdc) @@ -1273,7 +1278,15 @@ _cairo_win32_scaled_font_init_glyph_path if (!path) return CAIRO_STATUS_NO_MEMORY; - status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc); + if (scaled_font->base.options.hint_style == CAIRO_HINT_STYLE_NONE) { + status = _cairo_win32_scaled_font_select_unscaled_font (&scaled_font->base, hdc); + x_scale = scaled_font->base.scale.xx/scaled_font->em_square; + y_scale = scaled_font->base.scale.yy/scaled_font->em_square; + } else { + status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc); + x_scale = 1.0; + y_scale = 1.0; + } if (status) goto CLEANUP_PATH; @@ -1308,8 +1321,8 @@ _cairo_win32_scaled_font_init_glyph_path ptr += sizeof (TTPOLYGONHEADER); _cairo_path_fixed_move_to (path, - _cairo_fixed_from_FIXED (header->pfxStart.x), - _cairo_fixed_from_FIXED (header->pfxStart.y)); + _cairo_scaled_fixed_from_FIXED (header->pfxStart.x, x_scale), + _cairo_scaled_fixed_from_FIXED (header->pfxStart.y, y_scale)); while (ptr < endPoly) { TTPOLYCURVE *curve = (TTPOLYCURVE *)ptr; @@ -1319,25 +1332,25 @@ _cairo_win32_scaled_font_init_glyph_path case TT_PRIM_LINE: for (i = 0; i < curve->cpfx; i++) { _cairo_path_fixed_line_to (path, - _cairo_fixed_from_FIXED (points[i].x), - _cairo_fixed_from_FIXED (points[i].y)); + _cairo_scaled_fixed_from_FIXED (points[i].x, x_scale), + _cairo_scaled_fixed_from_FIXED (points[i].y, y_scale)); } break; case TT_PRIM_QSPLINE: for (i = 0; i < curve->cpfx - 1; i++) { cairo_fixed_t p1x, p1y, p2x, p2y, cx, cy, c1x, c1y, c2x, c2y; _cairo_path_fixed_get_current_point (path, &p1x, &p1y); - cx = _cairo_fixed_from_FIXED (points[i].x); - cy = _cairo_fixed_from_FIXED (points[i].y); + cx = _cairo_scaled_fixed_from_FIXED (points[i].x, x_scale); + cy = _cairo_scaled_fixed_from_FIXED (points[i].y, y_scale); if (i + 1 == curve->cpfx - 1) { - p2x = _cairo_fixed_from_FIXED (points[i + 1].x); - p2y = _cairo_fixed_from_FIXED (points[i + 1].y); + p2x = _cairo_scaled_fixed_from_FIXED (points[i + 1].x, x_scale); + p2y = _cairo_scaled_fixed_from_FIXED (points[i + 1].y, y_scale); } else { /* records with more than one curve use interpolation for control points, per http://support.microsoft.com/kb/q87115/ */ - p2x = (cx + _cairo_fixed_from_FIXED (points[i + 1].x)) / 2; - p2y = (cy + _cairo_fixed_from_FIXED (points[i + 1].y)) / 2; + p2x = (cx + _cairo_scaled_fixed_from_FIXED (points[i + 1].x, x_scale)) / 2; + p2y = (cy + _cairo_scaled_fixed_from_FIXED (points[i + 1].y, y_scale)) / 2; } c1x = 2 * cx / 3 + p1x / 3; @@ -1351,12 +1364,12 @@ _cairo_win32_scaled_font_init_glyph_path case TT_PRIM_CSPLINE: for (i = 0; i < curve->cpfx - 2; i += 2) { _cairo_path_fixed_curve_to (path, - _cairo_fixed_from_FIXED (points[i].x), - _cairo_fixed_from_FIXED (points[i].y), - _cairo_fixed_from_FIXED (points[i + 1].x), - _cairo_fixed_from_FIXED (points[i + 1].y), - _cairo_fixed_from_FIXED (points[i + 2].x), - _cairo_fixed_from_FIXED (points[i + 2].y)); + _cairo_scaled_fixed_from_FIXED (points[i].x, x_scale), + _cairo_scaled_fixed_from_FIXED (points[i].y, y_scale), + _cairo_scaled_fixed_from_FIXED (points[i + 1].x, x_scale), + _cairo_scaled_fixed_from_FIXED (points[i + 1].y, y_scale), + _cairo_scaled_fixed_from_FIXED (points[i + 2].x, x_scale), + _cairo_scaled_fixed_from_FIXED (points[i + 2].y, y_scale)); } break; }