diff --git a/lib/ui/text/font_collection.cc b/lib/ui/text/font_collection.cc index 66fb3f83077b2..3f41f6457c83e 100644 --- a/lib/ui/text/font_collection.cc +++ b/lib/ui/text/font_collection.cc @@ -158,6 +158,7 @@ void FontCollection::LoadFontFromList(const uint8_t* font_data, } else { font_provider.RegisterTypeface(typeface, family_name); } + collection_->ClearFontFamilyCache(); } } // namespace blink diff --git a/third_party/txt/src/txt/font_collection.cc b/third_party/txt/src/txt/font_collection.cc index 8cb7622fde0d3..ff687726ebed9 100644 --- a/third_party/txt/src/txt/font_collection.cc +++ b/third_party/txt/src/txt/font_collection.cc @@ -286,4 +286,8 @@ FontCollection::GetFallbackFontFamily(const sk_sp& manager, return insert_it.first->second; } +void FontCollection::ClearFontFamilyCache() { + font_collections_cache_.clear(); +} + } // namespace txt diff --git a/third_party/txt/src/txt/font_collection.h b/third_party/txt/src/txt/font_collection.h index 094d405ceaf1c..c98b4d29ca05d 100644 --- a/third_party/txt/src/txt/font_collection.h +++ b/third_party/txt/src/txt/font_collection.h @@ -59,6 +59,9 @@ class FontCollection : public std::enable_shared_from_this { // missing from the requested font family. void DisableFontFallback(); + // Remove all entries in the font family cache. + void ClearFontFamilyCache(); + private: struct FamilyKey { FamilyKey(const std::vector& families, const std::string& loc);