OLD | NEW |
1 /* libs/graphics/ports/SkFontHost_fontconfig_direct.cpp | 1 /* libs/graphics/ports/SkFontHost_fontconfig_direct.cpp |
2 ** | 2 ** |
3 ** Copyright 2009, Google Inc. | 3 ** Copyright 2009, Google Inc. |
4 ** | 4 ** |
5 ** Licensed under the Apache License, Version 2.0 (the "License"); | 5 ** Licensed under the Apache License, Version 2.0 (the "License"); |
6 ** you may not use this file except in compliance with the License. | 6 ** you may not use this file except in compliance with the License. |
7 ** You may obtain a copy of the License at | 7 ** You may obtain a copy of the License at |
8 ** | 8 ** |
9 ** http://www.apache.org/licenses/LICENSE-2.0 | 9 ** http://www.apache.org/licenses/LICENSE-2.0 |
10 ** | 10 ** |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 fcvalue.type = FcTypeInteger; | 71 fcvalue.type = FcTypeInteger; |
72 fcvalue.u.i = is_bold && *is_bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL; | 72 fcvalue.u.i = is_bold && *is_bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL; |
73 FcPatternAdd(pattern, FC_WEIGHT, fcvalue, 0); | 73 FcPatternAdd(pattern, FC_WEIGHT, fcvalue, 0); |
74 | 74 |
75 fcvalue.type = FcTypeInteger; | 75 fcvalue.type = FcTypeInteger; |
76 fcvalue.u.i = is_italic && *is_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN; | 76 fcvalue.u.i = is_italic && *is_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN; |
77 FcPatternAdd(pattern, FC_SLANT, fcvalue, 0); | 77 FcPatternAdd(pattern, FC_SLANT, fcvalue, 0); |
78 | 78 |
| 79 fcvalue.type = FcTypeBool; |
| 80 fcvalue.u.b = FcTrue; |
| 81 FcPatternAdd(pattern, FC_SCALABLE, fcvalue, 0); |
| 82 |
79 FcConfigSubstitute(0, pattern, FcMatchPattern); | 83 FcConfigSubstitute(0, pattern, FcMatchPattern); |
80 FcDefaultSubstitute(pattern); | 84 FcDefaultSubstitute(pattern); |
81 | 85 |
82 // Font matching: | 86 // Font matching: |
83 // CSS often specifies a fallback list of families: | 87 // CSS often specifies a fallback list of families: |
84 // font-family: a, b, c, serif; | 88 // font-family: a, b, c, serif; |
85 // However, fontconfig will always do its best to find *a* font when asked | 89 // However, fontconfig will always do its best to find *a* font when asked |
86 // for something so we need a way to tell if the match which it has found is | 90 // for something so we need a way to tell if the match which it has found is |
87 // "good enough" for us. Otherwise, we can return NULL which gets piped up | 91 // "good enough" for us. Otherwise, we can return NULL which gets piped up |
88 // and lets WebKit know to try the next CSS family name. However, fontconfig | 92 // and lets WebKit know to try the next CSS family name. However, fontconfig |
(...skipping 21 matching lines...) Expand all Loading... |
110 FcChar8* post_config_family; | 114 FcChar8* post_config_family; |
111 FcPatternGetString(pattern, FC_FAMILY, 0, &post_config_family); | 115 FcPatternGetString(pattern, FC_FAMILY, 0, &post_config_family); |
112 | 116 |
113 FcResult result; | 117 FcResult result; |
114 FcPattern* match = FcFontMatch(0, pattern, &result); | 118 FcPattern* match = FcFontMatch(0, pattern, &result); |
115 if (!match) { | 119 if (!match) { |
116 FcPatternDestroy(pattern); | 120 FcPatternDestroy(pattern); |
117 return false; | 121 return false; |
118 } | 122 } |
119 | 123 |
120 // Skip non-scalable fonts. They don't work with FT_Set_Char_Size() | |
121 // in SkFontHost_FreeType.cpp. | |
122 FcBool scalable = FcFalse; | |
123 FcPatternGetBool(match, FC_SCALABLE, 0, &scalable); | |
124 if (scalable != FcTrue) { | |
125 FcPatternDestroy(match); | |
126 FcPatternDestroy(pattern); | |
127 return false; | |
128 } | |
129 | |
130 FcChar8* post_match_family; | 124 FcChar8* post_match_family; |
131 FcPatternGetString(match, FC_FAMILY, 0, &post_match_family); | 125 FcPatternGetString(match, FC_FAMILY, 0, &post_match_family); |
132 const bool family_names_match = | 126 const bool family_names_match = |
133 family.empty() ? | 127 family.empty() ? |
134 true : | 128 true : |
135 strcasecmp((char *)post_config_family, (char *)post_match_family) == 0; | 129 strcasecmp((char *)post_config_family, (char *)post_match_family) == 0; |
136 | 130 |
137 FcPatternDestroy(pattern); | 131 FcPatternDestroy(pattern); |
138 | 132 |
139 if (!family_names_match && !IsFallbackFontAllowed(family)) { | 133 if (!family_names_match && !IsFallbackFontAllowed(family)) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 202 |
209 int FontConfigDirect::Open(unsigned fileid) { | 203 int FontConfigDirect::Open(unsigned fileid) { |
210 SkAutoMutexAcquire ac(mutex_); | 204 SkAutoMutexAcquire ac(mutex_); |
211 const std::map<unsigned, std::string>::const_iterator | 205 const std::map<unsigned, std::string>::const_iterator |
212 i = fileid_to_filename_.find(fileid); | 206 i = fileid_to_filename_.find(fileid); |
213 if (i == fileid_to_filename_.end()) | 207 if (i == fileid_to_filename_.end()) |
214 return -1; | 208 return -1; |
215 | 209 |
216 return open(i->second.c_str(), O_RDONLY); | 210 return open(i->second.c_str(), O_RDONLY); |
217 } | 211 } |
OLD | NEW |