Simplify QFontDatabase::load() a bit

Change-Id: Iaf7db1eb542db1ea0f2ca6c83282961bf4341243
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
bb10
Konstantin Ritt 2014-12-03 17:46:03 +04:00
parent f2663f2ae4
commit e1e3715db5
1 changed files with 15 additions and 19 deletions

View File

@ -654,18 +654,6 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
fontDef->ignorePitch = false;
}
static void getEngineData(const QFontPrivate *d, const QFontDef &def)
{
// look for the requested font in the engine data cache
d->engineData = QFontCache::instance()->findEngineData(def);
if (!d->engineData) {
// create a new one
d->engineData = new QFontEngineData;
QFontCache::instance()->insertEngineData(def, d->engineData);
}
d->engineData->ref.ref();
}
static QStringList familyList(const QFontDef &req)
{
// list of families to try
@ -2614,19 +2602,27 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (req.stretch == 0)
req.stretch = 100;
if (!d->engineData) {
// look for the requested font in the engine data cache
d->engineData = QFontCache::instance()->findEngineData(req);
if (!d->engineData) {
// create a new one
d->engineData = new QFontEngineData;
QFontCache::instance()->insertEngineData(req, d->engineData);
}
d->engineData->ref.ref();
}
// the cached engineData could have already loaded the engine we want
if (d->engineData->engines[script])
return;
// 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, req);
// the cached engineData could have already loaded the engine we want
if (d->engineData->engines[script])
return;
QFontEngine *fe = QFontCache::instance()->findEngine(key);
// list of families to try