| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 | 173 |
| 174 int resulting_bold; | 174 int resulting_bold; |
| 175 if (FcPatternGetInteger(match, FC_WEIGHT, 0, &resulting_bold)) | 175 if (FcPatternGetInteger(match, FC_WEIGHT, 0, &resulting_bold)) |
| 176 resulting_bold = FC_WEIGHT_NORMAL; | 176 resulting_bold = FC_WEIGHT_NORMAL; |
| 177 | 177 |
| 178 int resulting_italic; | 178 int resulting_italic; |
| 179 if (FcPatternGetInteger(match, FC_SLANT, 0, &resulting_italic)) | 179 if (FcPatternGetInteger(match, FC_SLANT, 0, &resulting_italic)) |
| 180 resulting_italic = FC_SLANT_ROMAN; | 180 resulting_italic = FC_SLANT_ROMAN; |
| 181 | 181 |
| 182 // If we ask for an italic font, fontconfig might take a roman font and set |
| 183 // the undocumented property FC_MATRIX to a skew matrix. It'll then say |
| 184 // that the font is italic or oblique. So, if we see a matrix, we don't |
| 185 // believe that it's italic. |
| 186 FcValue matrix; |
| 187 const bool have_matrix = FcPatternGet(match, FC_MATRIX, 0, &matrix) == 0; |
| 188 |
| 182 if (is_bold) | 189 if (is_bold) |
| 183 *is_bold = resulting_bold >= FC_WEIGHT_BOLD; | 190 *is_bold = resulting_bold >= FC_WEIGHT_BOLD; |
| 184 if (is_italic) | 191 if (is_italic) |
| 185 *is_italic = resulting_italic == FC_SLANT_ITALIC; | 192 *is_italic = resulting_italic > FC_SLANT_ROMAN && !have_matrix; |
| 186 | 193 |
| 187 if (result_family) | 194 if (result_family) |
| 188 *result_family = (char *) c_family; | 195 *result_family = (char *) c_family; |
| 189 | 196 |
| 190 FcPatternDestroy(match); | 197 FcPatternDestroy(match); |
| 191 | 198 |
| 192 return true; | 199 return true; |
| 193 } | 200 } |
| 194 | 201 |
| 195 int FontConfigDirect::Open(unsigned fileid) { | 202 int FontConfigDirect::Open(unsigned fileid) { |
| 196 SkAutoMutexAcquire ac(mutex_); | 203 SkAutoMutexAcquire ac(mutex_); |
| 197 const std::map<unsigned, std::string>::const_iterator | 204 const std::map<unsigned, std::string>::const_iterator |
| 198 i = fileid_to_filename_.find(fileid); | 205 i = fileid_to_filename_.find(fileid); |
| 199 if (i == fileid_to_filename_.end()) | 206 if (i == fileid_to_filename_.end()) |
| 200 return -1; | 207 return -1; |
| 201 | 208 |
| 202 return open(i->second.c_str(), O_RDONLY); | 209 return open(i->second.c_str(), O_RDONLY); |
| 203 } | 210 } |
| OLD | NEW |