summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rwxr-xr-xapp/gfx/canvas_linux.cc23
-rwxr-xr-xapp/gfx/font_skia.cc1
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;
}