From b2497ddd0ef7fddc0d29d49b00a4a951b79860e5 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Tue, 27 Apr 2021 11:44:10 -0400 Subject: [PATCH] Revert "Revert "onMatchFaceStyle is unused, so remove it"" This relands the idea that onMatchFaceStyle is no longer used, but leaves the baseclass virtual to stage removing it from client subclasses. This reverts commit 3c04a655086423adccb0b52521fa31b35b57b8f8. Change-Id: I18570065249c86f7f155c28288dce3ea9d59f619 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401759 Reviewed-by: Ben Wagner Commit-Queue: Mike Reed --- include/core/SkFontMgr.h | 8 ++++++-- include/ports/SkFontMgr_indirect.h | 3 --- modules/skottie/src/SkottieTest.cpp | 6 ------ modules/skottie/tests/Text.cpp | 3 --- modules/skparagraph/include/TypefaceFontProvider.h | 3 --- src/core/SkFontMgr.cpp | 3 --- src/fonts/SkFontMgr_indirect.cpp | 7 ------- src/ports/SkFontHost_win.cpp | 8 -------- src/ports/SkFontMgr_FontConfigInterface.cpp | 4 ---- src/ports/SkFontMgr_android.cpp | 12 ------------ src/ports/SkFontMgr_custom.cpp | 13 ------------- src/ports/SkFontMgr_custom.h | 2 -- src/ports/SkFontMgr_fontconfig.cpp | 9 --------- src/ports/SkFontMgr_fuchsia.cpp | 5 ----- src/ports/SkFontMgr_mac_ct.cpp | 5 ----- src/ports/SkFontMgr_win_dw.cpp | 11 ----------- tools/fonts/TestFontMgr.cpp | 6 ------ 17 files changed, 6 insertions(+), 102 deletions(-) diff --git a/include/core/SkFontMgr.h b/include/core/SkFontMgr.h index cd0ba067a1..8b9ef068b9 100644 --- a/include/core/SkFontMgr.h +++ b/include/core/SkFontMgr.h @@ -137,8 +137,6 @@ protected: virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&, const char* bcp47[], int bcp47Count, SkUnichar character) const = 0; - virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, - const SkFontStyle&) const = 0; virtual sk_sp onMakeFromData(sk_sp, int ttcIndex) const = 0; virtual sk_sp onMakeFromStreamIndex(std::unique_ptr, @@ -150,6 +148,12 @@ protected: virtual sk_sp onLegacyMakeTypeface(const char familyName[], SkFontStyle) const = 0; + // this method is never called -- will be removed + virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, + const SkFontStyle&) const { + return nullptr; + } + private: /** Implemented by porting layer to return the default factory. */ diff --git a/include/ports/SkFontMgr_indirect.h b/include/ports/SkFontMgr_indirect.h index 0d993a5158..73210bc9a5 100644 --- a/include/ports/SkFontMgr_indirect.h +++ b/include/ports/SkFontMgr_indirect.h @@ -47,9 +47,6 @@ protected: int bcp47Count, SkUnichar character) const override; - SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontStyle) const override; - sk_sp onMakeFromStreamIndex(std::unique_ptr, int ttcIndex) const override; sk_sp onMakeFromStreamArgs(std::unique_ptr stream, const SkFontArguments& args) const override; diff --git a/modules/skottie/src/SkottieTest.cpp b/modules/skottie/src/SkottieTest.cpp index f0f7c58f2b..55e88725d5 100644 --- a/modules/skottie/src/SkottieTest.cpp +++ b/modules/skottie/src/SkottieTest.cpp @@ -220,9 +220,6 @@ DEF_TEST(Skottie_Properties, reporter) { SkUnichar character) const override { return nullptr; } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - return nullptr; - } sk_sp onMakeFromData(sk_sp, int ttcIndex) const override { return fTestFont; } @@ -643,9 +640,6 @@ DEF_TEST(Skottie_Shaper_ExplicitFontMgr, reporter) { fFallbackCount++; return nullptr; } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - return nullptr; - } sk_sp onMakeFromData(sk_sp, int) const override { return nullptr; diff --git a/modules/skottie/tests/Text.cpp b/modules/skottie/tests/Text.cpp index b831b211f4..0177f9eb06 100644 --- a/modules/skottie/tests/Text.cpp +++ b/modules/skottie/tests/Text.cpp @@ -42,9 +42,6 @@ private: SkUnichar character) const override { return nullptr; } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - return nullptr; - } sk_sp onMakeFromData(sk_sp, int ttcIndex) const override { return nullptr; diff --git a/modules/skparagraph/include/TypefaceFontProvider.h b/modules/skparagraph/include/TypefaceFontProvider.h index 3d4b82c4fc..88acf953d1 100644 --- a/modules/skparagraph/include/TypefaceFontProvider.h +++ b/modules/skparagraph/include/TypefaceFontProvider.h @@ -53,9 +53,6 @@ public: SkUnichar) const override { return nullptr; } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - return nullptr; - } sk_sp onMakeFromData(sk_sp, int) const override { return nullptr; } sk_sp onMakeFromStreamIndex(std::unique_ptr, int) const override { diff --git a/src/core/SkFontMgr.cpp b/src/core/SkFontMgr.cpp index c8282abd68..f93404c537 100644 --- a/src/core/SkFontMgr.cpp +++ b/src/core/SkFontMgr.cpp @@ -59,9 +59,6 @@ protected: SkUnichar character) const override { return nullptr; } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - return nullptr; - } sk_sp onMakeFromData(sk_sp, int) const override { return nullptr; diff --git a/src/fonts/SkFontMgr_indirect.cpp b/src/fonts/SkFontMgr_indirect.cpp index 9a425e1bc2..57ea24a313 100644 --- a/src/fonts/SkFontMgr_indirect.cpp +++ b/src/fonts/SkFontMgr_indirect.cpp @@ -150,13 +150,6 @@ SkTypeface* SkFontMgr_Indirect::onMatchFamilyStyleCharacter(const char familyNam return this->createTypefaceFromFontId(id); } -SkTypeface* SkFontMgr_Indirect::onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontStyle) const { - SkString familyName; - familyMember->getFamilyName(&familyName); - return this->matchFamilyStyle(familyName.c_str(), fontStyle); -} - sk_sp SkFontMgr_Indirect::onMakeFromStreamIndex(std::unique_ptr stream, int ttcIndex) const { return fImpl->makeFromStream(std::move(stream), ttcIndex); diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index d87c30d6c2..731327dbb1 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -2271,14 +2271,6 @@ protected: return nullptr; } - virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontstyle) const override { - // could be in base impl - SkString familyName; - ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); - return this->matchFamilyStyle(familyName.c_str(), fontstyle); - } - sk_sp onMakeFromStreamIndex(std::unique_ptr stream, int ttcIndex) const override { if (ttcIndex != 0) { diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp index 9378d5d3f5..aec954af6f 100644 --- a/src/ports/SkFontMgr_FontConfigInterface.cpp +++ b/src/ports/SkFontMgr_FontConfigInterface.cpp @@ -216,10 +216,6 @@ protected: SK_ABORT("Not implemented."); } - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override { - SK_ABORT("Not implemented."); - } - sk_sp onMakeFromData(sk_sp data, int ttcIndex) const override { return this->onMakeFromStreamIndex(SkMemoryStream::Make(std::move(data)), ttcIndex); } diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp index 17aa13d9f8..89c3dbd79c 100644 --- a/src/ports/SkFontMgr_android.cpp +++ b/src/ports/SkFontMgr_android.cpp @@ -358,18 +358,6 @@ protected: return sset->matchStyle(style); } - SkTypeface* onMatchFaceStyle(const SkTypeface* typeface, - const SkFontStyle& style) const override { - for (int i = 0; i < fStyleSets.count(); ++i) { - for (int j = 0; j < fStyleSets[i]->fStyles.count(); ++j) { - if (fStyleSets[i]->fStyles[j].get() == typeface) { - return fStyleSets[i]->matchStyle(style); - } - } - } - return nullptr; - } - static sk_sp find_family_style_character( const SkString& familyName, const SkTArray& fallbackNameToFamilyMap, diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp index c9f5d6616e..c0b72de94f 100644 --- a/src/ports/SkFontMgr_custom.cpp +++ b/src/ports/SkFontMgr_custom.cpp @@ -223,19 +223,6 @@ SkTypeface* SkFontMgr_Custom::onMatchFamilyStyleCharacter(const char familyName[ return nullptr; } -SkTypeface* SkFontMgr_Custom::onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontStyle) const -{ - for (int i = 0; i < fFamilies.count(); ++i) { - for (int j = 0; j < fFamilies[i]->fStyles.count(); ++j) { - if (fFamilies[i]->fStyles[j].get() == familyMember) { - return fFamilies[i]->matchStyle(fontStyle); - } - } - } - return nullptr; -} - sk_sp SkFontMgr_Custom::onMakeFromData(sk_sp data, int ttcIndex) const { return this->makeFromStream(std::make_unique(std::move(data)), ttcIndex); } diff --git a/src/ports/SkFontMgr_custom.h b/src/ports/SkFontMgr_custom.h index 12db4fe53e..de02a26c25 100644 --- a/src/ports/SkFontMgr_custom.h +++ b/src/ports/SkFontMgr_custom.h @@ -145,8 +145,6 @@ protected: SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&, const char* bcp47[], int bcp47Count, SkUnichar character) const override; - SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontStyle) const override; sk_sp onMakeFromData(sk_sp data, int ttcIndex) const override; sk_sp onMakeFromStreamIndex(std::unique_ptr, int ttcIndex) const override; sk_sp onMakeFromStreamArgs(std::unique_ptr, const SkFontArguments&) const override; diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp index c2da39b28f..b8e7f5900c 100644 --- a/src/ports/SkFontMgr_fontconfig.cpp +++ b/src/ports/SkFontMgr_fontconfig.cpp @@ -952,15 +952,6 @@ protected: return createTypefaceFromFcPattern(std::move(font)).release(); } - SkTypeface* onMatchFaceStyle(const SkTypeface* typeface, - const SkFontStyle& style) const override - { - //TODO: should the SkTypeface_fontconfig know its family? - const SkTypeface_fontconfig* fcTypeface = - static_cast(typeface); - return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY), style); - } - sk_sp onMakeFromStreamIndex(std::unique_ptr stream, int ttcIndex) const override { const size_t length = stream->getLength(); diff --git a/src/ports/SkFontMgr_fuchsia.cpp b/src/ports/SkFontMgr_fuchsia.cpp index 2bf76f1c51..db9135fd1b 100644 --- a/src/ports/SkFontMgr_fuchsia.cpp +++ b/src/ports/SkFontMgr_fuchsia.cpp @@ -242,7 +242,6 @@ protected: SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&, const char* bcp47[], int bcp47Count, SkUnichar character) const override; - SkTypeface* onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const override; sk_sp onMakeFromData(sk_sp, int ttcIndex) const override; sk_sp onMakeFromStreamIndex(std::unique_ptr, int ttcIndex) const override; @@ -370,10 +369,6 @@ SkTypeface* SkFontMgr_Fuchsia::onMatchFamilyStyleCharacter(const char familyName return typeface.release(); } -SkTypeface* SkFontMgr_Fuchsia::onMatchFaceStyle(const SkTypeface*, const SkFontStyle&) const { - return nullptr; -} - sk_sp SkFontMgr_Fuchsia::onMakeFromData(sk_sp, int ttcIndex) const { SkASSERT(false); return nullptr; diff --git a/src/ports/SkFontMgr_mac_ct.cpp b/src/ports/SkFontMgr_mac_ct.cpp index 0a50238b7d..bb62ccfd0b 100644 --- a/src/ports/SkFontMgr_mac_ct.cpp +++ b/src/ports/SkFontMgr_mac_ct.cpp @@ -557,11 +557,6 @@ protected: return SkTypeface_Mac::Make(std::move(fallbackFont), OpszVariation(), nullptr).release(); } - SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle&) const override { - return nullptr; - } - sk_sp onMakeFromData(sk_sp data, int ttcIndex) const override { if (ttcIndex != 0) { return nullptr; diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp index ba3b3ff501..8b04c3278d 100644 --- a/src/ports/SkFontMgr_win_dw.cpp +++ b/src/ports/SkFontMgr_win_dw.cpp @@ -292,8 +292,6 @@ protected: SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&, const char* bcp47[], int bcp47Count, SkUnichar character) const override; - SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontstyle) const override; sk_sp onMakeFromStreamIndex(std::unique_ptr, int ttcIndex) const override; sk_sp onMakeFromStreamArgs(std::unique_ptr, const SkFontArguments&) const override; sk_sp onMakeFromData(sk_sp, int ttcIndex) const override; @@ -874,15 +872,6 @@ sk_sp SkFontMgr_DirectWrite::layoutFallback(const WCHAR* dwFamilyNam return fontFallbackRenderer->ConsumeFallbackTypeface(); } -SkTypeface* SkFontMgr_DirectWrite::onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontstyle) const { - SkString familyName; - SkFontStyleSet_DirectWrite sset( - this, ((DWriteFontTypeface*)familyMember)->fDWriteFontFamily.get() - ); - return sset.matchStyle(fontstyle); -} - template class SkAutoIDWriteUnregister { public: SkAutoIDWriteUnregister(IDWriteFactory* factory, T* unregister) diff --git a/tools/fonts/TestFontMgr.cpp b/tools/fonts/TestFontMgr.cpp index 3b70a0a8a1..e759f6ca88 100644 --- a/tools/fonts/TestFontMgr.cpp +++ b/tools/fonts/TestFontMgr.cpp @@ -157,12 +157,6 @@ public: return this->matchFamilyStyle(familyName, style); } - SkTypeface* onMatchFaceStyle(const SkTypeface* tf, const SkFontStyle& style) const override { - SkString familyName; - tf->getFamilyName(&familyName); - return this->matchFamilyStyle(familyName.c_str(), style); - } - sk_sp onMakeFromData(sk_sp, int ttcIndex) const override { return nullptr; } sk_sp onMakeFromStreamIndex(std::unique_ptr, int ttcIndex) const override {