diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-02-23 18:04:22 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-02-23 18:04:22 +0100 |
commit | 0cf09c110c9919efcbc3ff3b59cb83622b4ce1b2 (patch) | |
tree | f9da8c140afb5dabc8f6d5b8f4dbe8c20793a938 /libstorycode/storycode.y | |
parent | 14c998b253489b88bc4da904409e32c86bbe92c0 (diff) |
Render text with font
Diffstat (limited to 'libstorycode/storycode.y')
-rw-r--r-- | libstorycode/storycode.y | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index 9d1e74f..483d0ea 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -85,7 +85,6 @@ %type <str> bulletpoint %type <str> frameopt %type <geom> geometry -%type <geom> style_slidesize %type <len> length %type <str> slidetitle %type <character> UNIT @@ -107,10 +106,12 @@ ctx->str = malloc(ctx->max_str*sizeof(char *)); if ( ctx->str == NULL ) ctx->max_str = 0; + style_reset(ctx); frameopts_reset(ctx); } %{ + void frameopts_reset(struct scpctx *ctx) { ctx->geom_set = 0; @@ -124,6 +125,11 @@ void frameopts_reset(struct scpctx *ctx) ctx->geom.h.unit = LENGTH_FRAC; } +void style_reset(struct scpctx *ctx) +{ + ctx->font = NULL; +} + void str_reset(struct scpctx *ctx) { ctx->n_str = 0; @@ -139,6 +145,13 @@ void add_str(struct scpctx *ctx, char *str) ctx->str[ctx->n_str++] = str; } + +void set_text_style(struct scpctx *ctx) +{ + stylesheet_set_slide_text_font(ctx->ss, ctx->font); + style_reset(ctx); +} + %} %% @@ -281,14 +294,21 @@ style_slide: style_slide_def: %empty -| style_slide_def style_slide_prestitle { printf("slide prestitle\n"); } -| style_slide_def style_slide_text { printf("slide text\n"); } -| style_slide_def style_slide_title { printf("slide title\n"); } -| style_slide_def style_slidesize { printf("slide size\n"); } +| style_slide_def style_slide_prestitle { } +| style_slide_def style_slide_text { } +| style_slide_def style_slide_title { } +| style_slide_def style_slidesize { } ; style_slidesize: - SIZE length TIMES length { $$.w = $2; $$.h = $4; $$.x.len = 0.0; $$.y.len = 0.0; printf("size\n");} + SIZE length TIMES length { if ( ($2.unit != LENGTH_UNIT) + || ($4.unit != LENGTH_UNIT) ) + { + fprintf(stderr, "Wrong slide size units\n"); + } else { + stylesheet_set_default_slide_size(ctx->ss, $2.len, $4.len); + } + } ; style_slide_prestitle: @@ -300,7 +320,7 @@ style_slide_title: ; style_slide_text: - TEXTFRAME OPENBRACE styledefs CLOSEBRACE { printf("slide text style\n"); } + TEXTFRAME OPENBRACE styledefs CLOSEBRACE { set_text_style(ctx); } ; styledefs: @@ -309,7 +329,7 @@ styledefs: ; styledef: - FONT STRING { printf("font def: '%s'\n", $2); } + FONT STRING { ctx->font = $2; } | GEOMETRY STRING { printf("type def: '%s'\n", $2); } | PAD STRING { printf("pad def: '%s'\n", $2); } | PARASPACE STRING { printf("align def: '%s'\n", $2); } |