From 6e26eb1c2087363b406d95f49f372836f1733067 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 29 Apr 2008 16:56:31 +0200 Subject: [PATCH] Allow to use a pango font description string. --- obrender/font.c | 9 +++++++++ obrender/render.h | 2 ++ openbox/config.c | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/obrender/font.c b/obrender/font.c index a22e23f5..988e3f2c 100644 --- a/obrender/font.c +++ b/obrender/font.c @@ -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) { diff --git a/obrender/render.h b/obrender/render.h index 59e77660..c4937780 100644 --- a/obrender/render.h +++ b/obrender/render.h @@ -397,6 +397,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 diff --git a/openbox/config.c b/openbox/config.c index 6c38eed1..b824822b 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -756,6 +756,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"); } -- 2.34.1