[subset] In SinglePosFormat1 serialize only 1 value record.

Previously one record per glyph in the subset was serialized.
This commit is contained in:
Garret Rieger 2021-04-22 16:45:14 -07:00
parent 92757f6809
commit 5df7c668ba
1 changed files with 14 additions and 8 deletions

View File

@ -103,6 +103,8 @@ struct ValueFormat : HBUINT16
* PosTable (may be NULL) */ * PosTable (may be NULL) */
#endif #endif
IntType& operator = (uint16_t i) { v = i; return *this; }
unsigned int get_len () const { return hb_popcount ((unsigned int) *this); } unsigned int get_len () const { return hb_popcount ((unsigned int) *this); }
unsigned int get_size () const { return get_len () * Value::static_size; } unsigned int get_size () const { return get_len () * Value::static_size; }
@ -758,21 +760,25 @@ struct SinglePosFormat1
ValueFormat valFormat, ValueFormat valFormat,
const hb_map_t *layout_variation_idx_map) const hb_map_t *layout_variation_idx_map)
{ {
auto out = c->extend_min (*this); if (unlikely (!c->extend_min (*this))) return;
if (unlikely (!out)) return; if (unlikely (!c->check_assign (valueFormat,
if (unlikely (!c->check_assign (valueFormat, valFormat, HB_SERIALIZE_ERROR_INT_OVERFLOW))) return; valFormat,
HB_SERIALIZE_ERROR_INT_OVERFLOW))) return;
+ it for (const hb_array_t<const Value>& _ : + it | hb_map (hb_second))
| hb_map (hb_second) {
| hb_apply ([&] (hb_array_t<const Value> _) valFormat.serialize_copy (c, src, &_, layout_variation_idx_map);
{ valFormat.serialize_copy (c, src, &_, layout_variation_idx_map); }) // Only serialize the first entry in the iterator, the rest are assumed to
; // be the same.
break;
}
auto glyphs = auto glyphs =
+ it + it
| hb_map_retains_sorting (hb_first) | hb_map_retains_sorting (hb_first)
; ;
// TODO(garretrieger): serialize_subset this.
coverage.serialize (c, this).serialize (c, glyphs); coverage.serialize (c, this).serialize (c, glyphs);
} }