Merge pull request #5136 from harfbuzz/kerx-fix

Kerx fix
This commit is contained in:
Behdad Esfahbod 2025-03-12 22:48:59 -06:00 committed by GitHub
commit 402876d489
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

View file

@ -235,6 +235,7 @@ struct LookupSegmentSingle
template <typename set_t, typename filter_t>
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 <typename set_t, typename filter_t>
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 <typename set_t, typename filter_t>
void collect_glyphs_filtered (set_t &glyphs, const filter_t &filter) const
{
if (glyph == DELETED_GLYPH) return;
if (!filter (value)) return;
glyphs.add (glyph);
}
@ -802,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);
}

View file

@ -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
@ -398,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:
@ -673,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:
@ -1010,7 +1011,10 @@ 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->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);

View file

@ -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;