From a319d0777b746a2bbe5cd5a206172f1580da3379 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 23 Jan 2015 12:44:24 -0800 Subject: [PATCH] [ft] Handle negative x_scale / y_scale --- src/hb-ft.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 7e75ba9..f57f566 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -99,6 +99,9 @@ hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED, if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, &v))) return 0; + if (font->x_scale < 0) + v = -v; + return (v + (1<<9)) >> 10; } @@ -530,14 +533,19 @@ hb_ft_font_set_funcs (hb_font_t *font) FT_Select_Charmap (ft_face, FT_ENCODING_UNICODE); - assert (font->y_scale >= 0); FT_Set_Char_Size (ft_face, - font->x_scale, font->y_scale, + abs (font->x_scale), abs (font->y_scale), 0, 0); #if 0 font->x_ppem * 72 * 64 / font->x_scale, font->y_ppem * 72 * 64 / font->y_scale); #endif + if (font->x_scale < 0 || font->y_scale < 0) + { + FT_Matrix matrix = { font->x_scale < 0 ? -1 : +1, 0, + 0, font->y_scale < 0 ? -1 : +1}; + FT_Set_Transform (ft_face, &matrix, NULL); + } ft_face->generic.data = blob; ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob; -- 2.7.4