From 5fbd590f015679bfcf8e7d718f78aca441f93957 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Tue, 28 Nov 2023 10:23:54 +0100 Subject: [PATCH] fix missing pixels on right side - thanks to patch from Boris-Chengbiao --- src/ptouch-print.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index a0e0804..c01df2a 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -239,6 +239,16 @@ int needed_width(char *text, char *font, int fsz) return brect[2]-brect[0]; } +int offset_x(char *text, char *font, int fsz) +{ + int brect[8]; + + if (gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text) != NULL) { + return -1; + } + return -brect[0]; +} + gdImage *render_text(char *font, char *line[], int lines, int tape_width) { int brect[8]; @@ -307,7 +317,8 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) if (debug) { printf("debug: line %i pos=%i ofs=%i\n", i+1, pos, ofs); } - if ((p=gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, 0, pos, line[i])) != NULL) { + int off_x = offset_x(line[i], font_file, fsz); + if ((p=gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x, pos, line[i])) != NULL) { printf(_("error in gdImageStringFT: %s\n"), p); } }