Chromium Code Reviews| 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 0d73691528dc98e837bbff53e6df82d203af37b3..0c0561f882519fae5cfb888cf718f07f524238e5 100644 |
| --- a/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc |
| +++ b/ppapi/shared_impl/private/ppb_browser_font_trusted_shared.cc |
| @@ -4,6 +4,8 @@ |
| #include "ppapi/shared_impl/private/ppb_browser_font_trusted_shared.h" |
| +#include <unicode/uscript.h> |
|
viettrungluu
2012/05/15 17:21:17
This is a dependency on ICU, and should be #includ
|
| + |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "ppapi/c/dev/ppb_font_dev.h" |
| @@ -37,6 +39,18 @@ namespace ppapi { |
| namespace { |
| +const char* kCommonScript = uscript_getShortName(USCRIPT_COMMON); |
|
viettrungluu
2012/05/15 17:21:17
I don't think we want to add this static initializ
brettw
2012/05/15 22:53:11
Right.
|
| + |
| +string16 GetFontFromMap( |
| + const webkit_glue::WebPreferences::ScriptFontFamilyMap& map, |
| + const std::string& script) { |
| + webkit_glue::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 +102,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, |
| + kCommonScript); |
| break; |
| case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF: |
| - resolved_family = prefs.sans_serif_font_family; |
| + resolved_family = GetFontFromMap(prefs.sans_serif_font_family_map, |
| + kCommonScript); |
| break; |
| case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE: |
| - resolved_family = prefs.fixed_font_family; |
| + resolved_family = GetFontFromMap(prefs.fixed_font_family_map, |
| + kCommonScript); |
| break; |
| case PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT: |
| default: |
| - resolved_family = prefs.standard_font_family; |
| + resolved_family = GetFontFromMap(prefs.standard_font_family_map, |
| + kCommonScript); |
| break; |
| } |
| } else { |
| @@ -115,7 +133,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, |
| + kCommonScript))) |
| result.size = static_cast<float>(prefs.default_fixed_font_size); |
| else |
| result.size = static_cast<float>(prefs.default_font_size); |
| @@ -314,4 +333,3 @@ void PPB_BrowserFont_Trusted_Shared::DrawTextToCanvas( |
| } |
| } // namespace ppapi |
| - |