lorid

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

commit 1e2a3c2e1c14a56c0bc47193249b332d128d46c1
parent d14cc816b394eaed6be63bcf1f0a24cc5b93c232
Author: nibo <nibo@relim.de>
Date:   Fri,  2 Aug 2024 18:33:54 +0200

Render boxed style in pdf

Diffstat:
Mchordpro.c | 2+-
Mout_pdf.c | 19+++++++++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -1628,7 +1628,7 @@ static struct ChoDirective *cho_directive_parse(const char *name) goto END; } else if ( strcmp(formatting_directives[5], name) == 0 || - strcmp(formatting_directives[4], name) == 0 + strcmp(formatting_directives[6], name) == 0 ) { directive->style->boxed = true; directive->dtype = DT_FORMATTING; diff --git a/out_pdf.c b/out_pdf.c @@ -466,7 +466,23 @@ static bool out_pdf_text_show(pdfio_stream_t *stream, struct TextLineItem *item, out_pdf_draw_line(stream, item, y, width, LL_OVER); out_pdf_draw_line(stream, item, y+1.5, width, LL_OVER); } - // TODO: Implement style->href and style->boxed + if (item->style->boxed) { + red = item->style->boxed_color->red / 255.0; + green = item->style->boxed_color->green / 255.0; + blue = item->style->boxed_color->blue / 255.0; + if (!pdfioContentSetStrokeColorRGB(stream, red, green, blue)) { + fprintf(stderr, "pdfioContentSetFillColorRGB failed.\n"); + return false; + } + if (!pdfioContentPathRect(stream, item->x - 2.0, y - 2.0, width + 4.0, item->style->font->size * 0.8 + 4.0)) { + fprintf(stderr, "pdfioContentPathRect failed.\n"); + return false; + } + if (!pdfioContentStroke(stream)) { + fprintf(stderr, "pdfioContentStroke failed.\n"); + return false; + } + } return true; } @@ -950,7 +966,6 @@ bool out_pdf_new(const char *cho_filepath, const char *output_folder_or_file, st fprintf(stderr, "annotations_create failed.\n"); return false; } - printf("annots size: %ld\n", pdfioArrayGetSize(annots)); if (pdfioArrayGetSize(annots) > 0) { if (!pdfioDictSetArray(page1_dict, "Annots", annots)) { fprintf(stderr, "pdfioDictSetArray failed.\n");