From 52b4da0967db468de1124e4ca01f2250ae74eba5 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 1 Aug 2022 19:24:46 +0200 Subject: Fix #790, don't rotate glyph positions with Raqm 0.9.0+ Raqm will apply the transformation matrix set on the FT_Face itself. --- src/gdft.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gdft.c b/src/gdft.c index 4cd2ae3..715bc25 100644 --- a/src/gdft.c +++ b/src/gdft.c @@ -431,11 +431,14 @@ gdTcl_UtfToUniChar (const char *str, Tcl_UniChar * chPtr) #ifdef HAVE_LIBRAQM #include +#else +#define RAQM_VERSION_ATLEAST(a,b,c) 0 #endif typedef struct { unsigned int index; FT_Pos x_advance; + FT_Pos y_advance; FT_Pos x_offset; FT_Pos y_offset; uint32_t cluster; @@ -483,6 +486,7 @@ textLayout(uint32_t *text, int len, info[i].x_offset = glyphs[i].x_offset; info[i].y_offset = glyphs[i].y_offset; info[i].x_advance = glyphs[i].x_advance; + info[i].y_advance = glyphs[i].y_advance; info[i].cluster = glyphs[i].cluster; } @@ -520,6 +524,7 @@ textLayout(uint32_t *text, int len, if (delta.x != 0) info[count - 1].x_advance += delta.x; info[count].x_advance = face->glyph->metrics.horiAdvance; + info[count].y_advance = 0; info[count].cluster = count; /* carriage returns or newlines */ @@ -1131,7 +1136,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImagePtr im, int *brect, int fg, const */ gdCache_head_t *tc_cache; /* Tuneable horizontal and vertical resolution in dots per inch */ - int hdpi, vdpi, horiAdvance, xshow_alloc = 0, xshow_pos = 0; + int hdpi, vdpi, horiAdvance, vertAdvance, xshow_alloc = 0, xshow_pos = 0; FT_Size platform_specific, platform_independent; if (strex) { @@ -1468,6 +1473,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImagePtr im, int *brect, int fg, const } horiAdvance = info[i].x_advance; + vertAdvance = info[i].y_advance; if (brect) { /* only if need brect */ @@ -1539,15 +1545,22 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImagePtr im, int *brect, int fg, const (the estimate was rounded up to next 1/METRIC_RES, so this should fit) */ FT_Pos pen_x = penf.x + info[i].x_offset; FT_Pos pen_y = penf.y - info[i].y_offset; +#if defined(HAVE_LIBRAQM) && RAQM_VERSION_ATLEAST (0, 9, 0) + gdft_draw_bitmap (tc_cache, im, fg, bm->bitmap, + (int)(x + pen_x*hdpi/(METRIC_RES*64) + bm->left), + (int)(y - pen_y*vdpi/(METRIC_RES*64) - bm->top)); +#else gdft_draw_bitmap (tc_cache, im, fg, bm->bitmap, (int)(x + (pen_x * cos_a + pen_y * sin_a)*hdpi/(METRIC_RES*64) + bm->left), (int)(y - (pen_x * sin_a - pen_y * cos_a)*vdpi/(METRIC_RES*64) - bm->top)); +#endif FT_Done_Glyph (image); } penf.x += horiAdvance; + penf.y += vertAdvance; } gdFree(text); -- cgit v1.2.1