From e0ab4e0596a0e3f384e372579bbf20b42d08cf0a Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Fri, 7 Jun 2019 10:19:21 +0200 Subject: [PATCH] added debugging info, try to fix centering of fonts when manually setting small font size --- src/ptouch-print.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 7222d4e..4b4ebd6 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -86,7 +86,9 @@ int print_img(ptouch_dev ptdev, gdImage *im) } offset=64-(gdImageSY(im)/2); /* always print centered */ if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { - printf("enable PackBits mode\n"); + if (debug) { + printf("enable PackBits mode\n"); + } ptouch_enable_packbits(ptdev); } if (ptouch_rasterstart(ptdev) != 0) { @@ -205,11 +207,13 @@ int needed_width(char *text, char *font, int fsz) gdImage *render_text(char *font, char *line[], int lines, int tape_width) { int brect[8]; - int i, black, x=0, tmp, fsz=0, ofs; + int i, black, x=0, tmp=0, fsz=0; char *p; gdImage *im=NULL; -// printf(_("%i lines, font = '%s'\n"), lines, font); + if (debug) { + printf(_("render_text(): %i lines, font = '%s'\n"), lines, font); + } if (gdFTUseFontConfig(1) != GD_TRUE) { printf(_("warning: font config not available\n")); } @@ -238,14 +242,28 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) gdImageColorAllocate(im, 255, 255, 255); black=gdImageColorAllocate(im, 0, 0, 0); /* gdImageStringFT(im,brect,fg,fontlist,size,angle,x,y,string) */ + /* find max needed line height for ALL lines */ + int max_height=0; for (i=0; i max_height) { + max_height=lineheight; + } + } + if (debug) { + printf("debug: needed (max) height is %ipx\n", max_height); + } + /* now render lines */ + for (i=0; i