From c6972ac6dda207714c6b835e5b9abb351d46384c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Mar 2025 15:29:48 -0700 Subject: [PATCH] [aat] Towards removing special deleting of 0xFFFF See https://github.com/harfbuzz/harfbuzz/discussions/5118 Remove the removal. Depend on the default_ignorable flag to hide them later. Test output adjusted. --- src/hb-aat-layout-morx-table.hh | 1 + src/hb-aat-layout.cc | 23 ------------------- src/hb-ot-shape.cc | 14 ----------- test/shape/data/in-house/tests/aat-morx.tests | 2 +- 4 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 9bc05a0eb..39895703a 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -589,6 +589,7 @@ struct LigatureSubtable { DEBUG_MSG (APPLY, nullptr, "Skipping ligature component"); if (unlikely (!buffer->move_to (match_positions[--match_length % ARRAY_LENGTH (match_positions)]))) return; + buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; _hb_glyph_info_set_default_ignorable (&buffer->cur()); if (unlikely (!buffer->replace_glyph (DELETED_GLYPH))) return; } diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 9fe77a575..44a1f3c82 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -320,29 +320,6 @@ hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan, } } -void -hb_aat_layout_zero_width_deleted_glyphs (hb_buffer_t *buffer) -{ - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - hb_glyph_position_t *pos = buffer->pos; - for (unsigned int i = 0; i < count; i++) - if (unlikely (info[i].codepoint == AAT::DELETED_GLYPH)) - pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0; -} - -static bool -is_deleted_glyph (const hb_glyph_info_t *info) -{ - return info->codepoint == AAT::DELETED_GLYPH; -} - -void -hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer) -{ - buffer->delete_glyphs_inplace (is_deleted_glyph); -} - /** * hb_aat_layout_has_positioning: * @face: #hb_face_t to work upon diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index c9defc49a..e55221f69 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -956,21 +956,11 @@ hb_ot_substitute_pre (const hb_ot_shape_context_t *c) _hb_buffer_allocate_gsubgpos_vars (c->buffer); hb_ot_substitute_plan (c); - -#ifndef HB_NO_AAT_SHAPE - if (c->plan->apply_morx && c->plan->apply_gpos) - hb_aat_layout_remove_deleted_glyphs (c->buffer); -#endif } static inline void hb_ot_substitute_post (const hb_ot_shape_context_t *c) { -#ifndef HB_NO_AAT_SHAPE - if (c->plan->apply_morx && !c->plan->apply_gpos) - hb_aat_layout_remove_deleted_glyphs (c->buffer); -#endif - hb_ot_deal_with_variation_selectors (c->buffer); hb_ot_hide_default_ignorables (c->buffer, c->font); @@ -1109,10 +1099,6 @@ hb_ot_position_plan (const hb_ot_shape_context_t *c) /* Finish off. Has to follow a certain order. */ hb_ot_layout_position_finish_advances (c->font, c->buffer); hb_ot_zero_width_default_ignorables (c->buffer); -#ifndef HB_NO_AAT_SHAPE - if (c->plan->apply_morx) - hb_aat_layout_zero_width_deleted_glyphs (c->buffer); -#endif hb_ot_layout_position_finish_offsets (c->font, c->buffer); /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ diff --git a/test/shape/data/in-house/tests/aat-morx.tests b/test/shape/data/in-house/tests/aat-morx.tests index b1b5079e0..b9ecd0d58 100644 --- a/test/shape/data/in-house/tests/aat-morx.tests +++ b/test/shape/data/in-house/tests/aat-morx.tests @@ -1,2 +1,2 @@ -../fonts/MORXTwentyeight.ttf;;U+0041,U+0078,U+0045,U+0079,U+0044,U+0079,U+0079;[A_E_D=0+1394|x=0+529|y=0+510|y=5+510|y=6+510] +../fonts/MORXTwentyeight.ttf;;U+0041,U+0078,U+0045,U+0079,U+0044,U+0079,U+0079;[A_E_D=0+1394|x=0+529|space=0+0|y=0+510|space=0+0|y=5+510|y=6+510] ../fonts/e6185e88b04432fbf373594d5971686bb7dd698d.ttf;;U+0B95,U+0BCD,U+0020,U+0B9A,U+0BCD;[ka-tamil=0+825|pulli-tamil=0@-392,0+0|space=2+260|ca-tamil=3+723|pulli-tamil=3@-320,0+0]