Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: include/core/SkFont.h

Issue 2163633002: Make SkFont a bit more useable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkPaint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 static sk_sp<SkFont> Make(sk_sp<SkTypeface>, SkScalar size, MaskType, uint32 _t flags); 120 static sk_sp<SkFont> Make(sk_sp<SkTypeface>, SkScalar size, MaskType, uint32 _t flags);
121 static sk_sp<SkFont> Make(sk_sp<SkTypeface>, SkScalar size, SkScalar scaleX, SkScalar skewX, 121 static sk_sp<SkFont> Make(sk_sp<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 sk_sp<SkFont> makeWithSize(SkScalar size) const;
129 /**
130 * Return a font with the same attributes of this font, but with the flags.
131 */
132 sk_sp<SkFont> makeWithFlags(uint32_t newFlags) const;
129 133
130 SkTypeface* getTypeface() const { return fTypeface.get(); } 134 SkTypeface* getTypeface() const { return fTypeface.get(); }
131 SkScalar getSize() const { return fSize; } 135 SkScalar getSize() const { return fSize; }
132 SkScalar getScaleX() const { return fScaleX; } 136 SkScalar getScaleX() const { return fScaleX; }
133 SkScalar getSkewX() const { return fSkewX; } 137 SkScalar getSkewX() const { return fSkewX; }
134 uint32_t getFlags() const { return fFlags; } 138 uint32_t getFlags() const { return fFlags; }
135 MaskType getMaskType() const { return (MaskType)fMaskType; } 139 MaskType getMaskType() const { return (MaskType)fMaskType; }
136 140
137 bool isVertical() const { return SkToBool(fFlags & kVertical_Flag); } 141 bool isVertical() const { return SkToBool(fFlags & kVertical_Flag); }
138 bool isEmbolden() const { return SkToBool(fFlags & kEmbolden_Flag); } 142 bool isEmbolden() const { return SkToBool(fFlags & kEmbolden_Flag); }
139 bool isEnableAutoHints() const { return SkToBool(fFlags & kEnableAutoHints_F lag); } 143 bool isEnableAutoHints() const { return SkToBool(fFlags & kEnableAutoHints_F lag); }
140 bool isEnableByteCodeHints() const { return SkToBool(fFlags & kEnableByteCod eHints_Flag); } 144 bool isEnableByteCodeHints() const { return SkToBool(fFlags & kEnableByteCod eHints_Flag); }
141 bool isUseNonLinearMetrics() const { return SkToBool(fFlags & kUseNonlinearM etrics_Flag); } 145 bool isUseNonLinearMetrics() const { return SkToBool(fFlags & kUseNonlinearM etrics_Flag); }
146 bool isDevKern() const { return SkToBool(fFlags & kDevKern_Flag); }
142 147
143 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding, 148 int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding,
144 uint16_t glyphs[], int maxGlyphCount) const; 149 uint16_t glyphs[], int maxGlyphCount) const;
145 150
151 int countText(const void* text, size_t byteLength, SkTextEncoding encoding) {
152 return this->textToGlyphs(text, byteLength, encoding, nullptr, 0);
153 }
154
146 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co nst; 155 SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding) co nst;
147 156
148 static sk_sp<SkFont> Testing_CreateFromPaint(const SkPaint&); 157 static sk_sp<SkFont> Testing_CreateFromPaint(const SkPaint&);
149 158
150 private: 159 private:
151 enum { 160 enum {
152 kAllFlags = 0xFF, 161 kAllFlags = 0xFF,
153 }; 162 };
154 163
155 SkFont(sk_sp<SkTypeface>, SkScalar size, SkScalar scaleX, SkScalar skewX, Ma skType, 164 SkFont(sk_sp<SkTypeface>, SkScalar size, SkScalar scaleX, SkScalar skewX, Ma skType,
156 uint32_t flags); 165 uint32_t flags);
157 166
158 sk_sp<SkTypeface> fTypeface; 167 sk_sp<SkTypeface> fTypeface;
159 SkScalar fSize; 168 SkScalar fSize;
160 SkScalar fScaleX; 169 SkScalar fScaleX;
161 SkScalar fSkewX; 170 SkScalar fSkewX;
162 uint16_t fFlags; 171 uint16_t fFlags;
163 uint8_t fMaskType; 172 uint8_t fMaskType;
164 // uint8_t fPad; 173 // uint8_t fPad;
165 }; 174 };
166 175
167 #endif 176 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698