[OT] Implement serialize() for AlternateSubst

This commit is contained in:
Behdad Esfahbod 2012-09-03 23:31:14 -04:00
parent 1f07e3382a
commit 2941683358
1 changed files with 33 additions and 0 deletions

View File

@ -485,6 +485,23 @@ struct AlternateSubstFormat1
return TRACE_RETURN (true);
}
inline bool serialize (hb_serialize_context_t *c,
const USHORT *glyphs,
unsigned int *alternate_len_list,
unsigned int num_glyphs,
const USHORT *alternate_glyphs_list)
{
TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
if (unlikely (!alternateSet.serialize (c, num_glyphs))) return TRACE_RETURN (false);
for (unsigned int i = 0; i < num_glyphs; i++) {
if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, alternate_glyphs_list, alternate_len_list[i]))) return TRACE_RETURN (false);
alternate_glyphs_list += alternate_len_list[i];
}
return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
return TRACE_RETURN (coverage.sanitize (c, this) && alternateSet.sanitize (c, this));
@ -534,6 +551,22 @@ struct AlternateSubst
}
}
inline bool serialize (hb_serialize_context_t *c,
const USHORT *glyphs,
unsigned int *alternate_len_list,
unsigned int num_glyphs,
const USHORT *alternate_glyphs_list)
{
TRACE_SERIALIZE ();
if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false);
unsigned int format = 1;
u.format.set (format);
switch (u.format) {
case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_list, num_glyphs, alternate_glyphs_list));
default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
if (!u.format.sanitize (c)) return TRACE_RETURN (false);