summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNedko Boshkilov <nboshkilov@abv.bg>2024-02-11 10:29:01 +0100
committerDominic Radermacher <dominic@familie-radermacher.ch>2024-02-11 10:29:01 +0100
commit312adc32090de93e092b38bff290594017dd0c4a (patch)
tree12cdc8cd3055a8f8d242a636110fefb615265269
parent935dd9a31b18158877f787dc17d01698826bd164 (diff)
fix baseline for cyrillic font
-rw-r--r--src/ptouch-print.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/ptouch-print.c b/src/ptouch-print.c
index c01df2a..95a44f6 100644
--- a/src/ptouch-print.c
+++ b/src/ptouch-print.c
@@ -193,14 +193,19 @@ int write_png(gdImage *im, const char *file)
int get_baselineoffset(char *text, char *font, int fsz)
{
int brect[8];
+ int o_offset;
+ int text_offset;
- if (strpbrk(text, "QgjpqyQµ") == NULL) { /* if we have none of these */
- return 0; /* we don't need an baseline offset */
- } /* else we need to calculate it */
+ /* NOTE: This assumes that 'o' is always on the baseline */
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o");
- int tmp=brect[1]-brect[5];
- gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "g");
- return (brect[1]-brect[5])-tmp;
+ o_offset=brect[1];
+ gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text);
+ text_offset=brect[1];
+ if (debug) {
+ printf(_("debug: o baseline offset - %d\n"), o_offset);
+ printf(_("debug: text baseline offset - %d\n"), text_offset);
+ }
+ return text_offset-o_offset;
}
/* --------------------------------------------------------------------