Add some infrastructure for font sizes.

This commit is contained in:
Marco Pesenti Gritti 2007-02-15 15:09:38 +01:00
parent bcdff5ddd3
commit e08ad4baf5
3 changed files with 40 additions and 1 deletions

View File

@ -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")

View File

@ -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 \

View File

@ -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 = {}