diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index 430397d3e32f8..7c2c334a99a74 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -33,6 +33,8 @@ typedef uint32_t SkFontID; /** Machine endian. */ typedef uint32_t SkFontTableTag; +#define SK_SUPPORT_LEGACY_TYPEFACE_MAKEFROMSTREAM + /** \class SkTypeface The SkTypeface class specifies the typeface and intrinsic style of a font. @@ -129,6 +131,11 @@ class SK_API SkTypeface : public SkWeakRefCnt { */ static sk_sp MakeFromStream(std::unique_ptr stream, int index = 0); +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_MAKEFROMSTREAM + // DEPRECATED -- call the version that takes unique_ptr + static sk_sp MakeFromStream(SkStreamAsset* stream, int index = 0); +#endif + /** Return a new typeface given a SkData. If the data is null, or is not a valid font file, * returns nullptr. */ diff --git a/include/ports/SkFontConfigInterface.h b/include/ports/SkFontConfigInterface.h index 01346f253175e..12f777d655a92 100644 --- a/include/ports/SkFontConfigInterface.h +++ b/include/ports/SkFontConfigInterface.h @@ -10,7 +10,6 @@ #include "SkFontStyle.h" #include "SkRefCnt.h" -#include "SkStream.h" #include "SkTypeface.h" class SkFontMgr; @@ -98,9 +97,7 @@ class SK_API SkFontConfigInterface : public SkRefCnt { * openStream(), but derived classes may implement more complex caching schemes. */ virtual sk_sp makeTypeface(const FontIdentity& identity) { - return SkTypeface::MakeFromStream(std::unique_ptr(this->openStream(identity)), - identity.fTTCIndex); - + return SkTypeface::MakeFromStream(this->openStream(identity), identity.fTTCIndex); } /** diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 7bfd47733de8c..8255c431a04bc 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -145,6 +145,13 @@ sk_sp SkTypeface::MakeFromName(const char name[], return SkFontMgr::RefDefault()->legacyMakeTypeface(name, fontStyle); } +#ifdef SK_SUPPORT_LEGACY_TYPEFACE_MAKEFROMSTREAM +// DEPRECATED +sk_sp SkTypeface::MakeFromStream(SkStreamAsset* stream, int index) { + return MakeFromStream(std::unique_ptr(stream), index); +} +#endif + sk_sp SkTypeface::MakeFromStream(std::unique_ptr stream, int index) { if (!stream) { return nullptr;