From edc0886df60741ecd3704c1df5f1f9fd2469c13e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 20 Feb 2023 21:03:00 -0500 Subject: cairo: Don't mis-scale metrics When metrics were ported to hb, we overlooked that the scaling done by cairo on the base metrics is no longer necessary. This was causing underlines and strikethroughs to be too small when rendering in a scaled context. Thanks to Behdad for help in tracking this down. Fixes: #730 --- pango/pangocairo-font.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index 598065c0..24bb325b 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -248,9 +248,6 @@ _pango_cairo_font_get_metrics (PangoFont *font, PangoRectangle extents; PangoFontDescription *desc; cairo_scaled_font_t *scaled_font; - cairo_matrix_t cairo_matrix; - PangoMatrix pango_matrix; - PangoMatrix identity = PANGO_MATRIX_INIT; glong sample_str_width; int height, shift; @@ -279,32 +276,6 @@ _pango_cairo_font_get_metrics (PangoFont *font, info->metrics = (* PANGO_CAIRO_FONT_GET_IFACE (font)->create_base_metrics_for_context) (cfont, context); - /* We now need to adjust the base metrics for ctm */ - cairo_scaled_font_get_ctm (scaled_font, &cairo_matrix); - pango_matrix.xx = cairo_matrix.xx; - pango_matrix.yx = cairo_matrix.yx; - pango_matrix.xy = cairo_matrix.xy; - pango_matrix.yy = cairo_matrix.yy; - pango_matrix.x0 = 0; - pango_matrix.y0 = 0; - if (G_UNLIKELY (0 != memcmp (&identity, &pango_matrix, 4 * sizeof (double)))) - { - double xscale = pango_matrix_get_font_scale_factor (&pango_matrix); - if (xscale) xscale = 1 / xscale; - - info->metrics->ascent *= xscale; - info->metrics->descent *= xscale; - info->metrics->height *= xscale; - info->metrics->underline_position *= xscale; - info->metrics->underline_thickness *= xscale; - info->metrics->strikethrough_position *= xscale; - info->metrics->strikethrough_thickness *= xscale; - } - - /* Set the matrix on the context so we don't have to adjust the derived - * metrics. */ - pango_context_set_matrix (context, &pango_matrix); - /* Ugly. We need to prevent recursion when we call into * PangoLayout to determine approximate char width. */ -- cgit v1.2.1