1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/render_view_impl.h"
7 #include "content/public/common/renderer_preferences.h"
8 #include "third_party/WebKit/public/web/linux/WebFontRendering.h"
9 #include "ui/gfx/font_render_params.h"
11 using blink::WebFontRendering
;
17 SkPaint::Hinting
RendererPreferencesToSkiaHinting(
18 const RendererPreferences
& prefs
) {
19 if (!prefs
.should_antialias_text
) {
20 // When anti-aliasing is off, GTK maps all non-zero hinting settings to
21 // 'Normal' hinting so we do the same. Otherwise, folks who have 'Slight'
22 // hinting selected will see readable text in everything expect Chromium.
23 switch (prefs
.hinting
) {
24 case gfx::FontRenderParams::HINTING_NONE
:
25 return SkPaint::kNo_Hinting
;
26 case gfx::FontRenderParams::HINTING_SLIGHT
:
27 case gfx::FontRenderParams::HINTING_MEDIUM
:
28 case gfx::FontRenderParams::HINTING_FULL
:
29 return SkPaint::kNormal_Hinting
;
32 return SkPaint::kNormal_Hinting
;
36 switch (prefs
.hinting
) {
37 case gfx::FontRenderParams::HINTING_NONE
: return SkPaint::kNo_Hinting
;
38 case gfx::FontRenderParams::HINTING_SLIGHT
: return SkPaint::kSlight_Hinting
;
39 case gfx::FontRenderParams::HINTING_MEDIUM
: return SkPaint::kNormal_Hinting
;
40 case gfx::FontRenderParams::HINTING_FULL
: return SkPaint::kFull_Hinting
;
43 return SkPaint::kNormal_Hinting
;
49 void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
50 const RendererPreferences
& prefs
= renderer_preferences_
;
51 WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs
));
52 WebFontRendering::setAutoHint(prefs
.use_autohinter
);
53 WebFontRendering::setUseBitmaps(prefs
.use_bitmaps
);
54 WebFontRendering::setLCDOrder(
55 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrder(
56 prefs
.subpixel_rendering
));
57 WebFontRendering::setLCDOrientation(
58 gfx::FontRenderParams::SubpixelRenderingToSkiaLCDOrientation(
59 prefs
.subpixel_rendering
));
60 WebFontRendering::setAntiAlias(prefs
.should_antialias_text
);
61 WebFontRendering::setSubpixelRendering(
62 prefs
.subpixel_rendering
!=
63 gfx::FontRenderParams::SUBPIXEL_RENDERING_NONE
);
64 WebFontRendering::setSubpixelPositioning(prefs
.use_subpixel_positioning
);
67 } // namespace content