mirror of https://github.com/vitalif/phantomjs
Fix application font loading in basic font db
ISSUE: 460 (http://code.google.com/p/phantomjs/issues/detail?id=460) this is a backport from qtbase: commit 89cfe9eb01ad75c14121dbd6038b7c791226acf1 Author: Jiang Jiang <jiang.jiang@nokia.com> Date: Thu Nov 10 18:01:56 2011 +0100 We need to reregister fonts in initializeDb because basic font db doesn't have an internal record like fontconfig does, so just repopulating the font database won't work. db->reregisterAppFonts is now used properly as intended (reregister application fonts after the system font database has been cleared). Also, static variable 'initialized' in initializeDb() is removed since we check privateDb()->count to see if it needs to be populated again. Task-number: QTBUG-22063 Change-Id: Ifc66392b56b72acbe08b99256c61421c204be5d7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>1.6
parent
bf029ae65a
commit
4669c16e64
|
@ -103,14 +103,22 @@ static QStringList fallbackFamilies(const QString &family, const QFont::Style &s
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt);
|
||||||
|
|
||||||
static void initializeDb()
|
static void initializeDb()
|
||||||
{
|
{
|
||||||
static int initialized = false;
|
QFontDatabasePrivate *db = privateDb();
|
||||||
|
|
||||||
if (!initialized) {
|
// init by asking for the platformfontdb for the first time or after invalidation
|
||||||
//init by asking for the platformfontdb for the first time :)
|
if (!db->count)
|
||||||
QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
|
QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
|
||||||
initialized = true;
|
|
||||||
|
if (db->reregisterAppFonts) {
|
||||||
|
for (int i = 0; i < db->applicationFonts.count(); i++) {
|
||||||
|
if (!db->applicationFonts.at(i).families.isEmpty())
|
||||||
|
registerFont(&db->applicationFonts[i]);
|
||||||
|
}
|
||||||
|
db->reregisterAppFonts = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +141,8 @@ void qt_applyFontDatabaseSettings(const QSettings &settings)
|
||||||
|
|
||||||
static inline void load(const QString & = QString(), int = -1)
|
static inline void load(const QString & = QString(), int = -1)
|
||||||
{
|
{
|
||||||
|
// Only initialize the database if it has been cleared or not initialized yet
|
||||||
|
if (!privateDb()->count)
|
||||||
initializeDb();
|
initializeDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue