Skip to content

Commit cd98f6b

Browse files
Clear the font collection's cache when a font is dynamically loaded (flutter#7436)
Fixes flutter#26293
1 parent dea6a08 commit cd98f6b

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/ui/text/font_collection.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ void FontCollection::LoadFontFromList(const uint8_t* font_data,
158158
} else {
159159
font_provider.RegisterTypeface(typeface, family_name);
160160
}
161+
collection_->ClearFontFamilyCache();
161162
}
162163

163164
} // namespace blink

third_party/txt/src/txt/font_collection.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,8 @@ FontCollection::GetFallbackFontFamily(const sk_sp<SkFontMgr>& manager,
286286
return insert_it.first->second;
287287
}
288288

289+
void FontCollection::ClearFontFamilyCache() {
290+
font_collections_cache_.clear();
291+
}
292+
289293
} // namespace txt

third_party/txt/src/txt/font_collection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class FontCollection : public std::enable_shared_from_this<FontCollection> {
5959
// missing from the requested font family.
6060
void DisableFontFallback();
6161

62+
// Remove all entries in the font family cache.
63+
void ClearFontFamilyCache();
64+
6265
private:
6366
struct FamilyKey {
6467
FamilyKey(const std::vector<std::string>& families, const std::string& loc);

0 commit comments

Comments
 (0)