Rename QPlatformFontDatabase::handleAvailableFontsChanged()

The function name was easy to mistake for a function you should call
after adding fonts via e.g. registerFont or registerFontFamily, but
in reality it's meant to be used when the platform font database
knows that fonts have changed in a way that needs a full populate.

Change-Id: I4a897944aaa5df891562f729440b5d98b54f61e0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit ed631011faab42071f5e4fd4ea978ec0a95b4633)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2022-07-04 13:43:57 +02:00 committed by Qt Cherry-pick Bot
parent cfdf9a19bf
commit bd712d5195
4 changed files with 11 additions and 5 deletions

View File

@ -79,7 +79,7 @@ QCoreTextFontDatabase::QCoreTextFontDatabase()
#if defined(Q_OS_MACOS)
m_fontSetObserver = QMacNotificationObserver(nil, NSFontSetChangedNotification, [] {
qCDebug(lcQpaFonts) << "Fonts have changed";
handleAvailableFontsChanged();
QPlatformFontDatabase::repopulateFontDatabase();
});
#endif
}

View File

@ -600,13 +600,19 @@ void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName,
}
/*!
Inform the Qt font database that the platform's available fonts have changed.
Requests that the platform font database should be repopulated.
This will result in invalidating the entire font database.
The next time the font database is accessed it will be repopulated
via a call to QPlatformFontDatabase::populate().
Application fonts will not be removed, and will be automatically
populated when the font database is repopulated.
\since 6.4
*/
void QPlatformFontDatabase::handleAvailableFontsChanged()
void QPlatformFontDatabase::repopulateFontDatabase()
{
QFontDatabasePrivate::instance()->invalidate();
}

View File

@ -103,7 +103,7 @@ public:
static void registerFontFamily(const QString &familyName);
static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
static void handleAvailableFontsChanged();
static void repopulateFontDatabase();
static bool isFamilyPopulated(const QString &familyName);
};

View File

@ -34,7 +34,7 @@ QIOSTheme::QIOSTheme()
m_contentSizeCategoryObserver = QMacNotificationObserver(nil,
UIContentSizeCategoryDidChangeNotification, [] {
qCDebug(lcQpaFonts) << "Contents size category changed to" << UIApplication.sharedApplication.preferredContentSizeCategory;
QPlatformFontDatabase::handleAvailableFontsChanged();
QPlatformFontDatabase::repopulateFontDatabase();
});
}