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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 FcPatternReference(pattern); | 583 FcPatternReference(pattern); |
584 face = SkTypeface_fontconfig::Create(pattern); | 584 face = SkTypeface_fontconfig::Create(pattern); |
585 if (face) { | 585 if (face) { |
586 fTFCache.add(face, SkFontStyle()); | 586 fTFCache.add(face, SkFontStyle()); |
587 } | 587 } |
588 } | 588 } |
589 return face; | 589 return face; |
590 } | 590 } |
591 | 591 |
592 public: | 592 public: |
593 SkFontMgr_fontconfig() | |
594 : fFC(FcInitLoadConfigAndFonts()) | |
595 , fFamilyNames(GetFamilyNames(fFC)) { } | |
596 | |
597 /** Takes control of the reference to 'config'. */ | 593 /** Takes control of the reference to 'config'. */ |
598 explicit SkFontMgr_fontconfig(FcConfig* config) | 594 explicit SkFontMgr_fontconfig(FcConfig* config) |
599 : fFC(config) | 595 : fFC(config ? config : FcInitLoadConfigAndFonts()) |
600 , fFamilyNames(GetFamilyNames(fFC)) { } | 596 , fFamilyNames(GetFamilyNames(fFC)) { } |
601 | 597 |
602 virtual ~SkFontMgr_fontconfig() { | 598 virtual ~SkFontMgr_fontconfig() { |
603 // Hold the lock while unrefing the config. | 599 // Hold the lock while unrefing the config. |
604 FCLocker lock; | 600 FCLocker lock; |
605 fFC.reset(); | 601 fFC.reset(); |
606 } | 602 } |
607 | 603 |
608 protected: | 604 protected: |
609 int onCountFamilies() const override { | 605 int onCountFamilies() const override { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 : SkFontStyle::kUpright_Slant); | 862 : SkFontStyle::kUpright_Slant); |
867 SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, sty
le)); | 863 SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, sty
le)); |
868 if (typeface.get()) { | 864 if (typeface.get()) { |
869 return typeface.detach(); | 865 return typeface.detach(); |
870 } | 866 } |
871 | 867 |
872 return this->matchFamilyStyle(NULL, style); | 868 return this->matchFamilyStyle(NULL, style); |
873 } | 869 } |
874 }; | 870 }; |
875 | 871 |
876 SkFontMgr* SkFontMgr::Factory() { | 872 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { |
877 return SkNEW(SkFontMgr_fontconfig); | 873 return new SkFontMgr_fontconfig(fc); |
878 } | 874 } |
OLD | NEW |