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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 755 |
756 FcResult result; | 756 FcResult result; |
757 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); | 757 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); |
758 if (NULL == font || !FontAccessible(font) || !FontFamilyNameMatches(font
, matchPattern)) { | 758 if (NULL == font || !FontAccessible(font) || !FontFamilyNameMatches(font
, matchPattern)) { |
759 return NULL; | 759 return NULL; |
760 } | 760 } |
761 | 761 |
762 return createTypefaceFromFcPattern(font); | 762 return createTypefaceFromFcPattern(font); |
763 } | 763 } |
764 | 764 |
| 765 #ifdef SK_FM_NEW_MATCH_FAMILY_STYLE_CHARACTER |
765 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], | 766 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
766 const SkFontStyle& style, | 767 const SkFontStyle& style, |
767 const char bpc47[], | 768 const char* bcp47[], |
768 uint32_t character) const SK
_OVERRIDE | 769 int bcp47Count, |
| 770 SkUnichar character) const S
K_OVERRIDE |
769 { | 771 { |
| 772 #else |
| 773 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
| 774 const SkFontStyle& style, |
| 775 const char bcp47_val[], |
| 776 SkUnichar character) const S
K_OVERRIDE |
| 777 { |
| 778 const char** bcp47 = &bcp47_val; |
| 779 int bcp47Count = bcp47_val ? 1 : 0; |
| 780 #endif |
770 FCLocker lock; | 781 FCLocker lock; |
771 | 782 |
772 SkAutoFcPattern pattern; | 783 SkAutoFcPattern pattern; |
773 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); | 784 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); |
774 fcpattern_from_skfontstyle(style, pattern); | 785 fcpattern_from_skfontstyle(style, pattern); |
775 | 786 |
776 SkAutoFcCharSet charSet; | 787 SkAutoFcCharSet charSet; |
777 FcCharSetAddChar(charSet, character); | 788 FcCharSetAddChar(charSet, character); |
778 FcPatternAddCharSet(pattern, FC_CHARSET, charSet); | 789 FcPatternAddCharSet(pattern, FC_CHARSET, charSet); |
779 | 790 |
780 if (bpc47) { | 791 if (bcp47Count > 0) { |
| 792 SkASSERT(bcp47); |
781 SkAutoFcLangSet langSet; | 793 SkAutoFcLangSet langSet; |
782 FcLangSetAdd(langSet, (const FcChar8*)bpc47); | 794 for (int i = bcp47Count; i --> 0;) { |
| 795 FcLangSetAdd(langSet, (const FcChar8*)bcp47[i]); |
| 796 } |
783 FcPatternAddLangSet(pattern, FC_LANG, langSet); | 797 FcPatternAddLangSet(pattern, FC_LANG, langSet); |
784 } | 798 } |
785 | 799 |
786 FcConfigSubstitute(fFC, pattern, FcMatchPattern); | 800 FcConfigSubstitute(fFC, pattern, FcMatchPattern); |
787 FcDefaultSubstitute(pattern); | 801 FcDefaultSubstitute(pattern); |
788 | 802 |
789 FcResult result; | 803 FcResult result; |
790 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); | 804 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); |
791 if (NULL == font || !FontAccessible(font) || !FontContainsCharacter(font
, character)) { | 805 if (NULL == font || !FontAccessible(font) || !FontContainsCharacter(font
, character)) { |
792 return NULL; | 806 return NULL; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 return typeface.detach(); | 859 return typeface.detach(); |
846 } | 860 } |
847 | 861 |
848 return this->matchFamilyStyle(NULL, style); | 862 return this->matchFamilyStyle(NULL, style); |
849 } | 863 } |
850 }; | 864 }; |
851 | 865 |
852 SkFontMgr* SkFontMgr::Factory() { | 866 SkFontMgr* SkFontMgr::Factory() { |
853 return SkNEW(SkFontMgr_fontconfig); | 867 return SkNEW(SkFontMgr_fontconfig); |
854 } | 868 } |
OLD | NEW |