diff options
author | 2017-07-27 10:45:29 -0400 | |
---|---|---|
committer | 2017-07-27 21:30:45 +0000 | |
commit | 713195071dc7bdeddec2d1c9fab9b3720f049f07 (patch) | |
tree | 1bc2d47ec9e66f81a14d626eb5ad8185dbecca27 /include/core/SkFontStyle.h | |
parent | 23890a9ac89005a15967fe8af8aaafc0edda5e32 (diff) |
Remove internal use of SkTypeface::Style.
Change-Id: I71cf04b12be95a54b7fb47d048ba1f8672ed9a8f
Reviewed-on: https://skia-review.googlesource.com/27760
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'include/core/SkFontStyle.h')
-rw-r--r-- | include/core/SkFontStyle.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/core/SkFontStyle.h b/include/core/SkFontStyle.h index 7dd25910a2..306895d78f 100644 --- a/include/core/SkFontStyle.h +++ b/include/core/SkFontStyle.h @@ -45,7 +45,12 @@ public: }; SkFontStyle(); - SkFontStyle(int weight, int width, Slant); + + constexpr SkFontStyle(int weight, int width, Slant slant) : fUnion {{ + static_cast<uint16_t>(SkTPin<int>(weight, kInvisible_Weight, kExtraBlack_Weight)), + static_cast<uint8_t >(SkTPin<int>(width, kUltraCondensed_Width, kUltraExpanded_Width)), + static_cast<uint8_t >(SkTPin<int>(slant, kUpright_Slant, kOblique_Slant)) + }} { } static SkFontStyle FromOldStyle(unsigned oldStyle); @@ -57,6 +62,19 @@ public: int width() const { return fUnion.fR.fWidth; } Slant slant() const { return (Slant)fUnion.fR.fSlant; } + static constexpr SkFontStyle Normal() { + return SkFontStyle(kNormal_Weight, kNormal_Width, kUpright_Slant); + } + static constexpr SkFontStyle Bold() { + return SkFontStyle(kBold_Weight, kNormal_Width, kUpright_Slant); + } + static constexpr SkFontStyle Italic() { + return SkFontStyle(kNormal_Weight, kNormal_Width, kItalic_Slant ); + } + static constexpr SkFontStyle BoldItalic() { + return SkFontStyle(kBold_Weight, kNormal_Width, kItalic_Slant ); + } + private: union { struct { |