Allow to use a pango font description string.
authorMikael Magnusson <mikachu@comhem.se>
Tue, 29 Apr 2008 14:56:31 +0000 (16:56 +0200)
committerMikael Magnusson <mikachu@gmail.com>
Sun, 19 Sep 2010 16:06:21 +0000 (18:06 +0200)
obrender/font.c
obrender/render.h
openbox/config.c

index a22e23f50b1d9f19be1dfe2a32c14f4dd738aaec..988e3f2c19c9a09dc2c3d57b5959fbce590a6219 100644 (file)
@@ -60,6 +60,15 @@ static void measure_font(const RrInstance *inst, RrFont *f)
 
 }
 
+void RrFontDescriptionFromString(RrFont *font, gchar *description)
+{
+    PangoFontDescription *desc;
+    desc = pango_font_description_from_string(description);
+    pango_font_description_merge(font->font_desc, desc, TRUE);
+    pango_font_description_free(desc);
+    pango_layout_set_font_description(font->layout, font->font_desc);
+}
+
 RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size,
                    RrFontWeight weight, RrFontSlant slant)
 {
index 37ffa553a201df07f0a15ecc8e97ddabf911ae9e..07fc9a7b2740dab65b95b5d31118590740b594f4 100644 (file)
@@ -331,6 +331,8 @@ RrSize *RrFontMeasureString (const RrFont *f, const gchar *str,
                              gboolean flow, gint maxwidth);
 gint    RrFontHeight        (const RrFont *f, gint shadow_offset_y);
 gint    RrFontMaxCharWidth  (const RrFont *f);
+/*! Select a font from a pango description string */
+void    RrFontDescriptionFromString(RrFont *font, gchar *description);
 
 /* Paint into the appearance. The old pixmap is returned (if there was one). It
    is the responsibility of the caller to call XFreePixmap on the return when
index 8bcad70fa0a44505d591c51378de9fb1e580275b..8b0ee84504dde8608a89d80cde24de512277ef28 100644 (file)
@@ -692,6 +692,13 @@ static void parse_theme(xmlNodePtr node, gpointer d)
 
         *font = RrFontOpen(ob_rr_inst, name, size, weight, slant);
         g_free(name);
+
+        if ((fnode = obt_xml_find_node(n->children, "description"))) {
+            gchar *s = obt_xml_node_string(fnode);
+            RrFontDescriptionFromString(*font, s);
+            g_free(s);
+        }
+
     next_font:
         n = obt_xml_find_node(n->next, "font");
     }