From cf674f38450f623d94e5695a221a186c0e551e27 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 12 Feb 2025 13:58:36 +0100 Subject: [PATCH] Treat variation selectors as ignorable chars The variation selectors only make sense in the context of the previous glyph and should never be shaped by themselves, therefore we should not pick a different font engine for these even if the cmap does not support it. They are sometimes needed to properly resolve the emojis, but the OpenType rules in the font may not be written with them in mind. If the cmap lookup fails for these, then Harfbuzz will map them to a zero-width space, thus ignoring them when resolving the OpenType rules. We treat these the same as other control characters and just ignore them when doing font merging. Note: This was handled through an ad hoc mechanism prior to the introduction of the emoji segmenter in 6.9.When the emoji segmenter is disabled, we still use this mechanism, which depends on us not ignoring the character in that case. Pick-to: 6.9 Fixes: QTBUG-133480 Change-Id: I8fa4e8d5e1aabad0946b8fd3fff044e2b2af5d0e Reviewed-by: Lars Knoll --- src/gui/text/qfontengine_p.h | 1 + tests/baseline/painting/scripts/glyphruns.qps | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 032a8b78126..4d1243ccc51 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -159,6 +159,7 @@ public: || ucs4 == QChar::LineFeed || ucs4 == QChar::CarriageReturn || ucs4 == QChar::ParagraphSeparator + || (!disableEmojiSegmenter() && (ucs4 & 0xFFF0) == 0xFE00) || QChar::category(ucs4) == QChar::Other_Control; } diff --git a/tests/baseline/painting/scripts/glyphruns.qps b/tests/baseline/painting/scripts/glyphruns.qps index 2b70c72610f..0683ef59ed1 100644 --- a/tests/baseline/painting/scripts/glyphruns.qps +++ b/tests/baseline/painting/scripts/glyphruns.qps @@ -143,7 +143,7 @@ translate 150 0 save setPen black setFont "sansserif" 16 normal - drawGlyphRun 0 40 "e😃m😇o😍j😜i😸!" + drawGlyphRun 0 40 "e😃m👩️‍⚕️o😍j😜i😸!" restore translate 0 55