lorid

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

commit 2aa159ea45aee41133fd3b97e11d4091a1d96a29
parent c07e927f82f28e776e0ebe159a0669ce80839ac0
Author: nibo <nibo@relim.de>
Date:   Thu, 13 Mar 2025 17:55:24 +0100

Fix subtitle printing

Diffstat:
Msrc/chordpro.c | 2+-
Msrc/config.c | 27+--------------------------
Msrc/out_pdf.c | 26+++++++++-----------------
3 files changed, 11 insertions(+), 44 deletions(-)

diff --git a/src/chordpro.c b/src/chordpro.c @@ -41,7 +41,7 @@ static const char *state_enums[] = { }; struct StyleProperty default_style_properties[] = { - // TODO: label and footer are missing + // TODO: footer are missing { TT_CHORD, SPT_FONT, { .font_name = NULL } }, { TT_CHORD, SPT_SIZE, { .font_size = EMPTY_DOUBLE } }, { TT_CHORD, SPT_COLOR, { .foreground_color = NULL } }, diff --git a/src/config.c b/src/config.c @@ -16,8 +16,7 @@ static const char *notation_systems[] = { "scandinavian", "latin", "roman", - "nashville", - "custom" // TODO: Is this needed + "nashville" }; static const char *parse_modes[] = { @@ -43,28 +42,6 @@ static const char *alignments[] = { "left", "center", "right" }; -/* static const char *g_valid_styles[] = { - "title", - "subtitle", - "footer", // TODO - "text", - "chorus", - "chord", - "annotation", - "comment", - "comment_italic", - "comment_boxed", - "tab", - "label", - "toc", - "grid", - "grid_margin", // TODO - "empty", // TODO - "diagram", // TODO - "diagram_base", // TODO - "chordfingers" // TODO -}; */ - static struct Note notes_common[] = { { .note = "C", .sharp = "C#", .flat = NULL }, { .note = "D", .sharp = "D#", .flat = "Db" }, @@ -324,7 +301,6 @@ config_notes_new_default(enum NotationSystem system) notes_default[i]->flat = strdup(notes[i].flat); } } - // notes_default[7] = NULL; // TODO: This is probably needless return notes_default; } @@ -514,7 +490,6 @@ config_load_default(void) config->output->styles[TT_COMMENT_BOX]->font->name = strdup(DEFAULT_FONT); config->output->styles[TT_COMMENT_BOX]->boxed = true; - // config->output->styles[15] = NULL; config->output->notes = config_notes_new_default(NS_COMMON); config->parser = emalloc(sizeof(struct ConfigParser)); config->parser->chords = emalloc(sizeof(struct ConfigChords)); diff --git a/src/out_pdf.c b/src/out_pdf.c @@ -2245,7 +2245,7 @@ pdf_toc_create( } title_style = config->output->styles[TT_TOC_TITLE]; if (!pdf_texts_add_text(&ctx, config->output->toc->title, title_style, A_CENTER, NUS_ROMAN)) { - LOG_DEBUG("pdf_texts_add_text failed."); + LOG_DEBUG("pdf_texts_add_text(toctitle) failed."); return false; } ctx.y -= 30.0; @@ -2337,25 +2337,17 @@ pdf_content_create( ctx.content->toc[ctx.toc_entry]->page_y = ctx.y; ctx.toc_entry++; if (!pdf_texts_add_text(&ctx, value, value_style, A_CENTER, NUS_WESTERN_ARABIC)) { - LOG_DEBUG("pdf_texts_add_text failed."); + LOG_DEBUG("pdf_texts_add_text(title) failed."); return false; } free(value); - /* - INFO: (*m)->style will be ignored and the config style will be - used because the subtitle style can only be manipulated from the - config file - */ - // output_style = config->output->styles[TT_SUBTITLE]; - if (!cho_metadata_value(songs[s]->metadata, "subtitle", config->metadata_separator, &value, &value_style)) { - LOG_DEBUG("pdf_texts_add_text failed."); - return false; - } - if (!pdf_texts_add_text(&ctx, value, value_style, A_CENTER, NUS_WESTERN_ARABIC)) { - LOG_DEBUG("pdf_texts_add_text failed."); - return false; + if (cho_metadata_value(songs[s]->metadata, "subtitle", config->metadata_separator, &value, &value_style)) { + if (!pdf_texts_add_text(&ctx, value, value_style, A_CENTER, NUS_WESTERN_ARABIC)) { + LOG_DEBUG("pdf_texts_add_text(subtitle) failed."); + return false; + } + free(value); } - free(value); texts = &ctx.content->pages[ctx.page]->texts; imgs = &ctx.content->pages[ctx.page]->images; diagrams = &ctx.content->pages[ctx.page]->diagrams; @@ -2363,7 +2355,7 @@ pdf_content_create( for (se = songs[s]->sections; *se; se++) { if ((*se)->label) { if (!pdf_texts_add_text(&ctx, (*se)->label->text, (*se)->label->style, A_LEFT, NUS_WESTERN_ARABIC)) { - LOG_DEBUG("pdf_texts_add_text failed."); + LOG_DEBUG("pdf_texts_add_text(label) failed."); return false; } texts = &ctx.content->pages[ctx.page]->texts;