From 11a77c6e0634e2feb6fe4e74806db2fdd2a799ec Mon Sep 17 00:00:00 2001 From: bungeman Date: Tue, 12 Apr 2016 13:45:06 -0700 Subject: Begin switch to SkFontStyle for legacy calls. This adds SK_VERY_LEGACY_CREATE_TYPEFACE which, when defined, provides only the old interface. Ideally, everyone would switch directly to SkFontMgr and use one of the newer calls, but there is currently no path for current users to get there. This updates all the internals to use SkFontStyle, after switching these over the higher level APIs can be switched. The Chromium follow on patch can be seen at https://crrev.com/1877673002 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1873923002 TBR=reed This doesn't really change API, just modernizes it. Review URL: https://codereview.chromium.org/1873923002 --- include/ports/SkFontConfigInterface.h | 8 ++++++++ include/ports/SkFontMgr.h | 12 ++++++++++-- include/ports/SkFontMgr_indirect.h | 25 ++++++++++++++----------- 3 files changed, 32 insertions(+), 13 deletions(-) (limited to 'include/ports') diff --git a/include/ports/SkFontConfigInterface.h b/include/ports/SkFontConfigInterface.h index 063cb9d553..464251bc2d 100644 --- a/include/ports/SkFontConfigInterface.h +++ b/include/ports/SkFontConfigInterface.h @@ -80,11 +80,19 @@ public: * * If a match is not found, return false, and ignore all out parameters. */ +#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE virtual bool matchFamilyName(const char familyName[], SkTypeface::Style requested, FontIdentity* outFontIdentifier, SkString* outFamilyName, SkTypeface::Style* outStyle) = 0; +#else + virtual bool matchFamilyName(const char familyName[], + SkFontStyle requested, + FontIdentity* outFontIdentifier, + SkString* outFamilyName, + SkFontStyle* outStyle) = 0; +#endif /** * Given a FontRef, open a stream to access its data, or return null diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h index 3e6c785be9..a961cd48ad 100644 --- a/include/ports/SkFontMgr.h +++ b/include/ports/SkFontMgr.h @@ -164,8 +164,11 @@ public: */ SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const; - SkTypeface* legacyCreateTypeface(const char familyName[], - unsigned typefaceStyleBits) const; +#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE + SkTypeface* legacyCreateTypeface(const char familyName[], unsigned typefaceStyleBits) const; +#else + SkTypeface* legacyCreateTypeface(const char familyName[], SkFontStyle style) const; +#endif /** * Return a ref to the default fontmgr. The caller must call unref() on @@ -196,8 +199,13 @@ protected: virtual SkTypeface* onCreateFromFontData(SkFontData*) const; virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const = 0; +#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const = 0; +#else + virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const = 0; +#endif + private: static SkFontMgr* Factory(); // implemented by porting layer friend SkFontMgr* sk_fontmgr_create_default(); diff --git a/include/ports/SkFontMgr_indirect.h b/include/ports/SkFontMgr_indirect.h index 37502d2404..b3f31c3b8e 100644 --- a/include/ports/SkFontMgr_indirect.h +++ b/include/ports/SkFontMgr_indirect.h @@ -38,24 +38,27 @@ protected: SkFontStyleSet* onMatchFamily(const char familyName[]) const override; - virtual SkTypeface* onMatchFamilyStyle(const char familyName[], - const SkFontStyle& fontStyle) const override; + SkTypeface* onMatchFamilyStyle(const char familyName[], + const SkFontStyle& fontStyle) const override; - virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], - const SkFontStyle&, - const char* bcp47[], - int bcp47Count, - SkUnichar character) const override; + SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], + const SkFontStyle&, + const char* bcp47[], + int bcp47Count, + SkUnichar character) const override; - virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, - const SkFontStyle& fontStyle) const override; + SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, + const SkFontStyle& fontStyle) const override; SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const override; SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override; SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override; - virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], - unsigned styleBits) const override; +#ifdef SK_VERY_LEGACY_CREATE_TYPEFACE + SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBits) const override; +#else + SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle) const override; +#endif private: SkTypeface* createTypefaceFromFontId(const SkFontIdentity& fontId) const; -- cgit v1.2.3