aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-25 21:48:42 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-25 21:48:42 +0100
commitb9c16eb6d903ab809b340d404139dcaa1872ea9c (patch)
treed0afc17d58be0c6c1ea3fb2ef07c83e1fd1b6c3d
parent572d0f24e4923cac794e7b2da8632951cd807852 (diff)
Use text font
-rw-r--r--libstorycode/slide_render_cairo.c10
-rw-r--r--libstorycode/stylesheet.c10
-rw-r--r--libstorycode/stylesheet.h3
3 files changed, 18 insertions, 5 deletions
diff --git a/libstorycode/slide_render_cairo.c b/libstorycode/slide_render_cairo.c
index 7e1cc91..b7e3f15 100644
--- a/libstorycode/slide_render_cairo.c
+++ b/libstorycode/slide_render_cairo.c
@@ -68,6 +68,9 @@ static void render_text(struct slide_item *item, cairo_t *cr, PangoContext *pc,
{
int i;
double x, y, w, h;
+ const char *font;
+ enum alignment align;
+ double fgcol[4];
PangoRectangle rect;
PangoFontDescription *fontdesc;
@@ -76,7 +79,10 @@ static void render_text(struct slide_item *item, cairo_t *cr, PangoContext *pc,
w = lcalc(item->geom.w, parent_w);
h = lcalc(item->geom.h, parent_h);
- fontdesc = pango_font_description_from_string(stylesheet_get_slide_text_font(ss));
+ font = stylesheet_get_font(ss, STYEL_SLIDE_TEXT, fgcol, &align);
+ if ( font == NULL ) return;
+
+ fontdesc = pango_font_description_from_string(font);
if ( item->layouts == NULL ) {
item->layouts = malloc(item->n_paras*sizeof(PangoLayout *));
@@ -107,7 +113,7 @@ static void render_text(struct slide_item *item, cairo_t *cr, PangoContext *pc,
/* FIXME: Clip to w,h */
cairo_save(cr);
- cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_set_source_rgba(cr, fgcol[0], fgcol[1], fgcol[2], fgcol[3]);
cairo_translate(cr, x, y);
pango_cairo_update_layout(cr, item->layouts[i]);
pango_cairo_show_layout(cr, item->layouts[i]);
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index 451f3f0..142d8a7 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -232,9 +232,15 @@ int stylesheet_set_alignment(Stylesheet *s, enum style_element el, enum alignmen
}
-const char *stylesheet_get_slide_text_font(Stylesheet *s)
+const char *stylesheet_get_font(Stylesheet *s, enum style_element el,
+ double fgcol[4], enum alignment *alignment)
{
- if ( s == NULL ) return NULL;
+ int i;
+ struct style *sty = get_style(s, el);
+ if ( sty == NULL ) return NULL;
+
+ *alignment = sty->alignment;
+ for ( i=0; i<4; i++ ) fgcol[i] = sty->fgcol[i];
return s->slide_text.font;
}
diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h
index 5c33928..f192e8f 100644
--- a/libstorycode/stylesheet.h
+++ b/libstorycode/stylesheet.h
@@ -92,7 +92,8 @@ extern int stylesheet_set_fgcol(Stylesheet *s, enum style_element el, double rgb
extern int stylesheet_set_background(Stylesheet *s, enum style_element el, enum gradient grad,
double bgcol[4], double bgcol2[4]);
-extern const char *stylesheet_get_slide_text_font(Stylesheet *s);
+extern const char *stylesheet_get_font(Stylesheet *s, enum style_element el,
+ double fgcol[4], enum alignment *alignment);
extern int stylesheet_get_background(Stylesheet *s, enum style_element el,
enum gradient *grad, double *bgcol, double *bgcol2);