fix issues in ClassDefFormat1 serialize:

glyph ids in Iterator may be non-consecutive,
so the number in classValue might be larger than length of the Iterator
This commit is contained in:
Qunxin Liu 2020-04-02 16:57:01 -07:00 committed by Garret Rieger
parent 4a49b36a9e
commit c8cc1e378d
9 changed files with 18 additions and 7 deletions

View File

@ -1644,9 +1644,19 @@ struct ClassDefFormat1
return_trace (true);
}
startGlyph = (*it).first;
classValue.serialize (c, + it
| hb_map (hb_second));
hb_codepoint_t glyph_min = (*it).first;
hb_codepoint_t glyph_max = + it
| hb_map (hb_first)
| hb_reduce (hb_max, 0u);
unsigned glyph_count = glyph_max - glyph_min + 1;
startGlyph = glyph_min;
classValue.serialize (c, glyph_count);
for (const hb_pair_t<hb_codepoint_t, unsigned>& gid_klass_pair : + it)
{
unsigned idx = gid_klass_pair.first - glyph_min;
classValue[idx] = gid_klass_pair.second;
}
return_trace (true);
}
@ -1654,7 +1664,7 @@ struct ClassDefFormat1
hb_map_t *klass_map = nullptr /*OUT*/) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = klass_map ? *c->plan->glyphset () : *c->plan->_glyphset_gsub;
const hb_set_t &glyphset = *c->plan->_glyphset_gsub;
const hb_map_t &glyph_map = *c->plan->glyph_map;
hb_sorted_vector_t<HBGlyphID> glyphs;
@ -1823,7 +1833,7 @@ struct ClassDefFormat2
hb_map_t *klass_map = nullptr /*OUT*/) const
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = klass_map ? *c->plan->glyphset () : *c->plan->_glyphset_gsub;
const hb_set_t &glyphset = *c->plan->_glyphset_gsub;
const hb_map_t &glyph_map = *c->plan->glyph_map;
hb_sorted_vector_t<HBGlyphID> glyphs;

View File

@ -1240,7 +1240,7 @@ struct PairPosFormat2
})
;
const hb_set_t &glyphset = *c->plan->glyphset ();
const hb_set_t &glyphset = *c->plan->_glyphset_gsub;
const hb_map_t &glyph_map = *c->plan->glyph_map;
auto it =

View File

@ -0,0 +1 @@
--drop-tables-=GDEF,GPOS

View File

@ -4,7 +4,7 @@ Roboto-Regular.ttf
PROFILES:
default.txt
drop-hints.txt
keep-gdef.txt
keep-gdef-gpos.txt
SUBSETS:
Ḁ̃