| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser
ved. | 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser
ved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // If script is invalid, common or inherited or there's an error, | 290 // If script is invalid, common or inherited or there's an error, |
| 291 // infer a script based on the unicode block of a character. | 291 // infer a script based on the unicode block of a character. |
| 292 if (script <= USCRIPT_INHERITED || U_FAILURE(err)) | 292 if (script <= USCRIPT_INHERITED || U_FAILURE(err)) |
| 293 script = getScriptBasedOnUnicodeBlock(ucs4); | 293 script = getScriptBasedOnUnicodeBlock(ucs4); |
| 294 return script; | 294 return script; |
| 295 } | 295 } |
| 296 | 296 |
| 297 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager) | 297 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager) |
| 298 { | 298 { |
| 299 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"}; | 299 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"}; |
| 300 static const UChar* mathFonts[] = {L"Cambria Math", L"Segoe UI Symbol", L"Co
de2000"}; |
| 300 static const UChar* symbolFont = L"Segoe UI Symbol"; | 301 static const UChar* symbolFont = L"Segoe UI Symbol"; |
| 301 static const UChar* emojiFont = 0; | 302 static const UChar* emojiFont = 0; |
| 303 static const UChar* mathFont = 0; |
| 302 static bool initialized = false; | 304 static bool initialized = false; |
| 303 if (!initialized) { | 305 if (!initialized) { |
| 304 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { | 306 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { |
| 305 if (isFontPresent(emojiFonts[i], fontManager)) { | 307 if (isFontPresent(emojiFonts[i], fontManager)) { |
| 306 emojiFont = emojiFonts[i]; | 308 emojiFont = emojiFonts[i]; |
| 307 break; | 309 break; |
| 308 } | 310 } |
| 309 } | 311 } |
| 312 for (size_t i = 0; i < WTF_ARRAY_LENGTH(mathFonts); i++) { |
| 313 if (isFontPresent(mathFonts[i], fontManager)) { |
| 314 mathFont = mathFonts[i]; |
| 315 break; |
| 316 } |
| 317 } |
| 310 initialized = true; | 318 initialized = true; |
| 311 } | 319 } |
| 312 | 320 |
| 313 UBlockCode block = ublock_getCode(ucs4); | 321 UBlockCode block = ublock_getCode(ucs4); |
| 314 switch (block) { | 322 switch (block) { |
| 315 case UBLOCK_EMOTICONS: | 323 case UBLOCK_EMOTICONS: |
| 324 case UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT: |
| 316 return emojiFont; | 325 return emojiFont; |
| 317 case UBLOCK_PLAYING_CARDS: | 326 case UBLOCK_PLAYING_CARDS: |
| 318 case UBLOCK_MISCELLANEOUS_SYMBOLS: | 327 case UBLOCK_MISCELLANEOUS_SYMBOLS: |
| 328 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS: |
| 319 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: | 329 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: |
| 320 case UBLOCK_MISCELLANEOUS_TECHNICAL: | |
| 321 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: | 330 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: |
| 322 case UBLOCK_ALCHEMICAL_SYMBOLS: | 331 case UBLOCK_ALCHEMICAL_SYMBOLS: |
| 323 case UBLOCK_RUNIC: | 332 case UBLOCK_RUNIC: |
| 333 case UBLOCK_DINGBATS: |
| 334 case UBLOCK_GOTHIC: |
| 335 return symbolFont; |
| 336 case UBLOCK_ARROWS: |
| 337 case UBLOCK_MATHEMATICAL_OPERATORS: |
| 338 case UBLOCK_MISCELLANEOUS_TECHNICAL: |
| 339 case UBLOCK_GEOMETRIC_SHAPES: |
| 340 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A: |
| 341 case UBLOCK_SUPPLEMENTAL_ARROWS_A: |
| 342 case UBLOCK_SUPPLEMENTAL_ARROWS_B: |
| 343 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B: |
| 324 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: | 344 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: |
| 325 case UBLOCK_DINGBATS: | 345 case UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS: |
| 326 return symbolFont; | 346 case UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS: |
| 347 case UBLOCK_GEOMETRIC_SHAPES_EXTENDED: |
| 348 return mathFont; |
| 327 default: | 349 default: |
| 328 return 0; | 350 return 0; |
| 329 }; | 351 }; |
| 330 } | 352 } |
| 331 | 353 |
| 332 } // namespace | 354 } // namespace |
| 333 | 355 |
| 334 // FIXME: this is font fallback code version 0.1 | 356 // FIXME: this is font fallback code version 0.1 |
| 335 // - Cover all the scripts | 357 // - Cover all the scripts |
| 336 // - Get the default font for each script/generic family from the | 358 // - Get the default font for each script/generic family from the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 family = L"lucida sans unicode"; | 445 family = L"lucida sans unicode"; |
| 424 } | 446 } |
| 425 } | 447 } |
| 426 | 448 |
| 427 if (scriptChecked) | 449 if (scriptChecked) |
| 428 *scriptChecked = script; | 450 *scriptChecked = script; |
| 429 return family; | 451 return family; |
| 430 } | 452 } |
| 431 | 453 |
| 432 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |