diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-10-18 15:11:07 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-24 11:04:04 +0200 |
commit | 8c13b6b21fcf71893c1cf24c05dd4a576ee43490 (patch) | |
tree | 6bbca0299b2fe69bb7da210b9059bf1ff01e0e1a /src/gui/text/qfontdatabase_qpa.cpp | |
parent | 31d6ac13867957218fc9a974518b80e3e2d4742b (diff) |
Keep Multi font engine in QFontCache
If we only keep single QFontEngineFT in QFontCache, then when we
are looking for the MultiQPA next time with the same QFontDef,
the FT engine will be returned and we get no font fallback support.
That's why we need to keep the Multi engines in QFontCache as well
and distinguish them from the single item. Since QPA doesn't use
'screen' field of QFontCache::Key structure, we use it here to
indicate that we are caching a multi font engine.
Change-Id: Id899d5c5ba52f4bccf134bcd6b1c6386ba22063c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/text/qfontdatabase_qpa.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase_qpa.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 4cd47da6b7..95a0aff261 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -178,6 +178,11 @@ QFontEngine *loadEngine(int script, const QFontDef &request, fallbacks = family->fallbackFamilies; engine = new QFontEngineMultiQPA(engine, script, fallbacks); + + // Cache Multi font engine as well in case we got the FT single + // font engine when we are actually looking for a Multi one + QFontCache::Key key(request, script, 1); + QFontCache::instance()->instance()->insertEngine(key, engine); } return engine; @@ -230,7 +235,7 @@ bool QFontDatabase::supportsThreadedFontRendering() */ QFontEngine * QFontDatabase::findFont(int script, const QFontPrivate *fp, - const QFontDef &request) + const QFontDef &request, bool multi) { QMutexLocker locker(fontDatabaseMutex()); @@ -240,7 +245,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, initializeDb(); QFontEngine *engine; - QFontCache::Key key(request, script); + QFontCache::Key key(request, script, multi ? 1 : 0); engine = QFontCache::instance()->findEngine(key); if (engine) { qDebug() << "Cache hit level 1"; @@ -282,7 +287,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, for (int i = 0; !engine && i < fallbacks.size(); i++) { QFontDef def = request; def.family = fallbacks.at(i); - QFontCache::Key key(def,script); + QFontCache::Key key(def, script, multi ? 1 : 0); engine = QFontCache::instance()->findEngine(key); if (!engine) { QtFontDesc desc; @@ -328,7 +333,11 @@ void QFontDatabase::load(const QFontPrivate *d, int script) if (req.stretch == 0) req.stretch = 100; - QFontCache::Key key(req, script); + // Until we specifically asked not to, try looking for Multi font engine + // first, the last '1' indicates that we want Multi font engine instead + // of single ones + bool multi = !(req.styleStrategy & QFont::NoFontMerging); + QFontCache::Key key(req, script, multi ? 1 : 0); if (!d->engineData) getEngineData(d, key); @@ -359,7 +368,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) for (; !fe && it != end; ++it) { req.family = *it; - fe = QFontDatabase::findFont(script, d, req); + fe = QFontDatabase::findFont(script, d, req, multi); if (fe && (fe->type()==QFontEngine::Box) && !req.family.isEmpty()) fe = 0; } |