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

Unified Diff: third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp b/third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp
index 9e2f7619b4f1354be3089543ae8859c1a46f10c1..841f46ac90520526b94c3db92c108da9a27ab1c3 100644
--- a/third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp
+++ b/third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp
@@ -52,6 +52,8 @@ int32_t FontCache::s_smallCaptionFontHeight = 0;
AtomicString* FontCache::s_statusFontFamilyName = 0;
int32_t FontCache::s_statusFontHeight = 0;
+UScriptCode FontCache::m_preferredScriptForHan = USCRIPT_COMMON;
+
namespace {
int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight)
@@ -112,9 +114,25 @@ FontCache::FontCache()
m_fontManager = adoptPtr(fontManager);
}
-void FontCache::acceptLanguagesChanged(const String&)
+void FontCache::acceptLanguagesChanged(const String& acceptLanguages)
{
- // TODO(kojii): Take acceptLanguages into account for ambiguos scripts.
+ // Use the UI locale if it can disambiguate the Unified Han.
+ // Since Chrome synchronizes the ICU default locale with its UI locale,
+ // this ICU locale tells the current UI locale of Chrome.
+ m_preferredScriptForHan = scriptCodeForHanFromLocale(
+ icu::Locale::getDefault().getName(), '_');
+ if (m_preferredScriptForHan != USCRIPT_COMMON)
+ return;
+
+ // Use acceptLanguages if it has languages that can disambiguate.
+ Vector<String> languages;
+ acceptLanguages.split(',', languages);
+ for (String token : languages) {
+ token = token.stripWhiteSpace();
+ m_preferredScriptForHan = scriptCodeForHanFromLocale(token);
+ if (m_preferredScriptForHan != USCRIPT_COMMON)
+ return;
+ }
}
// Given the desired base font, this will create a SimpleFontData for a specific
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.h ('k') | third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698