Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: ui/gfx/font_render_params_linux.cc

Issue 929733002: Fix Pango font rendering with HiDPi displays on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Pango font rendering with HiDPi displays on Linux. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_ui.cc ('k') | ui/views/linux_ui/linux_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/font_render_params_linux.cc
diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc
index 5698f0d76cd08ffb85d42092918fdc5ed7051d38..ed338d66cbcbc46f553d1afd3ec22bd40a0127a1 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -16,8 +16,10 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
+#include "ui/gfx/display.h"
#include "ui/gfx/font.h"
#include "ui/gfx/linux_font_delegate.h"
+#include "ui/gfx/screen.h"
#include "ui/gfx/switches.h"
namespace gfx {
@@ -62,15 +64,6 @@ struct SynchronizedCache {
base::LazyInstance<SynchronizedCache>::Leaky g_synchronized_cache =
LAZY_INSTANCE_INITIALIZER;
-bool IsBrowserTextSubpixelPositioningEnabled(
- const FontRenderParamsQuery& query) {
-#if defined(OS_CHROMEOS)
- return query.device_scale_factor > 1.0f;
-#else
- return false;
-#endif
-}
-
// Converts Fontconfig FC_HINT_STYLE to FontRenderParams::Hinting.
FontRenderParams::Hinting ConvertFontconfigHintStyle(int hint_style) {
switch (hint_style) {
@@ -208,10 +201,19 @@ uint32 HashFontRenderParamsQuery(const FontRenderParamsQuery& query) {
FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
std::string* family_out) {
FontRenderParamsQuery actual_query(query);
+ if (actual_query.device_scale_factor == 0) {
#if defined(OS_CHROMEOS)
- if (actual_query.device_scale_factor == 0)
actual_query.device_scale_factor = device_scale_factor_for_internal_display;
+#else
+ // Linux does not support per-display DPI, so we use a slightly simpler
+ // code path than on Chrome OS to figure out the device scale factor.
+ gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
+ if (screen) {
+ gfx::Display display = screen->GetPrimaryDisplay();
+ actual_query.device_scale_factor = display.device_scale_factor();
+ }
#endif
+ }
const uint32 hash = HashFontRenderParamsQuery(actual_query);
SynchronizedCache* synchronized_cache = g_synchronized_cache.Pointer();
@@ -252,7 +254,7 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
actual_query.for_web_contents
? base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableWebkitTextSubpixelPositioning)
- : IsBrowserTextSubpixelPositioningEnabled(actual_query);
+ : actual_query.device_scale_factor > 1.0f;
// To enable subpixel positioning, we need to disable hinting.
if (params.subpixel_positioning)
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_ui.cc ('k') | ui/views/linux_ui/linux_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698