diff options
author | Eskil Abrahamsen Blomfeldt <[email protected]> | 2024-11-29 15:27:10 +0100 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2024-12-16 19:37:41 +0000 |
commit | aaf7437db3a520ab14220a46cf9427cb9a8d915c (patch) | |
tree | dec408eb6e3335d7214ffadba5f3495dcc534b47 | |
parent | c316712fb8792d651f8d4216e2de1b735867b95f (diff) |
Support variation selector when emoji segmenter is disabled
This amends cb2633468413d8c2a9e28d4c4a10b25e90dd3116.
The patch excluded the ad hoc parsing of variation selector
except when Qt was built without the emoji segmenter. The
reasoning being that the emoji parsing handles this correctly
now.
However, when setting the QT_DISABLE_EMOJI_SEGMENTER variable
in the environment, this is supposed to work as a fail safe
which gives you the original behavior, in case there are
regressions. Therefore, the variation selector handling needs
to be run also when this environment variable is set.
Pick-to: 6.9
Change-Id: I2669d29016a552775461aad13e50459baecdc26f
Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r-- | src/gui/text/qfontengine.cpp | 19 | ||||
-rw-r--r-- | src/gui/text/qfontengine_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 3 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 6be6a5aca29..f3c768d6bc7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1627,6 +1627,16 @@ QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const Glyp return *this; } +bool QFontEngine::disableEmojiSegmenter() +{ +#if defined(QT_NO_EMOJISEGMENTER) + return true; +#else + static const bool sDisableEmojiSegmenter = qEnvironmentVariableIntValue("QT_DISABLE_EMOJI_SEGMENTER") > 0; + return sDisableEmojiSegmenter; +#endif +} + // ------------------------------------------------------------------ // The box font engine // ------------------------------------------------------------------ @@ -1997,9 +2007,8 @@ int QFontEngineMulti::stringToCMap(const QChar *str, int len, int glyph_pos = 0; QStringIterator it(str, str + len); -#if defined(QT_NO_EMOJISEGMENTER) + const bool enableVariationSelectorHack = disableEmojiSegmenter(); char32_t previousUcs4 = 0; -#endif int lastFallback = -1; while (it.hasNext()) { @@ -2060,12 +2069,11 @@ int QFontEngineMulti::stringToCMap(const QChar *str, int len, } } -#if defined(QT_NO_EMOJISEGMENTER) // For variant-selectors, they are modifiers to the previous character. If we // end up with different font selections for the selector and the character it // modifies, we try applying the selector font to the preceding character as well const int variantSelectorBlock = 0xFE00; - if ((ucs4 & 0xFFF0) == variantSelectorBlock && glyph_pos > 0) { + if (enableVariationSelectorHack && (ucs4 & 0xFFF0) == variantSelectorBlock && glyph_pos > 0) { int selectorFontEngine = glyphs->glyphs[glyph_pos] >> 24; int precedingCharacterFontEngine = glyphs->glyphs[glyph_pos - 1] >> 24; @@ -2099,15 +2107,12 @@ int QFontEngineMulti::stringToCMap(const QChar *str, int len, } } } -#endif } it.advance(); ++glyph_pos; -#if defined(QT_NO_EMOJISEGMENTER) previousUcs4 = ucs4; -#endif } *nglyphs = glyph_pos; diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 466a0bbe548..654c3323609 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -260,6 +260,8 @@ public: virtual bool hasUnreliableGlyphOutline() const; virtual bool expectsGammaCorrectedBlending() const; + static bool disableEmojiSegmenter(); + enum HintStyle { HintNone, HintLight, diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 0b7651e65e6..a930f103c60 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1987,8 +1987,7 @@ void QTextEngine::itemize() const } #if !defined(QT_NO_EMOJISEGMENTER) - static const bool sDisableEmojiSegmenter = qEnvironmentVariableIntValue("QT_DISABLE_EMOJI_SEGMENTER") > 0; - const bool disableEmojiSegmenter = sDisableEmojiSegmenter || option.flags().testFlag(QTextOption::DisableEmojiParsing); + const bool disableEmojiSegmenter = QFontEngine::disableEmojiSegmenter() || option.flags().testFlag(QTextOption::DisableEmojiParsing); QVarLengthArray<CharacterCategory> categorizedString; if (!disableEmojiSegmenter) { |