| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 Google Inc. All rights reserved. |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 AtomicString FontCache::getGenericFamilyNameForScript( | 58 AtomicString FontCache::getGenericFamilyNameForScript( |
| 59 const AtomicString& familyName, | 59 const AtomicString& familyName, |
| 60 const FontDescription& fontDescription) { | 60 const FontDescription& fontDescription) { |
| 61 // If monospace, do not apply CJK hack to find i18n fonts, because | 61 // If monospace, do not apply CJK hack to find i18n fonts, because |
| 62 // i18n fonts are likely not monospace. Monospace is mostly used | 62 // i18n fonts are likely not monospace. Monospace is mostly used |
| 63 // for code, but when i18n characters appear in monospace, system | 63 // for code, but when i18n characters appear in monospace, system |
| 64 // fallback can still render the characters. | 64 // fallback can still render the characters. |
| 65 if (familyName == FontFamilyNames::webkit_monospace) | 65 if (familyName == FontFamilyNames::webkit_monospace) |
| 66 return familyName; | 66 return familyName; |
| 67 | 67 |
| 68 // The CJK hack below should be removed, at latest when we have |
| 69 // serif and sans-serif versions of CJK fonts. Until then, limit it |
| 70 // to only when the content locale is available. crbug.com/652146 |
| 71 const LayoutLocale* contentLocale = fontDescription.locale(); |
| 72 if (!contentLocale) |
| 73 return familyName; |
| 74 |
| 68 // This is a hack to use the preferred font for CJK scripts. | 75 // This is a hack to use the preferred font for CJK scripts. |
| 69 // TODO(kojii): This logic disregards either generic family name | 76 // TODO(kojii): This logic disregards either generic family name |
| 70 // or locale. We need an API that honors both to find appropriate | 77 // or locale. We need an API that honors both to find appropriate |
| 71 // fonts. crbug.com/642340 | 78 // fonts. crbug.com/642340 |
| 72 UChar32 examplerChar; | 79 UChar32 examplerChar; |
| 73 switch (fontDescription.script()) { | 80 switch (contentLocale->script()) { |
| 74 case USCRIPT_SIMPLIFIED_HAN: | 81 case USCRIPT_SIMPLIFIED_HAN: |
| 75 case USCRIPT_TRADITIONAL_HAN: | 82 case USCRIPT_TRADITIONAL_HAN: |
| 76 case USCRIPT_KATAKANA_OR_HIRAGANA: | 83 case USCRIPT_KATAKANA_OR_HIRAGANA: |
| 77 examplerChar = 0x4E00; // A common character in Japanese and Chinese. | 84 examplerChar = 0x4E00; // A common character in Japanese and Chinese. |
| 78 break; | 85 break; |
| 79 case USCRIPT_HANGUL: | 86 case USCRIPT_HANGUL: |
| 80 examplerChar = 0xAC00; | 87 examplerChar = 0xAC00; |
| 81 break; | 88 break; |
| 82 default: | 89 default: |
| 83 // For other scripts, use the default generic family mapping logic. | 90 // For other scripts, use the default generic family mapping logic. |
| 84 return familyName; | 91 return familyName; |
| 85 } | 92 } |
| 86 | 93 |
| 87 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 94 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 88 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, | 95 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, |
| 89 FontFallbackPriority::Text); | 96 FontFallbackPriority::Text); |
| 90 } | 97 } |
| 91 | 98 |
| 92 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |