| Index: ppapi/shared_impl/private/ppb_font_shared.cc
|
| diff --git a/ppapi/shared_impl/private/ppb_font_shared.cc b/ppapi/shared_impl/private/ppb_font_shared.cc
|
| index 36c9ed2272b7e91ed032fb6c22d50d61e7409e4f..569173e89ab590c43093855d57bfc99c5ba41b33 100644
|
| --- a/ppapi/shared_impl/private/ppb_font_shared.cc
|
| +++ b/ppapi/shared_impl/private/ppb_font_shared.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "ppapi/shared_impl/private/ppb_font_shared.h"
|
|
|
| +#include <unicode/uscript.h>
|
| +
|
| #include "base/debug/trace_event.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| @@ -40,6 +42,16 @@ namespace ppapi {
|
|
|
| namespace {
|
|
|
| +const char* kCommonScript = uscript_getShortName(USCRIPT_COMMON);
|
| +
|
| +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();
|
| +}
|
| +
|
| // Converts the given PP_TextRun to a TextRun, returning true on success.
|
| // False means the input was invalid.
|
| bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
|
| @@ -92,17 +104,21 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font,
|
| // Resolve the generic family.
|
| switch (font.family) {
|
| case PP_FONTFAMILY_SERIF:
|
| - resolved_family = prefs.serif_font_family;
|
| + resolved_family = GetFontFromMap(prefs.serif_font_family_map,
|
| + kCommonScript);
|
| break;
|
| case PP_FONTFAMILY_SANSSERIF:
|
| - resolved_family = prefs.sans_serif_font_family;
|
| + resolved_family = GetFontFromMap(prefs.sans_serif_font_family_map,
|
| + kCommonScript);
|
| break;
|
| case PP_FONTFAMILY_MONOSPACE:
|
| - resolved_family = prefs.fixed_font_family;
|
| + resolved_family = GetFontFromMap(prefs.fixed_font_family_map,
|
| + kCommonScript);
|
| break;
|
| case PP_FONTFAMILY_DEFAULT:
|
| default:
|
| - resolved_family = prefs.standard_font_family;
|
| + resolved_family = GetFontFromMap(prefs.standard_font_family_map,
|
| + kCommonScript);
|
| break;
|
| }
|
| } else {
|
| @@ -119,7 +135,8 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font,
|
| // 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);
|
| @@ -401,4 +418,3 @@ int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
|
| }
|
|
|
| } // namespace ppapi
|
| -
|
|
|