Linux: Apply system font settings (issue #1148).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1538 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-12-02 20:07:03 +00:00
parent 916d8d08c4
commit 64294f659d
1 changed files with 60 additions and 0 deletions

View File

@ -52,6 +52,10 @@
#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/shell_dialogs/selected_file_info.h" #include "ui/shell_dialogs/selected_file_info.h"
#if defined(OS_LINUX) || defined(OS_ANDROID)
#include "ui/gfx/font_render_params_linux.h"
#endif
namespace { namespace {
class CreateBrowserHelper { class CreateBrowserHelper {
@ -401,6 +405,62 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
return NULL; return NULL;
} }
#if defined(OS_LINUX) || defined(OS_ANDROID)
content::RendererPreferences* prefs = web_contents->GetMutableRendererPrefs();
const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
switch (params.hinting) {
case gfx::FontRenderParams::HINTING_NONE:
prefs->hinting = content::RENDERER_PREFERENCES_HINTING_NONE;
break;
case gfx::FontRenderParams::HINTING_SLIGHT:
prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SLIGHT;
break;
case gfx::FontRenderParams::HINTING_MEDIUM:
prefs->hinting = content::RENDERER_PREFERENCES_HINTING_MEDIUM;
break;
case gfx::FontRenderParams::HINTING_FULL:
prefs->hinting = content::RENDERER_PREFERENCES_HINTING_FULL;
break;
default:
NOTREACHED() << "Unhandled hinting style " << params.hinting;
prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT;
break;
}
prefs->use_autohinter = params.autohinter;
prefs->use_bitmaps = params.use_bitmaps;
switch (params.subpixel_rendering) {
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
break;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
break;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
break;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
break;
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
break;
default:
NOTREACHED() << "Unhandled subpixel rendering style "
<< params.subpixel_rendering;
prefs->subpixel_rendering =
content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
break;
}
web_contents->GetRenderViewHost()->SyncRendererPrefs();
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
if (client.get()) { if (client.get()) {
CefRefPtr<CefLifeSpanHandler> handler = client->GetLifeSpanHandler(); CefRefPtr<CefLifeSpanHandler> handler = client->GetLifeSpanHandler();
if (handler.get()) if (handler.get())