diff options
author | bungeman <bungeman@google.com> | 2017-02-17 18:03:49 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-23 18:41:57 +0000 |
commit | 0f3d0c37dbcaf4ec271d5fe847becc9b1aa6f537 (patch) | |
tree | cae67def2ed8a8ba416132b609cb98fe7563c691 /include/core/SkTypeface.h | |
parent | 6d67396bf06fb603825bf6a792a2e1c8eb405fe0 (diff) |
Add SkTypeface::getVariationDesignPosition.
Allow users to query a typeface's position in variation design space.
Change-Id: I173ee9eefdddee6b2613435ebcc6b08c25b382ed
Reviewed-on: https://skia-review.googlesource.com/8684
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core/SkTypeface.h')
-rw-r--r-- | include/core/SkTypeface.h | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index 51d5a0b11c..07d8bc395b 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -11,6 +11,7 @@ #include "../private/SkBitmaskEnum.h" #include "../private/SkOnce.h" #include "../private/SkWeakRefCnt.h" +#include "SkFontArguments.h" #include "SkFontStyle.h" #include "SkRect.h" #include "SkString.h" @@ -77,6 +78,20 @@ public: */ bool isFixedPitch() const { return fIsFixedPitch; } + /** Copy into 'coordinates' (allocated by the caller) the design variation coordinates. + * + * @param coordinates the buffer into which to write the design variation coordinates. + * @param coordinateCount the number of entries available through 'coordinates'. + * + * @return The number of axes, or -1 if there is an error. + * If 'coordinates != nullptr' and 'coordinateCount >= numAxes' then 'coordinates' will be + * filled with the variation coordinates describing the position of this typeface in design + * variation space. It is possible the number of axes can be retrieved but actual position + * cannot. + */ + int getVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], + int coordinateCount) const; + /** Return a 32bit value for this typeface, unique for the underlying font data. Will never return 0. */ @@ -96,16 +111,16 @@ public: /** Returns the default typeface, which is never nullptr. */ static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); - /** Creates a new reference to the typeface that most closely matches the - requested familyName and fontStyle. This method allows extended font - face specifiers as in the SkFontStyle type. Will never return null. + /** Creates a new reference to the typeface that most closely matches the + requested familyName and fontStyle. This method allows extended font + face specifiers as in the SkFontStyle type. Will never return null. - @param familyName May be NULL. The name of the font family. - @param fontStyle The style of the typeface. - @return reference to the closest-matching typeface. Call must call + @param familyName May be NULL. The name of the font family. + @param fontStyle The style of the typeface. + @return reference to the closest-matching typeface. Call must call unref() when they are done. */ - static sk_sp<SkTypeface> MakeFromName(const char familyName[], SkFontStyle fontStyle); + 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. @@ -341,6 +356,10 @@ protected: // TODO: make pure virtual. virtual std::unique_ptr<SkFontData> onMakeFontData() const; + virtual int onGetVariationDesignPosition( + SkFontArguments::VariationPosition::Coordinate coordinates[], + int coordinateCount) const = 0; + virtual void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const = 0; virtual int onCharsToGlyphs(const void* chars, Encoding, SkGlyphID glyphs[], |