Fix application font loading in basic font db

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>
bb10
Jiang Jiang 2011-11-10 18:01:56 +01:00 committed by Qt by Nokia
parent f02c2389ee
commit 89cfe9eb01
1 changed files with 13 additions and 5 deletions

View File

@ -105,22 +105,30 @@ static QStringList fallbackFamilies(const QString &family, const QFont::Style &s
return retList;
}
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt);
static void initializeDb()
{
static int initialized = false;
QFontDatabasePrivate *db = privateDb();
if (!initialized || db->reregisterAppFonts) {
//init by asking for the platformfontdb for the first time :)
// init by asking for the platformfontdb for the first time or after invalidation
if (!db->count)
QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
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;
initialized = true;
}
}
static inline void load(const QString & = QString(), int = -1)
{
initializeDb();
// Only initialize the database if it has been cleared or not initialized yet
if (!privateDb()->count)
initializeDb();
}
static