Flush font cache when we load new application fonts

If new application fonts are loaded during the lifetime of the
application, it's possible that we have already cached fallbacks
for requests for the newly loaded font families. To make sure we
redo requests for the updated database, we have to flush the cache,
just like we do when removing application fonts.

Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: I2a6d2a7459187d69d14ef639e2b710c8d553b86e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Eskil Abrahamsen Blomfeldt 2022-03-18 12:46:41 +01:00
parent 919f514f29
commit 678548afe8
1 changed files with 8 additions and 2 deletions

View File

@ -2136,10 +2136,16 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString &
applicationFonts[i] = font;
// If the cache has not yet been populated, we need to reload the application font later
if (wasEmpty)
if (wasEmpty) {
invalidate();
else
} else {
emit qApp->fontDatabaseChanged();
// The font cache may have cached lookups for the font that was now
// loaded, so it has to be flushed.
QFontCache::instance()->clear();
}
return i;
}