QFontDatabase: Track empty slots in application font list via file name

This allows us to use the properties of the application font as a way to
distinguish whether the font has been populated or not.

Change-Id: Iccce32b23c1b987f2f75fef955227bddc2495fa3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Tor Arne Vestbø 2022-03-28 14:52:31 +02:00
parent c159546401
commit 88c0a317ec
2 changed files with 5 additions and 4 deletions

View File

@ -1296,10 +1296,9 @@ QFontDatabasePrivate *QFontDatabasePrivate::ensureFontDatabase()
auto *platformFontDatabase = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
platformFontDatabase->populateFontDatabase();
for (int i = 0; i < d->applicationFonts.count(); i++) {
if (!d->applicationFonts.at(i).properties.isEmpty()) {
auto *font = &d->applicationFonts[i];
auto *font = &d->applicationFonts[i];
if (!font->isNull())
platformFontDatabase->addApplicationFont(font->data, font->fileName, font);
}
}
}
return d;
@ -2107,7 +2106,7 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString &
int i;
for (i = 0; i < applicationFonts.count(); ++i)
if (applicationFonts.at(i).properties.isEmpty())
if (applicationFonts.at(i).isNull())
break;
if (i >= applicationFonts.count()) {
applicationFonts.append(ApplicationFont());

View File

@ -244,6 +244,8 @@ public:
QString fileName;
QByteArray data;
bool isNull() const { return fileName.isEmpty(); }
struct Properties {
QString familyName;
QString styleName;