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>
This commit is contained in:
parent
31d6ac1386
commit
8c13b6b21f
@ -153,7 +153,7 @@ private:
|
||||
static void createDatabase();
|
||||
static void parseFontName(const QString &name, QString &foundry, QString &family);
|
||||
static QString resolveFontFamilyAlias(const QString &family);
|
||||
static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request);
|
||||
static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request, bool multi = false);
|
||||
static void load(const QFontPrivate *d, int script);
|
||||
|
||||
friend struct QFontDef;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ void QFontEngineMultiQPA::loadEngine(int at)
|
||||
request.family = fallbackFamilies.at(at-1);
|
||||
engines[at] = QFontDatabase::findFont(script,
|
||||
/*fontprivate*/0,
|
||||
request);
|
||||
request, false);
|
||||
Q_ASSERT(engines[at]);
|
||||
engines[at]->ref.ref();
|
||||
engines[at]->fontDef = request;
|
||||
|
Loading…
x
Reference in New Issue
Block a user