OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights | 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 SkFontMgr* font_manager) { | 444 SkFontMgr* font_manager) { |
445 static ScriptToFontMap script_font_map; | 445 static ScriptToFontMap script_font_map; |
446 static bool initialized = false; | 446 static bool initialized = false; |
447 if (!initialized) { | 447 if (!initialized) { |
448 InitializeScriptFontMap(script_font_map); | 448 InitializeScriptFontMap(script_font_map); |
449 initialized = true; | 449 initialized = true; |
450 } | 450 } |
451 | 451 |
452 if (script == USCRIPT_INVALID_CODE) | 452 if (script == USCRIPT_INVALID_CODE) |
453 return 0; | 453 return 0; |
454 ASSERT(script < USCRIPT_CODE_LIMIT); | 454 DCHECK_LT(script, USCRIPT_CODE_LIMIT); |
455 if (generic == FontDescription::kMonospaceFamily) { | 455 if (generic == FontDescription::kMonospaceFamily) { |
456 const UChar* monospace_family = FindMonospaceFontForScript(script); | 456 const UChar* monospace_family = FindMonospaceFontForScript(script); |
457 if (monospace_family) | 457 if (monospace_family) |
458 return monospace_family; | 458 return monospace_family; |
459 } | 459 } |
460 if (script_font_map[script].candidate_family_names) | 460 if (script_font_map[script].candidate_family_names) |
461 FindFirstExistingCandidateFont(script_font_map[script], font_manager); | 461 FindFirstExistingCandidateFont(script_font_map[script], font_manager); |
462 return script_font_map[script].family_name; | 462 return script_font_map[script].family_name; |
463 } | 463 } |
464 | 464 |
465 // FIXME: | 465 // FIXME: |
466 // - Handle 'Inherited', 'Common' and 'Unknown' | 466 // - Handle 'Inherited', 'Common' and 'Unknown' |
467 // (see http://www.unicode.org/reports/tr24/#Usage_Model ) | 467 // (see http://www.unicode.org/reports/tr24/#Usage_Model ) |
468 // For 'Inherited' and 'Common', perhaps we need to | 468 // For 'Inherited' and 'Common', perhaps we need to |
469 // accept another parameter indicating the previous family | 469 // accept another parameter indicating the previous family |
470 // and just return it. | 470 // and just return it. |
471 // - All the characters (or characters up to the point a single | 471 // - All the characters (or characters up to the point a single |
472 // font can cover) need to be taken into account | 472 // font can cover) need to be taken into account |
473 const UChar* GetFallbackFamily(UChar32 character, | 473 const UChar* GetFallbackFamily(UChar32 character, |
474 FontDescription::GenericFamilyType generic, | 474 FontDescription::GenericFamilyType generic, |
475 const LayoutLocale* content_locale, | 475 const LayoutLocale* content_locale, |
476 UScriptCode* script_checked, | 476 UScriptCode* script_checked, |
477 FontFallbackPriority fallback_priority, | 477 FontFallbackPriority fallback_priority, |
478 SkFontMgr* font_manager) { | 478 SkFontMgr* font_manager) { |
479 ASSERT(character); | 479 DCHECK(character); |
480 ASSERT(font_manager); | 480 DCHECK(font_manager); |
481 UBlockCode block = fallback_priority == FontFallbackPriority::kEmojiEmoji | 481 UBlockCode block = fallback_priority == FontFallbackPriority::kEmojiEmoji |
482 ? UBLOCK_EMOTICONS | 482 ? UBLOCK_EMOTICONS |
483 : ublock_getCode(character); | 483 : ublock_getCode(character); |
484 const UChar* family = GetFontBasedOnUnicodeBlock(block, font_manager); | 484 const UChar* family = GetFontBasedOnUnicodeBlock(block, font_manager); |
485 if (family) { | 485 if (family) { |
486 if (script_checked) | 486 if (script_checked) |
487 *script_checked = USCRIPT_INVALID_CODE; | 487 *script_checked = USCRIPT_INVALID_CODE; |
488 return family; | 488 return family; |
489 } | 489 } |
490 | 490 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 family = L"lucida sans unicode"; | 536 family = L"lucida sans unicode"; |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 if (script_checked) | 540 if (script_checked) |
541 *script_checked = script; | 541 *script_checked = script; |
542 return family; | 542 return family; |
543 } | 543 } |
544 | 544 |
545 } // namespace blink | 545 } // namespace blink |
OLD | NEW |