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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 FC_PROPORTIONAL != get_int(pattern, FC_SPACING, FC_PROPORTIO
NAL)) | 445 FC_PROPORTIONAL != get_int(pattern, FC_SPACING, FC_PROPORTIO
NAL)) |
446 , fPattern(pattern) | 446 , fPattern(pattern) |
447 { }; | 447 { }; |
448 | 448 |
449 typedef SkTypeface_FreeType INHERITED; | 449 typedef SkTypeface_FreeType INHERITED; |
450 }; | 450 }; |
451 | 451 |
452 class SkFontMgr_fontconfig : public SkFontMgr { | 452 class SkFontMgr_fontconfig : public SkFontMgr { |
453 mutable SkAutoFcConfig fFC; | 453 mutable SkAutoFcConfig fFC; |
454 SkAutoTUnref<SkDataTable> fFamilyNames; | 454 SkAutoTUnref<SkDataTable> fFamilyNames; |
455 SkTypeface_FreeType::Scanner fScanner; | |
456 | 455 |
457 class StyleSet : public SkFontStyleSet { | 456 class StyleSet : public SkFontStyleSet { |
458 public: | 457 public: |
459 /** @param parent does not take ownership of the reference. | 458 /** @param parent does not take ownership of the reference. |
460 * @param fontSet takes ownership of the reference. | 459 * @param fontSet takes ownership of the reference. |
461 */ | 460 */ |
462 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet) | 461 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet) |
463 : fFontMgr(SkRef(parent)), fFontSet(fontSet) | 462 : fFontMgr(SkRef(parent)), fFontSet(fontSet) |
464 { } | 463 { } |
465 | 464 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 820 |
822 /** @param stream does not take ownership of the reference. */ | 821 /** @param stream does not take ownership of the reference. */ |
823 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const
SK_OVERRIDE { | 822 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const
SK_OVERRIDE { |
824 const size_t length = stream->getLength(); | 823 const size_t length = stream->getLength(); |
825 if (length <= 0 || (1u << 30) < length) { | 824 if (length <= 0 || (1u << 30) < length) { |
826 return NULL; | 825 return NULL; |
827 } | 826 } |
828 | 827 |
829 SkFontStyle style; | 828 SkFontStyle style; |
830 bool isFixedWidth = false; | 829 bool isFixedWidth = false; |
831 if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth)) { | 830 if (!SkTypeface_FreeType::ScanFont(stream, ttcIndex, NULL, &style, &isFi
xedWidth)) { |
832 return NULL; | 831 return NULL; |
833 } | 832 } |
834 | 833 |
835 return SkNEW_ARGS(SkTypeface_stream, (style, isFixedWidth, ttcIndex, | 834 return SkNEW_ARGS(SkTypeface_stream, (style, isFixedWidth, ttcIndex, |
836 static_cast<SkStreamAsset*>(stream
))); | 835 static_cast<SkStreamAsset*>(stream
))); |
837 } | 836 } |
838 | 837 |
839 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV
ERRIDE { | 838 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV
ERRIDE { |
840 SkAutoTUnref<SkStreamAsset> stream(SkNEW_ARGS(SkMemoryStream, (data))); | 839 SkAutoTUnref<SkStreamAsset> stream(SkNEW_ARGS(SkMemoryStream, (data))); |
841 return this->createFromStream(stream, ttcIndex); | 840 return this->createFromStream(stream, ttcIndex); |
(...skipping 18 matching lines...) Expand all Loading... |
860 return typeface.detach(); | 859 return typeface.detach(); |
861 } | 860 } |
862 | 861 |
863 return this->matchFamilyStyle(NULL, style); | 862 return this->matchFamilyStyle(NULL, style); |
864 } | 863 } |
865 }; | 864 }; |
866 | 865 |
867 SkFontMgr* SkFontMgr::Factory() { | 866 SkFontMgr* SkFontMgr::Factory() { |
868 return SkNEW(SkFontMgr_fontconfig); | 867 return SkNEW(SkFontMgr_fontconfig); |
869 } | 868 } |
OLD | NEW |