Add some infrastructure for font sizes.
This commit is contained in:
parent
bcdff5ddd3
commit
e08ad4baf5
@ -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")
|
(include "gtkmozembed.defs")
|
||||||
|
@ -45,7 +45,9 @@ libsugarprivate_la_SOURCES = \
|
|||||||
sugar-push-scroller.c \
|
sugar-push-scroller.c \
|
||||||
sugar-push-scroller.h \
|
sugar-push-scroller.h \
|
||||||
sugar-tray-manager.c \
|
sugar-tray-manager.c \
|
||||||
sugar-tray-manager.h
|
sugar-tray-manager.h \
|
||||||
|
sugar-utils.c \
|
||||||
|
sugar-utils.h
|
||||||
|
|
||||||
BUILT_SOURCES = \
|
BUILT_SOURCES = \
|
||||||
sugar-marshal.c \
|
sugar-marshal.c \
|
||||||
|
@ -16,8 +16,17 @@
|
|||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import math
|
||||||
|
|
||||||
import gtk
|
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 = {
|
_system_colors = {
|
||||||
'toolbar-background' : '#414141',
|
'toolbar-background' : '#414141',
|
||||||
@ -94,6 +103,27 @@ class Color(object):
|
|||||||
LABEL_TEXT = SystemColor('label-text')
|
LABEL_TEXT = SystemColor('label-text')
|
||||||
DESKTOP_BACKGROUND = SystemColor('desktop-background')
|
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 ###
|
### Deprecated: we should drop this once we removed stylesheets ###
|
||||||
|
|
||||||
_styles = {}
|
_styles = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user