From 0d0bdaa02e6e38e2b1997e50a4f3411fcf70176b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 28 Jan 2021 18:16:16 -0500 Subject: [PATCH 1/3] gsk: Fix a thinko With subpixel positioning, we need to offset the cached glyphs by their phase. --- gsk/gl/gskglglyphcache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gsk/gl/gskglglyphcache.c b/gsk/gl/gskglglyphcache.c index b147dcef21..9cff7d7ca1 100644 --- a/gsk/gl/gskglglyphcache.c +++ b/gsk/gl/gskglglyphcache.c @@ -149,10 +149,10 @@ render_glyph (GlyphCacheKey *key, glyph_info.glyph = key->data.glyph; glyph_info.geometry.width = value->draw_width * 1024; if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG) - glyph_info.geometry.x_offset = 0; + glyph_info.geometry.x_offset = 250 * key->data.xshift; else - glyph_info.geometry.x_offset = - value->draw_x * 1024; - glyph_info.geometry.y_offset = - value->draw_y * 1024; + glyph_info.geometry.x_offset = 250 * key->data.xshift - value->draw_x * 1024; + glyph_info.geometry.y_offset = 250 * key->data.yshift - value->draw_y * 1024; glyph_string.num_glyphs = 1; glyph_string.glyphs = &glyph_info; From da59c77ae271f564762abf18daa551dfdc31fee1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 28 Jan 2021 18:17:22 -0500 Subject: [PATCH 2/3] widget: Use subpixel positioning Before turning off pangos rounding of glyph positions, we must check if the cairo we are using is new enough to have working subpixel positioning (the relevant cairo commit is 52a7c79fd4ff96bb5fac175f0199819b0f8c18fc). --- gtk/gtkwidget.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3168091367..cddb261e47 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6305,9 +6305,11 @@ update_pango_context (GtkWidget *widget, font_desc = gtk_css_style_get_pango_font (style); pango_context_set_font_description (context, font_desc); - pango_font_description_free (font_desc); + if (cairo_version () >= CAIRO_VERSION_ENCODE (1, 17, 4)) + pango_context_set_round_glyph_positions (context, FALSE); + pango_context_set_base_dir (context, _gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL); From 20fb155e8c360b0c84f3115e6fd7b32fbea130e9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 28 Jan 2021 18:19:42 -0500 Subject: [PATCH 3/3] gsk: Fix render node serialization When looking for ascii glyphs, we must match the pango shape flags that GTK is using. --- gsk/gskrendernodeparser.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index 90183482f2..c53597732d 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -689,14 +689,16 @@ create_ascii_glyphs (PangoFont *font) for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++) { const char text[2] = { i, 0 }; + PangoShapeFlags flags = 0; - pango_shape_with_flags (text, - 1, - text, - 1, + if (cairo_version () < CAIRO_VERSION_ENCODE (1, 17, 4)) + flags = PANGO_SHAPE_ROUND_POSITIONS; + + pango_shape_with_flags (text, 1, + text, 1, ¬_a_hack, glyph_string, - PANGO_SHAPE_ROUND_POSITIONS); + flags); if (glyph_string->num_glyphs != 1) {