summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-09-19 09:51:26 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-09-25 06:42:47 +0000
commit5d2b12d71cacf9ccd182f2af2e0882c18d483c5f (patch)
tree906ad37aa3f931a8598908dc4bbedbccb808621b /src/gui/text
parent41ffe37a5fb0120c90737aaecba315cdbc03fc39 (diff)
Fix synchronization error when matching font with empty family
We currently match font family names in cross-platform code, before asking the system to load it. In the case of an empty family name, we will return the first font in the list which matches the other conditions. After that, though, we would pass the empty family name to the platform font database, and some old platform-specific matching was invoked. In the case of Windows, we would default to MS Sans Serif, which is the old Windows 1.0 raster font and which is probably used by Qt exclusively in the world at this point. The problem in the end was that the font info would be out of sync. If the font matched by Qt happened to be smoothly scalable, then we would treat MS Sans Serif as smoothly scalable, giving us random glyphs when displaying text in Qt Quick. We would also overwrite the family name with the one matched by Qt, so even when MS Sans Serif was used to render the text, we would report that it was something else. For empty font families, we therefore pass the family we have actually matched into the platform database. This will have the side effect of trusting the font matching in Qt, but only for the rare case where someone actually explicitly sets the font family to the empty string. Note that the random glyph bug that triggered the investigation is not happening anymore after 1eedfd0e66c7afd682f682a659cda2942485cd08 because we will detect the glyph outlines as unreliable in the MS Sans Serif font now instead of trusting the smoothly scalable flag. But there would still be a mismatch between the font used for rendering and the matched font. Task-number: QTBUG-63147 Change-Id: I4a09ffddf9f8a0fabe7738e2944b6d874e4728f0 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 288352b370..afbf783c3a 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2685,7 +2685,15 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
}
if (index >= 0) {
- engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
+ QFontDef fontDef = request;
+
+ // Don't pass empty family names to the platform font database, since it will then invoke its own matching
+ // and we will be out of sync with the matched font.
+ if (fontDef.family.isEmpty())
+ fontDef.family = desc.family->name;
+
+ engine = loadEngine(script, fontDef, desc.family, desc.foundry, desc.style, desc.size);
+
if (engine)
initFontDef(desc, request, &engine->fontDef, multi);
else