From 4499ae0225172ab7590619219b21fe0a0c14d66e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 28 Jun 2022 15:43:57 -0600 Subject: [PATCH] [coretext] Fix positioning of out-of-order glyphs Unfortunately this now generates negative advances. To be fixed... --- src/hb-coretext.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 0178db66b..99b33c001 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -1075,7 +1075,8 @@ resize_and_retry: advance = positions[j + 1].x - positions[j].x; else /* last glyph */ advance = run_advance - (positions[j].x - positions[0].x); - info->mask = round (advance * x_mult); + /* int cast necessary to pass through negative values. */ + info->mask = (int) round (advance * x_mult); info->var1.i32 = x_offset; info->var2.i32 = round (positions[j].y * y_mult); info++; @@ -1091,7 +1092,8 @@ resize_and_retry: advance = positions[j + 1].y - positions[j].y; else /* last glyph */ advance = run_advance - (positions[j].y - positions[0].y); - info->mask = round (advance * y_mult); + /* int cast necessary to pass through negative values. */ + info->mask = (int) round (advance * y_mult); info->var1.i32 = round (positions[j].x * x_mult); info->var2.i32 = y_offset; info++; @@ -1167,6 +1169,10 @@ resize_and_retry: } } + /* TODO: Sometimes the above positioning code generates negative + * advance values. Fix them up. Example, with NotoNastaliqUrdu + * font and sequence ابهد. */ + buffer->clear_glyph_flags (); buffer->unsafe_to_break ();