[subset-input] Simplify axes_location allocation

This commit is contained in:
Behdad Esfahbod 2023-01-11 13:21:57 -07:00
parent df721e0562
commit 5cab4a55d2
3 changed files with 6 additions and 10 deletions

View File

@ -48,12 +48,11 @@ hb_subset_input_create_or_fail (void)
for (auto& set : input->sets_iter ())
set = hb_set_create ();
input->axes_location = hb_hashmap_create<hb_tag_t, float> ();
#ifdef HB_EXPERIMENTAL_API
input->name_table_overrides = hb_hashmap_create<hb_ot_name_record_ids_t, hb_bytes_t> ();
#endif
if (!input->axes_location ||
if (
#ifdef HB_EXPERIMENTAL_API
!input->name_table_overrides ||
#endif
@ -253,8 +252,6 @@ hb_subset_input_destroy (hb_subset_input_t *input)
for (hb_set_t* set : input->sets_iter ())
hb_set_destroy (set);
hb_hashmap_destroy (input->axes_location);
#ifdef HB_EXPERIMENTAL_API
if (input->name_table_overrides)
{
@ -456,7 +453,7 @@ hb_subset_input_pin_axis_to_default (hb_subset_input_t *input,
if (!hb_ot_var_find_axis_info (face, axis_tag, &axis_info))
return false;
return input->axes_location->set (axis_tag, axis_info.default_value);
return input->axes_location.set (axis_tag, axis_info.default_value);
}
/**
@ -486,7 +483,7 @@ hb_subset_input_pin_axis_location (hb_subset_input_t *input,
return false;
float val = hb_clamp(axis_value, axis_info.min_value, axis_info.max_value);
return input->axes_location->set (axis_tag, val);
return input->axes_location.set (axis_tag, val);
}
#endif

View File

@ -106,7 +106,7 @@ struct hb_subset_input_t
// If set loca format will always be the long version.
bool force_long_loca = false;
hb_hashmap_t<hb_tag_t, float> *axes_location;
hb_hashmap_t<hb_tag_t, float> axes_location;
#ifdef HB_EXPERIMENTAL_API
hb_hashmap_t<hb_ot_name_record_ids_t, hb_bytes_t> *name_table_overrides;
#endif
@ -129,7 +129,7 @@ struct hb_subset_input_t
return true;
}
return axes_location->in_error ()
return axes_location.in_error ()
#ifdef HB_EXPERIMENTAL_API
|| name_table_overrides->in_error ()
#endif

View File

@ -857,8 +857,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
plan->gdef_varstore_inner_maps.init ();
if (input->axes_location)
plan->user_axes_location = *input->axes_location;
plan->user_axes_location = input->axes_location;
plan->all_axes_pinned = false;
plan->pinned_at_default = true;