1
0
mirror of https://git.familie-radermacher.ch/linux/ptouch-print.git synced 2025-05-13 15:22:56 +00:00

fix baseline for cyrillic font

This commit is contained in:
Nedko Boshkilov 2024-02-11 10:29:01 +01:00 committed by Dominic Radermacher
parent 935dd9a31b
commit 312adc3209

View File

@ -193,14 +193,19 @@ int write_png(gdImage *im, const char *file)
int get_baselineoffset(char *text, char *font, int fsz) int get_baselineoffset(char *text, char *font, int fsz)
{ {
int brect[8]; int brect[8];
int o_offset;
int text_offset;
if (strpbrk(text, "QgjpqyQµ") == NULL) { /* if we have none of these */ /* NOTE: This assumes that 'o' is always on the baseline */
return 0; /* we don't need an baseline offset */
} /* else we need to calculate it */
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o"); gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o");
int tmp=brect[1]-brect[5]; o_offset=brect[1];
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "g"); gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text);
return (brect[1]-brect[5])-tmp; 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;
} }
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------