diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-01 22:18:58 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-01 22:18:58 +0000 |
commit | a59da9da39e721731e558e39b6fca64330431c8c (patch) | |
tree | 01fcf7c61e2f018cb31bb8720315328343e237d3 | |
parent | 2a877b9e053158fe2919068d40a9d63760a04cc3 (diff) | |
download | chromium_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
-rwxr-xr-x | app/gfx/canvas_linux.cc | 23 | ||||
-rwxr-xr-x | app/gfx/font_skia.cc | 1 |
2 files changed, 24 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); diff --git a/app/gfx/font_skia.cc b/app/gfx/font_skia.cc index 8cf0280..eee1238 100755 --- a/app/gfx/font_skia.cc +++ b/app/gfx/font_skia.cc @@ -39,6 +39,7 @@ static double GetPangoScaleFactor() { scale_factor = 1; else scale_factor /= 72.0; + determined_scale = true; } return scale_factor; } |