[MultipleSubst] Rewrite serialize signature as single iterator

This commit is contained in:
Behdad Esfahbod 2022-08-05 15:05:51 -06:00
parent 65d28bc5a7
commit a4e0fd1685
3 changed files with 21 additions and 20 deletions

View File

@ -35,19 +35,17 @@ struct MultipleSubst
}
}
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))>
template<typename Iterator,
hb_requires (hb_is_sorted_iterator (Iterator))>
bool serialize (hb_serialize_context_t *c,
GlyphIterator glyphs,
SequenceIterator sequences)
Iterator it)
{
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, sequences));
case 1: return_trace (u.format1.serialize (c, it));
default:return_trace (false);
}
}

View File

@ -71,16 +71,23 @@ 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))>
template<typename Iterator,
hb_requires (hb_is_sorted_iterator (Iterator))>
bool serialize (hb_serialize_context_t *c,
GlyphIterator glyphs,
SequenceIterator sequences)
Iterator it)
{
TRACE_SERIALIZE (this);
auto sequences =
+ it
| hb_map (hb_second)
;
auto glyphs =
+ it
| hb_map_retains_sorting (hb_first)
;
if (unlikely (!c->extend_min (this))) return_trace (false);
if (unlikely (!sequence.serialize (c, glyphs.length))) return_trace (false);
if (unlikely (!sequence.serialize (c, sequences.length))) return_trace (false);
for (auto& pair : hb_zip (sequences, sequence))
{

View File

@ -119,20 +119,16 @@ struct SubstLookup : Lookup
return_trace (false);
}
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))>
template<typename Iterator,
hb_requires (hb_is_sorted_iterator (Iterator))>
bool serialize (hb_serialize_context_t *c,
uint32_t lookup_props,
GlyphIterator glyphs,
SequenceIterator sequences)
Iterator it)
{
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,
sequences))
serialize (c, it))
{
c->add_link (get_subtables<SubTable> ()[0], c->pop_pack ());
return_trace (true);