diff --git a/third_party/txt/src/txt/asset_data_provider.cc b/third_party/txt/src/txt/asset_data_provider.cc index 6b1b841240609..fa35cc08539bb 100644 --- a/third_party/txt/src/txt/asset_data_provider.cc +++ b/third_party/txt/src/txt/asset_data_provider.cc @@ -37,7 +37,7 @@ AssetFontStyleSet* AssetDataProvider::MatchFamily( if (found == registered_families_.end()) { return nullptr; } - return &found->second; + return SkRef(&found->second); } void AssetDataProvider::RegisterTypeface(sk_sp typeface) { diff --git a/third_party/txt/src/txt/asset_font_style_set.cc b/third_party/txt/src/txt/asset_font_style_set.cc index 7b145d56617f8..c0ebcf78e2aba 100644 --- a/third_party/txt/src/txt/asset_font_style_set.cc +++ b/third_party/txt/src/txt/asset_font_style_set.cc @@ -31,7 +31,7 @@ SkTypeface* AssetFontStyleSet::createTypeface(int index) { if (index_cast >= typefaces_.size()) { return nullptr; } - return typefaces_[index_cast].get(); + return SkRef(typefaces_[index_cast].get()); } SkTypeface* AssetFontStyleSet::matchStyle(const SkFontStyle& pattern) { @@ -42,7 +42,7 @@ SkTypeface* AssetFontStyleSet::matchStyle(const SkFontStyle& pattern) { if (typeface->fontStyle() == pattern) return typeface.get(); - return typefaces_[0].get(); + return SkRef(typefaces_[0].get()); } } // namespace txt diff --git a/third_party/txt/src/txt/font_collection.cc b/third_party/txt/src/txt/font_collection.cc index c74b0d913c416..28ca6cd469295 100644 --- a/third_party/txt/src/txt/font_collection.cc +++ b/third_party/txt/src/txt/font_collection.cc @@ -100,7 +100,7 @@ FontCollection::GetMinikinFontCollectionForFamily(const std::string& family) { } for (sk_sp& manager : GetFontManagerOrder()) { - auto font_style_set = manager->matchFamily(family.c_str()); + sk_sp font_style_set(manager->matchFamily(family.c_str())); if (font_style_set == nullptr || font_style_set->count() == 0) { continue; } @@ -111,8 +111,8 @@ FontCollection::GetMinikinFontCollectionForFamily(const std::string& family) { for (int i = 0, style_count = font_style_set->count(); i < style_count; ++i) { // Create the skia typeface. - auto skia_typeface = - sk_ref_sp(font_style_set->createTypeface(i)); + sk_sp skia_typeface( + sk_sp(font_style_set->createTypeface(i))); if (skia_typeface == nullptr) { continue; }