mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 01:18:13 +00:00
[instancer] add serialize() for VarRegionList
The region list argument comes from item_variations_t.get_region_list()
This commit is contained in:
parent
b153af8553
commit
2326879229
3 changed files with 50 additions and 0 deletions
|
@ -2475,6 +2475,12 @@ struct VarRegionAxis
|
|||
* have to do that at runtime. */
|
||||
}
|
||||
|
||||
bool serialize (hb_serialize_context_t *c) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
return_trace (c->embed (this));
|
||||
}
|
||||
|
||||
public:
|
||||
F2DOT14 startCoord;
|
||||
F2DOT14 peakCoord;
|
||||
|
@ -2532,6 +2538,47 @@ struct VarRegionList
|
|||
return_trace (c->check_struct (this) && axesZ.sanitize (c, axisCount * regionCount));
|
||||
}
|
||||
|
||||
bool serialize (hb_serialize_context_t *c,
|
||||
const hb_vector_t<hb_tag_t>& axis_tags,
|
||||
const hb_vector_t<const hb_hashmap_t<hb_tag_t, Triple>*>& regions)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
unsigned axis_count = axis_tags.length;
|
||||
unsigned region_count = regions.length;
|
||||
if (!axis_count || !region_count) return_trace (false);
|
||||
if (unlikely (hb_unsigned_mul_overflows (axis_count * region_count,
|
||||
VarRegionAxis::static_size))) return_trace (false);
|
||||
if (unlikely (!c->extend_min (this))) return_trace (false);
|
||||
axisCount = axis_count;
|
||||
regionCount = region_count;
|
||||
|
||||
for (unsigned r = 0; r < region_count; r++)
|
||||
{
|
||||
const auto& region = regions[r];
|
||||
for (unsigned i = 0; i < axis_count; i++)
|
||||
{
|
||||
hb_tag_t tag = axis_tags.arrayZ[i];
|
||||
VarRegionAxis var_region_rec;
|
||||
Triple *coords;
|
||||
if (region->has (tag, &coords))
|
||||
{
|
||||
var_region_rec.startCoord.set_float (coords->minimum);
|
||||
var_region_rec.peakCoord.set_float (coords->middle);
|
||||
var_region_rec.endCoord.set_float (coords->maximum);
|
||||
}
|
||||
else
|
||||
{
|
||||
var_region_rec.startCoord.set_int (0);
|
||||
var_region_rec.peakCoord.set_int (0);
|
||||
var_region_rec.endCoord.set_int (0);
|
||||
}
|
||||
if (!var_region_rec.serialize (c))
|
||||
return_trace (false);
|
||||
}
|
||||
}
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
bool serialize (hb_serialize_context_t *c, const VarRegionList *src, const hb_inc_bimap_t ®ion_map)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
|
|
@ -113,6 +113,8 @@ HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_index_map)
|
|||
|
||||
//axis_index->axis_tag mapping in fvar axis array
|
||||
HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_old_index_tag_map)
|
||||
//vector of retained axis tags in the order of axes given in the 'fvar' table
|
||||
HB_SUBSET_PLAN_MEMBER (hb_vector_t<hb_tag_t>, axis_tags)
|
||||
|
||||
//hmtx metrics map: new gid->(advance, lsb)
|
||||
HB_SUBSET_PLAN_MEMBER (mutable hb_hashmap_t E(<hb_codepoint_t, hb_pair_t E(<unsigned, int>)>), hmtx_map)
|
||||
|
|
|
@ -927,6 +927,7 @@ _normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan)
|
|||
{
|
||||
axis_not_pinned = true;
|
||||
plan->axes_index_map.set (old_axis_idx, new_axis_idx);
|
||||
plan->axis_tags.push (axis_tag);
|
||||
new_axis_idx++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue