[subset] Fix unecessary trailing 0 bytes left by ContextFormat2 pruning.

Uneeded rules where beind removed from the count by the bytes for them was being left in the font.
This commit is contained in:
Garret Rieger 2022-11-23 23:50:49 +00:00
parent 51028e63e6
commit ff3cac0ccd
16 changed files with 5 additions and 1 deletions

View File

@ -2411,6 +2411,7 @@ struct ContextFormat2_5
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
bool ret = true;
int non_zero_index = -1, index = 0;
auto snapshot = c->serializer->snapshot();
for (const auto& _ : + hb_enumerate (ruleSet)
| hb_filter (klass_map, hb_first))
{
@ -2422,8 +2423,10 @@ struct ContextFormat2_5
}
if (coverage_glyph_classes.has (_.first) &&
o->serialize_subset (c, _.second, this, lookup_map, &klass_map))
o->serialize_subset (c, _.second, this, lookup_map, &klass_map)) {
non_zero_index = index;
snapshot = c->serializer->snapshot();
}
index++;
}
@ -2437,6 +2440,7 @@ struct ContextFormat2_5
out->ruleSet.pop ();
index--;
}
c->serializer->revert (snapshot);
return_trace (bool (out->ruleSet));
}