Request actual font family request in final color font fail safe

When we're trying to resolve a font for color emojis, we will
prefer any color font over the selected font (since a normal
font may have monochrome glyphs for emoji characters and that's
not what we are after).

If there are no color fonts on the system at all, we need to do
a final match where we ignore whether the font is in color or
not and just return it anyway.

In this final pass we would find the first best match among the
fallbacks (typically the first one), but never actually check
the font that was requested in the first place. This was a
mistake. Unless it does not exist, we should just return the
requested font family.

Task-number: QTBUG-132377
Change-Id: Ie53a6bd665ebdaaca92bf0c33fabf5195e1aa5fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit b154af082c8679fa09f325735025d98df9a8dcff)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2025-01-15 15:12:41 +01:00 committed by Qt Cherry-pick Bot
parent 10b88f3f20
commit e958f05aec

View File

@ -2802,6 +2802,11 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &req,
// and extra pass on the fallbacks for this.
if (!engine && script == QFontDatabasePrivate::Script_Emoji) {
qCDebug(lcFontMatch, "No color fonts found on system. Doing final fallback match.");
// Since we no longer require color fonts, we need to retry to check if the
// actual requested font is available as a non-color font.
if (!requestFamily.isEmpty())
fallbacks.prepend(requestFamily);
engine = findMatchingFallback(QChar::Script_Common, script);
}
}