Avoid loading and keeping unused fallback font engines
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Wed, 15 Feb 2012 14:06:00 +0000 (15:06 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 17 Feb 2012 04:26:34 +0000 (05:26 +0100)
commit2801db558c56e98753e297c1aeabd4fd2975e09a
tree14726483adef27b2e19f67ee0a4a0d2ef1a577a9
parent4212898822f1798dac0167e4f6a147bd8a3b3dcc
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>
14 files changed:
src/gui/text/qfont.cpp
src/gui/text/qfont_p.h
src/gui/text/qfontdatabase_qpa.cpp
src/gui/text/qfontengine.cpp
src/gui/text/qfontengine_ft_p.h
src/gui/text/qfontengine_p.h
src/gui/text/qfontengine_qpa_p.h
src/gui/text/qplatformfontdatabase_qpa.cpp
src/gui/text/qplatformfontdatabase_qpa.h
src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp [new file with mode: 0644]
src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h [new file with mode: 0644]