summaryrefslogtreecommitdiffstats
path: root/app/gfx/canvas_linux.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 22:18:58 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 22:18:58 +0000
commita59da9da39e721731e558e39b6fca64330431c8c (patch)
tree01fcf7c61e2f018cb31bb8720315328343e237d3 /app/gfx/canvas_linux.cc
parent2a877b9e053158fe2919068d40a9d63760a04cc3 (diff)
downloadchromium_src-a59da9da39e721731e558e39b6fca64330431c8c.zip
chromium_src-a59da9da39e721731e558e39b6fca64330431c8c.tar.gz
chromium_src-a59da9da39e721731e558e39b6fca64330431c8c.tar.bz2
Fixes bug where Chrome was not rendering fonts at the size it should
have been. This was only apparent at DPIs other than the default, such as is typically seen on netbooks. BUG=none TEST=none Review URL: http://codereview.chromium.org/452031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/canvas_linux.cc')
-rwxr-xr-xapp/gfx/canvas_linux.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/gfx/canvas_linux.cc b/app/gfx/canvas_linux.cc
index df0bdf7..2e213e5 100755
--- a/app/gfx/canvas_linux.cc
+++ b/app/gfx/canvas_linux.cc
@@ -20,6 +20,20 @@ namespace {
// DrawStringInt().
static cairo_font_options_t* cairo_font_options = NULL;
+// Returns the resolution used by pango. A negative values means the resolution
+// hasn't been set.
+static double GetPangoResolution() {
+ static double resolution;
+ static bool determined_resolution = false;
+ if (!determined_resolution) {
+ determined_resolution = true;
+ PangoContext* default_context = gdk_pango_context_get();
+ resolution = pango_cairo_context_get_resolution(default_context);
+ g_object_unref(default_context);
+ }
+ return resolution;
+}
+
// Update |cairo_font_options| based on GtkSettings, allocating it if needed.
static void UpdateCairoFontOptions() {
if (!cairo_font_options)
@@ -135,6 +149,15 @@ static void SetupPangoLayout(PangoLayout* layout,
PANGO_WRAP_WORD_CHAR : PANGO_WRAP_WORD);
}
+ // Set the resolution to match that used by Gtk. If we don't set the
+ // resolution and the resolution differs from the default, Gtk and Chrome end
+ // up drawing at different sizes.
+ double resolution = GetPangoResolution();
+ if (resolution > 0) {
+ pango_cairo_context_set_resolution(pango_layout_get_context(layout),
+ resolution);
+ }
+
PangoFontDescription* desc = gfx::Font::PangoFontFromGfxFont(font);
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);