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

Unified Diff: webkit/glue/webpreferences.cc

Issue 7606028: Pass per-script fonts to WebKit settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« webkit/glue/webpreferences.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webpreferences.cc
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index 615b68c9859dc120cc7ef560d6001a5c7d0141c0..73294efeb5edd7fc3e3aa6871524de961b81d33c 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -92,6 +92,53 @@ WebPreferences::WebPreferences()
WebPreferences::~WebPreferences() {
}
+void setStandardFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setStandardFontFamily(font, script);
+}
+
+void setFixedFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setFixedFontFamily(font, script);
+}
+
+void setSerifFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setSerifFontFamily(font, script);
+}
+
+void setSansSerifFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setSansSerifFontFamily(font, script);
+}
+
+void setCursiveFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setCursiveFontFamily(font, script);
+}
+
+void setFantasyFontFamilyWrapper(WebSettings* settings,
+ const string16& font,
+ UScriptCode script) {
+ settings->setFantasyFontFamily(font, script);
+}
+
+void WebPreferences::ApplyFontsFromMap(const ScriptFontFamilyMap& map,
tony 2011/08/10 19:23:40 It looks like this could also be a local function
+ SetFontFamilyWrapper setter,
+ WebSettings* settings) const {
+ for (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);
+ }
+}
+
void WebPreferences::Apply(WebView* web_view) const {
WebSettings* settings = web_view->settings();
settings->setStandardFontFamily(standard_font_family);
@@ -100,6 +147,16 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setSansSerifFontFamily(sans_serif_font_family);
settings->setCursiveFontFamily(cursive_font_family);
settings->setFantasyFontFamily(fantasy_font_family);
+ ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper,settings);
+ ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
+ ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
+ settings);
+ ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
+ settings);
settings->setDefaultFontSize(default_font_size);
settings->setDefaultFixedFontSize(default_fixed_font_size);
settings->setMinimumFontSize(minimum_font_size);
« webkit/glue/webpreferences.h ('K') | « webkit/glue/webpreferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698