| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/font_render_params_linux.h" | 5 #include "ui/gfx/font_render_params_linux.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/gfx/display.h" |
| 9 #include "ui/gfx/switches.h" | 10 #include "ui/gfx/switches.h" |
| 10 | 11 |
| 11 #if defined(TOOLKIT_GTK) | 12 #if defined(TOOLKIT_GTK) |
| 12 #include <gtk/gtk.h> | 13 #include <gtk/gtk.h> |
| 13 #else | 14 #else |
| 14 #include <fontconfig/fontconfig.h> | 15 #include <fontconfig/fontconfig.h> |
| 15 #endif | 16 #endif |
| 16 | 17 |
| 17 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS) | 18 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 18 #include "ui/gfx/linux_font_delegate.h" | 19 #include "ui/gfx/linux_font_delegate.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 namespace gfx { | 22 namespace gfx { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 bool SubpixelPositioningRequested(bool renderer) { | 26 bool SubpixelPositioningRequested(bool renderer) { |
| 26 return CommandLine::ForCurrentProcess()->HasSwitch( | 27 const CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 27 renderer ? | 28 if (renderer) { |
| 28 switches::kEnableWebkitTextSubpixelPositioning : | 29 // Text rendered by Blink in high-DPI mode is poorly-hinted unless subpixel |
| 29 switches::kEnableBrowserTextSubpixelPositioning); | 30 // positioning is used (as opposed to each glyph being individually snapped |
| 31 // to the pixel grid). |
| 32 return cl->HasSwitch(switches::kEnableWebkitTextSubpixelPositioning) || |
| 33 (Display::HasForceDeviceScaleFactor() && |
| 34 Display::GetForcedDeviceScaleFactor() != 1.0); |
| 35 } |
| 36 return cl->HasSwitch(switches::kEnableBrowserTextSubpixelPositioning); |
| 30 } | 37 } |
| 31 | 38 |
| 32 // Initializes |params| with the system's default settings. |renderer| is true | 39 // Initializes |params| with the system's default settings. |renderer| is true |
| 33 // when setting WebKit renderer defaults. | 40 // when setting WebKit renderer defaults. |
| 34 void LoadDefaults(FontRenderParams* params, bool renderer) { | 41 void LoadDefaults(FontRenderParams* params, bool renderer) { |
| 35 #if defined(TOOLKIT_GTK) | 42 #if defined(TOOLKIT_GTK) |
| 36 params->antialiasing = true; | 43 params->antialiasing = true; |
| 37 // TODO(wangxianzhu): autohinter is now true to keep original behavior | 44 // TODO(wangxianzhu): autohinter is now true to keep original behavior |
| 38 // of WebKit, but it might not be the best value. | 45 // of WebKit, but it might not be the best value. |
| 39 params->autohinter = true; | 46 params->autohinter = true; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 LoadDefaults(&default_params, /* renderer */ true); | 161 LoadDefaults(&default_params, /* renderer */ true); |
| 155 loaded_defaults = true; | 162 loaded_defaults = true; |
| 156 return default_params; | 163 return default_params; |
| 157 } | 164 } |
| 158 | 165 |
| 159 bool GetDefaultWebkitSubpixelPositioning() { | 166 bool GetDefaultWebkitSubpixelPositioning() { |
| 160 return SubpixelPositioningRequested(true); | 167 return SubpixelPositioningRequested(true); |
| 161 } | 168 } |
| 162 | 169 |
| 163 } // namespace gfx | 170 } // namespace gfx |
| OLD | NEW |