From 77995f0b9a3aab83cd9be6384400492f309eb3d9 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 19 Mar 2021 11:36:01 -0700 Subject: [PATCH] Do not return a Minikin font collection if the SkFontStyleSet is unable to create any typefaces (flutter/engine#24951) --- engine/src/flutter/lib/ui/text/asset_manager_font_provider.cc | 2 ++ engine/src/flutter/third_party/txt/src/txt/font_collection.cc | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/engine/src/flutter/lib/ui/text/asset_manager_font_provider.cc b/engine/src/flutter/lib/ui/text/asset_manager_font_provider.cc index c1ae48e137..b07472f7e7 100644 --- a/engine/src/flutter/lib/ui/text/asset_manager_font_provider.cc +++ b/engine/src/flutter/lib/ui/text/asset_manager_font_provider.cc @@ -117,6 +117,8 @@ SkTypeface* AssetManagerFontStyleSet::createTypeface(int i) { // Ownership of the stream is transferred. asset.typeface = SkTypeface::MakeFromStream(std::move(stream)); if (!asset.typeface) { + FML_DLOG(ERROR) << "Unable to load font asset for family: " + << family_name_; return nullptr; } } 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 d9b00807a3..7c0e4e4830 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 @@ -295,6 +295,10 @@ std::shared_ptr FontCollection::CreateMinikinFontFamily( } } + if (skia_typefaces.empty()) { + return nullptr; + } + SortSkTypefaces(skia_typefaces); std::vector minikin_fonts;