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

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

Issue 1695653002: Take Accept-Language into account in CJK font fallback for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@al
Patch Set: Rebase Created 4 years, 10 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 | « third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp ('k') | 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // this ICU locale tells the current UI locale of Chrome. 223 // this ICU locale tells the current UI locale of Chrome.
224 UScriptCode hanScript = scriptCodeForHanFromLocale( 224 UScriptCode hanScript = scriptCodeForHanFromLocale(
225 icu::Locale::getDefault().getName(), '_'); 225 icu::Locale::getDefault().getName(), '_');
226 // For other locales, use the simplified Chinese font for Han. 226 // For other locales, use the simplified Chinese font for Han.
227 const UChar* localeFamily = scriptFontMap[hanScript == USCRIPT_COMMON 227 const UChar* localeFamily = scriptFontMap[hanScript == USCRIPT_COMMON
228 ? USCRIPT_SIMPLIFIED_HAN : hanScript]; 228 ? USCRIPT_SIMPLIFIED_HAN : hanScript];
229 if (localeFamily) 229 if (localeFamily)
230 scriptFontMap[USCRIPT_HAN] = localeFamily; 230 scriptFontMap[USCRIPT_HAN] = localeFamily;
231 } 231 }
232 232
233 static UScriptCode scriptForHan(UScriptCode contentScript,
234 const AtomicString& contentLocale)
235 {
236 UScriptCode script = scriptCodeForHanFromLocale(contentScript, contentLocale );
237 if (script != USCRIPT_COMMON)
238 return script;
239 script = FontCache::preferredScriptForHan();
240 if (script != USCRIPT_COMMON)
241 return script;
242 return USCRIPT_HAN;
243 }
244
233 // There are a lot of characters in USCRIPT_COMMON that can be covered 245 // There are a lot of characters in USCRIPT_COMMON that can be covered
234 // by fonts for scripts closely related to them. See 246 // by fonts for scripts closely related to them. See
235 // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:] 247 // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:]
236 // FIXME: make this more efficient with a wider coverage 248 // FIXME: make this more efficient with a wider coverage
237 UScriptCode getScriptBasedOnUnicodeBlock(int ucs4) 249 UScriptCode getScriptBasedOnUnicodeBlock(int ucs4)
238 { 250 {
239 UBlockCode block = ublock_getCode(ucs4); 251 UBlockCode block = ublock_getCode(ucs4);
240 switch (block) { 252 switch (block) {
241 case UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION: 253 case UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION:
242 return USCRIPT_HAN; 254 return USCRIPT_HAN;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // For the full-width ASCII characters (U+FF00 - U+FF5E), use the font for 413 // For the full-width ASCII characters (U+FF00 - U+FF5E), use the font for
402 // Han (determined in a locale-dependent way above). Full-width ASCII 414 // Han (determined in a locale-dependent way above). Full-width ASCII
403 // characters are rather widely used in Japanese and Chinese documents and 415 // characters are rather widely used in Japanese and Chinese documents and
404 // they're fully covered by Chinese, Japanese and Korean fonts. 416 // they're fully covered by Chinese, Japanese and Korean fonts.
405 if (0xFF00 < character && character < 0xFF5F) 417 if (0xFF00 < character && character < 0xFF5F)
406 script = USCRIPT_HAN; 418 script = USCRIPT_HAN;
407 419
408 if (script == USCRIPT_COMMON) 420 if (script == USCRIPT_COMMON)
409 script = getScriptBasedOnUnicodeBlock(character); 421 script = getScriptBasedOnUnicodeBlock(character);
410 422
411 // For unified-Han scripts, try the lang attribute. 423 // For unified-Han scripts, try the lang attribute, system, or
412 if (script == USCRIPT_HAN) { 424 // accept-languages.
413 script = scriptCodeForHanFromLocale(contentScript, contentLocale); 425 if (script == USCRIPT_HAN)
414 // Use the UI locale if it is still ambiguous. 426 script = scriptForHan(contentScript, contentLocale);
415 if (script == USCRIPT_COMMON)
416 script = USCRIPT_SIMPLIFIED_HAN;
417 }
418 427
419 family = getFontFamilyForScript(script, generic, fontManager); 428 family = getFontFamilyForScript(script, generic, fontManager);
420 // Another lame work-around to cover non-BMP characters. 429 // Another lame work-around to cover non-BMP characters.
421 // If the font family for script is not found or the character is 430 // If the font family for script is not found or the character is
422 // not in BMP (> U+FFFF), we resort to the hard-coded list of 431 // not in BMP (> U+FFFF), we resort to the hard-coded list of
423 // fallback fonts for now. 432 // fallback fonts for now.
424 if (!family || character > 0xFFFF) { 433 if (!family || character > 0xFFFF) {
425 int plane = character >> 16; 434 int plane = character >> 16;
426 switch (plane) { 435 switch (plane) {
427 case 1: 436 case 1:
(...skipping 14 matching lines...) Expand all
442 family = L"lucida sans unicode"; 451 family = L"lucida sans unicode";
443 } 452 }
444 } 453 }
445 454
446 if (scriptChecked) 455 if (scriptChecked)
447 *scriptChecked = script; 456 *scriptChecked = script;
448 return family; 457 return family;
449 } 458 }
450 459
451 } // namespace blink 460 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698