| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // this ICU locale tells the current UI locale of Chrome. | 311 // this ICU locale tells the current UI locale of Chrome. |
| 312 UScriptCode hanScript = scriptCodeForHanFromLocale( | 312 UScriptCode hanScript = scriptCodeForHanFromLocale( |
| 313 icu::Locale::getDefault().getName(), '_'); | 313 icu::Locale::getDefault().getName(), '_'); |
| 314 // For other locales, use the simplified Chinese font for Han. | 314 // For other locales, use the simplified Chinese font for Han. |
| 315 const UChar* localeFamily = scriptFontMap[hanScript == USCRIPT_COMMON | 315 const UChar* localeFamily = scriptFontMap[hanScript == USCRIPT_COMMON |
| 316 ? USCRIPT_SIMPLIFIED_HAN : hanScript]; | 316 ? USCRIPT_SIMPLIFIED_HAN : hanScript]; |
| 317 if (localeFamily) | 317 if (localeFamily) |
| 318 scriptFontMap[USCRIPT_HAN] = localeFamily; | 318 scriptFontMap[USCRIPT_HAN] = localeFamily; |
| 319 } | 319 } |
| 320 | 320 |
| 321 static UScriptCode scriptForHan(UScriptCode contentScript, | 321 static UScriptCode scriptForHan(const LayoutLocale& contentLocale) |
| 322 const AtomicString& contentLocale) | |
| 323 { | 322 { |
| 324 UScriptCode script = scriptCodeForHanFromLocale(contentScript, contentLocale
); | 323 UScriptCode script = contentLocale.scriptForHan(); |
| 325 if (script != USCRIPT_COMMON) | 324 if (script != USCRIPT_HAN) |
| 326 return script; | 325 return script; |
| 327 script = AcceptLanguagesResolver::preferredHanScript(); | 326 script = AcceptLanguagesResolver::preferredHanScript(); |
| 328 if (script != USCRIPT_COMMON) | 327 if (script != USCRIPT_COMMON) |
| 329 return script; | 328 return script; |
| 330 // Use UI locale. See initializeScriptFontMap(). | 329 // Use UI locale. See initializeScriptFontMap(). |
| 331 return USCRIPT_HAN; | 330 return USCRIPT_HAN; |
| 332 } | 331 } |
| 333 | 332 |
| 334 // There are a lot of characters in USCRIPT_COMMON that can be covered | 333 // There are a lot of characters in USCRIPT_COMMON that can be covered |
| 335 // by fonts for scripts closely related to them. See | 334 // by fonts for scripts closely related to them. See |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // FIXME: | 473 // FIXME: |
| 475 // - Handle 'Inherited', 'Common' and 'Unknown' | 474 // - Handle 'Inherited', 'Common' and 'Unknown' |
| 476 // (see http://www.unicode.org/reports/tr24/#Usage_Model ) | 475 // (see http://www.unicode.org/reports/tr24/#Usage_Model ) |
| 477 // For 'Inherited' and 'Common', perhaps we need to | 476 // For 'Inherited' and 'Common', perhaps we need to |
| 478 // accept another parameter indicating the previous family | 477 // accept another parameter indicating the previous family |
| 479 // and just return it. | 478 // and just return it. |
| 480 // - All the characters (or characters up to the point a single | 479 // - All the characters (or characters up to the point a single |
| 481 // font can cover) need to be taken into account | 480 // font can cover) need to be taken into account |
| 482 const UChar* getFallbackFamily(UChar32 character, | 481 const UChar* getFallbackFamily(UChar32 character, |
| 483 FontDescription::GenericFamilyType generic, | 482 FontDescription::GenericFamilyType generic, |
| 484 UScriptCode contentScript, | 483 const LayoutLocale& contentLocale, |
| 485 const AtomicString& contentLocale, | |
| 486 UScriptCode* scriptChecked, | 484 UScriptCode* scriptChecked, |
| 487 FontFallbackPriority fallbackPriority, | 485 FontFallbackPriority fallbackPriority, |
| 488 SkFontMgr* fontManager) | 486 SkFontMgr* fontManager) |
| 489 { | 487 { |
| 490 ASSERT(character); | 488 ASSERT(character); |
| 491 ASSERT(fontManager); | 489 ASSERT(fontManager); |
| 492 UBlockCode block = fallbackPriority == FontFallbackPriority::EmojiEmoji ? | 490 UBlockCode block = fallbackPriority == FontFallbackPriority::EmojiEmoji ? |
| 493 UBLOCK_EMOTICONS : ublock_getCode(character); | 491 UBLOCK_EMOTICONS : ublock_getCode(character); |
| 494 const UChar* family = getFontBasedOnUnicodeBlock(block, fontManager); | 492 const UChar* family = getFontBasedOnUnicodeBlock(block, fontManager); |
| 495 if (family) { | 493 if (family) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 506 // they're fully covered by Chinese, Japanese and Korean fonts. | 504 // they're fully covered by Chinese, Japanese and Korean fonts. |
| 507 if (0xFF00 < character && character < 0xFF5F) | 505 if (0xFF00 < character && character < 0xFF5F) |
| 508 script = USCRIPT_HAN; | 506 script = USCRIPT_HAN; |
| 509 | 507 |
| 510 if (script == USCRIPT_COMMON) | 508 if (script == USCRIPT_COMMON) |
| 511 script = getScriptBasedOnUnicodeBlock(character); | 509 script = getScriptBasedOnUnicodeBlock(character); |
| 512 | 510 |
| 513 // For unified-Han scripts, try the lang attribute, system, or | 511 // For unified-Han scripts, try the lang attribute, system, or |
| 514 // accept-languages. | 512 // accept-languages. |
| 515 if (script == USCRIPT_HAN) | 513 if (script == USCRIPT_HAN) |
| 516 script = scriptForHan(contentScript, contentLocale); | 514 script = scriptForHan(contentLocale); |
| 517 | 515 |
| 518 family = getFontFamilyForScript(script, generic, fontManager); | 516 family = getFontFamilyForScript(script, generic, fontManager); |
| 519 // Another lame work-around to cover non-BMP characters. | 517 // Another lame work-around to cover non-BMP characters. |
| 520 // If the font family for script is not found or the character is | 518 // If the font family for script is not found or the character is |
| 521 // not in BMP (> U+FFFF), we resort to the hard-coded list of | 519 // not in BMP (> U+FFFF), we resort to the hard-coded list of |
| 522 // fallback fonts for now. | 520 // fallback fonts for now. |
| 523 if (!family || character > 0xFFFF) { | 521 if (!family || character > 0xFFFF) { |
| 524 int plane = character >> 16; | 522 int plane = character >> 16; |
| 525 switch (plane) { | 523 switch (plane) { |
| 526 case 1: | 524 case 1: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 541 family = L"lucida sans unicode"; | 539 family = L"lucida sans unicode"; |
| 542 } | 540 } |
| 543 } | 541 } |
| 544 | 542 |
| 545 if (scriptChecked) | 543 if (scriptChecked) |
| 546 *scriptChecked = script; | 544 *scriptChecked = script; |
| 547 return family; | 545 return family; |
| 548 } | 546 } |
| 549 | 547 |
| 550 } // namespace blink | 548 } // namespace blink |
| OLD | NEW |