Add a reverse () call to hb_array_t.

This commit is contained in:
Garret Rieger 2020-02-25 17:39:59 -08:00
parent 38c6598c1c
commit 50129b03a1
2 changed files with 30 additions and 11 deletions

View File

@ -171,6 +171,21 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, 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)

View File

@ -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,