Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/browser.py
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-04-10 14:44:04 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-04-10 15:37:38 (GMT)
commit21b490da36fef775836de15f909717393b92f231 (patch)
treec25b8903add54a9f3503d14a0d78714549debd4f /browser.py
parent90dfe3666762a15ce8cfb5e454e89200a4f11cb7 (diff)
Set default-font-size and monospace-font-size in WebKit based on GtkSettings
The font size that GtkSettings provides is multiplied to reach the default values in WebKitWebSettings in a common 96dpi display. Those are 12 for default-font-size and 10 for monospace-font-size, so the monospace font is calculated as 2 units less from the default Gtk+ font. This is similar to Epiphany approach, when the "Use system fonts" is checked in the preferences dialog. This workarounds #3428 "Browse should set DPI for XO screen", tested with screenshots that the resulting font sizes are similar to the previous Browse based on Gecko in the XO. Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Daniel Drake <dsd@laptop.org>
Diffstat (limited to 'browser.py')
-rw-r--r--browser.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/browser.py b/browser.py
index dd95746..f35ded3 100644
--- a/browser.py
+++ b/browser.py
@@ -466,8 +466,21 @@ class Browser(WebKit.WebView):
WebKit.WebView.__init__(self)
web_settings = self.get_settings()
+
+ # Add SugarLabs user agent:
identifier = ' Sugar Labs/' + self.CURRENT_SUGAR_VERSION
web_settings.props.user_agent += identifier
+
+ # Change font size based in the GtkSettings font size. The
+ # gtk-font-name property is a string with format '[font name]
+ # [font size]' like 'Sans Serif 10'.
+ gtk_settings = Gtk.Settings.get_default()
+ gtk_font_name = gtk_settings.get_property('gtk-font-name')
+ gtk_font_size = float(gtk_font_name.split()[-1])
+ web_settings.props.default_font_size = gtk_font_size * 1.2
+ web_settings.props.default_monospace_font_size = \
+ gtk_font_size * 1.2 - 2
+
self.set_settings(web_settings)
# Reference to the global history and callbacks to handle it: