reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ |
| 9 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <unistd.h> |
| 12 | #include <fcntl.h> |
| 13 | |
| 14 | #include <fontconfig/fontconfig.h> |
| 15 | |
| 16 | #include "SkFontConfigInterface.h" |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 17 | #include "SkStream.h" |
| 18 | |
| 19 | class SkFontConfigInterfaceDirect : public SkFontConfigInterface { |
| 20 | public: |
| 21 | SkFontConfigInterfaceDirect(); |
| 22 | virtual ~SkFontConfigInterfaceDirect(); |
| 23 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 24 | virtual bool matchFamilyName(const char familyName[], |
| 25 | SkTypeface::Style requested, |
| 26 | FontIdentity* outFontIdentifier, |
| 27 | SkString* outFamilyName, |
| 28 | SkTypeface::Style* outStyle) SK_OVERRIDE; |
| 29 | virtual SkStream* openStream(const FontIdentity&) SK_OVERRIDE; |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 30 | |
| 31 | private: |
| 32 | SkMutex mutex_; |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
reed@google.com | d66045e | 2013-03-04 19:07:02 +0000 | [diff] [blame] | 35 | SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() { |
| 36 | static SkFontConfigInterface* gDirect; |
| 37 | if (NULL == gDirect) { |
| 38 | gDirect = new SkFontConfigInterfaceDirect; |
| 39 | } |
| 40 | return gDirect; |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | namespace { |
| 44 | |
| 45 | // Equivalence classes, used to match the Liberation and other fonts |
| 46 | // with their metric-compatible replacements. See the discussion in |
| 47 | // GetFontEquivClass(). |
| 48 | enum FontEquivClass |
| 49 | { |
| 50 | OTHER, |
| 51 | SANS, |
| 52 | SERIF, |
| 53 | MONO, |
| 54 | SYMBOL, |
| 55 | PGOTHIC, |
| 56 | GOTHIC, |
| 57 | PMINCHO, |
| 58 | MINCHO, |
| 59 | SIMSUN, |
| 60 | NSIMSUN, |
| 61 | SIMHEI, |
| 62 | PMINGLIU, |
| 63 | MINGLIU, |
| 64 | PMINGLIUHK, |
| 65 | MINGLIUHK, |
commit-bot@chromium.org | c4de776 | 2013-03-20 13:33:33 +0000 | [diff] [blame^] | 66 | CAMBRIA, |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | // Match the font name against a whilelist of fonts, returning the equivalence |
| 70 | // class. |
| 71 | FontEquivClass GetFontEquivClass(const char* fontname) |
| 72 | { |
| 73 | // It would be nice for fontconfig to tell us whether a given suggested |
| 74 | // replacement is a "strong" match (that is, an equivalent font) or |
| 75 | // a "weak" match (that is, fontconfig's next-best attempt at finding a |
| 76 | // substitute). However, I played around with the fontconfig API for |
| 77 | // a good few hours and could not make it reveal this information. |
| 78 | // |
| 79 | // So instead, we hardcode. Initially this function emulated |
| 80 | // /etc/fonts/conf.d/30-metric-aliases.conf |
| 81 | // from my Ubuntu system, but we're better off being very conservative. |
| 82 | |
| 83 | // Arimo, Tinos and Cousine are a set of fonts metric-compatible with |
| 84 | // Arial, Times New Roman and Courier New with a character repertoire |
| 85 | // much larger than Liberation. Note that Cousine is metrically |
| 86 | // compatible with Courier New, but the former is sans-serif while |
| 87 | // the latter is serif. |
| 88 | |
| 89 | |
| 90 | struct FontEquivMap { |
| 91 | FontEquivClass clazz; |
| 92 | const char name[40]; |
| 93 | }; |
| 94 | |
| 95 | static const FontEquivMap kFontEquivMap[] = { |
| 96 | { SANS, "Arial" }, |
| 97 | { SANS, "Arimo" }, |
| 98 | { SANS, "Liberation Sans" }, |
| 99 | |
| 100 | { SERIF, "Times New Roman" }, |
| 101 | { SERIF, "Tinos" }, |
| 102 | { SERIF, "Liberation Serif" }, |
| 103 | |
| 104 | { MONO, "Courier New" }, |
| 105 | { MONO, "Cousine" }, |
| 106 | { MONO, "Liberation Mono" }, |
| 107 | |
| 108 | { SYMBOL, "Symbol" }, |
| 109 | { SYMBOL, "Symbol Neu" }, |
| 110 | |
| 111 | // MS Pゴシック |
| 112 | { PGOTHIC, "MS PGothic" }, |
| 113 | { PGOTHIC, "\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0" |
| 114 | "\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf" }, |
| 115 | { PGOTHIC, "IPAPGothic" }, |
| 116 | { PGOTHIC, "MotoyaG04Gothic" }, |
| 117 | |
| 118 | // MS ゴシック |
| 119 | { GOTHIC, "MS Gothic" }, |
| 120 | { GOTHIC, "\xef\xbc\xad\xef\xbc\xb3 " |
| 121 | "\xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf" }, |
| 122 | { GOTHIC, "IPAGothic" }, |
| 123 | { GOTHIC, "MotoyaG04GothicMono" }, |
| 124 | |
| 125 | // MS P明朝 |
| 126 | { PMINCHO, "MS PMincho" }, |
| 127 | { PMINCHO, "\xef\xbc\xad\xef\xbc\xb3 \xef\xbc\xb0" |
| 128 | "\xe6\x98\x8e\xe6\x9c\x9d"}, |
| 129 | { PMINCHO, "IPAPMincho" }, |
| 130 | { PMINCHO, "MotoyaG04Mincho" }, |
| 131 | |
| 132 | // MS 明朝 |
| 133 | { MINCHO, "MS Mincho" }, |
| 134 | { MINCHO, "\xef\xbc\xad\xef\xbc\xb3 \xe6\x98\x8e\xe6\x9c\x9d" }, |
| 135 | { MINCHO, "IPAMincho" }, |
| 136 | { MINCHO, "MotoyaG04MinchoMono" }, |
| 137 | |
| 138 | // 宋体 |
| 139 | { SIMSUN, "Simsun" }, |
| 140 | { SIMSUN, "\xe5\xae\x8b\xe4\xbd\x93" }, |
| 141 | { SIMSUN, "MSung GB18030" }, |
| 142 | { SIMSUN, "Song ASC" }, |
| 143 | |
| 144 | // 新宋体 |
| 145 | { NSIMSUN, "NSimsun" }, |
| 146 | { NSIMSUN, "\xe6\x96\xb0\xe5\xae\x8b\xe4\xbd\x93" }, |
| 147 | { NSIMSUN, "MSung GB18030" }, |
| 148 | { NSIMSUN, "N Song ASC" }, |
| 149 | |
| 150 | // 黑体 |
| 151 | { SIMHEI, "Simhei" }, |
| 152 | { SIMHEI, "\xe9\xbb\x91\xe4\xbd\x93" }, |
| 153 | { SIMHEI, "MYingHeiGB18030" }, |
| 154 | { SIMHEI, "MYingHeiB5HK" }, |
| 155 | |
commit-bot@chromium.org | c4de776 | 2013-03-20 13:33:33 +0000 | [diff] [blame^] | 156 | // 新細明體 |
| 157 | { PMINGLIU, "PMingLiU"}, |
| 158 | { PMINGLIU, "\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94" }, |
| 159 | { PMINGLIU, "MSung B5HK"}, |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 160 | |
commit-bot@chromium.org | c4de776 | 2013-03-20 13:33:33 +0000 | [diff] [blame^] | 161 | // 細明體 |
| 162 | { MINGLIU, "MingLiU"}, |
| 163 | { MINGLIU, "\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94" }, |
| 164 | { MINGLIU, "MSung B5HK"}, |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 165 | |
commit-bot@chromium.org | c4de776 | 2013-03-20 13:33:33 +0000 | [diff] [blame^] | 166 | // 新細明體 |
| 167 | { PMINGLIUHK, "PMingLiU_HKSCS"}, |
| 168 | { PMINGLIUHK, "\xe6\x96\xb0\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94_HKSCS" }, |
| 169 | { PMINGLIUHK, "MSung B5HK"}, |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 170 | |
commit-bot@chromium.org | c4de776 | 2013-03-20 13:33:33 +0000 | [diff] [blame^] | 171 | // 細明體 |
| 172 | { MINGLIUHK, "MingLiU_HKSCS"}, |
| 173 | { MINGLIUHK, "\xe7\xb4\xb0\xe6\x98\x8e\xe9\xab\x94_HKSCS" }, |
| 174 | { MINGLIUHK, "MSung B5HK"}, |
| 175 | |
| 176 | // Cambria |
| 177 | { CAMBRIA, "Cambria" }, |
| 178 | { CAMBRIA, "Caladea" }, |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | static const size_t kFontCount = |
| 182 | sizeof(kFontEquivMap)/sizeof(kFontEquivMap[0]); |
| 183 | |
| 184 | // TODO(jungshik): If this loop turns out to be hot, turn |
| 185 | // the array to a static (hash)map to speed it up. |
| 186 | for (size_t i = 0; i < kFontCount; ++i) { |
| 187 | if (strcasecmp(kFontEquivMap[i].name, fontname) == 0) |
| 188 | return kFontEquivMap[i].clazz; |
| 189 | } |
| 190 | return OTHER; |
| 191 | } |
| 192 | |
| 193 | |
| 194 | // Return true if |font_a| and |font_b| are visually and at the metrics |
| 195 | // level interchangeable. |
| 196 | bool IsMetricCompatibleReplacement(const char* font_a, const char* font_b) |
| 197 | { |
| 198 | FontEquivClass class_a = GetFontEquivClass(font_a); |
| 199 | FontEquivClass class_b = GetFontEquivClass(font_b); |
| 200 | |
| 201 | return class_a != OTHER && class_a == class_b; |
| 202 | } |
| 203 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 204 | // Normally we only return exactly the font asked for. In last-resort |
| 205 | // cases, the request either doesn't specify a font or is one of the |
| 206 | // basic font names like "Sans", "Serif" or "Monospace". This function |
| 207 | // tells you whether a given request is for such a fallback. |
| 208 | bool IsFallbackFontAllowed(const std::string& family) { |
| 209 | const char* family_cstr = family.c_str(); |
| 210 | return family.empty() || |
| 211 | strcasecmp(family_cstr, "sans") == 0 || |
| 212 | strcasecmp(family_cstr, "serif") == 0 || |
| 213 | strcasecmp(family_cstr, "monospace") == 0; |
| 214 | } |
| 215 | |
| 216 | // Find matching font from |font_set| for the given font family. |
| 217 | FcPattern* MatchFont(FcFontSet* font_set, |
| 218 | FcChar8* post_config_family, |
| 219 | const std::string& family) { |
| 220 | // Older versions of fontconfig have a bug where they cannot select |
| 221 | // only scalable fonts so we have to manually filter the results. |
| 222 | FcPattern* match = NULL; |
| 223 | for (int i = 0; i < font_set->nfont; ++i) { |
| 224 | FcPattern* current = font_set->fonts[i]; |
| 225 | FcBool is_scalable; |
| 226 | |
| 227 | if (FcPatternGetBool(current, FC_SCALABLE, 0, |
| 228 | &is_scalable) != FcResultMatch || |
| 229 | !is_scalable) { |
| 230 | continue; |
| 231 | } |
| 232 | |
| 233 | // fontconfig can also return fonts which are unreadable |
| 234 | FcChar8* c_filename; |
| 235 | if (FcPatternGetString(current, FC_FILE, 0, &c_filename) != FcResultMatch) |
| 236 | continue; |
| 237 | |
| 238 | if (access(reinterpret_cast<char*>(c_filename), R_OK) != 0) |
| 239 | continue; |
| 240 | |
| 241 | match = current; |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | if (match && !IsFallbackFontAllowed(family)) { |
| 246 | bool acceptable_substitute = false; |
| 247 | for (int id = 0; id < 255; ++id) { |
| 248 | FcChar8* post_match_family; |
| 249 | if (FcPatternGetString(match, FC_FAMILY, id, &post_match_family) != |
| 250 | FcResultMatch) |
| 251 | break; |
| 252 | acceptable_substitute = |
| 253 | (strcasecmp(reinterpret_cast<char*>(post_config_family), |
| 254 | reinterpret_cast<char*>(post_match_family)) == 0 || |
| 255 | // Workaround for Issue 12530: |
| 256 | // requested family: "Bitstream Vera Sans" |
| 257 | // post_config_family: "Arial" |
| 258 | // post_match_family: "Bitstream Vera Sans" |
| 259 | // -> We should treat this case as a good match. |
| 260 | strcasecmp(family.c_str(), |
| 261 | reinterpret_cast<char*>(post_match_family)) == 0) || |
| 262 | IsMetricCompatibleReplacement(family.c_str(), |
| 263 | reinterpret_cast<char*>(post_match_family)); |
| 264 | if (acceptable_substitute) |
| 265 | break; |
| 266 | } |
| 267 | if (!acceptable_substitute) |
| 268 | return NULL; |
| 269 | } |
| 270 | |
| 271 | return match; |
| 272 | } |
| 273 | |
| 274 | // Retrieves |is_bold|, |is_italic| and |font_family| properties from |font|. |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 275 | SkTypeface::Style GetFontStyle(FcPattern* font) { |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 276 | int resulting_bold; |
| 277 | if (FcPatternGetInteger(font, FC_WEIGHT, 0, &resulting_bold)) |
| 278 | resulting_bold = FC_WEIGHT_NORMAL; |
| 279 | |
| 280 | int resulting_italic; |
| 281 | if (FcPatternGetInteger(font, FC_SLANT, 0, &resulting_italic)) |
| 282 | resulting_italic = FC_SLANT_ROMAN; |
| 283 | |
| 284 | // If we ask for an italic font, fontconfig might take a roman font and set |
| 285 | // the undocumented property FC_MATRIX to a skew matrix. It'll then say |
| 286 | // that the font is italic or oblique. So, if we see a matrix, we don't |
| 287 | // believe that it's italic. |
| 288 | FcValue matrix; |
| 289 | const bool have_matrix = FcPatternGet(font, FC_MATRIX, 0, &matrix) == 0; |
| 290 | |
| 291 | // If we ask for an italic font, fontconfig might take a roman font and set |
| 292 | // FC_EMBOLDEN. |
| 293 | FcValue embolden; |
| 294 | const bool have_embolden = FcPatternGet(font, FC_EMBOLDEN, 0, &embolden) == 0; |
| 295 | |
| 296 | int styleBits = 0; |
| 297 | if (resulting_bold > FC_WEIGHT_MEDIUM && !have_embolden) { |
| 298 | styleBits |= SkTypeface::kBold; |
| 299 | } |
| 300 | if (resulting_italic > FC_SLANT_ROMAN && !have_matrix) { |
| 301 | styleBits |= SkTypeface::kItalic; |
| 302 | } |
| 303 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 304 | return (SkTypeface::Style)styleBits; |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | } // anonymous namespace |
| 308 | |
| 309 | /////////////////////////////////////////////////////////////////////////////// |
| 310 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 311 | #define kMaxFontFamilyLength 2048 |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 312 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 313 | SkFontConfigInterfaceDirect::SkFontConfigInterfaceDirect() { |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 314 | FcInit(); |
| 315 | } |
| 316 | |
| 317 | SkFontConfigInterfaceDirect::~SkFontConfigInterfaceDirect() { |
| 318 | } |
| 319 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 320 | bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[], |
| 321 | SkTypeface::Style style, |
| 322 | FontIdentity* outIdentity, |
| 323 | SkString* outFamilyName, |
| 324 | SkTypeface::Style* outStyle) { |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 325 | std::string familyStr(familyName ? familyName : ""); |
| 326 | if (familyStr.length() > kMaxFontFamilyLength) { |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 327 | return false; |
| 328 | } |
| 329 | |
| 330 | SkAutoMutexAcquire ac(mutex_); |
| 331 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 332 | FcPattern* pattern = FcPatternCreate(); |
| 333 | |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 334 | if (familyName) { |
| 335 | FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); |
| 336 | } |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 337 | FcPatternAddInteger(pattern, FC_WEIGHT, |
| 338 | (style & SkTypeface::kBold) ? FC_WEIGHT_BOLD |
| 339 | : FC_WEIGHT_NORMAL); |
| 340 | FcPatternAddInteger(pattern, FC_SLANT, |
| 341 | (style & SkTypeface::kItalic) ? FC_SLANT_ITALIC |
| 342 | : FC_SLANT_ROMAN); |
| 343 | FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); |
| 344 | |
| 345 | FcConfigSubstitute(NULL, pattern, FcMatchPattern); |
| 346 | FcDefaultSubstitute(pattern); |
| 347 | |
| 348 | // Font matching: |
| 349 | // CSS often specifies a fallback list of families: |
| 350 | // font-family: a, b, c, serif; |
| 351 | // However, fontconfig will always do its best to find *a* font when asked |
| 352 | // for something so we need a way to tell if the match which it has found is |
| 353 | // "good enough" for us. Otherwise, we can return NULL which gets piped up |
| 354 | // and lets WebKit know to try the next CSS family name. However, fontconfig |
| 355 | // configs allow substitutions (mapping "Arial -> Helvetica" etc) and we |
| 356 | // wish to support that. |
| 357 | // |
| 358 | // Thus, if a specific family is requested we set @family_requested. Then we |
| 359 | // record two strings: the family name after config processing and the |
| 360 | // family name after resolving. If the two are equal, it's a good match. |
| 361 | // |
| 362 | // So consider the case where a user has mapped Arial to Helvetica in their |
| 363 | // config. |
| 364 | // requested family: "Arial" |
| 365 | // post_config_family: "Helvetica" |
| 366 | // post_match_family: "Helvetica" |
| 367 | // -> good match |
| 368 | // |
| 369 | // and for a missing font: |
| 370 | // requested family: "Monaco" |
| 371 | // post_config_family: "Monaco" |
| 372 | // post_match_family: "Times New Roman" |
| 373 | // -> BAD match |
| 374 | // |
| 375 | // However, we special-case fallback fonts; see IsFallbackFontAllowed(). |
| 376 | FcChar8* post_config_family; |
| 377 | FcPatternGetString(pattern, FC_FAMILY, 0, &post_config_family); |
| 378 | |
| 379 | FcResult result; |
| 380 | FcFontSet* font_set = FcFontSort(0, pattern, 0, 0, &result); |
| 381 | if (!font_set) { |
| 382 | FcPatternDestroy(pattern); |
| 383 | return false; |
| 384 | } |
| 385 | |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 386 | FcPattern* match = MatchFont(font_set, post_config_family, familyStr); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 387 | if (!match) { |
| 388 | FcPatternDestroy(pattern); |
| 389 | FcFontSetDestroy(font_set); |
| 390 | return false; |
| 391 | } |
| 392 | |
| 393 | FcPatternDestroy(pattern); |
| 394 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 395 | // From here out we just extract our results from 'match' |
| 396 | |
| 397 | if (FcPatternGetString(match, FC_FAMILY, 0, &post_config_family) != FcResultMatch) { |
| 398 | FcFontSetDestroy(font_set); |
| 399 | return false; |
| 400 | } |
| 401 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 402 | FcChar8* c_filename; |
| 403 | if (FcPatternGetString(match, FC_FILE, 0, &c_filename) != FcResultMatch) { |
| 404 | FcFontSetDestroy(font_set); |
| 405 | return false; |
| 406 | } |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 407 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 408 | int face_index; |
| 409 | if (FcPatternGetInteger(match, FC_INDEX, 0, &face_index) != FcResultMatch) { |
| 410 | FcFontSetDestroy(font_set); |
| 411 | return false; |
| 412 | } |
| 413 | |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 414 | FcFontSetDestroy(font_set); |
| 415 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 416 | if (outIdentity) { |
reed@google.com | 8c9737e | 2013-03-06 13:06:03 +0000 | [diff] [blame] | 417 | outIdentity->fTTCIndex = face_index; |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 418 | outIdentity->fString.set((const char*)c_filename); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 419 | } |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 420 | if (outFamilyName) { |
| 421 | outFamilyName->set((const char*)post_config_family); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 422 | } |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 423 | if (outStyle) { |
| 424 | *outStyle = GetFontStyle(match); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 425 | } |
reed@google.com | ee619a0 | 2013-02-26 22:58:09 +0000 | [diff] [blame] | 426 | return true; |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 427 | } |
| 428 | |
reed@google.com | f71a233 | 2013-02-27 19:06:30 +0000 | [diff] [blame] | 429 | SkStream* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) { |
reed@google.com | 8c3f84d | 2013-03-19 13:34:55 +0000 | [diff] [blame] | 430 | return SkStream::NewFromFile(identity.fString.c_str()); |
reed@google.com | b1c65b6 | 2013-02-26 15:50:51 +0000 | [diff] [blame] | 431 | } |