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

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

Issue 307243002: Fix font family based fallback font selection (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Windows link fix. Created 6 years, 6 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
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/fonts/FontCache.h" 32 #include "platform/fonts/FontCache.h"
33 33
34 34
35 #include "platform/fonts/SimpleFontData.h" 35 #include "platform/fonts/SimpleFontData.h"
36 #include "platform/fonts/FontDescription.h" 36 #include "platform/fonts/FontDescription.h"
37 #include "platform/fonts/FontFaceCreationParams.h"
37 38
38 #include "SkTypeface_android.h" 39 #include "SkTypeface_android.h"
39 40
40 namespace WebCore { 41 namespace WebCore {
41 42
42 static AtomicString getFamilyNameForCharacter(UChar32 c, UScriptCode script) 43 static AtomicString getFamilyNameForCharacter(UChar32 c, UScriptCode script)
43 { 44 {
44 // This is a hack to use the preferred font for CJK scripts. 45 // This is a hack to use the preferred font for CJK scripts.
45 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts. 46 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts.
46 const char* locale; 47 const char* locale;
(...skipping 20 matching lines...) Expand all
67 return emptyAtom; 68 return emptyAtom;
68 69
69 return skiaFamilyName.c_str(); 70 return skiaFamilyName.c_str();
70 } 71 }
71 72
72 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*) 73 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*)
73 { 74 {
74 AtomicString familyName = getFamilyNameForCharacter(c, fontDescription.scrip t()); 75 AtomicString familyName = getFamilyNameForCharacter(c, fontDescription.scrip t());
75 if (familyName.isEmpty()) 76 if (familyName.isEmpty())
76 return getLastResortFallbackFont(fontDescription, DoNotRetain); 77 return getLastResortFallbackFont(fontDescription, DoNotRetain);
77 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, fam ilyName), DoNotRetain); 78 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, Fon tFaceCreationParams(familyName)), DoNotRetain);
78 } 79 }
79 80
80 // static 81 // static
81 AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& family Name, UScriptCode script) 82 AtomicString FontCache::getGenericFamilyNameForScript(const AtomicString& family Name, UScriptCode script)
82 { 83 {
83 // This is a hack to use the preferred font for CJK scripts. 84 // This is a hack to use the preferred font for CJK scripts.
84 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts. 85 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts.
85 UChar32 examplerChar; 86 UChar32 examplerChar;
86 switch (script) { 87 switch (script) {
87 case USCRIPT_SIMPLIFIED_HAN: 88 case USCRIPT_SIMPLIFIED_HAN:
88 case USCRIPT_TRADITIONAL_HAN: 89 case USCRIPT_TRADITIONAL_HAN:
89 case USCRIPT_KATAKANA_OR_HIRAGANA: 90 case USCRIPT_KATAKANA_OR_HIRAGANA:
90 examplerChar = 0x4E00; // A common character in Japanese and Chinese. 91 examplerChar = 0x4E00; // A common character in Japanese and Chinese.
91 break; 92 break;
92 case USCRIPT_HANGUL: 93 case USCRIPT_HANGUL:
93 examplerChar = 0xAC00; 94 examplerChar = 0xAC00;
94 break; 95 break;
95 default: 96 default:
96 // For other scripts, use the default generic family mapping logic. 97 // For other scripts, use the default generic family mapping logic.
97 return familyName; 98 return familyName;
98 } 99 }
99 100
100 return getFamilyNameForCharacter(examplerChar, script); 101 return getFamilyNameForCharacter(examplerChar, script);
101 } 102 }
102 103
103 } // namespace WebCore 104 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontFaceCreationParams.h ('k') | Source/platform/fonts/linux/FontCacheLinux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698