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"}; | |
301 static const UChar* symbolFont = L"Segoe UI Symbol"; | 300 static const UChar* symbolFont = L"Segoe UI Symbol"; |
302 static const UChar* emojiFont = 0; | 301 static const UChar* emojiFont = 0; |
303 static const UChar* mathFont = 0; | |
304 static bool initialized = false; | 302 static bool initialized = false; |
305 if (!initialized) { | 303 if (!initialized) { |
306 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { | 304 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { |
307 if (isFontPresent(emojiFonts[i], fontManager)) { | 305 if (isFontPresent(emojiFonts[i], fontManager)) { |
308 emojiFont = emojiFonts[i]; | 306 emojiFont = emojiFonts[i]; |
309 break; | 307 break; |
310 } | 308 } |
311 } | 309 } |
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 } | |
318 initialized = true; | 310 initialized = true; |
319 } | 311 } |
320 | 312 |
321 UBlockCode block = ublock_getCode(ucs4); | 313 UBlockCode block = ublock_getCode(ucs4); |
322 switch (block) { | 314 switch (block) { |
323 case UBLOCK_EMOTICONS: | 315 case UBLOCK_EMOTICONS: |
324 case UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT: | |
325 return emojiFont; | 316 return emojiFont; |
326 case UBLOCK_PLAYING_CARDS: | 317 case UBLOCK_PLAYING_CARDS: |
327 case UBLOCK_MISCELLANEOUS_SYMBOLS: | 318 case UBLOCK_MISCELLANEOUS_SYMBOLS: |
328 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS: | |
329 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: | 319 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: |
| 320 case UBLOCK_MISCELLANEOUS_TECHNICAL: |
330 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: | 321 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: |
331 case UBLOCK_ALCHEMICAL_SYMBOLS: | 322 case UBLOCK_ALCHEMICAL_SYMBOLS: |
332 case UBLOCK_RUNIC: | 323 case UBLOCK_RUNIC: |
| 324 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: |
333 case UBLOCK_DINGBATS: | 325 case UBLOCK_DINGBATS: |
334 case UBLOCK_GOTHIC: | |
335 return symbolFont; | 326 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: | |
344 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS: | |
345 case UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS: | |
346 case UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS: | |
347 case UBLOCK_GEOMETRIC_SHAPES_EXTENDED: | |
348 return mathFont; | |
349 default: | 327 default: |
350 return 0; | 328 return 0; |
351 }; | 329 }; |
352 } | 330 } |
353 | 331 |
354 } // namespace | 332 } // namespace |
355 | 333 |
356 // FIXME: this is font fallback code version 0.1 | 334 // FIXME: this is font fallback code version 0.1 |
357 // - Cover all the scripts | 335 // - Cover all the scripts |
358 // - Get the default font for each script/generic family from the | 336 // - Get the default font for each script/generic family from the |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 family = L"lucida sans unicode"; | 423 family = L"lucida sans unicode"; |
446 } | 424 } |
447 } | 425 } |
448 | 426 |
449 if (scriptChecked) | 427 if (scriptChecked) |
450 *scriptChecked = script; | 428 *scriptChecked = script; |
451 return family; | 429 return family; |
452 } | 430 } |
453 | 431 |
454 } // namespace blink | 432 } // namespace blink |
OLD | NEW |