mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 23:41:03 +01:00
[instancer] add merge_tuple_variations ()
This commit is contained in:
1 parent
fea47dd3f2
commit
389446c563
2 files changed
+45
No files matched your search
@@ -646,6 +646,33 @@ struct TupleVariationData
|
||||
tuple_vars = std::move (new_vars);
|
||||
}
|
||||
}
|
||||
|
||||
/* merge tuple variations with overlapping tents */
|
||||
void merge_tuple_variations ()
|
||||
{
|
||||
hb_vector_t<tuple_delta_t> new_vars;
|
||||
hb_hashmap_t<hb_hashmap_t<hb_tag_t, Triple>, unsigned> m;
|
||||
unsigned i = 0;
|
||||
for (const tuple_delta_t& var : tuple_vars)
|
||||
{
|
||||
/* if all axes are pinned, drop the tuple variation */
|
||||
if (var.axis_tuples.is_empty ()) continue;
|
||||
|
||||
unsigned *idx;
|
||||
if (m.has (var.axis_tuples, &idx))
|
||||
{
|
||||
new_vars[*idx] += var;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_vars.push (var);
|
||||
m.set (var.axis_tuples, i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
tuple_vars.fini ();
|
||||
tuple_vars = std::move (new_vars);
|
||||
}
|
||||
};
|
||||
|
||||
struct tuple_iterator_t
|
||||
|
||||
@@ -42,12 +42,30 @@ struct Triple {
|
||||
maximum == o.maximum;
|
||||
}
|
||||
|
||||
bool operator != (const Triple o) const
|
||||
{ return !(*this == o); }
|
||||
|
||||
bool is_point () const
|
||||
{ return minimum == middle && middle == maximum; }
|
||||
|
||||
bool contains (float point) const
|
||||
{ return minimum <= point && point <= maximum; }
|
||||
|
||||
/* from hb_array_t hash ()*/
|
||||
uint32_t hash () const
|
||||
{
|
||||
uint32_t current = /*cbf29ce4*/0x84222325;
|
||||
current = current ^ hb_hash (minimum);
|
||||
current = current * 16777619;
|
||||
|
||||
current = current ^ hb_hash (middle);
|
||||
current = current * 16777619;
|
||||
|
||||
current = current ^ hb_hash (maximum);
|
||||
current = current * 16777619;
|
||||
return current;
|
||||
}
|
||||
|
||||
float minimum;
|
||||
float middle;
|
||||
float maximum;
|
||||
|
||||
Reference in new issue
Block a user