[MultipleSubst] Rewrite serialize() in terms of iterators

Unused still, and hence untested
This commit is contained in:
Behdad Esfahbod 2022-08-05 14:56:07 -06:00
parent b57ea3b053
commit 65d28bc5a7
3 changed files with 25 additions and 22 deletions

View File

@ -35,19 +35,19 @@ struct MultipleSubst
}
}
/* TODO This function is unused and not updated to 24bit GIDs. Should be done by using
* iterators. While at it perhaps using iterator of arrays of hb_codepoint_t instead. */
template<typename GlyphIterator, typename SequenceIterator,
hb_requires (hb_is_sorted_source_of (GlyphIterator, hb_codepoint_t)),
hb_requires (hb_is_source_of (typename SequenceIterator::item_t, hb_codepoint_t))>
bool serialize (hb_serialize_context_t *c,
hb_sorted_array_t<const HBGlyphID16> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const HBGlyphID16> substitute_glyphs_list)
GlyphIterator glyphs,
SequenceIterator sequences)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (u.format))) return_trace (false);
unsigned int format = 1;
u.format = format;
switch (u.format) {
case 1: return_trace (u.format1.serialize (c, glyphs, substitute_len_list, substitute_glyphs_list));
case 1: return_trace (u.format1.serialize (c, glyphs, sequences));
default:return_trace (false);
}
}

View File

@ -71,22 +71,24 @@ struct MultipleSubstFormat1_2
return_trace ((this+sequence[index]).apply (c));
}
template<typename GlyphIterator, typename SequenceIterator,
hb_requires (hb_is_sorted_source_of (GlyphIterator, hb_codepoint_t)),
hb_requires (hb_is_source_of (typename SequenceIterator::item_t, hb_codepoint_t))>
bool serialize (hb_serialize_context_t *c,
hb_sorted_array_t<const HBGlyphID16> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const HBGlyphID16> substitute_glyphs_list)
GlyphIterator glyphs,
SequenceIterator sequences)
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (this))) return_trace (false);
if (unlikely (!sequence.serialize (c, glyphs.length))) return_trace (false);
for (unsigned int i = 0; i < glyphs.length; i++)
for (auto& pair : hb_zip (sequences, sequence))
{
unsigned int substitute_len = substitute_len_list[i];
if (unlikely (!sequence[i]
.serialize_serialize (c, substitute_glyphs_list.sub_array (0, substitute_len))))
if (unlikely (!pair.second
.serialize_serialize (c, pair.first)))
return_trace (false);
substitute_glyphs_list += substitute_len;
}
return_trace (coverage.serialize_serialize (c, glyphs));
}

View File

@ -119,19 +119,20 @@ struct SubstLookup : Lookup
return_trace (false);
}
bool serialize_multiple (hb_serialize_context_t *c,
template<typename GlyphIterator, typename SequenceIterator,
hb_requires (hb_is_sorted_source_of (GlyphIterator, hb_codepoint_t)),
hb_requires (hb_is_source_of (typename SequenceIterator::item_t, hb_codepoint_t))>
bool serialize (hb_serialize_context_t *c,
uint32_t lookup_props,
hb_sorted_array_t<const HBGlyphID16> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const HBGlyphID16> substitute_glyphs_list)
GlyphIterator glyphs,
SequenceIterator sequences)
{
TRACE_SERIALIZE (this);
if (unlikely (!Lookup::serialize (c, SubTable::Multiple, lookup_props, 1))) return_trace (false);
if (c->push<SubTable> ()->u.multiple.
serialize (c,
glyphs,
substitute_len_list,
substitute_glyphs_list))
sequences))
{
c->add_link (get_subtables<SubTable> ()[0], c->pop_pack ());
return_trace (true);