[subset] add subset plan reference, set/get user data functions.

This commit is contained in:
Garret Rieger 2022-02-11 14:54:23 -08:00
parent b65e48a786
commit ae8d373bcf
4 changed files with 81 additions and 6 deletions

View File

@ -641,3 +641,62 @@ hb_subset_plan_codepoint_to_old_glyph_mapping (const hb_subset_plan_t *plan)
{
return plan->codepoint_to_glyph;
}
/**
* hb_subset_plan_reference: (skip)
* @plan: a #hb_subset_plan_t object.
*
* Increases the reference count on @plan.
*
* Return value: @plan.
*
* Since: REPLACEME
**/
hb_subset_plan_t *
hb_subset_plan_reference (hb_subset_plan_t *plan)
{
return hb_object_reference (plan);
}
/**
* hb_subset_plan_set_user_data: (skip)
* @plan: a #hb_subset_plan_t object.
* @key: The user-data key to set
* @data: A pointer to the user data
* @destroy: (nullable): A callback to call when @data is not needed anymore
* @replace: Whether to replace an existing data with the same key
*
* Attaches a user-data key/data pair to the given subset plan object.
*
* Return value: %true if success, %false otherwise
*
* Since: REPLACEME
**/
hb_bool_t
hb_subset_plan_set_user_data (hb_subset_plan_t *plan,
hb_user_data_key_t *key,
void *data,
hb_destroy_func_t destroy,
hb_bool_t replace)
{
return hb_object_set_user_data (plan, key, data, destroy, replace);
}
/**
* hb_subset_plan_get_user_data: (skip)
* @plan: a #hb_subset_plan_t object.
* @key: The user-data key to query
*
* Fetches the user data associated with the specified key,
* attached to the specified subset plan object.
*
* Return value: (transfer none): A pointer to the user data
*
* Since: REPLACEME
**/
void *
hb_subset_plan_get_user_data (const hb_subset_plan_t *plan,
hb_user_data_key_t *key)
{
return hb_object_get_user_data (plan, key);
}

View File

@ -349,7 +349,7 @@ hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input)
return nullptr;
}
hb_face_t * result = hb_subset_from_plan_or_fail (plan);
hb_face_t * result = hb_subset_plan_execute_or_fail (plan);
hb_subset_plan_destroy (plan);
return result;
}
@ -365,7 +365,7 @@ hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input)
* Since: REPLACEME
**/
hb_face_t *
hb_subset_from_plan_or_fail (hb_subset_plan_t *plan)
hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan)
{
if (unlikely (plan->in_error ())) {
return nullptr;

View File

@ -155,7 +155,7 @@ HB_EXTERN hb_face_t *
hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input);
HB_EXTERN hb_face_t *
hb_subset_from_plan_or_fail (hb_subset_plan_t *plan);
hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan);
HB_EXTERN hb_subset_plan_t *
hb_subset_plan_create (hb_face_t *face,
@ -173,6 +173,22 @@ hb_subset_plan_new_to_old_glyph_mapping (const hb_subset_plan_t *plan);
HB_EXTERN const hb_map_t*
hb_subset_plan_codepoint_to_old_glyph_mapping (const hb_subset_plan_t *plan);
HB_EXTERN hb_subset_plan_t *
hb_subset_plan_reference (hb_subset_plan_t *plan);
HB_EXTERN hb_bool_t
hb_subset_plan_set_user_data (hb_subset_plan_t *plan,
hb_user_data_key_t *key,
void *data,
hb_destroy_func_t destroy,
hb_bool_t replace);
HB_EXTERN void *
hb_subset_plan_get_user_data (const hb_subset_plan_t *plan,
hb_user_data_key_t *key);
HB_END_DECLS
#endif /* HB_SUBSET_H */

View File

@ -180,7 +180,7 @@ test_subset_plan (void)
mapping = hb_subset_plan_codepoint_to_old_glyph_mapping (plan);
g_assert (hb_map_get (mapping, 0x63) == 3);
hb_face_t* face_abc_subset = hb_subset_from_plan_or_fail (plan);
hb_face_t* face_abc_subset = hb_subset_plan_execute_or_fail (plan);
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('g','l','y','f'));