lorid

convert chordpro to pdf
git clone git://git.relim.de/lorid.git
Log | Files | Refs | README | LICENSE

commit ab320e67862f49a4ab4497046e4a903fe4e646fb
parent 1e2a3c2e1c14a56c0bc47193249b332d128d46c1
Author: nibo <nibo@relim.de>
Date:   Sat,  3 Aug 2024 12:45:53 +0200

Implement resetting font directive values

e.g. if you previously had the directive
'{textfont: Noto Sans}' and then have the
directive '{textfont}' the textfont value
will be reset to default.

Diffstat:
Mchordpro.c | 25++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/chordpro.c b/chordpro.c @@ -1793,6 +1793,7 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config) songs[so]->sections[se]->lines[li]->lyrics[ly] = cho_line_item_new(); struct Tag **tags = NULL; struct Style *tag_style; + struct Style *config_style; struct StyleProperty sprop; while (feof(fp) == 0) { read = fread(&buf, 1, 1, fp); @@ -1951,7 +1952,29 @@ struct ChoSong **cho_songs_parse(FILE *fp, struct Config *config) songs[so]->sections[se]->lines[li]->lyrics[ly] = cho_line_item_new(); break; case DT_FONT: - // TODO: Reset directive value to default + config_style = cho_style_new_from_config(); + sprop.ftype = directive->ftype; + sprop.type = directive->sprop; + switch (directive->sprop) { + case SPT_FONT: + sprop.u.font_name = strdup(config_style->font->name); + break; + case SPT_SIZE: + sprop.u.font_size = config_style->font->size; + break; + case SPT_COLOR: + sprop.u.foreground_color = cho_rgbcolor_duplicate(config_style->foreground_color); + break; + default: + fprintf(stderr, "INFO: Ignoring invalid style property type '%s'.\n", the_style_property_type(directive->sprop)); + } + cho_style_change_default(sprop); + if (sprop.type == SPT_FONT) { + free(sprop.u.font_name); + } else if (sprop.type == SPT_COLOR) { + free(sprop.u.foreground_color); + } + cho_style_free(config_style); break; case DT_CUSTOM: fprintf(stderr, "INFO: Ignoring custom directive '%s'.\n", directive_name);