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

Unified Diff: ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc

Issue 10107014: Migrate WebKit "global script" font prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fixes Created 8 years, 8 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: ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
diff --git a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc b/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
index ab7c45acdc7012b58c9c5ec8cbefe2ef65f51224..f1a942876f2f78613c0df7dc58b90f332165fe20 100644
--- a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
+++ b/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc
@@ -37,6 +37,16 @@ namespace ppapi {
namespace {
+const char kWebKitCommonScript[] = "Zyyy";
+
+string16 GetFontFromMap(const WebPreferences::ScriptFontFamilyMap& map,
+ const std::string& script) {
+ WebPreferences::ScriptFontFamilyMap::const_iterator it = map.find(script);
+ if (it != map.end())
+ return it->second;
+ return string16();
+}
+
bool PPTextRunToWebTextRun(const PP_BrowserFont_Trusted_TextRun& text,
WebTextRun* run) {
StringVar* text_string = StringVar::FromPPVar(text.text);
@@ -88,17 +98,21 @@ WebFontDescription PPFontDescToWebFontDesc(
// Resolve the generic family.
switch (font.family) {
case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF:
- resolved_family = prefs.serif_font_family;
+ resolved_family = GetFontFromMap(prefs.serif_font_family_map,
+ kWebKitCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF:
- resolved_family = prefs.sans_serif_font_family;
+ resolved_family = GetFontFromMap(prefs.sans_serif_font_family_map,
+ kWebKitCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE:
- resolved_family = prefs.fixed_font_family;
+ resolved_family = GetFontFromMap(prefs.fixed_font_family_map,
+ kWebKitCommonScript);
break;
case PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT:
default:
- resolved_family = prefs.standard_font_family;
+ resolved_family = GetFontFromMap(prefs.standard_font_family_map,
+ kWebKitCommonScript);
break;
}
} else {
@@ -115,7 +129,8 @@ WebFontDescription PPFontDescToWebFontDesc(
// level to detect if the requested font is fixed width, so we only apply
// the alternate font size to the default fixed font family.
if (StringToLowerASCII(resolved_family) ==
- StringToLowerASCII(prefs.fixed_font_family))
+ StringToLowerASCII(GetFontFromMap(prefs.fixed_font_family_map,
+ kWebKitCommonScript)))
result.size = static_cast<float>(prefs.default_fixed_font_size);
else
result.size = static_cast<float>(prefs.default_font_size);
@@ -322,4 +337,3 @@ void PPB_BrowserFont_Trusted_Shared::DrawTextToCanvas(
}
} // namespace ppapi
-

Powered by Google App Engine
This is Rietveld 408576698