Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/android/FontCacheAndroid.cpp

Issue 2396143002: Merge 2840: Re-limit the CJK font hack for Android to only when the content language is available (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // static 51 // static
52 AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& family Name, const FontDescription& fontDescription) 52 AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& family Name, const FontDescription& fontDescription)
53 { 53 {
54 // If monospace, do not apply CJK hack to find i18n fonts, because 54 // If monospace, do not apply CJK hack to find i18n fonts, because
55 // i18n fonts are likely not monospace. Monospace is mostly used 55 // i18n fonts are likely not monospace. Monospace is mostly used
56 // for code, but when i18n characters appear in monospace, system 56 // for code, but when i18n characters appear in monospace, system
57 // fallback can still render the characters. 57 // fallback can still render the characters.
58 if (familyName == FontFamilyNames::webkit_monospace) 58 if (familyName == FontFamilyNames::webkit_monospace)
59 return familyName; 59 return familyName;
60 60
61 // This is a hack to use the preferred font for CJK scripts. 61 // The CJK hack below should be removed, at latest when we have
62 // TODO(kojii): This logic disregards either generic family name 62 // serif and sans-serif versions of CJK fonts. Until then, limit it
63 // or locale. We need an API that honors both to find appropriate 63 // to only when the content locale is available. crbug.com/652146
64 // fonts. crbug.com/642340 64 const LayoutLocale* contentLocale = fontDescription.locale();
65 UChar32 examplerChar; 65 if (!contentLocale)
66 switch (fontDescription.script()) { 66 return familyName;
67
68 // This is a hack to use the preferred font for CJK scripts.
69 // TODO(kojii): This logic disregards either generic family name
70 // or locale. We need an API that honors both to find appropriate
71 // fonts. crbug.com/642340
72 UChar32 examplerChar;
73 switch (contentLocale->script()) {
67 case USCRIPT_SIMPLIFIED_HAN: 74 case USCRIPT_SIMPLIFIED_HAN:
68 case USCRIPT_TRADITIONAL_HAN: 75 case USCRIPT_TRADITIONAL_HAN:
69 case USCRIPT_KATAKANA_OR_HIRAGANA: 76 case USCRIPT_KATAKANA_OR_HIRAGANA:
70 examplerChar = 0x4E00; // A common character in Japanese and Chinese. 77 examplerChar = 0x4E00; // A common character in Japanese and Chinese.
71 break; 78 break;
72 case USCRIPT_HANGUL: 79 case USCRIPT_HANGUL:
73 examplerChar = 0xAC00; 80 examplerChar = 0xAC00;
74 break; 81 break;
75 default: 82 default:
76 // For other scripts, use the default generic family mapping logic. 83 // For other scripts, use the default generic family mapping logic.
77 return familyName; 84 return familyName;
78 } 85 }
79 86
80 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); 87 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
81 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text); 88 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text);
82 } 89 }
83 90
84 } // namespace blink 91 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698