From 346331d37518f6de411f28bc09917fee475cad15 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 24 Dec 2022 10:35:26 -0700 Subject: [PATCH] [ft] Fix negative xscale --- src/hb-ft.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 66d6d841e..ee6d648f4 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -443,6 +443,7 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, FT_Matrix matrix; FT_Get_Transform (ft_face, &matrix, nullptr); x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; + x_mult *= font->x_scale < 0 ? -1 : +1; } else #endif @@ -487,6 +488,7 @@ hb_ft_get_glyph_v_advance (hb_font_t *font, FT_Matrix matrix; FT_Get_Transform (ft_font->ft_face, &matrix, nullptr); y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; + y_mult *= font->y_scale < 0 ? -1 : +1; } else #endif @@ -525,7 +527,9 @@ hb_ft_get_glyph_v_origin (hb_font_t *font, FT_Matrix matrix; FT_Get_Transform (ft_face, &matrix, nullptr); x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; + x_mult *= font->x_scale < 0 ? -1 : +1; y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; + y_mult *= font->y_scale < 0 ? -1 : +1; } else #endif @@ -586,7 +590,9 @@ hb_ft_get_glyph_extents (hb_font_t *font, FT_Matrix matrix; FT_Get_Transform (ft_face, &matrix, nullptr); x_mult = sqrtf ((float)matrix.xx * matrix.xx + (float)matrix.xy * matrix.xy) / 65536.f; + x_mult *= font->x_scale < 0 ? -1 : +1; y_mult = sqrtf ((float)matrix.yx * matrix.yx + (float)matrix.yy * matrix.yy) / 65536.f; + y_mult *= font->y_scale < 0 ? -1 : +1; } else #endif