From 21b490da36fef775836de15f909717393b92f231 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Tue, 10 Apr 2012 14:44:04 +0000 Subject: 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 Acked-by: Daniel Drake --- (limited to 'browser.py') 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: -- cgit v0.9.1