From bc6eba9407a214a6ed987c59f638245d5e376d3f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Aug 2025 13:29:15 -0600 Subject: [PATCH] Fix kerx attachment shaping issues (#5515) * [ot-shape] Don't zero offsets of default-ignorables Part of fixing https://github.com/harfbuzz/harfbuzz/issues/5514 * [ot-shape] Propagate chain offsets in opposite direction if RTL Part of fixing https://github.com/harfbuzz/harfbuzz/issues/5514 --- src/OT/Layout/GPOS/GPOS.hh | 11 +++++++++-- src/hb-ot-shape.cc | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/OT/Layout/GPOS/GPOS.hh b/src/OT/Layout/GPOS/GPOS.hh index ce3f74d8c..c657d13c2 100644 --- a/src/OT/Layout/GPOS/GPOS.hh +++ b/src/OT/Layout/GPOS/GPOS.hh @@ -149,8 +149,15 @@ GPOS::position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer) /* Handle attachments */ if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT) - for (unsigned i = 0; i < len; i++) - propagate_attachment_offsets (pos, len, i, direction); + { + // https://github.com/harfbuzz/harfbuzz/issues/5514 + if (HB_DIRECTION_IS_FORWARD (direction)) + for (unsigned i = 0; i < len; i++) + propagate_attachment_offsets (pos, len, i, direction); + else + for (unsigned i = len; i-- > 0; ) + propagate_attachment_offsets (pos, len, i, direction); + } if (unlikely (font->slant_xy) && HB_DIRECTION_IS_HORIZONTAL (direction)) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 1bd9684e7..8da06e7ab 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -788,7 +788,13 @@ hb_ot_zero_width_default_ignorables (const hb_buffer_t *buffer) unsigned int i = 0; for (i = 0; i < count; i++) if (unlikely (_hb_glyph_info_is_default_ignorable (&info[i]))) - pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0; + { + pos[i].x_advance = pos[i].y_advance = 0; + if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + pos[i].x_offset = 0; + else + pos[i].y_offset = 0; + } } static void