Clear the font collection's cache when a font is dynamically loaded (flutter/engine#7436)

Fixes https://github.com/flutter/flutter/issues/26293
This commit is contained in:
Jason Simmons
2019-01-10 11:26:49 -08:00
committed by GitHub
parent 12604b5aed
commit 613bb815ba
3 changed files with 8 additions and 0 deletions

View File

@@ -158,6 +158,7 @@ void FontCollection::LoadFontFromList(const uint8_t* font_data,
} else {
font_provider.RegisterTypeface(typeface, family_name);
}
collection_->ClearFontFamilyCache();
}
} // namespace blink

View File

@@ -286,4 +286,8 @@ FontCollection::GetFallbackFontFamily(const sk_sp<SkFontMgr>& manager,
return insert_it.first->second;
}
void FontCollection::ClearFontFamilyCache() {
font_collections_cache_.clear();
}
} // namespace txt

View File

@@ -59,6 +59,9 @@ class FontCollection : public std::enable_shared_from_this<FontCollection> {
// 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<std::string>& families, const std::string& loc);