aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/stylesheet.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-23 18:04:22 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-23 18:04:22 +0100
commit0cf09c110c9919efcbc3ff3b59cb83622b4ce1b2 (patch)
treef9da8c140afb5dabc8f6d5b8f4dbe8c20793a938 /libstorycode/stylesheet.c
parent14c998b253489b88bc4da904409e32c86bbe92c0 (diff)
Render text with font
Diffstat (limited to 'libstorycode/stylesheet.c')
-rw-r--r--libstorycode/stylesheet.c95
1 files changed, 93 insertions, 2 deletions
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index 00210ec..2d715a2 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -30,18 +30,82 @@
#include "stylesheet.h"
+struct style
+{
+ struct frame_geom geom;
+ char *font;
+ double fgcol[4]; /* r g b a */
+ double bgcol[4]; /* r g b a */
+ double bgcol2[4]; /* r g b a, if gradient */
+ double paraspace[4]; /* l r t b */
+ double padding[4]; /* l r t b */
+};
+
+
struct _stylesheet
{
- int n_items;
+ struct style narrative;
+
+ double default_slide_w;
+ double default_slide_h;
+ struct style slide_text;
+ struct style slide_prestitle;
+ struct style slide_slidetitle;
};
+static void default_style(struct style *s)
+{
+ s->geom.x.len = 0.0;
+ s->geom.x.unit = LENGTH_FRAC;
+ s->geom.y.len = 0.0;
+ s->geom.y.unit = LENGTH_FRAC;
+ s->geom.w.len = 1.0;
+ s->geom.w.unit = LENGTH_FRAC;
+ s->geom.h.len = 1.0;
+ s->geom.h.unit = LENGTH_FRAC;
+
+ s->font = strdup("Sans 12");
+
+ s->fgcol[0] = 0.0;
+ s->fgcol[1] = 0.0;
+ s->fgcol[2] = 0.0;
+ s->fgcol[3] = 1.0;
+
+ s->bgcol[0] = 1.0;
+ s->bgcol[1] = 1.0;
+ s->bgcol[2] = 1.0;
+ s->bgcol[3] = 1.0;
+
+ s->bgcol2[0] = 1.0;
+ s->bgcol2[1] = 1.0;
+ s->bgcol2[2] = 1.0;
+ s->bgcol2[3] = 1.0;
+
+ s->paraspace[0] = 0.0;
+ s->paraspace[1] = 0.0;
+ s->paraspace[2] = 0.0;
+ s->paraspace[3] = 0.0;
+
+ s->padding[0] = 0.0;
+ s->padding[1] = 0.0;
+ s->padding[2] = 0.0;
+ s->padding[3] = 0.0;
+}
+
+
Stylesheet *stylesheet_new()
{
Stylesheet *s;
s = malloc(sizeof(*s));
if ( s == NULL ) return NULL;
- s->n_items = 0;
+
+ /* Ultimate defaults */
+ default_style(&s->narrative);
+ default_style(&s->slide_text);
+ default_style(&s->slide_prestitle);
+ default_style(&s->slide_slidetitle);
+
return s;
}
@@ -49,3 +113,30 @@ void stylesheet_free(Stylesheet *s)
{
free(s);
}
+
+
+int stylesheet_set_default_slide_size(Stylesheet *s, double w, double h)
+{
+ if ( s == NULL ) return 1;
+ s->default_slide_w = w;
+ s->default_slide_h = h;
+ return 0;
+}
+
+
+int stylesheet_set_slide_text_font(Stylesheet *s, char *font)
+{
+ if ( s == NULL ) return 1;
+ if ( s->slide_text.font != NULL ) {
+ free(s->slide_text.font);
+ }
+ s->slide_text.font = font;
+ return 0;
+}
+
+
+const char *stylesheet_get_slide_text_font(Stylesheet *s)
+{
+ if ( s == NULL ) return NULL;
+ return s->slide_text.font;
+}