diff --git a/Source/WebCore/platform/graphics/FontCache.h b/Source/WebCore/platform/graphics/FontCache.h index 9f1b68b8f1e27..09bd1bc692f2a 100644 --- a/Source/WebCore/platform/graphics/FontCache.h +++ b/Source/WebCore/platform/graphics/FontCache.h @@ -257,6 +257,10 @@ class FontCache : public CanMakeCheckedPtr { UncheckedKeyHashSet m_knownFamilies; #endif +#if PLATFORM(QT) + UncheckedKeyHashMap m_fontFamilyCache; +#endif + #if PLATFORM(COCOA) FontDatabase m_databaseAllowingUserInstalledFonts { AllowUserInstalledFonts::Yes }; FontDatabase m_databaseDisallowingUserInstalledFonts { AllowUserInstalledFonts::No }; diff --git a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp index 7856f8e64525c..3149e4ac0b862 100644 --- a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp @@ -96,7 +96,11 @@ Ref FontCache::lastResortFallbackFont(const FontDescription& fontDescripti std::unique_ptr FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomString& family, const FontCreationContext&, OptionSet) { - if (!QFontDatabase::hasFamily(family.string())) + auto addResult = m_fontFamilyCache.ensure(family, [&family] { + return QFontDatabase::hasFamily(family.string()); + }); + + if (!addResult.iterator->value) return nullptr; return std::make_unique(fontDescription, family); }