lorid

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

commit a4368b630d09cf6b5ba2631a93ce1f314d0387f4
parent 156fc6db49ca0e39887d3afd7ac2d85eba07f593
Author: nibo <nibo@relim.de>
Date:   Sat,  5 Oct 2024 10:52:25 +0200

Improve behaviour when to start a new page

Diffstat:
Mout_pdf.c | 17+++++++++++++++--
Mout_pdf.h | 2++
2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/out_pdf.c b/out_pdf.c @@ -758,6 +758,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) text[t]->lines[tl]->items[0]->x = MARGIN_HORIZONTAL + (LINE_WIDTH - width) / 2; text[t]->lines[tl]->items[1] = NULL; text[t]->lines[tl]->btype = BT_LINE; + text[t]->lines[tl]->ftype = SF_TITLE; y -= text_line_set_lineheight(text[t]->lines[tl], SF_TEXT); if (y < MARGIN_BOTTOM) { y = MEDIABOX_HEIGHT - MARGIN_TOP; @@ -809,6 +810,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) text[t]->lines[tl]->items[0]->x = MARGIN_HORIZONTAL + (LINE_WIDTH - width) / 2; text[t]->lines[tl]->items[1] = NULL; text[t]->lines[tl]->btype = BT_LINE; + text[t]->lines[tl]->ftype = SF_SUBTITLE; y -= text_line_set_lineheight(text[t]->lines[tl], SF_TEXT); if (y < MARGIN_BOTTOM) { y = MEDIABOX_HEIGHT - MARGIN_TOP; @@ -856,6 +858,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) text[t]->lines[tl]->items[0]->x = MARGIN_HORIZONTAL; text[t]->lines[tl]->items[1] = NULL; text[t]->lines[tl]->btype = BT_LINE; + text[t]->lines[tl]->ftype = SF_LABEL; y -= text_line_set_lineheight(text[t]->lines[tl], SF_TEXT); if (y < MARGIN_BOTTOM) { y = MEDIABOX_HEIGHT - MARGIN_TOP; @@ -972,6 +975,7 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) fprintf(stderr, "WARN: text line (chords/annotations) doesn't fit.\n"); } text[t]->lines[tl]->btype = lines[li]->btype; + text[t]->lines[tl]->ftype = SF_CHORD; y -= text_line_set_lineheight(text[t]->lines[tl], SF_CHORD); if (y < MARGIN_BOTTOM) { // INFO: we don't split the chords and corresponding lyrics @@ -1051,10 +1055,19 @@ static struct Text **text_create(struct ChoSong **songs, struct Config *config) fprintf(stderr, "WARN: text line (lyrics) doesn't fit.\n"); } text[t]->lines[tl]->btype = lines[li]->btype; + text[t]->lines[tl]->ftype = SF_TEXT; y -= text_line_set_lineheight(text[t]->lines[tl], SF_TEXT); if (y < MARGIN_BOTTOM) { - y = MEDIABOX_HEIGHT - MARGIN_TOP; - text[t]->lines[tl]->btype = BT_PAGE; + if (text[t]->lines[tl-1]->ftype == SF_CHORD) { + text[t]->lines[tl-2]->btype = BT_PAGE; + y = MEDIABOX_HEIGHT - MARGIN_TOP; + y -= text[t]->lines[tl-1]->height; + y -= text[t]->lines[tl]->height; + } else { + text[t]->lines[tl-1]->btype = BT_PAGE; + y = MEDIABOX_HEIGHT - MARGIN_TOP; + y -= text[t]->lines[tl]->height; + } } tli = 0; if (spaces) { diff --git a/out_pdf.h b/out_pdf.h @@ -1,4 +1,5 @@ #include <pdfio.h> +#include "chordpro.h" #define MEDIABOX_HEIGHT 878.0 #define MEDIABOX_WIDTH 631.0 @@ -43,6 +44,7 @@ struct TextLine { struct TextLineItem **items; double height; enum BreakType btype; + enum SongFragmentType ftype; }; struct Text {