diff --git a/engine/src/flutter/third_party/txt/src/minikin/FontCollection.cpp b/engine/src/flutter/third_party/txt/src/minikin/FontCollection.cpp index 0018e8f144..ebbb104dd1 100644 --- a/engine/src/flutter/third_party/txt/src/minikin/FontCollection.cpp +++ b/engine/src/flutter/third_party/txt/src/minikin/FontCollection.cpp @@ -292,6 +292,14 @@ const std::shared_ptr& FontCollection::getFamilyForChar( uint32_t langListId, int variant) const { if (ch >= mMaxChar) { + // libtxt: check if the fallback font provider can match this character + if (mFallbackFontProvider) { + const std::shared_ptr& fallback = + mFallbackFontProvider->matchFallbackFont(ch); + if (fallback) { + return fallback; + } + } return mFamilies[0]; } 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 46b9a8fcfa..ad92cf7748 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 @@ -32,15 +32,6 @@ namespace txt { namespace { -// Example characters representing character classes that may require a -// fallback font. -const std::vector fallback_characters{ - 0x1f600, // emoji - 0x4e00, // CJK - 0x5d0, // Hebrew - 0x627, // Arabic -}; - // Font families that will be used as a last resort if no font manager provides // a font matching a particular character. const std::vector last_resort_fonts{ @@ -201,19 +192,6 @@ FontCollection::GetFontFamilyForTypeface(const sk_sp& typeface) { } void FontCollection::UpdateFallbackFonts(sk_sp manager) { - // Prepopulate the fallback font cache with fonts matching some widely - // used character classes. - for (SkUnichar fallback_char : fallback_characters) { - sk_sp typeface(manager->matchFamilyStyleCharacter( - 0, SkFontStyle(), nullptr, 0, fallback_char)); - if (typeface) { - // Create a Minikin font family for this typeface if one does not already - // exist. - GetFontFamilyForTypeface(typeface); - } - } - - // Add additional font families to be used if nothing else matches. for (const std::string& family : last_resort_fonts) { sk_sp typeface( manager->matchFamilyStyle(family.c_str(), SkFontStyle()));