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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. | |
drott
2016/08/30 08:18:58
Looks okay to me but let's file a bug to keep trac
| |
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 // FIXME: Use new Skia API once Android system supports per-family and per-s cript fallback fonts. |
56 UChar32 examplerChar; | 63 UChar32 examplerChar; |
57 switch (fontDescription.script()) { | 64 switch (fontDescription.script()) { |
58 case USCRIPT_SIMPLIFIED_HAN: | 65 case USCRIPT_SIMPLIFIED_HAN: |
59 case USCRIPT_TRADITIONAL_HAN: | 66 case USCRIPT_TRADITIONAL_HAN: |
60 case USCRIPT_KATAKANA_OR_HIRAGANA: | 67 case USCRIPT_KATAKANA_OR_HIRAGANA: |
61 examplerChar = 0x4E00; // A common character in Japanese and Chinese. | 68 examplerChar = 0x4E00; // A common character in Japanese and Chinese. |
62 break; | 69 break; |
63 case USCRIPT_HANGUL: | 70 case USCRIPT_HANGUL: |
64 examplerChar = 0xAC00; | 71 examplerChar = 0xAC00; |
65 break; | 72 break; |
66 default: | 73 default: |
67 // For other scripts, use the default generic family mapping logic. | 74 // For other scripts, use the default generic family mapping logic. |
68 return familyName; | 75 return familyName; |
69 } | 76 } |
70 | 77 |
71 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); | 78 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
72 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text); | 79 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, Fo ntFallbackPriority::Text); |
73 } | 80 } |
74 | 81 |
75 } // namespace blink | 82 } // namespace blink |
OLD | NEW |