[OT] Implement serialize() for MultiSubst
This commit is contained in:
parent
4912030dfb
commit
1f07e3382a
|
@ -676,6 +676,16 @@ struct GenericArrayOf
|
||||||
inline unsigned int get_size (void) const
|
inline unsigned int get_size (void) const
|
||||||
{ return len.static_size + len * Type::static_size; }
|
{ return len.static_size + len * Type::static_size; }
|
||||||
|
|
||||||
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
|
unsigned int items_len)
|
||||||
|
{
|
||||||
|
TRACE_SERIALIZE ();
|
||||||
|
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
||||||
|
len.set (items_len); /* TODO(serialize) Overflow? */
|
||||||
|
if (unlikely (!c->extend (*this))) return TRACE_RETURN (false);
|
||||||
|
return TRACE_RETURN (true);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool serialize (hb_serialize_context_t *c,
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
const Type *items,
|
const Type *items,
|
||||||
unsigned int items_len)
|
unsigned int items_len)
|
||||||
|
|
|
@ -276,6 +276,16 @@ struct Sequence
|
||||||
return TRACE_RETURN (true);
|
return TRACE_RETURN (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
|
const USHORT *glyphs,
|
||||||
|
unsigned int num_glyphs)
|
||||||
|
{
|
||||||
|
TRACE_SERIALIZE ();
|
||||||
|
if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false);
|
||||||
|
if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return TRACE_RETURN (false);
|
||||||
|
return TRACE_RETURN (true);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
|
@ -320,6 +330,23 @@ struct MultipleSubstFormat1
|
||||||
return TRACE_RETURN ((this+sequence[index]).apply (c));
|
return TRACE_RETURN ((this+sequence[index]).apply (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
|
const USHORT *glyphs,
|
||||||
|
unsigned int *substitute_len_list,
|
||||||
|
unsigned int num_glyphs,
|
||||||
|
const USHORT *substitute_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 (!sequence.serialize (c, num_glyphs))) return TRACE_RETURN (false);
|
||||||
|
for (unsigned int i = 0; i < num_glyphs; i++) {
|
||||||
|
if (unlikely (!sequence[i].serialize (c, this).serialize (c, substitute_glyphs_list, substitute_len_list[i]))) return TRACE_RETURN (false);
|
||||||
|
substitute_glyphs_list += substitute_len_list[i];
|
||||||
|
}
|
||||||
|
return TRACE_RETURN (true);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, this));
|
return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, this));
|
||||||
|
@ -369,6 +396,22 @@ struct MultipleSubst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
|
const USHORT *glyphs,
|
||||||
|
unsigned int *substitute_len_list,
|
||||||
|
unsigned int num_glyphs,
|
||||||
|
const USHORT *substitute_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, substitute_len_list, num_glyphs, substitute_glyphs_list));
|
||||||
|
default:return TRACE_RETURN (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
|
if (!u.format.sanitize (c)) return TRACE_RETURN (false);
|
||||||
|
|
Loading…
Reference in New Issue