Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/graphics/style.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-02-15 14:09:38 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-02-15 14:09:38 (GMT)
commite08ad4baf5735bd0a46a6c44e797f0c84dc4446f (patch)
treed607ee3aa36c9eca2e90a348e167244633d307ae /sugar/graphics/style.py
parentbcdff5ddd33d28d637f49c029923e518902cc852 (diff)
Add some infrastructure for font sizes.
Diffstat (limited to 'sugar/graphics/style.py')
-rw-r--r--sugar/graphics/style.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/sugar/graphics/style.py b/sugar/graphics/style.py
index 730f795..ab1d036 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 = {}