diff --git a/src/hb-array.hh b/src/hb-array.hh index cbd6485ac..c9c6dee9c 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -171,6 +171,21 @@ struct hb_array_t : hb_iter_with_fallback_t, Type&> unsigned int get_size () const { return length * this->get_item_size (); } + void reverse () + { + int rhs = length - 1; + int lhs = 0; + while (rhs > lhs) + { + Type value_rhs = arrayZ[rhs]; + Type value_lhs = arrayZ[lhs]; + arrayZ[rhs] = value_lhs; + arrayZ[lhs] = value_rhs; + rhs--; + lhs++; + } + } + hb_array_t sub_array (unsigned int start_offset = 0, unsigned int *seg_count = nullptr /* IN/OUT */) const { if (!start_offset && !seg_count) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 4f862d9d7..7969aad05 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -850,6 +850,20 @@ struct VariationSelectorRecord return GLYPH_VARIANT_NOT_FOUND; } + VariationSelectorRecord(const VariationSelectorRecord& other) + { + *this = other; + } + + void operator= (const VariationSelectorRecord& other) + { + varSelector = other.varSelector; + HBUINT32 offset = other.defaultUVS; + defaultUVS = offset; + offset = other.nonDefaultUVS; + nonDefaultUVS = offset; + } + void collect_unicodes (hb_set_t *out, const void *base) const { (base+defaultUVS).collect_unicodes (out); @@ -992,17 +1006,7 @@ struct CmapSubtableFormat14 void _reverse_variation_records () { - int rhs = record.len - 1; - int lhs = 0; - while (rhs > lhs) - { - int value_rhs = record[rhs].varSelector; - int value_lhs = record[lhs].varSelector; - record[rhs].varSelector = value_lhs; - record[lhs].varSelector = value_rhs; - rhs--; - lhs++; - } + record.as_array ().reverse (); } void _add_links_to_variation_records (hb_serialize_context_t *c,