OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkTypeface_DEFINED | 8 #ifndef SkTypeface_DEFINED |
11 #define SkTypeface_DEFINED | 9 #define SkTypeface_DEFINED |
12 | 10 |
13 #include "../private/SkOncePtr.h" | 11 #include "../private/SkOncePtr.h" |
14 #include "../private/SkWeakRefCnt.h" | 12 #include "../private/SkWeakRefCnt.h" |
15 #include "SkFontStyle.h" | 13 #include "SkFontStyle.h" |
16 #include "SkRect.h" | 14 #include "SkRect.h" |
17 #include "SkString.h" | 15 #include "SkString.h" |
18 | 16 |
| 17 #define SK_SUPPORT_NEW_ONCREATESCALERCONTEXT |
| 18 |
19 class SkDescriptor; | 19 class SkDescriptor; |
20 class SkFontData; | 20 class SkFontData; |
21 class SkFontDescriptor; | 21 class SkFontDescriptor; |
22 class SkScalerContext; | 22 class SkScalerContext; |
23 struct SkScalerContextRec; | 23 struct SkScalerContextRec; |
| 24 struct SkScalerContextEffects; |
24 class SkStream; | 25 class SkStream; |
25 class SkStreamAsset; | 26 class SkStreamAsset; |
26 class SkAdvancedTypefaceMetrics; | 27 class SkAdvancedTypefaceMetrics; |
27 class SkWStream; | 28 class SkWStream; |
28 | 29 |
29 typedef uint32_t SkFontID; | 30 typedef uint32_t SkFontID; |
30 /** Machine endian. */ | 31 /** Machine endian. */ |
31 typedef uint32_t SkFontTableTag; | 32 typedef uint32_t SkFontTableTag; |
32 | 33 |
33 /** \class SkTypeface | 34 /** \class SkTypeface |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 * Return the font data, or NULL on failure. | 289 * Return the font data, or NULL on failure. |
289 * The caller is responsible for deleting the font data. | 290 * The caller is responsible for deleting the font data. |
290 */ | 291 */ |
291 SkFontData* createFontData() const; | 292 SkFontData* createFontData() const; |
292 | 293 |
293 /** | 294 /** |
294 * Return a scalercontext for the given descriptor. If this fails, then | 295 * Return a scalercontext for the given descriptor. If this fails, then |
295 * if allowFailure is true, this returns NULL, else it returns a | 296 * if allowFailure is true, this returns NULL, else it returns a |
296 * dummy scalercontext that will not crash, but will draw nothing. | 297 * dummy scalercontext that will not crash, but will draw nothing. |
297 */ | 298 */ |
298 SkScalerContext* createScalerContext(const SkDescriptor*, | 299 SkScalerContext* createScalerContext(const SkScalerContextEffects&, const Sk
Descriptor*, |
299 bool allowFailure = false) const; | 300 bool allowFailure = false) const; |
300 | 301 |
301 /** | 302 /** |
302 * Return a rectangle (scaled to 1-pt) that represents the union of the bou
nds of all | 303 * Return a rectangle (scaled to 1-pt) that represents the union of the bou
nds of all |
303 * of the glyphs, but each one positioned at (0,). This may be conservative
ly large, and | 304 * of the glyphs, but each one positioned at (0,). This may be conservative
ly large, and |
304 * will not take into account any hinting or other size-specific adjustment
s. | 305 * will not take into account any hinting or other size-specific adjustment
s. |
305 */ | 306 */ |
306 SkRect getBounds() const; | 307 SkRect getBounds() const; |
307 | 308 |
308 // PRIVATE / EXPERIMENTAL -- do not call | 309 // PRIVATE / EXPERIMENTAL -- do not call |
(...skipping 20 matching lines...) Expand all Loading... |
329 */ | 330 */ |
330 SkTypeface(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch =
false); | 331 SkTypeface(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch =
false); |
331 virtual ~SkTypeface(); | 332 virtual ~SkTypeface(); |
332 | 333 |
333 /** Sets the fixedPitch bit. If used, must be called in the constructor. */ | 334 /** Sets the fixedPitch bit. If used, must be called in the constructor. */ |
334 void setIsFixedPitch(bool isFixedPitch) { fIsFixedPitch = isFixedPitch; } | 335 void setIsFixedPitch(bool isFixedPitch) { fIsFixedPitch = isFixedPitch; } |
335 | 336 |
336 friend class SkScalerContext; | 337 friend class SkScalerContext; |
337 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal); | 338 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal); |
338 | 339 |
339 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const =
0; | 340 virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&
, |
| 341 const SkDescriptor*) const =
0; |
340 virtual void onFilterRec(SkScalerContextRec*) const = 0; | 342 virtual void onFilterRec(SkScalerContextRec*) const = 0; |
341 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 343 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
342 PerGlyphInfo, | 344 PerGlyphInfo, |
343 const uint32_t* glyphIDs, | 345 const uint32_t* glyphIDs, |
344 uint32_t glyphIDsCount) const = 0; | 346 uint32_t glyphIDsCount) const = 0; |
345 | 347 |
346 virtual SkStreamAsset* onOpenStream(int* ttcIndex) const = 0; | 348 virtual SkStreamAsset* onOpenStream(int* ttcIndex) const = 0; |
347 // TODO: make pure virtual. | 349 // TODO: make pure virtual. |
348 virtual SkFontData* onCreateFontData() const; | 350 virtual SkFontData* onCreateFontData() const; |
349 | 351 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 SkFontStyle fStyle; | 405 SkFontStyle fStyle; |
404 bool fIsFixedPitch; | 406 bool fIsFixedPitch; |
405 | 407 |
406 friend class SkPaint; | 408 friend class SkPaint; |
407 friend class SkGlyphCache; // GetDefaultTypeface | 409 friend class SkGlyphCache; // GetDefaultTypeface |
408 | 410 |
409 typedef SkWeakRefCnt INHERITED; | 411 typedef SkWeakRefCnt INHERITED; |
410 }; | 412 }; |
411 | 413 |
412 #endif | 414 #endif |
OLD | NEW |