diff options
-rw-r--r-- | include/core/SkTypeface.h | 14 | ||||
-rw-r--r-- | src/core/SkTypeface.cpp | 21 | ||||
-rw-r--r-- | tests/TypefaceTest.cpp | 2 |
3 files changed, 7 insertions, 30 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index 0b65ba9151..5a821716a3 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -99,8 +99,8 @@ public: */ static bool Equal(const SkTypeface* facea, const SkTypeface* faceb); - /** Returns the default typeface, which is never nullptr. */ - static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); + /** Returns the default normal typeface, which is never nullptr. */ + static sk_sp<SkTypeface> MakeDefault(); /** Creates a new reference to the typeface that most closely matches the requested familyName and fontStyle. This method allows extended font @@ -113,16 +113,6 @@ public: */ static sk_sp<SkTypeface> MakeFromName(const char familyName[], SkFontStyle fontStyle); - /** Return the typeface that most closely matches the requested typeface and style. - Use this to pick a new style from the same family of the existing typeface. - If family is nullptr, this selects from the default font's family. - - @param family May be NULL. The name of the existing type face. - @param s The style (normal, bold, italic) of the type face. - @return the closest-matching typeface. - */ - static sk_sp<SkTypeface> MakeFromTypeface(SkTypeface* family, Style); - /** Return a new typeface given a file. If the file does not exist, or is not a valid font file, returns nullptr. */ diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 83edea9775..0c8c4b96ae 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -99,8 +99,8 @@ SkTypeface* SkTypeface::GetDefaultTypeface(Style style) { return defaults[style].get(); } -sk_sp<SkTypeface> SkTypeface::MakeDefault(Style style) { - return sk_ref_sp(GetDefaultTypeface(style)); +sk_sp<SkTypeface> SkTypeface::MakeDefault() { + return sk_ref_sp(GetDefaultTypeface(SkTypeface::kNormal)); } uint32_t SkTypeface::UniqueID(const SkTypeface* face) { @@ -128,29 +128,16 @@ sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], fontStyle.slant() == SkFontStyle::kUpright_Slant) && (fontStyle.weight() == SkFontStyle::kBold_Weight || fontStyle.weight() == SkFontStyle::kNormal_Weight)) { - return MakeDefault(static_cast<SkTypeface::Style>( + return sk_ref_sp(GetDefaultTypeface(static_cast<SkTypeface::Style>( (fontStyle.slant() == SkFontStyle::kItalic_Slant ? SkTypeface::kItalic : SkTypeface::kNormal) | (fontStyle.weight() == SkFontStyle::kBold_Weight ? SkTypeface::kBold : - SkTypeface::kNormal))); + SkTypeface::kNormal)))); } sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); return fm->legacyMakeTypeface(name, fontStyle); } -sk_sp<SkTypeface> SkTypeface::MakeFromTypeface(SkTypeface* family, Style s) { - if (!family) { - return SkTypeface::MakeDefault(s); - } - - if (family->fontStyle() == SkFontStyle::FromOldStyle(s)) { - return sk_ref_sp(family); - } - - sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); - return sk_sp<SkTypeface>(fm->matchFaceStyle(family, SkFontStyle::FromOldStyle(s))); -} - sk_sp<SkTypeface> SkTypeface::MakeFromStream(SkStreamAsset* stream, int index) { sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); return fm->makeFromStream(std::unique_ptr<SkStreamAsset>(stream), index); diff --git a/tests/TypefaceTest.cpp b/tests/TypefaceTest.cpp index 415d64abb1..6175d36157 100644 --- a/tests/TypefaceTest.cpp +++ b/tests/TypefaceTest.cpp @@ -169,7 +169,7 @@ DEF_TEST(TypefaceVariationIndex, reporter) { DEF_TEST(Typeface, reporter) { sk_sp<SkTypeface> t1(SkTypeface::MakeFromName(nullptr, SkFontStyle())); - sk_sp<SkTypeface> t2(SkTypeface::MakeDefault(SkTypeface::kNormal)); + sk_sp<SkTypeface> t2(SkTypeface::MakeDefault()); REPORTER_ASSERT(reporter, SkTypeface::Equal(t1.get(), t2.get())); REPORTER_ASSERT(reporter, SkTypeface::Equal(nullptr, t1.get())); |