[pitivi] ruler: Use system font



commit 946b99fab2df1d9cf37ab63b2b7570dac7c90ada
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Jan 10 21:42:43 2014 +0100

    ruler: Use system font

 pitivi/timeline/ruler.py |    5 ++---
 pitivi/utils/ui.py       |   21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 3b756a9..9d3e999 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -34,7 +34,7 @@ from gettext import gettext as _
 from pitivi.utils.pipeline import Seeker
 from pitivi.utils.timeline import Zoomable
 from pitivi.utils.loggable import Loggable
-from pitivi.utils.ui import time_to_string, beautify_length
+from pitivi.utils.ui import NORMAL_FONT, time_to_string, beautify_length
 
 # Color #393f3f stolen from the dark variant of Adwaita.
 # There's *no way* to get the GTK3 theme's bg color there (it's always black)
@@ -271,8 +271,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
             context.fill()
 
     def drawRuler(self, context):
-        # FIXME use system defaults
-        context.set_font_face(cairo.ToyFontFace("Cantarell"))
+        context.set_font_face(NORMAL_FONT)
         context.set_font_size(NORMAL_FONT_SIZE)
 
         spacing, scale = self._getSpacing(context)
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index 0e79801..e94e122 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -32,6 +32,7 @@ from gettext import ngettext, gettext as _
 from gi.repository import Cogl
 from gi.repository import GLib
 from gi.repository import GES
+from gi.repository import Gio
 from gi.repository import Gst
 from gi.repository import Gtk
 from gi.repository.GstPbutils import DiscovererVideoInfo, DiscovererAudioInfo,\
@@ -92,6 +93,26 @@ VIDEO_TRANSITION_TARGET_ENTRY = Gtk.TargetEntry.new("pitivi/video-transition", 0
 LAYER_CONTROL_TARGET_ENTRY = Gtk.TargetEntry.new("pitivi/layer-control", 0, TYPE_PITIVI_LAYER_CONTROL)
 
 
+def _get_settings(schema):
+    if schema not in Gio.Settings.list_schemas():
+        return None
+    return Gio.Settings(schema)
+
+
+def _get_font(font_spec, default):
+    raw_font = default
+    settings = _get_settings("org.gnome.desktop.interface")
+    if settings:
+        if font_spec in settings.list_keys():
+            raw_font = settings.get_string(font_spec)
+    face = raw_font.rsplit(" ", 1)[0]
+    return cairo.ToyFontFace(face)
+
+NORMAL_FONT = _get_font("font-name", "Cantarell")
+DOCUMENT_FONT = _get_font("document-font-name", "Sans")
+MONOSPACE_FONT = _get_font("monospace-font-name", "Monospace")
+
+
 # ---------------------- ARGB color helper-------------------------------------#
 def pack_color_32(red, green, blue, alpha=0xFFFF):
     """Packs the specified 16bit color values in a 32bit RGBA value."""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]