From 54fbb74ac2c45b5daeee1e2173c7a2767a13c758 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 5 Mar 2019 19:54:13 +0100 Subject: Honour fgcol in narrative --- libstorycode/narrative_render_cairo.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c index 6024ccc..744822d 100644 --- a/libstorycode/narrative_render_cairo.c +++ b/libstorycode/narrative_render_cairo.c @@ -75,8 +75,12 @@ static void wrap_text(struct narrative_item *item, PangoContext *pc, enum alignment align; struct length paraspace[4]; double wrap_w; + PangoAttrList *attrs; + PangoAttribute *attr; + double fgcol[4]; + guint16 r, g, b; - font = stylesheet_get_font(ss, el, NULL, &align); + font = stylesheet_get_font(ss, el, fgcol, &align); if ( font == NULL ) return; fontdesc = pango_font_description_from_string(font); @@ -97,6 +101,14 @@ static void wrap_text(struct narrative_item *item, PangoContext *pc, /* Calculate width of actual text */ wrap_w = w - item->space_l - item->space_r; + /* Set foreground colour */ + attrs = pango_attr_list_new(); + r = fgcol[0] * 65535; + g = fgcol[1] * 65535; + b = fgcol[2] * 65535; + attr = pango_attr_foreground_new(r, g, b); + pango_attr_list_insert(attrs, attr); + if ( item->layout == NULL ) { item->layout = pango_layout_new(pc); } @@ -104,6 +116,7 @@ static void wrap_text(struct narrative_item *item, PangoContext *pc, pango_layout_set_text(item->layout, item->text, -1); pango_layout_set_alignment(item->layout, palignment); pango_layout_set_font_description(item->layout, fontdesc); + pango_layout_set_attributes(item->layout, attrs); /* FIXME: Handle *bold*, _underline_, /italic/ etc. */ //pango_layout_set_attributes(item->layout, attrs); -- cgit v1.2.3