diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-03-04 16:27:38 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-05 13:55:35 +0100 |
commit | 3fec94fd07f23dabfa23524d55028dc09cd1ddbb (patch) | |
tree | 106e8a4accf46cc8668fdcf899925a63181cc831 /src/gui/text | |
parent | 9f1089531d75b0a831e03c3a31ef8b4e5c0b54f4 (diff) |
Prevent repeated and unnecessary font population QCoreTextFontDatabase
The platform font database is populated from QFontDatabase, through the
static initializeDb() function, whenever the font database determines
that the platform database has not been initialized (by checking if the
font database is empty).
There are other clients of QPlatformFontDatabase though, such as QFont,
which uses the platform font database to check for the default family.
The CoreText implementation of determining the default family relies
on data that is computed during font population, and hence does an
internal (self-triggered) populate.
To prevent repeated populates as a result of calling QFont::defaultFamily()
we guard the populate by a similar isEmpty() check as QFontDatabase does,
but to ensure that this check works in the case of an invalidated font
database, we need to propagate the font database invalidation down to
the platform font database.
Change-Id: I8d06c6f6fc5da6353c087335859eaca008c2f6a6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 1 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.h | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index b8ac7efb6c..fbb7fe02d6 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -420,6 +420,7 @@ void QFontDatabasePrivate::invalidate() { QFontCache::instance()->clear(); free(); + QGuiApplicationPrivate::platformIntegration()->fontDatabase()->invalidate(); emit static_cast<QGuiApplication *>(QCoreApplication::instance())->fontDatabaseChanged(); } diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 3049e0ab5e..5f277c878a 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -276,6 +276,16 @@ void QPlatformFontDatabase::populateFontDatabase() } /*! + This function is called whenever the font database is invalidated. + + Reimplement this function to clear any internal data structures that + will need to be rebuilt at the next call to populateFontDatabase(). +*/ +void QPlatformFontDatabase::invalidate() +{ +} + +/*! Returns a multi font engine in the specified \a script to encapsulate \a fontEngine with the option to fall back to the fonts given by \a fallbacks if \a fontEngine does not support a certain character. diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 5f2c9a74ba..870480809b 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -96,6 +96,8 @@ class Q_GUI_EXPORT QPlatformFontDatabase public: virtual ~QPlatformFontDatabase(); virtual void populateFontDatabase(); + virtual void invalidate(); + virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script); virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle); virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; |