| 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); | 764 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); |
| 765 if (NULL == font || !FontAccessible(font) || !FontFamilyNameMatches(font
, matchPattern)) { | 765 if (NULL == font || !FontAccessible(font) || !FontFamilyNameMatches(font
, matchPattern)) { |
| 766 return NULL; | 766 return NULL; |
| 767 } | 767 } |
| 768 | 768 |
| 769 return createTypefaceFromFcPattern(font); | 769 return createTypefaceFromFcPattern(font); |
| 770 } | 770 } |
| 771 | 771 |
| 772 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], | 772 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], |
| 773 const SkFontStyle& style, | 773 const SkFontStyle& style, |
| 774 const char bpc47[], | 774 const char* bcp47[], |
| 775 uint32_t character) const SK
_OVERRIDE | 775 int bcpLength, |
| 776 SkUnichar character) const S
K_OVERRIDE |
| 776 { | 777 { |
| 777 FCLocker lock; | 778 FCLocker lock; |
| 778 | 779 |
| 779 SkAutoFcPattern pattern; | 780 SkAutoFcPattern pattern; |
| 780 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); | 781 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); |
| 781 fcpattern_from_skfontstyle(style, pattern); | 782 fcpattern_from_skfontstyle(style, pattern); |
| 782 | 783 |
| 783 SkAutoFcCharSet charSet; | 784 SkAutoFcCharSet charSet; |
| 784 FcCharSetAddChar(charSet, character); | 785 FcCharSetAddChar(charSet, character); |
| 785 FcPatternAddCharSet(pattern, FC_CHARSET, charSet); | 786 FcPatternAddCharSet(pattern, FC_CHARSET, charSet); |
| 786 | 787 |
| 787 if (bpc47) { | 788 if (bcpLength > 0) { |
| 789 SkASSERT(bcp47); |
| 788 SkAutoFcLangSet langSet; | 790 SkAutoFcLangSet langSet; |
| 789 FcLangSetAdd(langSet, (const FcChar8*)bpc47); | 791 for (int i = 0; i < bcpLength; i++) { |
| 792 FcLangSetAdd(langSet, (const FcChar8*)bcp47[i]); |
| 793 } |
| 790 FcPatternAddLangSet(pattern, FC_LANG, langSet); | 794 FcPatternAddLangSet(pattern, FC_LANG, langSet); |
| 791 } | 795 } |
| 792 | 796 |
| 793 FcConfigSubstitute(fFC, pattern, FcMatchPattern); | 797 FcConfigSubstitute(fFC, pattern, FcMatchPattern); |
| 794 FcDefaultSubstitute(pattern); | 798 FcDefaultSubstitute(pattern); |
| 795 | 799 |
| 796 FcResult result; | 800 FcResult result; |
| 797 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); | 801 SkAutoFcPattern font(FcFontMatch(fFC, pattern, &result)); |
| 798 if (NULL == font || !FontAccessible(font) || !FontContainsCharacter(font
, character)) { | 802 if (NULL == font || !FontAccessible(font) || !FontContainsCharacter(font
, character)) { |
| 799 return NULL; | 803 return NULL; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 return typeface.detach(); | 856 return typeface.detach(); |
| 853 } | 857 } |
| 854 | 858 |
| 855 return this->matchFamilyStyle(NULL, style); | 859 return this->matchFamilyStyle(NULL, style); |
| 856 } | 860 } |
| 857 }; | 861 }; |
| 858 | 862 |
| 859 SkFontMgr* SkFontMgr::Factory() { | 863 SkFontMgr* SkFontMgr::Factory() { |
| 860 return SkNEW(SkFontMgr_fontconfig); | 864 return SkNEW(SkFontMgr_fontconfig); |
| 861 } | 865 } |
| OLD | NEW |