Use system's setting for font renderering, fixes #301.
This commit is contained in:
parent
cfeb00e629
commit
afd927f749
2 changed files with 56 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "ui/base/models/simple_menu_model.h"
|
#include "ui/base/models/simple_menu_model.h"
|
||||||
#include "ui/base/x/active_window_watcher_x.h"
|
#include "ui/base/x/active_window_watcher_x.h"
|
||||||
#include "ui/base/x/x11_util.h"
|
#include "ui/base/x/x11_util.h"
|
||||||
|
#include "ui/gfx/font_render_params_linux.h"
|
||||||
#include "ui/gfx/gtk_util.h"
|
#include "ui/gfx/gtk_util.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/skia_utils_gtk.h"
|
#include "ui/gfx/skia_utils_gtk.h"
|
||||||
|
@ -54,6 +55,44 @@ void SubstractBorderSize(int* width, int* height) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::RendererPreferencesHintingEnum GetRendererPreferencesHintingEnum(
|
||||||
|
gfx::FontRenderParams::Hinting hinting) {
|
||||||
|
switch (hinting) {
|
||||||
|
case gfx::FontRenderParams::HINTING_NONE:
|
||||||
|
return content::RENDERER_PREFERENCES_HINTING_NONE;
|
||||||
|
case gfx::FontRenderParams::HINTING_SLIGHT:
|
||||||
|
return content::RENDERER_PREFERENCES_HINTING_SLIGHT;
|
||||||
|
case gfx::FontRenderParams::HINTING_MEDIUM:
|
||||||
|
return content::RENDERER_PREFERENCES_HINTING_MEDIUM;
|
||||||
|
case gfx::FontRenderParams::HINTING_FULL:
|
||||||
|
return content::RENDERER_PREFERENCES_HINTING_FULL;
|
||||||
|
default:
|
||||||
|
NOTREACHED() << "Unhandled hinting style " << hinting;
|
||||||
|
return content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content::RendererPreferencesSubpixelRenderingEnum
|
||||||
|
GetRendererPreferencesSubpixelRenderingEnum(
|
||||||
|
gfx::FontRenderParams::SubpixelRendering subpixel_rendering) {
|
||||||
|
switch (subpixel_rendering) {
|
||||||
|
case gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE:
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
|
||||||
|
case gfx::FontRenderParams::SUBPIXEL_RENDERING_RGB:
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
|
||||||
|
case gfx::FontRenderParams::SUBPIXEL_RENDERING_BGR:
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
|
||||||
|
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VRGB:
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
|
||||||
|
case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
|
||||||
|
default:
|
||||||
|
NOTREACHED() << "Unhandled subpixel rendering style "
|
||||||
|
<< subpixel_rendering;
|
||||||
|
return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NativeWindowGtk::NativeWindowGtk(content::WebContents* web_contents,
|
NativeWindowGtk::NativeWindowGtk(content::WebContents* web_contents,
|
||||||
|
@ -118,6 +157,7 @@ NativeWindowGtk::NativeWindowGtk(content::WebContents* web_contents,
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWebKitColorStyle();
|
SetWebKitColorStyle();
|
||||||
|
SetFontRenderering();
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowGtk::~NativeWindowGtk() {
|
NativeWindowGtk::~NativeWindowGtk() {
|
||||||
|
@ -400,6 +440,19 @@ void NativeWindowGtk::SetWebKitColorStyle() {
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowGtk::SetFontRenderering() {
|
||||||
|
content::RendererPreferences* prefs =
|
||||||
|
GetWebContents()->GetMutableRendererPrefs();
|
||||||
|
const gfx::FontRenderParams& params = gfx::GetDefaultWebKitFontRenderParams();
|
||||||
|
prefs->should_antialias_text = params.antialiasing;
|
||||||
|
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
||||||
|
prefs->hinting = GetRendererPreferencesHintingEnum(params.hinting);
|
||||||
|
prefs->use_autohinter = params.autohinter;
|
||||||
|
prefs->use_bitmaps = params.use_bitmaps;
|
||||||
|
prefs->subpixel_rendering =
|
||||||
|
GetRendererPreferencesSubpixelRenderingEnum(params.subpixel_rendering);
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeWindowGtk::IsMaximized() const {
|
bool NativeWindowGtk::IsMaximized() const {
|
||||||
return state_ & GDK_WINDOW_STATE_MAXIMIZED;
|
return state_ & GDK_WINDOW_STATE_MAXIMIZED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,9 @@ class NativeWindowGtk : public NativeWindow,
|
||||||
// Set WebKit's style from current theme.
|
// Set WebKit's style from current theme.
|
||||||
void SetWebKitColorStyle();
|
void SetWebKitColorStyle();
|
||||||
|
|
||||||
|
// Set how font is renderered.
|
||||||
|
void SetFontRenderering();
|
||||||
|
|
||||||
// Whether window is maximized.
|
// Whether window is maximized.
|
||||||
bool IsMaximized() const;
|
bool IsMaximized() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue