From d46c181abb618dfd68308f97d519e46e35935a4b Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 19 Sep 2012 13:37:22 +0000 Subject: Text in XO is at the wrong size - SL #3850 Needed set the dpi with PangoCairo Signed-off-by: Gonzalo Odiard --- (limited to 'Area.py') diff --git a/Area.py b/Area.py index 5055c12..082b026 100644 --- a/Area.py +++ b/Area.py @@ -67,6 +67,7 @@ from gi.repository import Gdk from gi.repository import GdkPixbuf from gi.repository import GObject from gi.repository import Pango +from gi.repository import PangoCairo import logging import os @@ -95,6 +96,11 @@ TARGET_URI = 0 MAX_UNDO_STEPS = 12 RESIZE_ARROW_SIZE = style.GRID_CELL_SIZE / 2 +def _get_screen_dpi(): + xft_dpi = Gtk.Settings.get_default().get_property('gtk-xft-dpi') + dpi = float(xft_dpi / 1024) + logging.error('Setting dpi to: %f', dpi) + return dpi class Area(Gtk.DrawingArea): @@ -178,6 +184,8 @@ class Area(Gtk.DrawingArea): self.keep_aspect_ratio = False self.keep_shape_ratio = False + self._set_screen_dpi() + self._font_description = None self.set_font_description( Pango.FontDescription(self.tool['font_description'])) @@ -195,6 +203,11 @@ class Area(Gtk.DrawingArea): self.x_cursor = 0 self.y_cursor = 0 + def _set_screen_dpi(self): + dpi = _get_screen_dpi() + font_map_default = PangoCairo.font_map_get_default() + font_map_default.set_resolution(dpi) + def set_font_description(self, fd): self._font_description = fd self.activity.textview.modify_font(fd) -- cgit v0.9.1