From bd07d2878ff28baecf7b4b587a18ffbb744b7eb1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 30 Sep 2018 03:54:40 -0400 Subject: [PATCH] Use buffer scratch_flags to remember if we had any joiners --- src/hb-buffer.hh | 3 ++- src/hb-ot-layout.hh | 12 ++++++++++-- src/hb-ot-shape-complex-arabic.cc | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index bcaf066c7..24d46400a 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -68,7 +68,8 @@ enum hb_buffer_scratch_flags_t { HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u, - HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u, + HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS = 0x00000020u, + HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000040u, /* Reserved for complex shapers' internal use. */ HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index 7a787b77e..d9b954f4c 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -224,8 +224,16 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) { buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; props |= UPROPS_MASK_IGNORABLE; - if (u == 0x200Cu) props |= UPROPS_MASK_Cf_ZWNJ; - else if (u == 0x200Du) props |= UPROPS_MASK_Cf_ZWJ; + if (u == 0x200Cu) + { + props |= UPROPS_MASK_Cf_ZWNJ; + buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS; + } + else if (u == 0x200Du) + { + props |= UPROPS_MASK_Cf_ZWJ; + buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS; + } /* Mongolian Free Variation Selectors need to be remembered * because although we need to hide them like default-ignorables, * they need to non-ignorable during shaping. This is similar to diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index d136a6644..c4a695ab9 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -399,6 +399,9 @@ flip_joiners (const hb_ot_shape_plan_t *plan HB_UNUSED, hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) { + if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS)) + return; + unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; for (unsigned int i = 0; i < count; i++)