commit 72e53ecf48386a37bb13c856724f84934f3b2a0b
parent 935668c89438267ae74ae1435c6657884c1b3766
Author: nibo <nibo@relim.de>
Date: Sun, 12 Jan 2025 12:48:16 +0100
Refactor a bit
Diffstat:
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/out_pdf.c b/out_pdf.c
@@ -833,12 +833,17 @@ pdf_set_title(pdfio_file_t *pdf, struct ChoSong **songs)
}
static pdfio_stream_t *
-pdf_page_create(pdfio_file_t *pdf, struct PDFImage **imgs, pdfio_array_t *annots)
+pdf_page_create(
+ pdfio_file_t *pdf,
+ struct PDFImage **imgs,
+ pdfio_array_t *annots
+)
{
pdfio_dict_t *page_dict;
pdfio_stream_t *page_stream;
pdfio_array_t *color_array = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_ADOBE);
- int f;
+ struct Obj **f;
+ struct PDFImage **i;
page_dict = pdfioDictCreate(pdf);
if (!pdfioPageDictAddColorSpace(page_dict, "rgbcolorspace", color_array)) {
LOG_DEBUG("pdfioPageDictAddColorSpace failed.");
@@ -849,15 +854,15 @@ pdf_page_create(pdfio_file_t *pdf, struct PDFImage **imgs, pdfio_array_t *annots
return NULL;
}
if (imgs) {
- for (f = 0; imgs[f]; f++) {
- if (!pdfioPageDictAddImage(page_dict, imgs[f]->name, imgs[f]->obj)) {
+ for (i = imgs; *i; i++) {
+ if (!pdfioPageDictAddImage(page_dict, (*i)->name, (*i)->obj)) {
LOG_DEBUG("pdfioPageDictAddImage failed.");
return NULL;
}
}
}
- for (f = 0; g_fonts[f]; f++) {
- if (!pdfioPageDictAddFont(page_dict, g_fonts[f]->name, g_fonts[f]->value)) {
+ for (f = g_fonts; *f; f++) {
+ if (!pdfioPageDictAddFont(page_dict, (*f)->name, (*f)->value)) {
LOG_DEBUG("pdfioPageDictAddFont failed.");
return NULL;
}