commit 5ff41eade19ad7e68885727f900de471a85d03ed
parent 00e02c5bc470c53169964a21c53112c33fddb52e
Author: nibo <nibo@relim.de>
Date: Tue, 14 Jan 2025 17:53:24 +0100
Fix base fonts rendering weird
Diffstat:
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/out_pdf.c b/out_pdf.c
@@ -17,7 +17,6 @@ static struct Obj **g_fonts = NULL;
static char g_cho_dirpath[PATH_MAX];
static char g_current_font_name[200];
static double g_current_font_size;
-static pdfio_obj_t *g_current_font_obj = NULL;
static int g_current_page_index;
static pdfio_file_t *g_pdf_file = NULL;
@@ -515,13 +514,7 @@ pdf_font_set(pdfio_stream_t *stream, struct Font *font)
LOG_DEBUG("pdfioContentSetTextFont failed.");
return false;
}
- pdfio_obj_t *font_obj = out_pdf_fnt_obj_get_by_name(name);
- if (!font_obj) {
- LOG_DEBUG("out_pdf_fnt_obj_get_by_name failed.");
- return false;
- }
strcpy(g_current_font_name, name);
- g_current_font_obj = font_obj;
g_current_font_size = font->size;
page_index = g_current_page_index;
free(name);
@@ -654,7 +647,9 @@ static bool
pdf_text_show(pdfio_stream_t *stream, struct PDFText *text)
{
double red, green, blue, width;
+ bool unicode;
// TODO: Maybe store the width in PDFText!?
+ // TODO: Store 'unicode' in PDFText too
width = text_width(text->text, text->style);
if (width == ERROR) {
LOG_DEBUG("text_width failed.");
@@ -664,6 +659,7 @@ pdf_text_show(pdfio_stream_t *stream, struct PDFText *text)
LOG_DEBUG("pdf_font_set failed.");
return false;
}
+ unicode = !is_base_font(text->style->font);
red = text->style->foreground_color->red / 255.0;
green = text->style->foreground_color->green / 255.0;
blue = text->style->foreground_color->blue / 255.0;
@@ -683,7 +679,7 @@ pdf_text_show(pdfio_stream_t *stream, struct PDFText *text)
LOG_DEBUG("pdfioContentSetTextRise failed.");
return false;
}
- if (!pdfioContentTextShow(stream, true, text->text)) {
+ if (!pdfioContentTextShow(stream, unicode, text->text)) {
LOG_DEBUG("pdfioContentTextShow failed.");
return false;
}
@@ -2452,7 +2448,6 @@ out_pdf_create(
objs_free(g_fonts);
g_fonts = NULL;
g_current_font_size = 0.0;
- g_current_font_obj = NULL;
g_current_page_index = 0;
return pdf_filepath;
CLEAN: