From 360f1547f70fd5752a3a44892bfe5009a4357f3c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jun 2022 08:39:07 +0200 Subject: Fix QFontDatabase::hasFamily() for ambiguous families MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a font family has several instances from different foundries, we disambiguate this by adding the foundry name in brackets behind the family. But QFontDatabase::hasFamily() would only check for families().contains(familyName). So if the database contains e.g. Foo [Bar] and Foo [Baz] then a check for hasFamily("Foo") would fail. So we need to actually check for the family name instead. In doing this, we also skip the extra step of building the list and then searching it, but just go directly to the source. This removes the BLACKLISTing of Ubuntu and also introduces a QSKIP on Unix-based platforms without fontconfig, since there is no way to know which default fonts are acceptable on those platforms. Pick-to: 6.4 Fixes: QTBUG-86967 Change-Id: Id8ad80a1671daf1c14fbad8bb8f4c51ee1c59709 Reviewed-by: Tor Arne Vestbø --- src/gui/text/qfontdatabase.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index a4aa8bf356..5ffda4eb88 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1892,7 +1892,19 @@ bool QFontDatabase::hasFamily(const QString &family) QString parsedFamily, foundry; parseFontName(family, foundry, parsedFamily); const QString familyAlias = QFontDatabasePrivate::resolveFontFamilyAlias(parsedFamily); - return families().contains(familyAlias, Qt::CaseInsensitive); + + QMutexLocker locker(fontDatabaseMutex()); + QFontDatabasePrivate *d = QFontDatabasePrivate::ensureFontDatabase(); + + for (int i = 0; i < d->count; i++) { + QtFontFamily *f = d->families[i]; + if (f->populated && f->count == 0) + continue; + if (familyAlias.compare(f->name, Qt::CaseInsensitive) == 0) + return true; + } + + return false; } -- cgit v1.2.3