From 5a2539feb5d3bc1b4f28bd79725f6b9529c665da Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 9 Jan 2019 18:00:11 -0800 Subject: [PATCH] Clear the font collection's cache when a font is dynamically loaded Fixes https://github.com/flutter/flutter/issues/26293 --- lib/ui/text/font_collection.cc | 1 + third_party/txt/src/txt/font_collection.cc | 4 ++++ third_party/txt/src/txt/font_collection.h | 3 +++ 3 files changed, 8 insertions(+) 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);