From 061105ec443eb7350ffe217305f9d8902c179e2f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 22 Feb 2016 14:59:39 +0900 Subject: [PATCH] [coretext] Fix shaping with varying font size Fixes https://github.com/libass/libass/issues/212 --- src/hb-coretext.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 04cf057..90b163f 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -143,7 +143,6 @@ hb_coretext_face_get_cg_font (hb_face_t *face) struct hb_coretext_shaper_font_data_t { CTFontRef ct_font; - CGFloat x_mult, y_mult; /* From CT space to HB space. */ }; hb_coretext_shaper_font_data_t * @@ -167,8 +166,6 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font) if (font_size < 0) font_size = -font_size; - data->x_mult = (CGFloat) font->x_scale / font_size; - data->y_mult = (CGFloat) font->y_scale / font_size; data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL); if (unlikely (!data->ct_font)) { DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); @@ -483,6 +480,10 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + CGFloat ct_font_size = CTFontGetSize (font_data->ct_font); + CGFloat x_mult = (CGFloat) font->x_scale / ct_font_size; + CGFloat y_mult = (CGFloat) font->y_scale / ct_font_size; + /* Attach marks to their bases, to match the 'ot' shaper. * Adapted from hb-ot-shape:hb_form_clusters(). * Note that this only makes us be closer to the 'ot' shaper, @@ -1028,7 +1029,6 @@ resize_and_retry: positions = position_buf; } hb_glyph_info_t *info = run_info; - CGFloat x_mult = font_data->x_mult, y_mult = font_data->y_mult; if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) { hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult; -- 2.7.4