OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkTypeface_DEFINED | 10 #ifndef SkTypeface_DEFINED |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 */ | 218 */ |
219 size_t getTableData(SkFontTableTag tag, size_t offset, size_t length, | 219 size_t getTableData(SkFontTableTag tag, size_t offset, size_t length, |
220 void* data) const; | 220 void* data) const; |
221 | 221 |
222 /** | 222 /** |
223 * Return the units-per-em value for this typeface, or zero if there is an | 223 * Return the units-per-em value for this typeface, or zero if there is an |
224 * error. | 224 * error. |
225 */ | 225 */ |
226 int getUnitsPerEm() const; | 226 int getUnitsPerEm() const; |
227 | 227 |
| 228 /** |
| 229 * Given a run of glyphs, return the associated horizontal adjustments. |
| 230 * Adjustments are in "design units", which are integers relative to the |
| 231 * typeface's units per em (see getUnitsPerEm). |
| 232 * |
| 233 * Some typefaces are known to never support kerning. Calling this method |
| 234 * with all zeros (e.g. getKerningPairAdustments(NULL, 0, NULL)) returns |
| 235 * a boolean indicating if the typeface might support kerning. If it |
| 236 * returns false, then it will always return false (no kerning) for all |
| 237 * possible glyph runs. If it returns true, then it *may* return true for |
| 238 * somne glyph runs. |
| 239 * |
| 240 * If count is non-zero, then the glyphs parameter must point to at least |
| 241 * [count] valid glyph IDs, and the adjustments parameter must be |
| 242 * sized to at least [count - 1] entries. If the method returns true, then |
| 243 * [count-1] entries in the adjustments array will be set. If the method |
| 244 * returns false, then no kerning should be applied, and the adjustments |
| 245 * array will be in an undefined state (possibly some values may have been |
| 246 * written, but none of them should be interpreted as valid values). |
| 247 */ |
| 248 bool getKerningPairAdjustments(const uint16_t glyphs[], int count, |
| 249 int32_t adjustments[]) const; |
| 250 |
228 struct LocalizedString { | 251 struct LocalizedString { |
229 SkString fString; | 252 SkString fString; |
230 SkString fLanguage; | 253 SkString fLanguage; |
231 }; | 254 }; |
232 class LocalizedStrings : ::SkNoncopyable { | 255 class LocalizedStrings : ::SkNoncopyable { |
233 public: | 256 public: |
234 virtual ~LocalizedStrings() { } | 257 virtual ~LocalizedStrings() { } |
235 virtual bool next(LocalizedString* localizedString) = 0; | 258 virtual bool next(LocalizedString* localizedString) = 0; |
236 void unref() { SkDELETE(this); } | 259 void unref() { SkDELETE(this); } |
237 }; | 260 }; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 319 |
297 friend class SkScalerContext; | 320 friend class SkScalerContext; |
298 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal); | 321 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal); |
299 | 322 |
300 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const =
0; | 323 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const =
0; |
301 virtual void onFilterRec(SkScalerContextRec*) const = 0; | 324 virtual void onFilterRec(SkScalerContextRec*) const = 0; |
302 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 325 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
303 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, | 326 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, |
304 const uint32_t* glyphIDs, | 327 const uint32_t* glyphIDs, |
305 uint32_t glyphIDsCount) const = 0; | 328 uint32_t glyphIDsCount) const = 0; |
| 329 |
306 virtual SkStream* onOpenStream(int* ttcIndex) const = 0; | 330 virtual SkStream* onOpenStream(int* ttcIndex) const = 0; |
307 virtual void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const = 0
; | 331 virtual void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const = 0
; |
308 | 332 |
309 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 333 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
310 int glyphCount) const = 0; | 334 int glyphCount) const = 0; |
311 virtual int onCountGlyphs() const = 0; | 335 virtual int onCountGlyphs() const = 0; |
312 | 336 |
313 virtual int onGetUPEM() const = 0; | 337 virtual int onGetUPEM() const = 0; |
| 338 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, |
| 339 int32_t adjustments[]) const; |
314 | 340 |
315 virtual LocalizedStrings* onCreateFamilyNameIterator() const = 0; | 341 virtual LocalizedStrings* onCreateFamilyNameIterator() const = 0; |
316 | 342 |
317 virtual int onGetTableTags(SkFontTableTag tags[]) const = 0; | 343 virtual int onGetTableTags(SkFontTableTag tags[]) const = 0; |
318 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 344 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
319 size_t length, void* data) const = 0; | 345 size_t length, void* data) const = 0; |
320 | 346 |
321 virtual SkTypeface* onRefMatchingStyle(Style styleBits) const = 0; | 347 virtual SkTypeface* onRefMatchingStyle(Style styleBits) const = 0; |
322 | 348 |
323 private: | 349 private: |
324 SkFontID fUniqueID; | 350 SkFontID fUniqueID; |
325 Style fStyle; | 351 Style fStyle; |
326 bool fIsFixedPitch; | 352 bool fIsFixedPitch; |
327 | 353 |
328 friend class SkPaint; | 354 friend class SkPaint; |
329 friend class SkGlyphCache; // GetDefaultTypeface | 355 friend class SkGlyphCache; // GetDefaultTypeface |
330 // just so deprecated fonthost can call protected methods | 356 // just so deprecated fonthost can call protected methods |
331 friend class SkFontHost; | 357 friend class SkFontHost; |
332 | 358 |
333 typedef SkWeakRefCnt INHERITED; | 359 typedef SkWeakRefCnt INHERITED; |
334 }; | 360 }; |
335 | 361 |
336 #endif | 362 #endif |
OLD | NEW |