summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-11-10 17:01:56 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-05-04 18:23:32 (GMT)
commitd281f94c30aa15765c9c1ec0a613311514033076 (patch)
treed1b70dc6e736bc570554c07c46c623fbdedb247c /src/gui/text
parent6e5d6d292ba6bcd686367077228b17d02160bee9 (diff)
downloadQt-d281f94c30aa15765c9c1ec0a613311514033076.zip
Qt-d281f94c30aa15765c9c1ec0a613311514033076.tar.gz
Qt-d281f94c30aa15765c9c1ec0a613311514033076.tar.bz2
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> (cherry picked from commit 89cfe9eb01ad75c14121dbd6038b7c791226acf1) Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index 2e42f8c..8776a00 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -103,14 +103,22 @@ 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) {
- //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)
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,7 +141,9 @@ void qt_applyFontDatabaseSettings(const QSettings &settings)
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