summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Radermacher <dominic@familie-radermacher.ch>2023-11-28 10:23:54 +0100
committerDominic Radermacher <dominic@familie-radermacher.ch>2023-11-28 10:23:54 +0100
commit5fbd590f015679bfcf8e7d718f78aca441f93957 (patch)
tree1d73427b7aef19bde82a328afd60c23c9ae32562
parentf22e844eed773cc8e9ac876ad102d58dc972bb38 (diff)
fix missing pixels on right side - thanks to patch from Boris-Chengbiao
-rw-r--r--src/ptouch-print.c13
1 files changed, 12 insertions, 1 deletions
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);
}
}