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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 static bool Equal(const SkTypeface* facea, const SkTypeface* faceb); | 93 static bool Equal(const SkTypeface* facea, const SkTypeface* faceb); |
94 | 94 |
95 /** Returns the default typeface, which is never nullptr. */ | 95 /** Returns the default typeface, which is never nullptr. */ |
96 static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); | 96 static sk_sp<SkTypeface> MakeDefault(Style style = SkTypeface::kNormal); |
97 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 97 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
98 static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) { | 98 static SkTypeface* RefDefault(Style style = SkTypeface::kNormal) { |
99 return MakeDefault(style).release(); | 99 return MakeDefault(style).release(); |
100 } | 100 } |
101 #endif | 101 #endif |
102 | 102 |
| 103 /** Creates a new reference to the typeface that most closely matches the |
| 104 requested familyName and fontStyle. This method allows extended font |
| 105 face specifiers as in the SkFontStyle type. Will never return null. |
| 106 |
| 107 @param familyName May be NULL. The name of the font family. |
| 108 @param fontStyle The style of the typeface. |
| 109 @return reference to the closest-matching typeface. Call must call |
| 110 unref() when they are done. |
| 111 */ |
| 112 static sk_sp<SkTypeface> MakeFromName(const char familyName[], |
| 113 SkFontStyle fontStyle); |
| 114 |
| 115 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_MAKE_FROM_NAME |
103 /** Return the typeface that most closely matches the requested familyName a
nd style. | 116 /** 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. | 117 Pass nullptr as the familyName to request the default font for the reque
sted style. |
105 Will never return nullptr. | 118 Will never return nullptr. |
106 | 119 |
107 @param familyName May be NULL. The name of the font family. | 120 @param familyName May be NULL. The name of the font family. |
108 @param style The style (normal, bold, italic) of the typeface. | 121 @param style The style (normal, bold, italic) of the typeface. |
109 @return the closest-matching typeface. | 122 @return the closest-matching typeface. |
110 */ | 123 */ |
111 static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style); | 124 static sk_sp<SkTypeface> MakeFromName(const char familyName[], Style style); |
| 125 #endif |
112 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 126 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
113 static SkTypeface* CreateFromName(const char familyName[], Style style) { | 127 static SkTypeface* CreateFromName(const char familyName[], Style style) { |
114 return MakeFromName(familyName, style).release(); | 128 return MakeFromName(familyName, SkFontStyle::FromOldStyle(style)).releas
e(); |
115 } | 129 } |
116 #endif | 130 #endif |
117 | 131 |
118 /** Return the typeface that most closely matches the requested typeface and
style. | 132 /** 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. | 133 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. | 134 If family is nullptr, this selects from the default font's family. |
121 | 135 |
122 @param family May be NULL. The name of the existing type face. | 136 @param family May be NULL. The name of the existing type face. |
123 @param s The style (normal, bold, italic) of the type face. | 137 @param s The style (normal, bold, italic) of the type face. |
124 @return the closest-matching typeface. | 138 @return the closest-matching typeface. |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 mutable SkOnce fBoundsOnce; | 443 mutable SkOnce fBoundsOnce; |
430 bool fIsFixedPitch; | 444 bool fIsFixedPitch; |
431 | 445 |
432 friend class SkPaint; | 446 friend class SkPaint; |
433 friend class SkGlyphCache; // GetDefaultTypeface | 447 friend class SkGlyphCache; // GetDefaultTypeface |
434 | 448 |
435 typedef SkWeakRefCnt INHERITED; | 449 typedef SkWeakRefCnt INHERITED; |
436 }; | 450 }; |
437 | 451 |
438 #endif | 452 #endif |
OLD | NEW |