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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp

Issue 2215543002: Remove unnecessary font loading when loading font fallbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor based on codereview feedback Created 4 years, 4 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) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser ved. 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser ved.
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (equalIgnoringCase(family, AtomicString::fromUTF8(actualFamily.fStrin g.c_str()))) { 61 if (equalIgnoringCase(family, AtomicString::fromUTF8(actualFamily.fStrin g.c_str()))) {
62 matchesRequestedFamily = true; 62 matchesRequestedFamily = true;
63 break; 63 break;
64 } 64 }
65 } 65 }
66 actualFamilies->unref(); 66 actualFamilies->unref();
67 67
68 return matchesRequestedFamily; 68 return matchesRequestedFamily;
69 } 69 }
70 70
71 struct FontMapping {
72 const UChar* familyName;
73 const UChar** candidateFamilyNames;
74 };
71 // A simple mapping from UScriptCode to family name. This is a sparse array, 75 // A simple mapping from UScriptCode to family name. This is a sparse array,
72 // which works well since the range of UScriptCode values is small. 76 // which works well since the range of UScriptCode values is small.
73 typedef const UChar* ScriptToFontMap[USCRIPT_CODE_LIMIT]; 77 typedef FontMapping ScriptToFontMap[USCRIPT_CODE_LIMIT];
74 78
75 void initializeScriptMonospaceFontMap(ScriptToFontMap& scriptFontMap, SkFontMgr* fontManager) 79 void findMonospaceFontForScript(UScriptCode script, FontMapping& scriptFontMappi ng)
76 { 80 {
77 struct FontMap { 81 struct FontMap {
78 UScriptCode script; 82 UScriptCode script;
79 const UChar* family; 83 const UChar* family;
80 }; 84 };
81 85
82 static const FontMap fontMap[] = { 86 static const FontMap fontMap[] = {
83 { USCRIPT_HEBREW, L"courier new" }, 87 { USCRIPT_HEBREW, L"courier new" },
84 { USCRIPT_ARABIC, L"courier new" }, 88 { USCRIPT_ARABIC, L"courier new" },
85 }; 89 };
86 90
87 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontMap); ++i) 91 for (const auto& fontFamily : fontMap) {
88 scriptFontMap[fontMap[i].script] = fontMap[i].family; 92 if (fontFamily.script != script)
93 continue;
94 scriptFontMapping.familyName = fontFamily.family;
95 break;
96 }
89 } 97 }
90 98
91 void initializeScriptFontMap(ScriptToFontMap& scriptFontMap, SkFontMgr* fontMana ger) 99 void initializeScriptFontMap(ScriptToFontMap& scriptFontMap)
92 { 100 {
93 struct FontMap {
94 UScriptCode script;
95 const UChar* family;
96 };
97
98 static const FontMap fontMap[] = {
99 { USCRIPT_LATIN, L"Times New Roman" },
100 { USCRIPT_GREEK, L"Times New Roman" },
101 { USCRIPT_CYRILLIC, L"Times New Roman" },
102 // For USCRIPT_COMMON, we map blocks to scripts when
103 // that makes sense.
104 };
105
106 struct ScriptToFontFamilies { 101 struct ScriptToFontFamilies {
107 UScriptCode script; 102 UScriptCode script;
108 const UChar** families; 103 const UChar** families;
109 }; 104 };
110 105
111 // For the following scripts, multiple fonts may be listed. They are tried 106 // For the following scripts, multiple fonts may be listed. They are tried
112 // in order. The first slot is preferred but the font may not be available, 107 // in order. The first slot is preferred but the font may not be available,
113 // if so the remaining slots are tried in order. 108 // if so the remaining slots are tried in order.
114 // In general the order is the Windows 10 font follow by the 8.1, 8.0 and 109 // In general the order is the Windows 10 font follow by the 8.1, 8.0 and
115 // finally the font for Windows 7. 110 // finally the font for Windows 7.
116 // For scripts where an optional or region specific font may be available 111 // For scripts where an optional or region specific font may be available
117 // that should be listed before the generic one. 112 // that should be listed before the generic one.
118 // Based on the "Script and Font Support in Windows" MSDN documentation [1] 113 // Based on the "Script and Font Support in Windows" MSDN documentation [1]
119 // with overrides and additional fallbacks as needed. 114 // with overrides and additional fallbacks as needed.
120 // 1: https://msdn.microsoft.com/en-us/goglobal/bb688099.aspx 115 // 1: https://msdn.microsoft.com/en-us/goglobal/bb688099.aspx
121 static const UChar* arabicFonts[] = { L"Tahoma", L"Segoe UI", 0 }; 116 static const UChar* arabicFonts[] = { L"Tahoma", L"Segoe UI", 0 };
122 static const UChar* armenianFonts[] = { L"Segoe UI", L"Sylfaen", 0 }; 117 static const UChar* armenianFonts[] = { L"Segoe UI", L"Sylfaen", 0 };
123 static const UChar* bengaliFonts[] = { L"Nirmala UI", L"Vrinda", 0 }; 118 static const UChar* bengaliFonts[] = { L"Nirmala UI", L"Vrinda", 0 };
124 static const UChar* brahmiFonts[] = { L"Segoe UI Historic", 0 }; 119 static const UChar* brahmiFonts[] = { L"Segoe UI Historic", 0 };
125 static const UChar* brailleFonts[] = { L"Segoe UI Symbol", 0 }; 120 static const UChar* brailleFonts[] = { L"Segoe UI Symbol", 0 };
126 static const UChar* bugineseFonts[] = { L"Leelawadee UI", 0 }; 121 static const UChar* bugineseFonts[] = { L"Leelawadee UI", 0 };
127 static const UChar* canadianAaboriginalFonts[] = { L"Gadugi", 122 static const UChar* canadianAaboriginalFonts[] = { L"Gadugi",
128 L"Euphemia", 0 }; 123 L"Euphemia", 0 };
129 static const UChar* carianFonts[] = { L"Segoe UI Historic", 0 }; 124 static const UChar* carianFonts[] = { L"Segoe UI Historic", 0 };
130 static const UChar* cherokeeFonts[] = { L"Gadugi", L"Plantagenet", 0 }; 125 static const UChar* cherokeeFonts[] = { L"Gadugi", L"Plantagenet", 0 };
131 static const UChar* copticFonts[] = { L"Segoe UI Symbol", 0 }; 126 static const UChar* copticFonts[] = { L"Segoe UI Symbol", 0 };
132 static const UChar* cuneiformFonts[] = { L"Segoe UI Historic", 0 }; 127 static const UChar* cuneiformFonts[] = { L"Segoe UI Historic", 0 };
133 static const UChar* cypriotFonts[] = { L"Segoe UI Historic", 0 }; 128 static const UChar* cypriotFonts[] = { L"Segoe UI Historic", 0 };
129 static const UChar* cyrillicFonts[] = { L"Times New Roman", 0 };
134 static const UChar* deseretFonts[] = { L"Segoe UI Symbol", 0 }; 130 static const UChar* deseretFonts[] = { L"Segoe UI Symbol", 0 };
135 static const UChar* devanagariFonts[] = { L"Nirmala UI", L"Mangal", 0 }; 131 static const UChar* devanagariFonts[] = { L"Nirmala UI", L"Mangal", 0 };
136 static const UChar* egyptianHieroglyphsFonts[] = { L"Segoe UI Historic", 132 static const UChar* egyptianHieroglyphsFonts[] = { L"Segoe UI Historic",
137 0 }; 133 0 };
138 static const UChar* ethiopicFonts[] = { L"Nyala", L"Abyssinica SIL", 134 static const UChar* ethiopicFonts[] = { L"Nyala", L"Abyssinica SIL",
139 L"Ethiopia Jiret", L"Visual Geez Unicode", L"GF Zemen Unicode", 135 L"Ethiopia Jiret", L"Visual Geez Unicode", L"GF Zemen Unicode",
140 L"Ebrima", 0 }; 136 L"Ebrima", 0 };
141 static const UChar* georgianFonts[] = { L"Sylfaen", L"Segoe UI", 0 }; 137 static const UChar* georgianFonts[] = { L"Sylfaen", L"Segoe UI", 0 };
142 static const UChar* glagoliticFonts[] = { L"Segoe UI Historic", 138 static const UChar* glagoliticFonts[] = { L"Segoe UI Historic",
143 L"Segoe UI Symbol", 0 }; 139 L"Segoe UI Symbol", 0 };
144 static const UChar* gothicFonts[] = { L"Segoe UI Historic", 140 static const UChar* gothicFonts[] = { L"Segoe UI Historic",
145 L"Segoe UI Symbol", 0 }; 141 L"Segoe UI Symbol", 0 };
142 static const UChar* greekFonts[] = { L"Times New Roman", 0 };
146 static const UChar* gujaratiFonts[] = { L"Nirmala UI", L"Shruti", 0 }; 143 static const UChar* gujaratiFonts[] = { L"Nirmala UI", L"Shruti", 0 };
147 static const UChar* gurmukhiFonts[] = { L"Nirmala UI", L"Raavi", 0 }; 144 static const UChar* gurmukhiFonts[] = { L"Nirmala UI", L"Raavi", 0 };
148 static const UChar* hangulFonts[] = { L"Malgun Gothic", L"Gulim", 0 }; 145 static const UChar* hangulFonts[] = { L"Malgun Gothic", L"Gulim", 0 };
149 static const UChar* hebrewFonts[] = { L"David", L"Segoe UI", 0 }; 146 static const UChar* hebrewFonts[] = { L"David", L"Segoe UI", 0 };
150 static const UChar* imperialAramaicFonts[] = { L"Segoe UI Historic", 0 }; 147 static const UChar* imperialAramaicFonts[] = { L"Segoe UI Historic", 0 };
151 static const UChar* inscriptionalPahlaviFonts[] = { L"Segoe UI Historic", 148 static const UChar* inscriptionalPahlaviFonts[] = { L"Segoe UI Historic",
152 0 }; 149 0 };
153 static const UChar* inscriptionalParthianFonts[] = { L"Segoe UI Historic", 150 static const UChar* inscriptionalParthianFonts[] = { L"Segoe UI Historic",
154 0 }; 151 0 };
155 static const UChar* javaneseFonts[] = { L"Javanese Text", 0 }; 152 static const UChar* javaneseFonts[] = { L"Javanese Text", 0 };
156 static const UChar* kannadaFonts[] = { L"Tunga", L"Nirmala UI", 0 }; 153 static const UChar* kannadaFonts[] = { L"Tunga", L"Nirmala UI", 0 };
157 static const UChar* katakanaOrHiraganaFonts[] = { L"Meiryo", L"Yu Gothic", 154 static const UChar* katakanaOrHiraganaFonts[] = { L"Meiryo", L"Yu Gothic",
158 L"MS PGothic", L"Microsoft YaHei", 0 }; 155 L"MS PGothic", L"Microsoft YaHei", 0 };
159 static const UChar* kharoshthiFonts[] = { L"Segoe UI Historic", 0 }; 156 static const UChar* kharoshthiFonts[] = { L"Segoe UI Historic", 0 };
160 // Try Khmer OS before Vista fonts as it goes along better with Latin 157 // Try Khmer OS before Vista fonts as it goes along better with Latin
161 // and looks better/larger for the same size. 158 // and looks better/larger for the same size.
162 static const UChar* khmerFonts[] = { L"Leelawadee UI", L"Khmer UI", 159 static const UChar* khmerFonts[] = { L"Leelawadee UI", L"Khmer UI",
163 L"Khmer OS", L"MoolBoran", L"DaunPenh", 0 }; 160 L"Khmer OS", L"MoolBoran", L"DaunPenh", 0 };
164 static const UChar* laoFonts[] = { L"Leelawadee UI", L"Lao UI", 161 static const UChar* laoFonts[] = { L"Leelawadee UI", L"Lao UI",
165 L"DokChampa", L"Saysettha OT", L"Phetsarath OT", L"Code2000", 0 }; 162 L"DokChampa", L"Saysettha OT", L"Phetsarath OT", L"Code2000", 0 };
163 static const UChar* latinFonts[] = { L"Times New Roman", 0 };
166 static const UChar* lisuFonts[] = { L"Segoe UI", 0 }; 164 static const UChar* lisuFonts[] = { L"Segoe UI", 0 };
167 static const UChar* lycianFonts[] = { L"Segoe UI Historic", 0 }; 165 static const UChar* lycianFonts[] = { L"Segoe UI Historic", 0 };
168 static const UChar* lydianFonts[] = { L"Segoe UI Historic", 0 }; 166 static const UChar* lydianFonts[] = { L"Segoe UI Historic", 0 };
169 static const UChar* malayalamFonts[] = { L"Nirmala UI", L"Kartika", 0 }; 167 static const UChar* malayalamFonts[] = { L"Nirmala UI", L"Kartika", 0 };
170 static const UChar* meroiticCursiveFonts[] = { L"Segoe UI Historic", 168 static const UChar* meroiticCursiveFonts[] = { L"Segoe UI Historic",
171 L"Segoe UI Symbol", 0 }; 169 L"Segoe UI Symbol", 0 };
172 static const UChar* mongolianFonts[] = { L"Mongolian Baiti", 0 }; 170 static const UChar* mongolianFonts[] = { L"Mongolian Baiti", 0 };
173 static const UChar* myanmarFonts[] = { L"Myanmar Text", L"Padauk", 171 static const UChar* myanmarFonts[] = { L"Myanmar Text", L"Padauk",
174 L"Parabaik", L"Myanmar3", L"Code2000", 0 }; 172 L"Parabaik", L"Myanmar3", L"Code2000", 0 };
175 static const UChar* newTaiLueFonts[] = { L"Microsoft New Tai Lue", 0 }; 173 static const UChar* newTaiLueFonts[] = { L"Microsoft New Tai Lue", 0 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 { USCRIPT_BENGALI, bengaliFonts }, 217 { USCRIPT_BENGALI, bengaliFonts },
220 { USCRIPT_BRAHMI, brahmiFonts }, 218 { USCRIPT_BRAHMI, brahmiFonts },
221 { USCRIPT_BRAILLE, brailleFonts }, 219 { USCRIPT_BRAILLE, brailleFonts },
222 { USCRIPT_BUGINESE, bugineseFonts }, 220 { USCRIPT_BUGINESE, bugineseFonts },
223 { USCRIPT_CANADIAN_ABORIGINAL, canadianAaboriginalFonts }, 221 { USCRIPT_CANADIAN_ABORIGINAL, canadianAaboriginalFonts },
224 { USCRIPT_CARIAN, carianFonts }, 222 { USCRIPT_CARIAN, carianFonts },
225 { USCRIPT_CHEROKEE, cherokeeFonts }, 223 { USCRIPT_CHEROKEE, cherokeeFonts },
226 { USCRIPT_COPTIC, copticFonts }, 224 { USCRIPT_COPTIC, copticFonts },
227 { USCRIPT_CUNEIFORM, cuneiformFonts }, 225 { USCRIPT_CUNEIFORM, cuneiformFonts },
228 { USCRIPT_CYPRIOT, cypriotFonts }, 226 { USCRIPT_CYPRIOT, cypriotFonts },
227 { USCRIPT_CYRILLIC, cyrillicFonts },
229 { USCRIPT_DESERET, deseretFonts }, 228 { USCRIPT_DESERET, deseretFonts },
230 { USCRIPT_DEVANAGARI, devanagariFonts }, 229 { USCRIPT_DEVANAGARI, devanagariFonts },
231 { USCRIPT_EGYPTIAN_HIEROGLYPHS, egyptianHieroglyphsFonts }, 230 { USCRIPT_EGYPTIAN_HIEROGLYPHS, egyptianHieroglyphsFonts },
232 { USCRIPT_ETHIOPIC, ethiopicFonts }, 231 { USCRIPT_ETHIOPIC, ethiopicFonts },
233 { USCRIPT_GEORGIAN, georgianFonts }, 232 { USCRIPT_GEORGIAN, georgianFonts },
234 { USCRIPT_GLAGOLITIC, glagoliticFonts }, 233 { USCRIPT_GLAGOLITIC, glagoliticFonts },
235 { USCRIPT_GOTHIC, gothicFonts }, 234 { USCRIPT_GOTHIC, gothicFonts },
235 { USCRIPT_GREEK, greekFonts },
236 { USCRIPT_GUJARATI, gujaratiFonts }, 236 { USCRIPT_GUJARATI, gujaratiFonts },
237 { USCRIPT_GURMUKHI, gurmukhiFonts }, 237 { USCRIPT_GURMUKHI, gurmukhiFonts },
238 { USCRIPT_HANGUL, hangulFonts }, 238 { USCRIPT_HANGUL, hangulFonts },
239 { USCRIPT_HEBREW, hebrewFonts }, 239 { USCRIPT_HEBREW, hebrewFonts },
240 { USCRIPT_HIRAGANA, katakanaOrHiraganaFonts }, 240 { USCRIPT_HIRAGANA, katakanaOrHiraganaFonts },
241 { USCRIPT_IMPERIAL_ARAMAIC, imperialAramaicFonts }, 241 { USCRIPT_IMPERIAL_ARAMAIC, imperialAramaicFonts },
242 { USCRIPT_INSCRIPTIONAL_PAHLAVI, inscriptionalPahlaviFonts }, 242 { USCRIPT_INSCRIPTIONAL_PAHLAVI, inscriptionalPahlaviFonts },
243 { USCRIPT_INSCRIPTIONAL_PARTHIAN, inscriptionalParthianFonts }, 243 { USCRIPT_INSCRIPTIONAL_PARTHIAN, inscriptionalParthianFonts },
244 { USCRIPT_JAVANESE, javaneseFonts }, 244 { USCRIPT_JAVANESE, javaneseFonts },
245 { USCRIPT_KANNADA, kannadaFonts }, 245 { USCRIPT_KANNADA, kannadaFonts },
246 { USCRIPT_KATAKANA, katakanaOrHiraganaFonts }, 246 { USCRIPT_KATAKANA, katakanaOrHiraganaFonts },
247 { USCRIPT_KATAKANA_OR_HIRAGANA, katakanaOrHiraganaFonts }, 247 { USCRIPT_KATAKANA_OR_HIRAGANA, katakanaOrHiraganaFonts },
248 { USCRIPT_KHAROSHTHI, kharoshthiFonts }, 248 { USCRIPT_KHAROSHTHI, kharoshthiFonts },
249 { USCRIPT_KHMER, khmerFonts }, 249 { USCRIPT_KHMER, khmerFonts },
250 { USCRIPT_LAO, laoFonts }, 250 { USCRIPT_LAO, laoFonts },
251 { USCRIPT_LATIN, latinFonts },
251 { USCRIPT_LISU, lisuFonts }, 252 { USCRIPT_LISU, lisuFonts },
252 { USCRIPT_LYCIAN, lycianFonts }, 253 { USCRIPT_LYCIAN, lycianFonts },
253 { USCRIPT_LYDIAN, lydianFonts }, 254 { USCRIPT_LYDIAN, lydianFonts },
254 { USCRIPT_MALAYALAM, malayalamFonts }, 255 { USCRIPT_MALAYALAM, malayalamFonts },
255 { USCRIPT_MEROITIC_CURSIVE, meroiticCursiveFonts }, 256 { USCRIPT_MEROITIC_CURSIVE, meroiticCursiveFonts },
256 { USCRIPT_MONGOLIAN, mongolianFonts }, 257 { USCRIPT_MONGOLIAN, mongolianFonts },
257 { USCRIPT_MYANMAR, myanmarFonts }, 258 { USCRIPT_MYANMAR, myanmarFonts },
258 { USCRIPT_NEW_TAI_LUE, newTaiLueFonts }, 259 { USCRIPT_NEW_TAI_LUE, newTaiLueFonts },
259 { USCRIPT_NKO, nkoFonts }, 260 { USCRIPT_NKO, nkoFonts },
260 { USCRIPT_OGHAM, oghamFonts }, 261 { USCRIPT_OGHAM, oghamFonts },
(...skipping 17 matching lines...) Expand all
278 { USCRIPT_TELUGU, teluguFonts }, 279 { USCRIPT_TELUGU, teluguFonts },
279 { USCRIPT_THAANA, thaanaFonts }, 280 { USCRIPT_THAANA, thaanaFonts },
280 { USCRIPT_THAI, thaiFonts }, 281 { USCRIPT_THAI, thaiFonts },
281 { USCRIPT_TIBETAN, tibetanFonts }, 282 { USCRIPT_TIBETAN, tibetanFonts },
282 { USCRIPT_TIFINAGH, tifinaghFonts }, 283 { USCRIPT_TIFINAGH, tifinaghFonts },
283 { USCRIPT_TRADITIONAL_HAN, traditionalHanFonts }, 284 { USCRIPT_TRADITIONAL_HAN, traditionalHanFonts },
284 { USCRIPT_VAI, vaiFonts }, 285 { USCRIPT_VAI, vaiFonts },
285 { USCRIPT_YI, yiFonts } 286 { USCRIPT_YI, yiFonts }
286 }; 287 };
287 288
288 for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontMap); ++i) 289 for (const auto& fontFamily : scriptToFontFamilies) {
289 scriptFontMap[fontMap[i].script] = fontMap[i].family; 290 scriptFontMap[fontFamily.script].candidateFamilyNames = fontFamily.famil ies;
291 }
292 // Initialize the locale-dependent mapping from system locale.
293 UScriptCode hanScript = LayoutLocale::getSystem().scriptForHan();
290 294
291 // FIXME: Instead of scanning the hard-coded list, we have to 295 if (scriptFontMap[hanScript].candidateFamilyNames) {
292 // use EnumFont* to 'inspect' fonts to pick up fonts covering scripts 296 scriptFontMap[USCRIPT_HAN].candidateFamilyNames = scriptFontMap[hanScrip t].candidateFamilyNames;
293 // when it's possible (e.g. using OS/2 table). If we do that, this 297 }
294 // had better be pulled out of here. 298 }
295 for (size_t i = 0; i < WTF_ARRAY_LENGTH(scriptToFontFamilies); ++i) { 299
296 UScriptCode script = scriptToFontFamilies[i].script; 300 void findFirstExistingCandidateFont(FontMapping& scriptFontMapping, SkFontMgr* f ontManager)
297 scriptFontMap[script] = 0; 301 {
298 const UChar** familyPtr = scriptToFontFamilies[i].families; 302 for (const UChar** familyPtr = scriptFontMapping.candidateFamilyNames; *fami lyPtr; familyPtr++) {
299 while (*familyPtr) { 303 if (isFontPresent(*familyPtr, fontManager)) {
300 if (isFontPresent(*familyPtr, fontManager)) { 304 scriptFontMapping.familyName = *familyPtr;
301 scriptFontMap[script] = *familyPtr; 305 break;
302 break;
303 }
304 ++familyPtr;
305 } 306 }
306 } 307 }
307 308 scriptFontMapping.candidateFamilyNames = nullptr;
308 // Initialize the locale-dependent mapping from system locale.
309 UScriptCode hanScript = LayoutLocale::getSystem().scriptForHan();
310 if (const UChar* localeFamily = scriptFontMap[hanScript])
311 scriptFontMap[USCRIPT_HAN] = localeFamily;
312 } 309 }
313 310
314 // There are a lot of characters in USCRIPT_COMMON that can be covered 311 // There are a lot of characters in USCRIPT_COMMON that can be covered
315 // by fonts for scripts closely related to them. See 312 // by fonts for scripts closely related to them. See
316 // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:] 313 // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:]
317 // FIXME: make this more efficient with a wider coverage 314 // FIXME: make this more efficient with a wider coverage
318 UScriptCode getScriptBasedOnUnicodeBlock(int ucs4) 315 UScriptCode getScriptBasedOnUnicodeBlock(int ucs4)
319 { 316 {
320 UBlockCode block = ublock_getCode(ucs4); 317 UBlockCode block = ublock_getCode(ucs4);
321 switch (block) { 318 switch (block) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // - Update script_font_cache in response to WM_FONTCHANGE 429 // - Update script_font_cache in response to WM_FONTCHANGE
433 430
434 const UChar* getFontFamilyForScript(UScriptCode script, 431 const UChar* getFontFamilyForScript(UScriptCode script,
435 FontDescription::GenericFamilyType generic, 432 FontDescription::GenericFamilyType generic,
436 SkFontMgr* fontManager) 433 SkFontMgr* fontManager)
437 { 434 {
438 static ScriptToFontMap scriptFontMap; 435 static ScriptToFontMap scriptFontMap;
439 static ScriptToFontMap scriptMonospaceFontMap; 436 static ScriptToFontMap scriptMonospaceFontMap;
440 static bool initialized = false; 437 static bool initialized = false;
441 if (!initialized) { 438 if (!initialized) {
442 initializeScriptFontMap(scriptFontMap, fontManager); 439 initializeScriptFontMap(scriptFontMap);
443 initializeScriptMonospaceFontMap(scriptMonospaceFontMap, fontManager);
444 initialized = true; 440 initialized = true;
445 } 441 }
442
446 if (script == USCRIPT_INVALID_CODE) 443 if (script == USCRIPT_INVALID_CODE)
447 return 0; 444 return 0;
448 ASSERT(script < USCRIPT_CODE_LIMIT); 445 ASSERT(script < USCRIPT_CODE_LIMIT);
449 if (generic == FontDescription::MonospaceFamily && scriptMonospaceFontMap[sc ript]) 446 if (generic == FontDescription::MonospaceFamily) {
450 return scriptMonospaceFontMap[script]; 447 if (!scriptMonospaceFontMap[script].familyName) {
kojii 2016/08/06 09:33:13 Isn't this supposed to be: if (scriptMonospaceFo
Ilya Kulshin 2016/08/08 19:58:29 Since there's only two monospace overrides and the
451 return scriptFontMap[script]; 448 findMonospaceFontForScript(script, scriptMonospaceFontMap[script]);
449 }
450 if (scriptMonospaceFontMap[script].familyName)
451 return scriptMonospaceFontMap[script].familyName;
452 }
453 if (scriptFontMap[script].candidateFamilyNames)
454 findFirstExistingCandidateFont(scriptFontMap[script], fontManager);
455 return scriptFontMap[script].familyName;
452 } 456 }
453 457
454 // FIXME: 458 // FIXME:
455 // - Handle 'Inherited', 'Common' and 'Unknown' 459 // - Handle 'Inherited', 'Common' and 'Unknown'
456 // (see http://www.unicode.org/reports/tr24/#Usage_Model ) 460 // (see http://www.unicode.org/reports/tr24/#Usage_Model )
457 // For 'Inherited' and 'Common', perhaps we need to 461 // For 'Inherited' and 'Common', perhaps we need to
458 // accept another parameter indicating the previous family 462 // accept another parameter indicating the previous family
459 // and just return it. 463 // and just return it.
460 // - All the characters (or characters up to the point a single 464 // - All the characters (or characters up to the point a single
461 // font can cover) need to be taken into account 465 // font can cover) need to be taken into account
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 family = L"lucida sans unicode"; 528 family = L"lucida sans unicode";
525 } 529 }
526 } 530 }
527 531
528 if (scriptChecked) 532 if (scriptChecked)
529 *scriptChecked = script; 533 *scriptChecked = script;
530 return family; 534 return family;
531 } 535 }
532 536
533 } // namespace blink 537 } // 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