diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2012-02-15 15:06:00 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-17 05:26:34 +0100 |
commit | 2801db558c56e98753e297c1aeabd4fd2975e09a (patch) | |
tree | 14726483adef27b2e19f67ee0a4a0d2ef1a577a9 /src/gui/text/qplatformfontdatabase_qpa.h | |
parent | 4212898822f1798dac0167e4f6a147bd8a3b3dcc (diff) |
Avoid loading and keeping unused fallback font engines
When we request glyphs from fallback fonts, we would potentially
load all fonts on the system into memory. This is especially true
for glyphs that are not supported by any font (or by the last in
the list) in any "Common" script (which e.g. includes CJK).
This would make any application which tried to display unsupported
glyphs use huge amounts of memory for keeping unused fonts cached,
only limited by the number of fonts on the system.
The patch contains two solutions: First, before loading the font,
the multi font engine will be asked whether it needs to be tried
for the given character. By default, this will always be true, so
all fonts will be tried, but with the new font config multi engine
in the platform plugin, it will ask FontConfig whether the font
contains a glyph for the character.
Should the font be loaded and still fail to resolve the character
(which could be the case for other platforms), we will simply
delete it again immediately instead keeping it cached.
Change-Id: I92dfb39289a359f49caa02c2caf8baf66098fb59
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui/text/qplatformfontdatabase_qpa.h')
-rw-r--r-- | src/gui/text/qplatformfontdatabase_qpa.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h index 151442c5e1..6a58a3106c 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.h +++ b/src/gui/text/qplatformfontdatabase_qpa.h @@ -82,12 +82,14 @@ Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedW Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); class QFontRequestPrivate; +class QFontEngineMulti; class Q_GUI_EXPORT QPlatformFontDatabase { public: virtual ~QPlatformFontDatabase(); virtual void populateFontDatabase(); + virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script, const QStringList &fallbacks); virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); |