[subset] correct ClassDef format determination.

It was possible for glyph_min to be a glyph mapped to class zero which threw off the number of glyph calculation.
This commit is contained in:
Garret Rieger 2021-04-30 12:59:17 -07:00
parent 90713f270e
commit be50779cda

View File

@ -2308,11 +2308,13 @@ struct ClassDef
template<typename Iterator,
hb_requires (hb_is_iterator (Iterator))>
bool serialize (hb_serialize_context_t *c, Iterator it)
bool serialize (hb_serialize_context_t *c, Iterator it_with_class_zero)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
auto it = + it_with_class_zero | hb_filter (hb_second);
unsigned format = 2;
if (likely (it))
{
@ -2328,8 +2330,8 @@ struct ClassDef
{
hb_codepoint_t cur_gid = gid_klass_pair.first;
unsigned cur_klass = gid_klass_pair.second;
if (cur_klass) num_glyphs++;
if (cur_gid == glyph_min || !cur_klass) continue;
num_glyphs++;
if (cur_gid == glyph_min) continue;
if (cur_gid > glyph_max) glyph_max = cur_gid;
if (cur_gid != prev_gid + 1 ||
cur_klass != prev_klass)