Chromium Code Reviews| Index: content/browser/renderer_host/render_sandbox_host_linux.cc |
| =================================================================== |
| --- content/browser/renderer_host/render_sandbox_host_linux.cc (revision 258675) |
| +++ content/browser/renderer_host/render_sandbox_host_linux.cc (working copy) |
| @@ -407,24 +407,27 @@ |
| } |
| FcLangSet* langset = FcLangSetCreate(); |
| - MSCharSetToFontconfig(langset, charset); |
| + bool is_lgc = MSCharSetToFontconfig(langset, charset); |
| FcPattern* pattern = FcPatternCreate(); |
| - // TODO(agl): FC_FAMILy needs to change |
| FcPatternAddString(pattern, FC_FAMILY, |
| reinterpret_cast<const FcChar8*>(face.c_str())); |
| + // TODO(thestig) Check if we can access Chrome's per-script font preference |
| + // here and select better default fonts for non-LGC case. |
| std::string generic_font_name; |
| - switch (fallback_family) { |
| - case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF: |
| - generic_font_name = "Times New Roman"; |
| - break; |
| - case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF: |
| - generic_font_name = "Arial"; |
| - break; |
| - case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE: |
| - generic_font_name = "Courier New"; |
| - break; |
| + if (is_lgc) { |
| + switch (fallback_family) { |
| + case PP_BROWSERFONT_TRUSTED_FAMILY_SERIF: |
| + generic_font_name = "Times New Roman"; |
| + break; |
| + case PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF: |
| + generic_font_name = "Arial"; |
| + break; |
| + case PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE: |
| + generic_font_name = "Courier New"; |
| + break; |
| + } |
| } |
| if (!generic_font_name.empty()) { |
| const FcChar8* fc_generic_font_name = |
| @@ -547,7 +550,8 @@ |
| // MSCharSetToFontconfig translates a Microsoft charset identifier to a |
| // fontconfig language set by appending to |langset|. |
| - static void MSCharSetToFontconfig(FcLangSet* langset, unsigned fdwCharSet) { |
| + // Returns true if |langset| is Latin/Greek/Cyrillic. |
| + static bool MSCharSetToFontconfig(FcLangSet* langset, unsigned fdwCharSet) { |
| // We have need to translate raw fdwCharSet values into terms that |
| // fontconfig can understand. (See the description of fdwCharSet in the MSDN |
| // documentation for CreateFont: |
| @@ -566,6 +570,7 @@ |
| // So, for each of the documented fdwCharSet values I've had to take a |
| // guess at the set of ISO 639-1 languages intended. |
| + bool is_lgc = false; |
| switch (fdwCharSet) { |
| case NPCharsetAnsi: |
| // These values I don't really know what to do with, so I'm going to map |
| @@ -574,6 +579,7 @@ |
| case NPCharsetMac: |
| case NPCharsetOEM: |
| case NPCharsetSymbol: |
| + is_lgc = true; |
| FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("en")); |
| break; |
| case NPCharsetBaltic: |
| @@ -582,12 +588,11 @@ |
| FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("lv")); |
| FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("lt")); |
|
jungshik at Google
2014/03/28 23:03:01
lgc=true
|
| break; |
| - // TODO(jungshik): Would we be better off mapping Big5 to zh-tw |
| - // and GB2312 to zh-cn? Fontconfig has 4 separate orthography |
| - // files (zh-{cn,tw,hk,mo}. |
| case NPCharsetChineseBIG5: |
| + FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("zh-tw")); |
| + break; |
| case NPCharsetGB2312: |
| - FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("zh")); |
| + FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("zh-cn")); |
| break; |
| case NPCharsetEastEurope: |
| // A scattering of eastern European languages. |
| @@ -631,6 +636,7 @@ |
| // Don't add any languages in that case that we don't recognise the |
| // constant. |
| } |
| + return is_lgc; |
| } |
| void SendRendererReply(const std::vector<int>& fds, const Pickle& reply, |