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

Unified Diff: webkit/glue/webpreferences.cc

Issue 10532105: Use ICU script code "Jpan" instead of "Hrkt" in Japanese pref names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better sample texts Created 8 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 side-by-side diff with in-line comments
Download patch
Index: webkit/glue/webpreferences.cc
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index 4492c0658330d2c97efe5b9906af33b9ba5bdff9..674ce0704f57acaa57482b275bee1f66af31ab86 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -174,14 +174,38 @@ void setFantasyFontFamilyWrapper(WebSettings* settings,
typedef void (*SetFontFamilyWrapper)(
WebKit::WebSettings*, const string16&, UScriptCode);
+// If |scriptCode| is a member of a family of "similar" script codes, returns
+// the script code in that family that is used by WebKit for font selection
+// purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are
+// considered equivalent for the purposes of font selection. WebKit uses the
+// script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is
+// USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit
+// uses different scripts than the ones in Chrome pref names because the version
+// of ICU included on certain ports does not have some of the newer scripts. If
+// |scriptCode| is not a member of such a family, returns |scriptCode|.
+UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) {
+ switch (scriptCode) {
+ case USCRIPT_HIRAGANA:
+ case USCRIPT_KATAKANA:
+ case USCRIPT_JAPANESE:
+ return USCRIPT_KATAKANA_OR_HIRAGANA;
+ case USCRIPT_KOREAN:
+ return USCRIPT_HANGUL;
+ default:
+ return scriptCode;
+ }
+}
+
void ApplyFontsFromMap(const WebPreferences::ScriptFontFamilyMap& map,
SetFontFamilyWrapper setter,
WebSettings* settings) {
for (WebPreferences::ScriptFontFamilyMap::const_iterator it = map.begin();
it != map.end(); ++it) {
int32 script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
- if (script >= 0 && script < USCRIPT_CODE_LIMIT)
- (*setter)(settings, it->second, (UScriptCode) script);
+ if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
+ UScriptCode code = static_cast<UScriptCode>(script);
+ (*setter)(settings, it->second, GetScriptForWebSettings(code));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698