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 #include "SkFontDescriptor.h" | 8 #include "SkFontDescriptor.h" |
9 #include "SkFontHost_FreeType_common.h" | 9 #include "SkFontHost_FreeType_common.h" |
10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 }; | 56 }; |
57 | 57 |
58 /** The empty SkTypeface implementation for the custom font manager. | 58 /** The empty SkTypeface implementation for the custom font manager. |
59 * Used as the last resort fallback typeface. | 59 * Used as the last resort fallback typeface. |
60 */ | 60 */ |
61 class SkTypeface_Empty : public SkTypeface_Custom { | 61 class SkTypeface_Empty : public SkTypeface_Custom { |
62 public: | 62 public: |
63 SkTypeface_Empty() : INHERITED(SkFontStyle(), false, true, SkString(), 0) {} | 63 SkTypeface_Empty() : INHERITED(SkFontStyle(), false, true, SkString(), 0) {} |
64 | 64 |
65 protected: | 65 protected: |
66 SkStreamAsset* onOpenStream(int*) const override { return NULL; } | 66 SkStreamAsset* onOpenStream(int*) const override { return nullptr; } |
67 | 67 |
68 private: | 68 private: |
69 typedef SkTypeface_Custom INHERITED; | 69 typedef SkTypeface_Custom INHERITED; |
70 }; | 70 }; |
71 | 71 |
72 /** The stream SkTypeface implementation for the custom font manager. */ | 72 /** The stream SkTypeface implementation for the custom font manager. */ |
73 class SkTypeface_Stream : public SkTypeface_Custom { | 73 class SkTypeface_Stream : public SkTypeface_Custom { |
74 public: | 74 public: |
75 SkTypeface_Stream(const SkFontStyle& style, bool isFixedPitch, bool sysFont, | 75 SkTypeface_Stream(const SkFontStyle& style, bool isFixedPitch, bool sysFont, |
76 const SkString familyName, SkStreamAsset* stream, int inde
x) | 76 const SkString familyName, SkStreamAsset* stream, int inde
x) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid
ate) { | 149 static int match_score(const SkFontStyle& pattern, const SkFontStyle& candid
ate) { |
150 int score = 0; | 150 int score = 0; |
151 score += (pattern.width() - candidate.width()) * 100; | 151 score += (pattern.width() - candidate.width()) * 100; |
152 score += (pattern.isItalic() == candidate.isItalic()) ? 0 : 1000; | 152 score += (pattern.isItalic() == candidate.isItalic()) ? 0 : 1000; |
153 score += pattern.weight() - candidate.weight(); | 153 score += pattern.weight() - candidate.weight(); |
154 return score; | 154 return score; |
155 } | 155 } |
156 | 156 |
157 SkTypeface* matchStyle(const SkFontStyle& pattern) override { | 157 SkTypeface* matchStyle(const SkFontStyle& pattern) override { |
158 if (0 == fStyles.count()) { | 158 if (0 == fStyles.count()) { |
159 return NULL; | 159 return nullptr; |
160 } | 160 } |
161 | 161 |
162 SkTypeface_Custom* closest = fStyles[0]; | 162 SkTypeface_Custom* closest = fStyles[0]; |
163 int minScore = std::numeric_limits<int>::max(); | 163 int minScore = std::numeric_limits<int>::max(); |
164 for (int i = 0; i < fStyles.count(); ++i) { | 164 for (int i = 0; i < fStyles.count(); ++i) { |
165 bool bold = fStyles[i]->isBold(); | 165 bool bold = fStyles[i]->isBold(); |
166 bool italic = fStyles[i]->isItalic(); | 166 bool italic = fStyles[i]->isItalic(); |
167 SkFontStyle style = SkFontStyle(bold ? SkFontStyle::kBold_Weight | 167 SkFontStyle style = SkFontStyle(bold ? SkFontStyle::kBold_Weight |
168 : SkFontStyle::kNormal_Weight, | 168 : SkFontStyle::kNormal_Weight, |
169 SkFontStyle::kNormal_Width, | 169 SkFontStyle::kNormal_Width, |
(...skipping 26 matching lines...) Expand all Loading... |
196 * to load fonts from any source by changing the initialization. | 196 * to load fonts from any source by changing the initialization. |
197 */ | 197 */ |
198 class SkFontMgr_Custom : public SkFontMgr { | 198 class SkFontMgr_Custom : public SkFontMgr { |
199 public: | 199 public: |
200 typedef SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> Families; | 200 typedef SkTArray<SkAutoTUnref<SkFontStyleSet_Custom>, true> Families; |
201 class SystemFontLoader { | 201 class SystemFontLoader { |
202 public: | 202 public: |
203 virtual ~SystemFontLoader() { } | 203 virtual ~SystemFontLoader() { } |
204 virtual void loadSystemFonts(const SkTypeface_FreeType::Scanner&, Famili
es*) const = 0; | 204 virtual void loadSystemFonts(const SkTypeface_FreeType::Scanner&, Famili
es*) const = 0; |
205 }; | 205 }; |
206 explicit SkFontMgr_Custom(const SystemFontLoader& loader) : fDefaultFamily(N
ULL) { | 206 explicit SkFontMgr_Custom(const SystemFontLoader& loader) : fDefaultFamily(n
ullptr) { |
207 loader.loadSystemFonts(fScanner, &fFamilies); | 207 loader.loadSystemFonts(fScanner, &fFamilies); |
208 | 208 |
209 // Try to pick a default font. | 209 // Try to pick a default font. |
210 static const char* defaultNames[] = { | 210 static const char* defaultNames[] = { |
211 "Arial", "Verdana", "Times New Roman", "Droid Sans", NULL | 211 "Arial", "Verdana", "Times New Roman", "Droid Sans", nullptr |
212 }; | 212 }; |
213 for (size_t i = 0; i < SK_ARRAY_COUNT(defaultNames); ++i) { | 213 for (size_t i = 0; i < SK_ARRAY_COUNT(defaultNames); ++i) { |
214 SkFontStyleSet_Custom* set = this->onMatchFamily(defaultNames[i]); | 214 SkFontStyleSet_Custom* set = this->onMatchFamily(defaultNames[i]); |
215 if (NULL == set) { | 215 if (nullptr == set) { |
216 continue; | 216 continue; |
217 } | 217 } |
218 | 218 |
219 SkTypeface* tf = set->matchStyle(SkFontStyle(SkFontStyle::kNormal_We
ight, | 219 SkTypeface* tf = set->matchStyle(SkFontStyle(SkFontStyle::kNormal_We
ight, |
220 SkFontStyle::kNormal_Wi
dth, | 220 SkFontStyle::kNormal_Wi
dth, |
221 SkFontStyle::kUpright_S
lant)); | 221 SkFontStyle::kUpright_S
lant)); |
222 if (NULL == tf) { | 222 if (nullptr == tf) { |
223 continue; | 223 continue; |
224 } | 224 } |
225 | 225 |
226 fDefaultFamily = set; | 226 fDefaultFamily = set; |
227 break; | 227 break; |
228 } | 228 } |
229 if (NULL == fDefaultFamily) { | 229 if (nullptr == fDefaultFamily) { |
230 fDefaultFamily = fFamilies[0]; | 230 fDefaultFamily = fFamilies[0]; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 protected: | 234 protected: |
235 int onCountFamilies() const override { | 235 int onCountFamilies() const override { |
236 return fFamilies.count(); | 236 return fFamilies.count(); |
237 } | 237 } |
238 | 238 |
239 void onGetFamilyName(int index, SkString* familyName) const override { | 239 void onGetFamilyName(int index, SkString* familyName) const override { |
240 SkASSERT(index < fFamilies.count()); | 240 SkASSERT(index < fFamilies.count()); |
241 familyName->set(fFamilies[index]->getFamilyName()); | 241 familyName->set(fFamilies[index]->getFamilyName()); |
242 } | 242 } |
243 | 243 |
244 SkFontStyleSet_Custom* onCreateStyleSet(int index) const override { | 244 SkFontStyleSet_Custom* onCreateStyleSet(int index) const override { |
245 SkASSERT(index < fFamilies.count()); | 245 SkASSERT(index < fFamilies.count()); |
246 return SkRef(fFamilies[index].get()); | 246 return SkRef(fFamilies[index].get()); |
247 } | 247 } |
248 | 248 |
249 SkFontStyleSet_Custom* onMatchFamily(const char familyName[]) const override
{ | 249 SkFontStyleSet_Custom* onMatchFamily(const char familyName[]) const override
{ |
250 for (int i = 0; i < fFamilies.count(); ++i) { | 250 for (int i = 0; i < fFamilies.count(); ++i) { |
251 if (fFamilies[i]->getFamilyName().equals(familyName)) { | 251 if (fFamilies[i]->getFamilyName().equals(familyName)) { |
252 return SkRef(fFamilies[i].get()); | 252 return SkRef(fFamilies[i].get()); |
253 } | 253 } |
254 } | 254 } |
255 return NULL; | 255 return nullptr; |
256 } | 256 } |
257 | 257 |
258 SkTypeface* onMatchFamilyStyle(const char familyName[], | 258 SkTypeface* onMatchFamilyStyle(const char familyName[], |
259 const SkFontStyle& fontStyle) const override | 259 const SkFontStyle& fontStyle) const override |
260 { | 260 { |
261 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); | 261 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); |
262 return sset->matchStyle(fontStyle); | 262 return sset->matchStyle(fontStyle); |
263 } | 263 } |
264 | 264 |
265 SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFon
tStyle&, | 265 SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFon
tStyle&, |
266 const char* bcp47[], int bcp47Count, | 266 const char* bcp47[], int bcp47Count, |
267 SkUnichar character) const override | 267 SkUnichar character) const override |
268 { | 268 { |
269 return NULL; | 269 return nullptr; |
270 } | 270 } |
271 | 271 |
272 SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 272 SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, |
273 const SkFontStyle& fontStyle) const override | 273 const SkFontStyle& fontStyle) const override |
274 { | 274 { |
275 for (int i = 0; i < fFamilies.count(); ++i) { | 275 for (int i = 0; i < fFamilies.count(); ++i) { |
276 for (int j = 0; j < fFamilies[i]->fStyles.count(); ++j) { | 276 for (int j = 0; j < fFamilies[i]->fStyles.count(); ++j) { |
277 if (fFamilies[i]->fStyles[j] == familyMember) { | 277 if (fFamilies[i]->fStyles[j] == familyMember) { |
278 return fFamilies[i]->matchStyle(fontStyle); | 278 return fFamilies[i]->matchStyle(fontStyle); |
279 } | 279 } |
280 } | 280 } |
281 } | 281 } |
282 return NULL; | 282 return nullptr; |
283 } | 283 } |
284 | 284 |
285 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { | 285 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { |
286 return this->createFromStream(new SkMemoryStream(data), ttcIndex); | 286 return this->createFromStream(new SkMemoryStream(data), ttcIndex); |
287 } | 287 } |
288 | 288 |
289 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons
t override { | 289 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons
t override { |
290 SkAutoTDelete<SkStreamAsset> stream(bareStream); | 290 SkAutoTDelete<SkStreamAsset> stream(bareStream); |
291 if (NULL == stream || stream->getLength() <= 0) { | 291 if (nullptr == stream || stream->getLength() <= 0) { |
292 return NULL; | 292 return nullptr; |
293 } | 293 } |
294 | 294 |
295 bool isFixedPitch; | 295 bool isFixedPitch; |
296 SkFontStyle style; | 296 SkFontStyle style; |
297 SkString name; | 297 SkString name; |
298 if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, NU
LL)) { | 298 if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, nu
llptr)) { |
299 return new SkTypeface_Stream(style, isFixedPitch, false, name, strea
m.detach(), | 299 return new SkTypeface_Stream(style, isFixedPitch, false, name, strea
m.detach(), |
300 ttcIndex); | 300 ttcIndex); |
301 } else { | 301 } else { |
302 return NULL; | 302 return nullptr; |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ | 306 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ |
307 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); | 307 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); |
308 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex)
: NULL; | 308 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex)
: nullptr; |
309 } | 309 } |
310 | 310 |
311 SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBi
ts) const override { | 311 SkTypeface* onLegacyCreateTypeface(const char familyName[], unsigned styleBi
ts) const override { |
312 SkTypeface::Style oldStyle = (SkTypeface::Style)styleBits; | 312 SkTypeface::Style oldStyle = (SkTypeface::Style)styleBits; |
313 SkFontStyle style = SkFontStyle(oldStyle & SkTypeface::kBold | 313 SkFontStyle style = SkFontStyle(oldStyle & SkTypeface::kBold |
314 ? SkFontStyle::kBold_Weight | 314 ? SkFontStyle::kBold_Weight |
315 : SkFontStyle::kNormal_Weight, | 315 : SkFontStyle::kNormal_Weight, |
316 SkFontStyle::kNormal_Width, | 316 SkFontStyle::kNormal_Width, |
317 oldStyle & SkTypeface::kItalic | 317 oldStyle & SkTypeface::kItalic |
318 ? SkFontStyle::kItalic_Slant | 318 ? SkFontStyle::kItalic_Slant |
319 : SkFontStyle::kUpright_Slant); | 319 : SkFontStyle::kUpright_Slant); |
320 SkTypeface* tf = NULL; | 320 SkTypeface* tf = nullptr; |
321 | 321 |
322 if (familyName) { | 322 if (familyName) { |
323 tf = this->onMatchFamilyStyle(familyName, style); | 323 tf = this->onMatchFamilyStyle(familyName, style); |
324 } | 324 } |
325 | 325 |
326 if (NULL == tf) { | 326 if (nullptr == tf) { |
327 tf = fDefaultFamily->matchStyle(style); | 327 tf = fDefaultFamily->matchStyle(style); |
328 } | 328 } |
329 | 329 |
330 return SkSafeRef(tf); | 330 return SkSafeRef(tf); |
331 } | 331 } |
332 | 332 |
333 private: | 333 private: |
334 Families fFamilies; | 334 Families fFamilies; |
335 SkFontStyleSet_Custom* fDefaultFamily; | 335 SkFontStyleSet_Custom* fDefaultFamily; |
336 SkTypeface_FreeType::Scanner fScanner; | 336 SkTypeface_FreeType::Scanner fScanner; |
(...skipping 22 matching lines...) Expand all Loading... |
359 | 359 |
360 private: | 360 private: |
361 static SkFontStyleSet_Custom* find_family(SkFontMgr_Custom::Families& famili
es, | 361 static SkFontStyleSet_Custom* find_family(SkFontMgr_Custom::Families& famili
es, |
362 const char familyName[]) | 362 const char familyName[]) |
363 { | 363 { |
364 for (int i = 0; i < families.count(); ++i) { | 364 for (int i = 0; i < families.count(); ++i) { |
365 if (families[i]->getFamilyName().equals(familyName)) { | 365 if (families[i]->getFamilyName().equals(familyName)) { |
366 return families[i].get(); | 366 return families[i].get(); |
367 } | 367 } |
368 } | 368 } |
369 return NULL; | 369 return nullptr; |
370 } | 370 } |
371 | 371 |
372 static void load_directory_fonts(const SkTypeface_FreeType::Scanner& scanner
, | 372 static void load_directory_fonts(const SkTypeface_FreeType::Scanner& scanner
, |
373 const SkString& directory, const char* suff
ix, | 373 const SkString& directory, const char* suff
ix, |
374 SkFontMgr_Custom::Families* families) | 374 SkFontMgr_Custom::Families* families) |
375 { | 375 { |
376 SkOSFile::Iter iter(directory.c_str(), suffix); | 376 SkOSFile::Iter iter(directory.c_str(), suffix); |
377 SkString name; | 377 SkString name; |
378 | 378 |
379 while (iter.next(&name, false)) { | 379 while (iter.next(&name, false)) { |
380 SkString filename(SkOSPath::Join(directory.c_str(), name.c_str())); | 380 SkString filename(SkOSPath::Join(directory.c_str(), name.c_str())); |
381 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(filename.c_str(
))); | 381 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(filename.c_str(
))); |
382 if (!stream.get()) { | 382 if (!stream.get()) { |
383 SkDebugf("---- failed to open <%s>\n", filename.c_str()); | 383 SkDebugf("---- failed to open <%s>\n", filename.c_str()); |
384 continue; | 384 continue; |
385 } | 385 } |
386 | 386 |
387 int numFaces; | 387 int numFaces; |
388 if (!scanner.recognizedFont(stream, &numFaces)) { | 388 if (!scanner.recognizedFont(stream, &numFaces)) { |
389 SkDebugf("---- failed to open <%s> as a font\n", filename.c_str(
)); | 389 SkDebugf("---- failed to open <%s> as a font\n", filename.c_str(
)); |
390 continue; | 390 continue; |
391 } | 391 } |
392 | 392 |
393 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { | 393 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { |
394 bool isFixedPitch; | 394 bool isFixedPitch; |
395 SkString realname; | 395 SkString realname; |
396 SkFontStyle style = SkFontStyle(); // avoid uninitialized warnin
g | 396 SkFontStyle style = SkFontStyle(); // avoid uninitialized warnin
g |
397 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isF
ixedPitch, NULL)) { | 397 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isF
ixedPitch, nullptr)) { |
398 SkDebugf("---- failed to open <%s> <%d> as a font\n", | 398 SkDebugf("---- failed to open <%s> <%d> as a font\n", |
399 filename.c_str(), faceIndex); | 399 filename.c_str(), faceIndex); |
400 continue; | 400 continue; |
401 } | 401 } |
402 | 402 |
403 SkTypeface_Custom* tf = new SkTypeface_File(style, isFixedPitch, | 403 SkTypeface_Custom* tf = new SkTypeface_File(style, isFixedPitch, |
404 true, // system-fon
t (cannot delete) | 404 true, // system-fon
t (cannot delete) |
405 realname, filename.c
_str(), faceIndex); | 405 realname, filename.c
_str(), faceIndex); |
406 | 406 |
407 SkFontStyleSet_Custom* addTo = find_family(*families, realname.c
_str()); | 407 SkFontStyleSet_Custom* addTo = find_family(*families, realname.c
_str()); |
408 if (NULL == addTo) { | 408 if (nullptr == addTo) { |
409 addTo = new SkFontStyleSet_Custom(realname); | 409 addTo = new SkFontStyleSet_Custom(realname); |
410 families->push_back().reset(addTo); | 410 families->push_back().reset(addTo); |
411 } | 411 } |
412 addTo->appendTypeface(tf); | 412 addTo->appendTypeface(tf); |
413 } | 413 } |
414 } | 414 } |
415 | 415 |
416 SkOSFile::Iter dirIter(directory.c_str()); | 416 SkOSFile::Iter dirIter(directory.c_str()); |
417 while (dirIter.next(&name, true)) { | 417 while (dirIter.next(&name, true)) { |
418 if (name.startsWith(".")) { | 418 if (name.startsWith(".")) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 private: | 457 private: |
458 static SkFontStyleSet_Custom* find_family(SkFontMgr_Custom::Families& famili
es, | 458 static SkFontStyleSet_Custom* find_family(SkFontMgr_Custom::Families& famili
es, |
459 const char familyName[]) | 459 const char familyName[]) |
460 { | 460 { |
461 for (int i = 0; i < families.count(); ++i) { | 461 for (int i = 0; i < families.count(); ++i) { |
462 if (families[i]->getFamilyName().equals(familyName)) { | 462 if (families[i]->getFamilyName().equals(familyName)) { |
463 return families[i].get(); | 463 return families[i].get(); |
464 } | 464 } |
465 } | 465 } |
466 return NULL; | 466 return nullptr; |
467 } | 467 } |
468 | 468 |
469 static void load_embedded_font(const SkTypeface_FreeType::Scanner& scanner, | 469 static void load_embedded_font(const SkTypeface_FreeType::Scanner& scanner, |
470 const uint8_t* data, size_t size, int index, | 470 const uint8_t* data, size_t size, int index, |
471 SkFontMgr_Custom::Families* families) | 471 SkFontMgr_Custom::Families* families) |
472 { | 472 { |
473 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(data, size, fals
e)); | 473 SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(data, size, fals
e)); |
474 | 474 |
475 int numFaces; | 475 int numFaces; |
476 if (!scanner.recognizedFont(stream, &numFaces)) { | 476 if (!scanner.recognizedFont(stream, &numFaces)) { |
477 SkDebugf("---- failed to open <%d> as a font\n", index); | 477 SkDebugf("---- failed to open <%d> as a font\n", index); |
478 return; | 478 return; |
479 } | 479 } |
480 | 480 |
481 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { | 481 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { |
482 bool isFixedPitch; | 482 bool isFixedPitch; |
483 SkString realname; | 483 SkString realname; |
484 SkFontStyle style = SkFontStyle(); // avoid uninitialized warning | 484 SkFontStyle style = SkFontStyle(); // avoid uninitialized warning |
485 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixed
Pitch, NULL)) { | 485 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixed
Pitch, nullptr)) { |
486 SkDebugf("---- failed to open <%d> <%d> as a font\n", index, fac
eIndex); | 486 SkDebugf("---- failed to open <%d> <%d> as a font\n", index, fac
eIndex); |
487 return; | 487 return; |
488 } | 488 } |
489 | 489 |
490 SkTypeface_Custom* tf = | 490 SkTypeface_Custom* tf = |
491 new SkTypeface_Stream(style, isFixedPitch, true, // system-
font (cannot delete) | 491 new SkTypeface_Stream(style, isFixedPitch, true, // system-
font (cannot delete) |
492 realname, stream.detach(), faceIndex); | 492 realname, stream.detach(), faceIndex); |
493 | 493 |
494 SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str
()); | 494 SkFontStyleSet_Custom* addTo = find_family(*families, realname.c_str
()); |
495 if (NULL == addTo) { | 495 if (nullptr == addTo) { |
496 addTo = new SkFontStyleSet_Custom(realname); | 496 addTo = new SkFontStyleSet_Custom(realname); |
497 families->push_back().reset(addTo); | 497 families->push_back().reset(addTo); |
498 } | 498 } |
499 addTo->appendTypeface(tf); | 499 addTo->appendTypeface(tf); |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 const SkEmbeddedResourceHeader* fHeader; | 503 const SkEmbeddedResourceHeader* fHeader; |
504 }; | 504 }; |
505 | 505 |
506 SkFontMgr* SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header)
{ | 506 SkFontMgr* SkFontMgr_New_Custom_Embedded(const SkEmbeddedResourceHeader* header)
{ |
507 return new SkFontMgr_Custom(EmbeddedSystemFontLoader(header)); | 507 return new SkFontMgr_Custom(EmbeddedSystemFontLoader(header)); |
508 } | 508 } |
OLD | NEW |