OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkTypeface_DEFINED | 8 #ifndef SkTypeface_DEFINED |
9 #define SkTypeface_DEFINED | 9 #define SkTypeface_DEFINED |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 struct SkScalerContextEffects; | 22 struct SkScalerContextEffects; |
23 class SkStream; | 23 class SkStream; |
24 class SkStreamAsset; | 24 class SkStreamAsset; |
25 class SkAdvancedTypefaceMetrics; | 25 class SkAdvancedTypefaceMetrics; |
26 class SkWStream; | 26 class SkWStream; |
27 | 27 |
28 typedef uint32_t SkFontID; | 28 typedef uint32_t SkFontID; |
29 /** Machine endian. */ | 29 /** Machine endian. */ |
30 typedef uint32_t SkFontTableTag; | 30 typedef uint32_t SkFontTableTag; |
31 | 31 |
| 32 #ifdef SK_INTERNAL |
| 33 #ifndef SK_DONT_USE_LEGACY_TYPEFACE_MAKE_FROM_NAME |
| 34 #define SK_DONT_USE_LEGACY_TYPEFACE_MAKE_FROM_NAME |
| 35 #endif |
| 36 #endif |
| 37 |
32 /** \class SkTypeface | 38 /** \class SkTypeface |
33 | 39 |
34 The SkTypeface class specifies the typeface and intrinsic style of a font. | 40 The SkTypeface class specifies the typeface and intrinsic style of a font. |
35 This is used in the paint, along with optionally algorithmic settings like | 41 This is used in the paint, along with optionally algorithmic settings like |
36 textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specify | 42 textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specify |
37 how text appears when drawn (and measured). | 43 how text appears when drawn (and measured). |
38 | 44 |
39 Typeface objects are immutable, and so they can be shared between threads. | 45 Typeface objects are immutable, and so they can be shared between threads. |
40 */ | 46 */ |
41 class SK_API SkTypeface : public SkWeakRefCnt { | 47 class SK_API SkTypeface : public SkWeakRefCnt { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 static bool Equal(const SkTypeface* facea, const SkTypeface* faceb); | 99 static bool Equal(const SkTypeface* facea, const SkTypeface* faceb); |
94 | 100 |
95 /** Returns the default typeface, which is never nullptr. */ | 101 /** Returns the default typeface, which is never nullptr. */ |
96 static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); | 102 static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); |
97 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 103 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
98 static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) { | 104 static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) { |
99 return MakeDefault(style).release(); | 105 return MakeDefault(style).release(); |
100 } | 106 } |
101 #endif | 107 #endif |
102 | 108 |
| 109 /** Creates a new reference to the typeface that most closely matches the |
| 110 requested familyName and fontStyle. This method allows extended font |
| 111 face specifiers as in the SkFontStyle type. Will never return null. |
| 112 |
| 113 @param familyName May be NULL. The name of the font family. |
| 114 @param fontStyle The style of the typeface. |
| 115 @return reference to the closest-matching typeface. Call must call |
| 116 unref() when they are done. |
| 117 */ |
| 118 static sk_sp<SkTypeface> MakeFromName(const char familyName[], |
| 119 SkFontStyle fontStyle); |
| 120 |
| 121 #ifndef SK_DONT_USE_LEGACY_TYPEFACE_MAKE_FROM_NAME |
103 /** Return the typeface that most closely matches the requested familyName a
nd style. | 122 /** Return the typeface that most closely matches the requested familyName a
nd style. |
104 Pass nullptr as the familyName to request the default font for the reque
sted style. | 123 Pass nullptr as the familyName to request the default font for the reque
sted style. |
105 Will never return nullptr. | 124 Will never return nullptr. |
106 | 125 |
107 @param familyName May be NULL. The name of the font family. | 126 @param familyName May be NULL. The name of the font family. |
108 @param style The style (normal, bold, italic) of the typeface. | 127 @param style The style (normal, bold, italic) of the typeface. |
109 @return the closest-matching typeface. | 128 @return the closest-matching typeface. |
110 */ | 129 */ |
111 static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style); | 130 static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style); |
| 131 #endif |
112 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 132 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
113 static SkTypeface* CreateFromName(const char familyName[], Style style) { | 133 static SkTypeface* CreateFromName(const char familyName[], Style style) { |
114 return MakeFromName(familyName, style).release(); | 134 return MakeFromName(familyName, SkFontStyle::FromOldStyle(style)).releas
e(); |
115 } | 135 } |
116 #endif | 136 #endif |
117 | 137 |
118 /** Return the typeface that most closely matches the requested typeface and
style. | 138 /** Return the typeface that most closely matches the requested typeface and
style. |
119 Use this to pick a new style from the same family of the existing typefa
ce. | 139 Use this to pick a new style from the same family of the existing typefa
ce. |
120 If family is nullptr, this selects from the default font's family. | 140 If family is nullptr, this selects from the default font's family. |
121 | 141 |
122 @param family May be NULL. The name of the existing type face. | 142 @param family May be NULL. The name of the existing type face. |
123 @param s The style (normal, bold, italic) of the type face. | 143 @param s The style (normal, bold, italic) of the type face. |
124 @return the closest-matching typeface. | 144 @return the closest-matching typeface. |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 mutable SkOnce fBoundsOnce; | 449 mutable SkOnce fBoundsOnce; |
430 bool fIsFixedPitch; | 450 bool fIsFixedPitch; |
431 | 451 |
432 friend class SkPaint; | 452 friend class SkPaint; |
433 friend class SkGlyphCache; // GetDefaultTypeface | 453 friend class SkGlyphCache; // GetDefaultTypeface |
434 | 454 |
435 typedef SkWeakRefCnt INHERITED; | 455 typedef SkWeakRefCnt INHERITED; |
436 }; | 456 }; |
437 | 457 |
438 #endif | 458 #endif |
OLD | NEW |