From 7146e5818fc6185d74fcf9b3acfcb0d46f3cf1a6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 20:11:30 -0600 Subject: [PATCH 1/5] [kerx] Remove redundant check --- src/hb-aat-layout-kerx-table.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index bed31327c..d47f01a6d 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -1010,7 +1010,7 @@ struct KerxTable if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ()) goto skip; - c->machine_glyph_set = accel_data ? &accel_data[i].left_set : &Null(hb_bit_set_t); + c->machine_glyph_set = &accel_data[i].left_set; if (!c->buffer_intersects_machine ()) { From b861b54178289e589289d3fbda6c52f94a383e93 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 20:51:18 -0600 Subject: [PATCH 2/5] [kerx] Cosmetic --- src/hb-aat-layout-kerx-table.hh | 12 ++++++------ src/hb-aat-layout-morx-table.hh | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index d47f01a6d..fbf0d39ca 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -328,8 +328,9 @@ struct KerxSubTableFormat1 } else if (buffer->info[idx].mask & kern_mask) { - o.x_advance += c->font->em_scale_x (v); - o.x_offset += c->font->em_scale_x (v); + auto scaled = c->font->em_scale_x (v); + o.x_advance += scaled; + o.x_offset += scaled; } } else @@ -1010,7 +1011,10 @@ struct KerxTable if (HB_DIRECTION_IS_HORIZONTAL (c->buffer->props.direction) != st->u.header.is_horizontal ()) goto skip; + c->left_set = &accel_data[i].left_set; + c->right_set = &accel_data[i].right_set; c->machine_glyph_set = &accel_data[i].left_set; + c->machine_class_cache = &accel_data[i].class_cache; if (!c->buffer_intersects_machine ()) { @@ -1044,10 +1048,6 @@ struct KerxTable if (reverse) c->buffer->reverse (); - c->left_set = &accel_data[i].left_set; - c->right_set = &accel_data[i].right_set; - c->machine_class_cache = &accel_data[i].class_cache; - { /* See comment in sanitize() for conditional here. */ hb_sanitize_with_object_t with (&c->sanitizer, i < count - 1 ? st : (const SubTable *) nullptr); diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 0a99e8f4f..7aa820e33 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -1168,6 +1168,7 @@ struct Chain if (hb_none (hb_iter (c->range_flags) | hb_map ([subtable_flags] (const hb_aat_map_t::range_flags_t _) -> bool { return subtable_flags & (_.flags); }))) goto skip; + c->subtable_flags = subtable_flags; c->machine_glyph_set = accel ? &accel->subtables[i].glyph_set : &Null(hb_bit_set_t); c->machine_class_cache = accel ? &accel->subtables[i].class_cache : nullptr; From 6388ce2224134804c32b376349aed34b80b62af9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 20:58:06 -0600 Subject: [PATCH 3/5] [kerx] We don't need right_set in machine kerning --- src/hb-aat-layout-kerx-table.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index fbf0d39ca..96f5ed6fd 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -399,7 +399,7 @@ struct KerxSubTableFormat1 void collect_glyphs (set_t &left_set, set_t &right_set, unsigned num_glyphs) const { machine.collect_initial_glyphs (left_set, num_glyphs, *this); - machine.collect_glyphs (right_set, num_glyphs); + //machine.collect_glyphs (right_set, num_glyphs); // right_set is unused for machine kerning } protected: @@ -674,7 +674,7 @@ struct KerxSubTableFormat4 void collect_glyphs (set_t &left_set, set_t &right_set, unsigned num_glyphs) const { machine.collect_initial_glyphs (left_set, num_glyphs, *this); - machine.collect_glyphs (right_set, num_glyphs); + //machine.collect_glyphs (right_set, num_glyphs); // right_set is unused for machine kerning } protected: From 2449eb088275ef10009bdff1a5809c56f2c0dd63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 21:03:24 -0600 Subject: [PATCH 4/5] [aat] Adjust filtering to match collect_glyphs() --- src/hb-aat-layout-common.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 55d2975a4..1d9c6f0fe 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -235,6 +235,7 @@ struct LookupSegmentSingle template void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const { + if (first == DELETED_GLYPH) return; if (!filter (value)) return; glyphs.add_range (first, last); } @@ -324,6 +325,7 @@ struct LookupSegmentArray template void collect_glyphs_filtered (set_t &glyphs, const void *base, const filter_t &filter) const { + if (first == DELETED_GLYPH) return; const auto &values = base+valuesZ; for (hb_codepoint_t i = first; i <= last; i++) if (filter (values[i - first])) @@ -424,6 +426,7 @@ struct LookupSingle template void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const { + if (glyph == DELETED_GLYPH) return; if (!filter (value)) return; glyphs.add (glyph); } From c38d518718b799383672d158f84648f749dd23a7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Mar 2025 22:39:33 -0600 Subject: [PATCH 5/5] [aat/kerx] Fix initial-glyph collection logic Test: $ hb-shape GeezaPro.ttc --unicodes U+064A,U+064E,U+0651,U+0629 --- src/hb-aat-layout-common.hh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 1d9c6f0fe..bd4a56cea 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -805,6 +805,10 @@ struct StateTable } // And glyphs in those classes. + + if (filter (CLASS_DELETED_GLYPH)) + glyphs.add (DELETED_GLYPH); + (this+classTable).collect_glyphs_filtered (glyphs, num_glyphs, filter); }