path: root/src/gui
diff options
authorEskil Abrahamsen Blomfeldt <>2018-01-04 09:02:23 +0100
committerEskil Abrahamsen Blomfeldt <>2018-01-08 12:28:28 +0000
commit6ca48a847a1805c3826004c5b989b4ae14397a37 (patch)
tree6bf18cf3846e7597bc1a1cc76a19cfe52b71d487 /src/gui
parente586d9ea7f45c39d00d0fff2fdda4e20aa1c19cc (diff)
Fix fallback fonts for non-common writing system
When we request fallback fonts, we cannot discriminate the fonts based on the writing system support. This is especially important since common script is now merged with other scripts, meaning that a common script character will always go through the fallback mechanism when not supported by the main font. When drawing for instance a string of Devanagari characters on macOS, we would get a list of 33 fallback fonts, but almost all of them would be the default Devanagari font, since none of the other fallbacks would support that script. Meaning that we would just check the same font over and over, which makes no sense. The fallback list has been retrieved specifically for the given script, so we do not need to consider that when fetching the fonts. For most of the common set, we will not have noticed the bug, because at least one of the writing system-specific fallbacks will have had support for latin characters as well. But when trying to mix emojis and some non-common script, we would get a box in place of the emoji, which had been adopted to the main script and would only be looked for in the fonts supporting this. Note that this exposed an issue with the QRawFont test on some systems. When the sample text contained a space, it would be possible to get a fallback font for this character, since we now effectively support fallbacks. This is not the correct behavior, but it is unrelated to this fix, and it was not what the QRawFont::unsupportedWritingSystem() test was written to check. I have therefore removed the space from the sample text to make the test pass, and will make a separate task of fixing the issue of merging fonts for whitespace characters. [ChangeLog][QtGui][Text] Fixed a bug where mixing different writing systems with emojis could lead to missing glyphs. Task-number: QTBUG-61882 Change-Id: I00f6043bb01af1f2277723ccf643034aebf3e18f Reviewed-by: Konstantin Ritt <>
Diffstat (limited to 'src/gui')
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 596c79fd05..ebaeb9b49b 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1,6 +1,6 @@
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact:
** This file is part of the QtGui module of the Qt Toolkit.
@@ -1847,7 +1847,12 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
request.styleStrategy |= QFont::NoFontMerging; = fallbackFamilyAt(at - 1);
- if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) {
+ // At this point, the main script of the text has already been considered
+ // when fetching the list of fallback families from the database, and the
+ // info about the actual script of the characters may have been discarded,
+ // so we do not check for writing system support, but instead just load
+ // the family indiscriminately.
+ if (QFontEngine *engine = QFontDatabase::findFont(request, QFontDatabase::Any)) {
engine->fontDef.weight = request.weight;
if ( > QFont::StyleNormal)
engine-> =;