Chromium Code Reviews| Index: include/core/SkTypeface.h |
| diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h |
| index a080d84bd8c87ab9538a2c2c932fa8a6b4c171a0..a6d5f96835a9421472ed7ea9eae7d2dd5e6e5a3c 100644 |
| --- a/include/core/SkTypeface.h |
| +++ b/include/core/SkTypeface.h |
| @@ -11,6 +11,7 @@ |
| #define SkTypeface_DEFINED |
| #include "SkAdvancedTypefaceMetrics.h" |
| +#include "SkFontStyle.h" |
| #include "SkWeakRefCnt.h" |
| class SkDescriptor; |
| @@ -49,17 +50,22 @@ public: |
| kBoldItalic = 0x03 |
| }; |
| - /** Returns the typeface's intrinsic style attributes |
| - */ |
| - Style style() const { return fStyle; } |
| + SkFontStyle fontStyle() const { |
| + return fStyle; |
| + } |
| - /** Returns true if getStyle() has the kBold bit set. |
| - */ |
| - bool isBold() const { return (fStyle & kBold) != 0; } |
| + /** Returns the typeface's intrinsic style attributes. */ |
|
reed1
2014/10/20 18:39:56
mark as DEPRECATED?
bungeman-skia
2014/10/20 19:15:39
This question is why this isn't already checked in
|
| + Style style() const { |
| + return static_cast<Style>( |
| + (fStyle.weight() >= SkFontStyle::kSemiBold_Weight ? kBold : kNormal) | |
| + (fStyle.slant() != SkFontStyle::kUpright_Slant ? kItalic : kNormal)); |
| + } |
| - /** Returns true if getStyle() has the kItalic bit set. |
| - */ |
| - bool isItalic() const { return (fStyle & kItalic) != 0; } |
| + /** Returns true if getStyle() has the kBold bit set. */ |
| + bool isBold() const { return fStyle.weight() >= SkFontStyle::kSemiBold_Weight; } |
| + |
| + /** Returns true if getStyle() has the kItalic bit set. */ |
| + bool isItalic() const { return fStyle.slant() != SkFontStyle::kUpright_Slant; } |
| /** Returns true if the typeface claims to be fixed-pitch. |
| * This is a style bit, advance widths may vary even if this returns true. |
| @@ -285,7 +291,7 @@ public: |
| protected: |
| /** uniqueID must be unique and non-zero |
| */ |
| - SkTypeface(Style style, SkFontID uniqueID, bool isFixedPitch = false); |
| + SkTypeface(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch = false); |
| virtual ~SkTypeface(); |
| /** Sets the fixedPitch bit. If used, must be called in the constructor. */ |
| @@ -351,7 +357,7 @@ private: |
| static void DeleteDefault(SkTypeface*); |
| SkFontID fUniqueID; |
| - Style fStyle; |
| + SkFontStyle fStyle; |
| bool fIsFixedPitch; |
| friend class SkPaint; |