Chromium Code Reviews| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 // If script is invalid, common or inherited or there's an error, | 278 // If script is invalid, common or inherited or there's an error, |
| 279 // infer a script based on the unicode block of a character. | 279 // infer a script based on the unicode block of a character. |
| 280 if (script <= USCRIPT_INHERITED || U_FAILURE(err)) | 280 if (script <= USCRIPT_INHERITED || U_FAILURE(err)) |
| 281 script = getScriptBasedOnUnicodeBlock(ucs4); | 281 script = getScriptBasedOnUnicodeBlock(ucs4); |
| 282 return script; | 282 return script; |
| 283 } | 283 } |
| 284 | 284 |
| 285 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager) | 285 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager) |
| 286 { | 286 { |
| 287 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"}; | 287 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"}; |
| 288 static const UChar* mathFonts[] = {L"Cambria Math", L"Segoe UI Symbol", L"Co de2000"}; | |
| 288 static const UChar* symbolFont = L"Segoe UI Symbol"; | 289 static const UChar* symbolFont = L"Segoe UI Symbol"; |
| 289 static const UChar* emojiFont = 0; | 290 static const UChar* emojiFont = 0; |
| 291 static const UChar* mathFont = 0; | |
| 290 static bool initialized = false; | 292 static bool initialized = false; |
| 291 if (!initialized) { | 293 if (!initialized) { |
| 292 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { | 294 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { |
| 293 if (isFontPresent(emojiFonts[i], fontManager)) { | 295 if (isFontPresent(emojiFonts[i], fontManager)) { |
| 294 emojiFont = emojiFonts[i]; | 296 emojiFont = emojiFonts[i]; |
| 295 break; | 297 break; |
| 296 } | 298 } |
| 297 } | 299 } |
| 300 for (size_t i = 0; i < WTF_ARRAY_LENGTH(mathFonts); i++) { | |
| 301 if (isFontPresent(mathFonts[i], fontManager)) { | |
| 302 mathFont = mathFonts[i]; | |
| 303 break; | |
| 304 } | |
| 305 } | |
| 298 initialized = true; | 306 initialized = true; |
| 299 } | 307 } |
| 300 | 308 |
| 301 UBlockCode block = ublock_getCode(ucs4); | 309 UBlockCode block = ublock_getCode(ucs4); |
| 302 switch (block) { | 310 switch (block) { |
| 303 case UBLOCK_EMOTICONS: | 311 case UBLOCK_EMOTICONS: |
| 304 return emojiFont; | 312 return emojiFont; |
| 313 case UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT: | |
|
ebraminio
2015/09/04 21:28:24
Sorry, UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT whi
| |
| 305 case UBLOCK_PLAYING_CARDS: | 314 case UBLOCK_PLAYING_CARDS: |
| 306 case UBLOCK_MISCELLANEOUS_SYMBOLS: | 315 case UBLOCK_MISCELLANEOUS_SYMBOLS: |
| 316 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS: | |
| 307 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: | 317 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: |
| 308 case UBLOCK_MISCELLANEOUS_TECHNICAL: | |
| 309 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: | 318 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: |
| 310 case UBLOCK_ALCHEMICAL_SYMBOLS: | 319 case UBLOCK_ALCHEMICAL_SYMBOLS: |
| 311 case UBLOCK_RUNIC: | 320 case UBLOCK_RUNIC: |
| 321 case UBLOCK_DINGBATS: | |
| 322 case UBLOCK_GOTHIC: | |
| 323 return symbolFont; | |
| 324 case UBLOCK_ARROWS: | |
| 325 case UBLOCK_MATHEMATICAL_OPERATORS: | |
| 326 case UBLOCK_MISCELLANEOUS_TECHNICAL: | |
| 327 case UBLOCK_GEOMETRIC_SHAPES: | |
| 328 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A: | |
| 329 case UBLOCK_SUPPLEMENTAL_ARROWS_A: | |
| 330 case UBLOCK_SUPPLEMENTAL_ARROWS_B: | |
| 331 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B: | |
| 312 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: | 332 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: |
| 313 case UBLOCK_DINGBATS: | 333 case UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS: |
| 314 return symbolFont; | 334 case UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS: |
| 335 case UBLOCK_GEOMETRIC_SHAPES_EXTENDED: | |
| 336 return mathFont; | |
| 315 default: | 337 default: |
| 316 return 0; | 338 return 0; |
| 317 }; | 339 }; |
| 318 } | 340 } |
| 319 | 341 |
| 320 } // namespace | 342 } // namespace |
| 321 | 343 |
| 322 // FIXME: this is font fallback code version 0.1 | 344 // FIXME: this is font fallback code version 0.1 |
| 323 // - Cover all the scripts | 345 // - Cover all the scripts |
| 324 // - Get the default font for each script/generic family from the | 346 // - Get the default font for each script/generic family from the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 family = L"lucida sans unicode"; | 433 family = L"lucida sans unicode"; |
| 412 } | 434 } |
| 413 } | 435 } |
| 414 | 436 |
| 415 if (scriptChecked) | 437 if (scriptChecked) |
| 416 *scriptChecked = script; | 438 *scriptChecked = script; |
| 417 return family; | 439 return family; |
| 418 } | 440 } |
| 419 | 441 |
| 420 } // namespace blink | 442 } // namespace blink |
| OLD | NEW |