summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2023-03-11 11:26:15 +0100
committerChristian Persch <chpe@src.gnome.org>2023-03-11 11:26:15 +0100
commitc851dda5b459bc1d1d186c1134c8303be6e2a9f4 (patch)
tree8686e1618679a2fa7b1d2da042716e6b6c5e02bd
parentd02c5fce7d828c2c543d9ec01e36f4d6f97547ce (diff)
downloadvte-0.70.4.tar.gz
fonts: Keep the PangoLayout unchanged0.70.4
The previous commit still wasn't completely fixing the problem, since the FontInfo and the UnistrInfo are cached too, and m_layout will be re-used when creating the next UnistrInfo, but the code in pango_cairo_show_layout_line() requires the PangoLayout to still have the same text as when it was created for the UnistrInfo. To fix this, adopt the PangoLayout into the PangoLayoutLine cached in the UnistrInfo, and create a new layout for next use. Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2606 Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2620 (cherry picked from commit 3c8f66be867aca6656e4109ce880b6ea7431b895) (cherry picked from commit 164c0f1eb5165786e0addfe5317cf6de3061ddf9)
-rw-r--r--src/fonts-pangocairo.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/fonts-pangocairo.cc b/src/fonts-pangocairo.cc
index bbd8a6df..1479ebb1 100644
--- a/src/fonts-pangocairo.cc
+++ b/src/fonts-pangocairo.cc
@@ -452,7 +452,21 @@ FontInfo::get_unistr_info(vteunistr c)
{
uinfo->set_coverage(UnistrInfo::Coverage::USE_PANGO_LAYOUT_LINE);
+ // When using a cairo surface which uses show_text_glyphs,
+ // pango_cairo_show_layout_line() will use the text from
+ // @line->layout and it must be the text that was used when
+ // the PangoLayoutLine was created. Also, since @line was
+ // obtained from m_layout, when setting m_layout to a new
+ // text later this will change @line->layout to %NULL.
+ // To make this work, we instead adopt the @m_layout instance
+ // into @line->layout, and create a new @m_layout object.
+
+ line->layout = m_layout.release(); // adopted
ufi->using_pango_layout_line.line = pango_layout_line_ref (line);
+
+ auto const context = pango_layout_get_context(line->layout);
+ m_layout = vte::glib::take_ref(pango_layout_new(context));
+
} else {
PangoGlyphItem *glyph_item = (PangoGlyphItem *)line->runs->data;
PangoFont *pango_font = glyph_item->item->analysis.font;
@@ -482,11 +496,10 @@ FontInfo::get_unistr_info(vteunistr c)
ufi->using_pango_glyph_string.font = pango_font ? (PangoFont *)g_object_ref (pango_font) : NULL;
ufi->using_pango_glyph_string.glyph_string = pango_glyph_string_copy (glyph_string);
}
-
- /* release internal layout resources */
- pango_layout_set_text(m_layout.get(), "", -1);
}
+ // Don't reset m_layout here; it'll get reset anyway when we next use it.
+
#ifdef VTE_DEBUG
m_coverage_count[0]++;
m_coverage_count[uinfo->m_coverage]++;