diff --git a/engine/src/flutter/lib/ui/text/font_collection.cc b/engine/src/flutter/lib/ui/text/font_collection.cc index 66fb3f8307..3f41f6457c 100644 --- a/engine/src/flutter/lib/ui/text/font_collection.cc +++ b/engine/src/flutter/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/engine/src/flutter/third_party/txt/src/txt/font_collection.cc b/engine/src/flutter/third_party/txt/src/txt/font_collection.cc index 8cb7622fde..ff687726eb 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_collection.cc +++ b/engine/src/flutter/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/engine/src/flutter/third_party/txt/src/txt/font_collection.h b/engine/src/flutter/third_party/txt/src/txt/font_collection.h index 094d405cea..c98b4d29ca 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_collection.h +++ b/engine/src/flutter/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);