summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-04-22 06:27:16 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-05-13 01:08:36 +0000
commit43cab86802fb5a7447e6fd2d451f97a37b53f13c (patch)
tree2a4ac426a0a3e652c9f568006ff125f5b06ee344 /src/gui
parentc874e10cbcf67fa5fdddafc4dcbf8a54d7f36b2d (diff)
downloadqtbase-43cab86802fb5a7447e6fd2d451f97a37b53f13c.tar.gz
Fix overcaching the fallback families list for a requested family
The cached list didn't take fontStyle, styleHint and script into account. As long as QFontCache isn't explicitly disabled, loadEngine() rarely called for the same family, foundry, style and size - so avoid caching anything here at all. Change-Id: I7779bf33fc074edc00799f9a39d67327f8c88ccc Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontdatabase.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index d07b1c5628..e77856c8d1 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -346,7 +346,6 @@ struct QtFontFamily
populated(false),
fixedPitch(false),
name(n), count(0), foundries(0)
- , askedForFallback(false)
{
memset(writingSystems, 0, sizeof(writingSystems));
}
@@ -364,8 +363,6 @@ struct QtFontFamily
int count;
QtFontFoundry **foundries;
- QStringList fallbackFamilies;
- bool askedForFallback;
unsigned char writingSystems[QFontDatabase::WritingSystemsCount];
bool matchesFamilyName(const QString &familyName) const;
@@ -759,6 +756,7 @@ QString qt_resolveFontFamilyAlias(const QString &alias)
static QStringList fallbackFamilies(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
{
+ // make sure that the db has all fallback families
QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
@@ -884,20 +882,13 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size);
Q_ASSERT(!engine || engine->type() != QFontEngine::Multi);
if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
- // make sure that the db has all fallback families
- if (family && !family->askedForFallback) {
- QFont::Style fontStyle = QFont::Style(style->key.style);
- QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
- if (styleHint == QFont::AnyStyle && request.fixedPitch)
- styleHint = QFont::TypeWriter;
- family->fallbackFamilies = fallbackFamilies(family->name, fontStyle, styleHint, QChar::Script(script));
+ QStringList fallbacks = request.fallBackFamilies;
- family->askedForFallback = true;
- }
+ QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
+ if (styleHint == QFont::AnyStyle && request.fixedPitch)
+ styleHint = QFont::TypeWriter;
- QStringList fallbacks = request.fallBackFamilies;
- if (family)
- fallbacks += family->fallbackFamilies;
+ fallbacks += fallbackFamilies(family->name, QFont::Style(style->key.style), styleHint, QChar::Script(script));
QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script));