From e958f05aeca5d77b5868d4cc1350fa55dd1dc52f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 15 Jan 2025 15:12:41 +0100 Subject: [PATCH] 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 (cherry picked from commit b154af082c8679fa09f325735025d98df9a8dcff) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/qfontdatabase.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 5f3e7ab5cae..532db11568c 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -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); } }