Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/ports/SkFontMgr_fontconfig.cpp

Issue 672723002: Extend SkFontMgr_Custom to cover ttc, otf, pfb. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Keep FT_Stream alive, protect library with mutex. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
455 456
456 class StyleSet : public SkFontStyleSet { 457 class StyleSet : public SkFontStyleSet {
457 public: 458 public:
458 /** @param parent does not take ownership of the reference. 459 /** @param parent does not take ownership of the reference.
459 * @param fontSet takes ownership of the reference. 460 * @param fontSet takes ownership of the reference.
460 */ 461 */
461 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet) 462 StyleSet(const SkFontMgr_fontconfig* parent, FcFontSet* fontSet)
462 : fFontMgr(SkRef(parent)), fFontSet(fontSet) 463 : fFontMgr(SkRef(parent)), fFontSet(fontSet)
463 { } 464 { }
464 465
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 821
821 /** @param stream does not take ownership of the reference. */ 822 /** @param stream does not take ownership of the reference. */
822 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { 823 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE {
823 const size_t length = stream->getLength(); 824 const size_t length = stream->getLength();
824 if (length <= 0 || (1u << 30) < length) { 825 if (length <= 0 || (1u << 30) < length) {
825 return NULL; 826 return NULL;
826 } 827 }
827 828
828 SkFontStyle style; 829 SkFontStyle style;
829 bool isFixedWidth = false; 830 bool isFixedWidth = false;
830 if (!SkTypeface_FreeType::ScanFont(stream, ttcIndex, NULL, &style, &isFi xedWidth)) { 831 if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth)) {
831 return NULL; 832 return NULL;
832 } 833 }
833 834
834 return SkNEW_ARGS(SkTypeface_stream, (style, isFixedWidth, ttcIndex, 835 return SkNEW_ARGS(SkTypeface_stream, (style, isFixedWidth, ttcIndex,
835 static_cast<SkStreamAsset*>(stream ))); 836 static_cast<SkStreamAsset*>(stream )));
836 } 837 }
837 838
838 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV ERRIDE { 839 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV ERRIDE {
839 SkAutoTUnref<SkStreamAsset> stream(SkNEW_ARGS(SkMemoryStream, (data))); 840 SkAutoTUnref<SkStreamAsset> stream(SkNEW_ARGS(SkMemoryStream, (data)));
840 return this->createFromStream(stream, ttcIndex); 841 return this->createFromStream(stream, ttcIndex);
(...skipping 18 matching lines...) Expand all
859 return typeface.detach(); 860 return typeface.detach();
860 } 861 }
861 862
862 return this->matchFamilyStyle(NULL, style); 863 return this->matchFamilyStyle(NULL, style);
863 } 864 }
864 }; 865 };
865 866
866 SkFontMgr* SkFontMgr::Factory() { 867 SkFontMgr* SkFontMgr::Factory() {
867 return SkNEW(SkFontMgr_fontconfig); 868 return SkNEW(SkFontMgr_fontconfig);
868 } 869 }
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698