Add logging output to emoji segmenter

Change-Id: I33291128d27131ea77e8199862faf1dbcd5bf68f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2025-01-14 07:51:09 +01:00
parent 81e596c24f
commit 41199de2d8

View File

@ -26,6 +26,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
Q_STATIC_LOGGING_CATEGORY(lcEmojiSegmenter, "qt.text.emojisegmenter")
static const float smallCapsFraction = 0.7f; static const float smallCapsFraction = 0.7f;
namespace { namespace {
@ -1989,6 +1991,8 @@ void QTextEngine::itemize() const
#if !defined(QT_NO_EMOJISEGMENTER) #if !defined(QT_NO_EMOJISEGMENTER)
const bool disableEmojiSegmenter = QFontEngine::disableEmojiSegmenter() || option.flags().testFlag(QTextOption::DisableEmojiParsing); const bool disableEmojiSegmenter = QFontEngine::disableEmojiSegmenter() || option.flags().testFlag(QTextOption::DisableEmojiParsing);
qCDebug(lcEmojiSegmenter) << "Emoji segmenter disabled:" << disableEmojiSegmenter;
QVarLengthArray<CharacterCategory> categorizedString; QVarLengthArray<CharacterCategory> categorizedString;
if (!disableEmojiSegmenter) { if (!disableEmojiSegmenter) {
// Parse emoji sequences // Parse emoji sequences
@ -2033,6 +2037,10 @@ void QTextEngine::itemize() const
categorizedString.append(CharacterCategory::EMOJI_TEXT_PRESENTATION); categorizedString.append(CharacterCategory::EMOJI_TEXT_PRESENTATION);
else else
categorizedString.append(CharacterCategory::OTHER); categorizedString.append(CharacterCategory::OTHER);
qCDebug(lcEmojiSegmenter) << "Checking character" << (isSurrogate ? (i - 1) : i)
<< ", ucs4 ==" << ucs4
<< ", category:" << categorizedString.last();
} }
} }
#endif #endif
@ -2054,8 +2062,14 @@ void QTextEngine::itemize() const
while (uc < e) { while (uc < e) {
#if !defined(QT_NO_EMOJISEGMENTER) #if !defined(QT_NO_EMOJISEGMENTER)
// Find next emoji sequence // Find next emoji sequence
if (!disableEmojiSegmenter && categoryIt == nextIt) if (!disableEmojiSegmenter && categoryIt == nextIt) {
nextIt = scan_emoji_presentation(categoryIt, categoriesEnd, &isEmoji, &hasVs); nextIt = scan_emoji_presentation(categoryIt, categoriesEnd, &isEmoji, &hasVs);
qCDebug(lcEmojiSegmenter) << "Checking character" << (categoryIt - categoriesStart)
<< ", sequence length:" << (nextIt - categoryIt)
<< ", is emoji sequence:" << isEmoji;
}
#endif #endif
switch (*uc) { switch (*uc) {