| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 /** Return the typeface that most closely matches the requested typeface and
style. | 120 /** Return the typeface that most closely matches the requested typeface and
style. |
| 121 Use this to pick a new style from the same family of the existing typefa
ce. | 121 Use this to pick a new style from the same family of the existing typefa
ce. |
| 122 If family is nullptr, this selects from the default font's family. | 122 If family is nullptr, this selects from the default font's family. |
| 123 | 123 |
| 124 @param family May be NULL. The name of the existing type face. | 124 @param family May be NULL. The name of the existing type face. |
| 125 @param s The style (normal, bold, italic) of the type face. | 125 @param s The style (normal, bold, italic) of the type face. |
| 126 @return the closest-matching typeface. | 126 @return the closest-matching typeface. |
| 127 */ | 127 */ |
| 128 static sk_sp<SkTypeface> MakeFromTypeface(SkTypeface* family, Style); | 128 static sk_sp<SkTypeface> MakeFromTypeface(SkTypeface* family, Style); |
| 129 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | |
| 130 static SkTypeface* CreateFromTypeface(const SkTypeface* family, Style style)
{ | |
| 131 return MakeFromTypeface(const_cast<SkTypeface*>(family), style).release(
); | |
| 132 } | |
| 133 #endif | |
| 134 | 129 |
| 135 /** Return a new typeface given a file. If the file does not exist, or is | 130 /** Return a new typeface given a file. If the file does not exist, or is |
| 136 not a valid font file, returns nullptr. | 131 not a valid font file, returns nullptr. |
| 137 */ | 132 */ |
| 138 static sk_sp<SkTypeface> MakeFromFile(const char path[], int index = 0); | 133 static sk_sp<SkTypeface> MakeFromFile(const char path[], int index = 0); |
| 139 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 134 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| 140 static SkTypeface* CreateFromFile(const char path[], int index = 0) { | 135 static SkTypeface* CreateFromFile(const char path[], int index = 0) { |
| 141 return MakeFromFile(path, index).release(); | 136 return MakeFromFile(path, index).release(); |
| 142 } | 137 } |
| 143 #endif | 138 #endif |
| 144 | 139 |
| 145 /** Return a new typeface given a stream. If the stream is | 140 /** Return a new typeface given a stream. If the stream is |
| 146 not a valid font file, returns nullptr. Ownership of the stream is | 141 not a valid font file, returns nullptr. Ownership of the stream is |
| 147 transferred, so the caller must not reference it again. | 142 transferred, so the caller must not reference it again. |
| 148 */ | 143 */ |
| 149 static sk_sp<SkTypeface> MakeFromStream(SkStreamAsset* stream, int index = 0
); | 144 static sk_sp<SkTypeface> MakeFromStream(SkStreamAsset* stream, int index = 0
); |
| 150 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | 145 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
| 151 static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0) { | 146 static SkTypeface* CreateFromStream(SkStreamAsset* stream, int index = 0) { |
| 152 return MakeFromStream(stream, index).release(); | 147 return MakeFromStream(stream, index).release(); |
| 153 } | 148 } |
| 154 #endif | 149 #endif |
| 155 | 150 |
| 156 /** Return a new typeface given font data and configuration. If the data | 151 /** Return a new typeface given font data and configuration. If the data |
| 157 is not valid font data, returns nullptr. Ownership of the font data is | 152 is not valid font data, returns nullptr. Ownership of the font data is |
| 158 transferred, so the caller must not reference it again. | 153 transferred, so the caller must not reference it again. |
| 159 */ | 154 */ |
| 160 static sk_sp<SkTypeface> MakeFromFontData(SkFontData*); | 155 static sk_sp<SkTypeface> MakeFromFontData(SkFontData*); |
| 161 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | |
| 162 static SkTypeface* CreateFromFontData(SkFontData* fd) { | |
| 163 return MakeFromFontData(fd).release(); | |
| 164 } | |
| 165 #endif | |
| 166 | 156 |
| 167 /** Write a unique signature to a stream, sufficient to reconstruct a | 157 /** Write a unique signature to a stream, sufficient to reconstruct a |
| 168 typeface referencing the same font when Deserialize is called. | 158 typeface referencing the same font when Deserialize is called. |
| 169 */ | 159 */ |
| 170 void serialize(SkWStream*) const; | 160 void serialize(SkWStream*) const; |
| 171 | 161 |
| 172 /** Given the data previously written by serialize(), return a new instance | 162 /** Given the data previously written by serialize(), return a new instance |
| 173 of a typeface referring to the same font. If that font is not available, | 163 of a typeface referring to the same font. If that font is not available, |
| 174 return nullptr. | 164 return nullptr. |
| 175 Does not affect ownership of SkStream. | 165 Does not affect ownership of SkStream. |
| 176 */ | 166 */ |
| 177 static sk_sp<SkTypeface> MakeDeserialize(SkStream*); | 167 static sk_sp<SkTypeface> MakeDeserialize(SkStream*); |
| 178 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR | |
| 179 static SkTypeface* Deserialize(SkStream* stream) { | |
| 180 return MakeDeserialize(stream).release(); | |
| 181 } | |
| 182 #endif | |
| 183 | 168 |
| 184 enum Encoding { | 169 enum Encoding { |
| 185 kUTF8_Encoding, | 170 kUTF8_Encoding, |
| 186 kUTF16_Encoding, | 171 kUTF16_Encoding, |
| 187 kUTF32_Encoding | 172 kUTF32_Encoding |
| 188 }; | 173 }; |
| 189 | 174 |
| 190 /** | 175 /** |
| 191 * Given an array of character codes, of the specified encoding, | 176 * Given an array of character codes, of the specified encoding, |
| 192 * optionally return their corresponding glyph IDs (if glyphs is not NULL). | 177 * optionally return their corresponding glyph IDs (if glyphs is not NULL). |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 mutable SkOnce fBoundsOnce; | 416 mutable SkOnce fBoundsOnce; |
| 432 bool fIsFixedPitch; | 417 bool fIsFixedPitch; |
| 433 | 418 |
| 434 friend class SkPaint; | 419 friend class SkPaint; |
| 435 friend class SkGlyphCache; // GetDefaultTypeface | 420 friend class SkGlyphCache; // GetDefaultTypeface |
| 436 | 421 |
| 437 typedef SkWeakRefCnt INHERITED; | 422 typedef SkWeakRefCnt INHERITED; |
| 438 }; | 423 }; |
| 439 | 424 |
| 440 #endif | 425 #endif |
| OLD | NEW |