| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkFont_DEFINED | 8 #ifndef SkFont_DEFINED |
| 9 #define SkFont_DEFINED | 9 #define SkFont_DEFINED |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 kEmbolden_Flag = 1 << 6, | 110 kEmbolden_Flag = 1 << 6, |
| 111 kDevKern_Flag = 1 << 7, // ifdef ANDROID ? | 111 kDevKern_Flag = 1 << 7, // ifdef ANDROID ? |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 enum MaskType { | 114 enum MaskType { |
| 115 kBW_MaskType, | 115 kBW_MaskType, |
| 116 kA8_MaskType, | 116 kA8_MaskType, |
| 117 kLCD_MaskType, | 117 kLCD_MaskType, |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 static sk_sp<SkFont> Make(sk_sp<SkTypeface>, SkScalar size, MaskType, uint32
_t flags); | 120 static SkFont* Create(SkTypeface*, SkScalar size, MaskType, uint32_t flags); |
| 121 static sk_sp<SkFont> Make(sk_sp<SkTypeface>, SkScalar size, SkScalar scaleX,
SkScalar skewX, | 121 static SkFont* Create(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar
skewX, |
| 122 MaskType, uint32_t flags); | 122 MaskType, uint32_t flags); |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Return a font with the same attributes of this font, but with the specif
ied size. | 125 * Return a font with the same attributes of this font, but with the specif
ied size. |
| 126 * If size is not supported (e.g. <= 0 or non-finite) NULL will be returned
. | 126 * If size is not supported (e.g. <= 0 or non-finite) NULL will be returned
. |
| 127 */ | 127 */ |
| 128 sk_sp<SkFont> makeWithSize(SkScalar size) const; | 128 SkFont* cloneWithSize(SkScalar size) const; |
| 129 | 129 |
| 130 SkTypeface* getTypeface() const { return fTypeface.get(); } | 130 SkTypeface* getTypeface() const { return fTypeface; } |
| 131 SkScalar getSize() const { return fSize; } | 131 SkScalar getSize() const { return fSize; } |
| 132 SkScalar getScaleX() const { return fScaleX; } | 132 SkScalar getScaleX() const { return fScaleX; } |
| 133 SkScalar getSkewX() const { return fSkewX; } | 133 SkScalar getSkewX() const { return fSkewX; } |
| 134 uint32_t getFlags() const { return fFlags; } | 134 uint32_t getFlags() const { return fFlags; } |
| 135 MaskType getMaskType() const { return (MaskType)fMaskType; } | 135 MaskType getMaskType() const { return (MaskType)fMaskType; } |
| 136 | 136 |
| 137 bool isVertical() const { return SkToBool(fFlags & kVertical_Flag); } | 137 bool isVertical() const { return SkToBool(fFlags & kVertical_Flag); } |
| 138 bool isEmbolden() const { return SkToBool(fFlags & kEmbolden_Flag); } | 138 bool isEmbolden() const { return SkToBool(fFlags & kEmbolden_Flag); } |
| 139 bool isEnableAutoHints() const { return SkToBool(fFlags & kEnableAutoHints_F
lag); } | 139 bool isEnableAutoHints() const { return SkToBool(fFlags & kEnableAutoHints_F
lag); } |
| 140 bool isEnableByteCodeHints() const { return SkToBool(fFlags & kEnableByteCod
eHints_Flag); } | 140 bool isEnableByteCodeHints() const { return SkToBool(fFlags & kEnableByteCod
eHints_Flag); } |
| 141 bool isUseNonLinearMetrics() const { return SkToBool(fFlags & kUseNonlinearM
etrics_Flag); } | 141 bool isUseNonLinearMetrics() const { return SkToBool(fFlags & kUseNonlinearM
etrics_Flag); } |
| 142 | 142 |
| 143 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding, | 143 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding, |
| 144 uint16_t glyphs[], int maxGlyphCount) const; | 144 uint16_t glyphs[], int maxGlyphCount) const; |
| 145 | 145 |
| 146 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co
nst; | 146 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co
nst; |
| 147 | 147 |
| 148 static sk_sp<SkFont> Testing_CreateFromPaint(const SkPaint&); | 148 static SkFont* Testing_CreateFromPaint(const SkPaint&); |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 enum { | 151 enum { |
| 152 kAllFlags = 0xFF, | 152 kAllFlags = 0xFF, |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 SkFont(sk_sp<SkTypeface>, SkScalar size, SkScalar scaleX, SkScalar skewX, Ma
skType, | 155 SkFont(SkTypeface*, SkScalar size, SkScalar scaleX, SkScalar skewX, MaskType
, uint32_t flags); |
| 156 uint32_t flags); | 156 virtual ~SkFont(); |
| 157 | 157 |
| 158 sk_sp<SkTypeface> fTypeface; | 158 SkTypeface* fTypeface; |
| 159 SkScalar fSize; | 159 SkScalar fSize; |
| 160 SkScalar fScaleX; | 160 SkScalar fScaleX; |
| 161 SkScalar fSkewX; | 161 SkScalar fSkewX; |
| 162 uint16_t fFlags; | 162 uint16_t fFlags; |
| 163 uint8_t fMaskType; | 163 uint8_t fMaskType; |
| 164 // uint8_t fPad; | 164 // uint8_t fPad; |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 #endif | 167 #endif |
| OLD | NEW |