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

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

Issue 2288383002: Disable CJK specific generic font families for monospace on Android (Closed)
Patch Set: drott review, updated comments Created 4 years, 3 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 | third_party/WebKit/Source/platform/fonts/android/FontCacheAndroidTest.cpp » ('j') | 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); 44 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
45 AtomicString familyName = getFamilyNameForCharacter(fm.get(), c, fontDescrip tion, fallbackPriority); 45 AtomicString familyName = getFamilyNameForCharacter(fm.get(), c, fontDescrip tion, fallbackPriority);
46 if (familyName.isEmpty()) 46 if (familyName.isEmpty())
47 return getLastResortFallbackFont(fontDescription, DoNotRetain); 47 return getLastResortFallbackFont(fontDescription, DoNotRetain);
48 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, Fon tFaceCreationParams(familyName)), DoNotRetain); 48 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, Fon tFaceCreationParams(familyName)), DoNotRetain);
49 } 49 }
50 50
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
55 // i18n fonts are likely not monospace. Monospace is mostly used
56 // for code, but when i18n characters appear in monospace, system
57 // fallback can still render the characters.
58 if (familyName == FontFamilyNames::webkit_monospace)
59 return familyName;
60
54 // This is a hack to use the preferred font for CJK scripts. 61 // This is a hack to use the preferred font for CJK scripts.
55 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts. 62 // TODO(kojii): This logic disregards either generic family name
63 // or locale. We need an API that honors both to find appropriate
64 // fonts. crbug.com/642340
56 UChar32 examplerChar; 65 UChar32 examplerChar;
57 switch (fontDescription.script()) { 66 switch (fontDescription.script()) {
58 case USCRIPT_SIMPLIFIED_HAN: 67 case USCRIPT_SIMPLIFIED_HAN:
59 case USCRIPT_TRADITIONAL_HAN: 68 case USCRIPT_TRADITIONAL_HAN:
60 case USCRIPT_KATAKANA_OR_HIRAGANA: 69 case USCRIPT_KATAKANA_OR_HIRAGANA:
61 examplerChar = 0x4E00; // A common character in Japanese and Chinese. 70 examplerChar = 0x4E00; // A common character in Japanese and Chinese.
62 break; 71 break;
63 case USCRIPT_HANGUL: 72 case USCRIPT_HANGUL:
64 examplerChar = 0xAC00; 73 examplerChar = 0xAC00;
65 break; 74 break;
66 default: 75 default:
67 // For other scripts, use the default generic family mapping logic. 76 // For other scripts, use the default generic family mapping logic.
68 return familyName; 77 return familyName;
69 } 78 }
70 79
71 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); 80 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
72 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text); 81 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text);
73 } 82 }
74 83
75 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/fonts/android/FontCacheAndroidTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698