OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 "SkDataTable.h" | 8 #include "SkDataTable.h" |
9 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
10 #include "SkFontHost_FreeType_common.h" | 10 #include "SkFontHost_FreeType_common.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 class SkTypeface_stream : public SkTypeface_FreeType { | 383 class SkTypeface_stream : public SkTypeface_FreeType { |
384 public: | 384 public: |
385 /** @param stream does not take ownership of the reference, does take owners
hip of the stream.*/ | 385 /** @param stream does not take ownership of the reference, does take owners
hip of the stream.*/ |
386 SkTypeface_stream(SkTypeface::Style style, bool fixedWidth, int ttcIndex, Sk
StreamAsset* stream) | 386 SkTypeface_stream(SkTypeface::Style style, bool fixedWidth, int ttcIndex, Sk
StreamAsset* stream) |
387 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) | 387 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) |
388 , fStream(SkRef(stream)) | 388 , fStream(SkRef(stream)) |
389 , fIndex(ttcIndex) | 389 , fIndex(ttcIndex) |
390 { }; | 390 { }; |
391 | 391 |
| 392 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE { |
| 393 familyName->reset(); |
| 394 } |
| 395 |
392 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co
nst SK_OVERRIDE { | 396 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co
nst SK_OVERRIDE { |
393 desc->setStyle(this->style()); | 397 desc->setStyle(this->style()); |
394 *serialize = true; | 398 *serialize = true; |
395 } | 399 } |
396 | 400 |
397 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { | 401 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { |
398 *ttcIndex = fIndex; | 402 *ttcIndex = fIndex; |
399 return fStream->duplicate(); | 403 return fStream->duplicate(); |
400 } | 404 } |
401 | 405 |
402 private: | 406 private: |
403 SkAutoTUnref<SkStreamAsset> fStream; | 407 SkAutoTUnref<SkStreamAsset> fStream; |
404 int fIndex; | 408 int fIndex; |
405 | 409 |
406 typedef SkTypeface_FreeType INHERITED; | 410 typedef SkTypeface_FreeType INHERITED; |
407 }; | 411 }; |
408 | 412 |
409 class SkTypeface_fontconfig : public SkTypeface_FreeType { | 413 class SkTypeface_fontconfig : public SkTypeface_FreeType { |
410 public: | 414 public: |
411 /** @param pattern takes ownership of the reference. */ | 415 /** @param pattern takes ownership of the reference. */ |
412 static SkTypeface_fontconfig* Create(FcPattern* pattern) { | 416 static SkTypeface_fontconfig* Create(FcPattern* pattern) { |
413 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern)); | 417 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern)); |
414 } | 418 } |
415 mutable SkAutoFcPattern fPattern; | 419 mutable SkAutoFcPattern fPattern; |
416 | 420 |
| 421 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE { |
| 422 *familyName = get_string(fPattern, FC_FAMILY); |
| 423 } |
| 424 |
417 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co
nst SK_OVERRIDE { | 425 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co
nst SK_OVERRIDE { |
418 FCLocker lock; | 426 FCLocker lock; |
419 desc->setFamilyName(get_string(fPattern, FC_FAMILY)); | 427 desc->setFamilyName(get_string(fPattern, FC_FAMILY)); |
420 desc->setFontFileName(get_string(fPattern, FC_FILE)); | 428 desc->setFontFileName(get_string(fPattern, FC_FILE)); |
421 desc->setFullName(get_string(fPattern, FC_FULLNAME)); | 429 desc->setFullName(get_string(fPattern, FC_FULLNAME)); |
422 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME)); | 430 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME)); |
423 desc->setStyle(this->style()); | 431 desc->setStyle(this->style()); |
424 *serialize = false; | 432 *serialize = false; |
425 } | 433 } |
426 | 434 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 return typeface.detach(); | 856 return typeface.detach(); |
849 } | 857 } |
850 | 858 |
851 return this->matchFamilyStyle(NULL, style); | 859 return this->matchFamilyStyle(NULL, style); |
852 } | 860 } |
853 }; | 861 }; |
854 | 862 |
855 SkFontMgr* SkFontMgr::Factory() { | 863 SkFontMgr* SkFontMgr::Factory() { |
856 return SkNEW(SkFontMgr_fontconfig); | 864 return SkNEW(SkFontMgr_fontconfig); |
857 } | 865 } |
OLD | NEW |