diff --git a/lib/python/_sugar.defs b/lib/python/_sugar.defs index a142077b..2963628f 100644 --- a/lib/python/_sugar.defs +++ b/lib/python/_sugar.defs @@ -284,4 +284,11 @@ ) ) +;; From sugar-utils.h + +(define-function get_screen_dpi + (c-name "sugar_get_screen_dpi") + (return-type "gint") +) + (include "gtkmozembed.defs") diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am index 4fb34311..837d72ca 100644 --- a/lib/src/Makefile.am +++ b/lib/src/Makefile.am @@ -45,7 +45,9 @@ libsugarprivate_la_SOURCES = \ sugar-push-scroller.c \ sugar-push-scroller.h \ sugar-tray-manager.c \ - sugar-tray-manager.h + sugar-tray-manager.h \ + sugar-utils.c \ + sugar-utils.h BUILT_SOURCES = \ sugar-marshal.c \ diff --git a/sugar/graphics/style.py b/sugar/graphics/style.py index 730f795e..ab1d0369 100644 --- a/sugar/graphics/style.py +++ b/sugar/graphics/style.py @@ -16,8 +16,17 @@ # Boston, MA 02111-1307, USA. import logging +import math import gtk +import pango + +import _sugar + +_screen_factor = gtk.gdk.screen_width() / 1200.0 +_dpi_factor = _sugar.get_screen_dpi() / 201.0 +_default_font_size = math.ceil(9 / _dpi_factor * _screen_factor) +print _default_font_size _system_colors = { 'toolbar-background' : '#414141', @@ -94,6 +103,27 @@ class Color(object): LABEL_TEXT = SystemColor('label-text') DESKTOP_BACKGROUND = SystemColor('desktop-background') +_system_fonts = { + 'default' : 'Bitstream Vera Sans %d' % _default_font_size +} + +class BaseFont(object): + def __init__(self, desc): + self._desc = desc + + def get_desc(self): + return self._desc + + def get_pango_desc(self): + return pango.FontDescription(self._desc) + +class SystemFont(BaseFont): + def __init__(self, font_id): + BaseFont.__init__(self, _system_fonts[font_id]) + +class Font(object): + DEFAULT = SystemFont('default') + ### Deprecated: we should drop this once we removed stylesheets ### _styles = {}