From edb57a8d9af6513c8d4ed5799bd208e4b9d68927 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 10:42:48 -0700 Subject: [PATCH 01/22] Make subset input const in the subsetting operation. Don't modify the subset input's sets. --- src/hb-subset-plan.cc | 19 +++++++++++++------ src/hb-subset-plan.hh | 2 +- src/hb-subset.cc | 2 +- src/hb-subset.h | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 84a3fbc5f..4d078b7e3 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -400,6 +400,13 @@ _nameid_closure (hb_face_t *face, #endif } +static hb_set_t* copy (const hb_set_t* other) +{ + hb_set_t* set = hb_set_create (); + set->set (other); + return set; +} + /** * hb_subset_plan_create: * Computes a plan for subsetting the supplied face according @@ -412,7 +419,7 @@ _nameid_closure (hb_face_t *face, **/ hb_subset_plan_t * hb_subset_plan_create (hb_face_t *face, - hb_subset_input_t *input) + const hb_subset_input_t *input) { hb_subset_plan_t *plan; if (unlikely (!(plan = hb_object_create ()))) @@ -428,12 +435,12 @@ hb_subset_plan_create (hb_face_t *face, plan->prune_unicode_ranges = !input->no_prune_unicode_ranges; plan->retain_all_layout_features = input->retain_all_layout_features; plan->unicodes = hb_set_create (); - plan->name_ids = hb_set_reference (input->name_ids); + plan->name_ids = copy (plan->name_ids); _nameid_closure (face, plan->name_ids); - plan->name_languages = hb_set_reference (input->name_languages); - plan->layout_features = hb_set_reference (input->layout_features); - plan->glyphs_requested = hb_set_reference (input->glyphs); - plan->drop_tables = hb_set_reference (input->drop_tables); + plan->name_languages = copy (input->name_languages); + plan->layout_features = copy (input->layout_features); + plan->glyphs_requested = copy (input->glyphs); + plan->drop_tables = copy (input->drop_tables); plan->source = hb_face_reference (face); plan->dest = hb_face_builder_create (); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 01117f4b0..6f832ee42 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -204,7 +204,7 @@ typedef struct hb_subset_plan_t hb_subset_plan_t; HB_INTERNAL hb_subset_plan_t * hb_subset_plan_create (hb_face_t *face, - hb_subset_input_t *input); + const hb_subset_input_t *input); HB_INTERNAL void hb_subset_plan_destroy (hb_subset_plan_t *plan); diff --git a/src/hb-subset.cc b/src/hb-subset.cc index d91699de4..1b8cc2967 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -303,7 +303,7 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) * Subsets a font according to provided input. **/ hb_face_t * -hb_subset (hb_face_t *source, hb_subset_input_t *input) +hb_subset (hb_face_t *source, const hb_subset_input_t *input) { if (unlikely (!input || !source)) return hb_face_get_empty (); diff --git a/src/hb-subset.h b/src/hb-subset.h index 249540f02..1df8cfbbf 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -119,7 +119,7 @@ hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input); /* hb_subset () */ HB_EXTERN hb_face_t * -hb_subset (hb_face_t *source, hb_subset_input_t *input); +hb_subset (hb_face_t *source, const hb_subset_input_t *input); HB_END_DECLS From b38e49dcfa8c8cf11b4586ce93784ce7523b5f48 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 10:57:58 -0700 Subject: [PATCH 02/22] [subset] add get/set user data methods to subset input. --- src/hb-subset-input.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ src/hb-subset.h | 10 ++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index f56d8a468..8917f87f0 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -378,3 +378,45 @@ hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input) return subset_input->no_prune_unicode_ranges; } +/** + * hb_subset_input_set_user_data: (skip) + * @face: A subset input 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 input object. + * + * Return value: %true if success, %false otherwise + * + * Since: REPLACE + **/ +hb_bool_t +hb_subset_input_set_user_data (hb_subset_input_t *input, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) +{ + return hb_object_set_user_data (input, key, data, destroy, replace); +} + +/** + * hb_subset_input_get_user_data: (skip) + * @face: A subset input object + * @key: The user-data key to query + * + * Fetches the user data associated with the specified key, + * attached to the specified subset input object. + * + * Return value: (transfer none): A pointer to the user data + * + * Since: REPLACE + **/ +void * +hb_subset_input_get_user_data (const hb_subset_input_t *input, + hb_user_data_key_t *key) +{ + return hb_object_get_user_data (input, key); +} diff --git a/src/hb-subset.h b/src/hb-subset.h index 1df8cfbbf..786dd1af5 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -121,6 +121,16 @@ hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input); HB_EXTERN hb_face_t * hb_subset (hb_face_t *source, const hb_subset_input_t *input); +HB_EXTERN hb_bool_t +hb_subset_input_set_user_data (hb_subset_input_t *input, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + +HB_EXTERN void * +hb_subset_input_get_user_data (const hb_subset_input_t *input, + hb_user_data_key_t *key); HB_END_DECLS From 83727837ef8818eec7c7c840117e7752c4bb487e Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 11:09:14 -0700 Subject: [PATCH 03/22] [subset] add proposed enum property get/set method. --- src/hb-subset-input.cc | 15 +++++++++++++++ src/hb-subset.h | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 8917f87f0..c81ee2bf5 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -276,6 +276,21 @@ hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input) return subset_input->drop_tables; } + +HB_EXTERN hb_bool_t +hb_subset_input_get_bool (hb_subset_property_t property) +{ + // TODO(garretrieger): implement. + return false; +} + +HB_EXTERN void +hb_subset_input_set_bool (hb_subset_property_t property, hb_bool_t value) +{ + // TODO(garretrieger): implement. +} + + HB_EXTERN void hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, hb_bool_t drop_hints) diff --git a/src/hb-subset.h b/src/hb-subset.h index 786dd1af5..b5bf4cc5d 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -39,6 +39,15 @@ HB_BEGIN_DECLS typedef struct hb_subset_input_t hb_subset_input_t; +enum hb_subset_property_t +{ + HB_SUBSET_PROPERTY_HINTING = 1, + HB_SUBSET_PROPERTY_RETAIN_GIDS = 2, + HB_SUBSET_PROPERTY_DESUBROUTINIZE = 3, + HB_SUBSET_PROPERTY_NAME_LEGACY = 4, + HB_SUBSET_PROPERTY_SET_OVERLAPS_FLAG = 5, +}; + HB_EXTERN hb_subset_input_t * hb_subset_input_create_or_fail (void); @@ -72,6 +81,15 @@ hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input); HB_EXTERN hb_set_t * hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input); + +HB_EXTERN hb_bool_t +hb_subset_input_get_bool (hb_subset_property_t property); + +HB_EXTERN void +hb_subset_input_set_bool (hb_subset_property_t property, hb_bool_t value); + +// TODO(garretrieger): remove bool property get/set methods. + HB_EXTERN void hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, hb_bool_t drop_hints); From 38de3491a08633175d7e40d9acabd48d813f755a Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 12:54:14 -0700 Subject: [PATCH 04/22] [subset] add implementation for get/set flag on subset input. --- src/hb-subset-input.cc | 61 +++++++++++++++++++++++++++++++++--------- src/hb-subset.h | 35 +++++++++++++----------- 2 files changed, 67 insertions(+), 29 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index c81ee2bf5..647621d54 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -258,7 +258,7 @@ hb_subset_input_layout_features_set (hb_subset_input_t *subset_input) HB_EXTERN void hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, - hb_bool_t value) + hb_bool_t value) { subset_input->retain_all_layout_features = value; } @@ -278,19 +278,54 @@ hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input) HB_EXTERN hb_bool_t -hb_subset_input_get_bool (hb_subset_property_t property) +hb_subset_input_get_flag (hb_subset_input_t *input, + hb_subset_flag_t flag) { - // TODO(garretrieger): implement. - return false; + switch (flag) + { + case HB_SUBSET_FLAG_HINTING: + return !input->drop_hints; + case HB_SUBSET_FLAG_RETAIN_GIDS: + return input->retain_gids; + case HB_SUBSET_FLAG_DESUBROUTINIZE: + return input->desubroutinize; + case HB_SUBSET_FLAG_NAME_LEGACY: + return input->name_legacy; + case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: + return input->overlaps_flag; + default: + return false; + } } HB_EXTERN void -hb_subset_input_set_bool (hb_subset_property_t property, hb_bool_t value) +hb_subset_input_set_flag (hb_subset_input_t *input, + hb_subset_flag_t flag, + hb_bool_t value) { - // TODO(garretrieger): implement. + switch (flag) + { + case HB_SUBSET_FLAG_HINTING: + input->drop_hints = !value; + break; + case HB_SUBSET_FLAG_RETAIN_GIDS: + input->retain_gids = value; + break; + case HB_SUBSET_FLAG_DESUBROUTINIZE: + input->desubroutinize = value; + break; + case HB_SUBSET_FLAG_NAME_LEGACY: + input->name_legacy = value; + break; + case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: + input->overlaps_flag = value; + break; + default: + // Do nothing. + break; + } } - HB_EXTERN void hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, hb_bool_t drop_hints) @@ -356,7 +391,7 @@ hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input) HB_EXTERN void hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, - hb_bool_t overlaps_flag) + hb_bool_t overlaps_flag) { subset_input->overlaps_flag = overlaps_flag; } @@ -409,10 +444,10 @@ hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input) **/ hb_bool_t hb_subset_input_set_user_data (hb_subset_input_t *input, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace) + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace) { return hb_object_set_user_data (input, key, data, destroy, replace); } @@ -431,7 +466,7 @@ hb_subset_input_set_user_data (hb_subset_input_t *input, **/ void * hb_subset_input_get_user_data (const hb_subset_input_t *input, - hb_user_data_key_t *key) + hb_user_data_key_t *key) { return hb_object_get_user_data (input, key); } diff --git a/src/hb-subset.h b/src/hb-subset.h index b5bf4cc5d..6be93d28d 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -39,14 +39,14 @@ HB_BEGIN_DECLS typedef struct hb_subset_input_t hb_subset_input_t; -enum hb_subset_property_t +typedef enum { - HB_SUBSET_PROPERTY_HINTING = 1, - HB_SUBSET_PROPERTY_RETAIN_GIDS = 2, - HB_SUBSET_PROPERTY_DESUBROUTINIZE = 3, - HB_SUBSET_PROPERTY_NAME_LEGACY = 4, - HB_SUBSET_PROPERTY_SET_OVERLAPS_FLAG = 5, -}; + HB_SUBSET_FLAG_HINTING = 1, + HB_SUBSET_FLAG_RETAIN_GIDS = 2, + HB_SUBSET_FLAG_DESUBROUTINIZE = 3, + HB_SUBSET_FLAG_NAME_LEGACY = 4, + HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, +} hb_subset_flag_t; HB_EXTERN hb_subset_input_t * hb_subset_input_create_or_fail (void); @@ -74,7 +74,7 @@ hb_subset_input_layout_features_set (hb_subset_input_t *subset_input); HB_EXTERN void hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, - hb_bool_t value); + hb_bool_t value); HB_EXTERN hb_bool_t hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input); @@ -83,10 +83,13 @@ hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input); HB_EXTERN hb_bool_t -hb_subset_input_get_bool (hb_subset_property_t property); +hb_subset_input_get_flag (hb_subset_input_t *input, + hb_subset_flag_t flag); HB_EXTERN void -hb_subset_input_set_bool (hb_subset_property_t property, hb_bool_t value); +hb_subset_input_set_flag (hb_subset_input_t *input, + hb_subset_flag_t flag, + hb_bool_t value); // TODO(garretrieger): remove bool property get/set methods. @@ -116,7 +119,7 @@ hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input); HB_EXTERN void hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, - hb_bool_t overlaps_flag); + hb_bool_t overlaps_flag); HB_EXTERN hb_bool_t hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input); @@ -141,14 +144,14 @@ hb_subset (hb_face_t *source, const hb_subset_input_t *input); HB_EXTERN hb_bool_t hb_subset_input_set_user_data (hb_subset_input_t *input, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); HB_EXTERN void * hb_subset_input_get_user_data (const hb_subset_input_t *input, - hb_user_data_key_t *key); + hb_user_data_key_t *key); HB_END_DECLS From 9fb3a2563333a0af1b67b2519f50cbc8278a8244 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 13:46:35 -0700 Subject: [PATCH 05/22] [subset] Use hb_set_copy in subset input. --- src/hb-subset-plan.cc | 65 +++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 4d078b7e3..b13ec2862 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -58,7 +58,7 @@ _add_cff_seac_components (const OT::cff1::accelerator_t &cff, static void _remap_palette_indexes (const hb_set_t *palette_indexes, - hb_map_t *mapping /* OUT */) + hb_map_t *mapping /* OUT */) { unsigned new_idx = 0; for (unsigned palette_index : palette_indexes->iter ()) @@ -87,12 +87,12 @@ _remap_indexes (const hb_set_t *indexes, #ifndef HB_NO_SUBSET_LAYOUT typedef void (*layout_collect_func_t) (hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, const hb_tag_t *languages, const hb_tag_t *features, hb_set_t *lookup_indexes /* OUT */); -static void _collect_subset_layout (hb_face_t *face, - hb_tag_t table_tag, - const hb_set_t *layout_features_to_retain, - bool retain_all_features, +static void _collect_subset_layout (hb_face_t *face, + hb_tag_t table_tag, + const hb_set_t *layout_features_to_retain, + bool retain_all_features, layout_collect_func_t layout_collect_func, - hb_set_t *lookup_indices /* OUT */) + hb_set_t *lookup_indices /* OUT */) { if (retain_all_features) { @@ -128,12 +128,12 @@ static void _collect_subset_layout (hb_face_t *face, template static inline void -_closure_glyphs_lookups_features (hb_face_t *face, - hb_set_t *gids_to_retain, +_closure_glyphs_lookups_features (hb_face_t *face, + hb_set_t *gids_to_retain, const hb_set_t *layout_features_to_retain, - bool retain_all_features, - hb_map_t *lookups, - hb_map_t *features, + bool retain_all_features, + hb_map_t *lookups, + hb_map_t *features, script_langsys_map *langsys_map) { hb_blob_ptr_t table = hb_sanitize_context_t ().reference_table (face); @@ -208,9 +208,9 @@ static inline void #endif static inline void -_cmap_closure (hb_face_t *face, - const hb_set_t *unicodes, - hb_set_t *glyphset) +_cmap_closure (hb_face_t *face, + const hb_set_t *unicodes, + hb_set_t *glyphset) { OT::cmap::accelerator_t cmap; cmap.init (face); @@ -341,10 +341,10 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, #ifndef HB_NO_VAR if (close_over_gdef) _collect_layout_variation_indices (plan->source, - plan->_glyphset_gsub, - plan->gpos_lookups, - plan->layout_variation_indices, - plan->layout_variation_idx_map); + plan->_glyphset_gsub, + plan->gpos_lookups, + plan->layout_variation_indices, + plan->layout_variation_idx_map); #endif #ifndef HB_NO_SUBSET_CFF @@ -355,11 +355,11 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, static void _create_old_gid_to_new_gid_map (const hb_face_t *face, - bool retain_gids, - const hb_set_t *all_gids_to_retain, - hb_map_t *glyph_map, /* OUT */ - hb_map_t *reverse_glyph_map, /* OUT */ - unsigned int *num_glyphs /* OUT */) + bool retain_gids, + const hb_set_t *all_gids_to_retain, + hb_map_t *glyph_map, /* OUT */ + hb_map_t *reverse_glyph_map, /* OUT */ + unsigned int *num_glyphs /* OUT */) { if (!retain_gids) { @@ -400,13 +400,6 @@ _nameid_closure (hb_face_t *face, #endif } -static hb_set_t* copy (const hb_set_t* other) -{ - hb_set_t* set = hb_set_create (); - set->set (other); - return set; -} - /** * hb_subset_plan_create: * Computes a plan for subsetting the supplied face according @@ -418,7 +411,7 @@ static hb_set_t* copy (const hb_set_t* other) * Since: 1.7.5 **/ hb_subset_plan_t * -hb_subset_plan_create (hb_face_t *face, +hb_subset_plan_create (hb_face_t *face, const hb_subset_input_t *input) { hb_subset_plan_t *plan; @@ -435,12 +428,12 @@ hb_subset_plan_create (hb_face_t *face, plan->prune_unicode_ranges = !input->no_prune_unicode_ranges; plan->retain_all_layout_features = input->retain_all_layout_features; plan->unicodes = hb_set_create (); - plan->name_ids = copy (plan->name_ids); + plan->name_ids = hb_set_copy (plan->name_ids); _nameid_closure (face, plan->name_ids); - plan->name_languages = copy (input->name_languages); - plan->layout_features = copy (input->layout_features); - plan->glyphs_requested = copy (input->glyphs); - plan->drop_tables = copy (input->drop_tables); + plan->name_languages = hb_set_copy (input->name_languages); + plan->layout_features = hb_set_copy (input->layout_features); + plan->glyphs_requested = hb_set_copy (input->glyphs); + plan->drop_tables = hb_set_copy (input->drop_tables); plan->source = hb_face_reference (face); plan->dest = hb_face_builder_create (); From 8bf5d4d4f787600e5e290bb8d59ee13f3a0d2515 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 14:05:17 -0700 Subject: [PATCH 06/22] [subset] Remove hb_subset_input_get/set_drop_hints. --- src/hb-subset-input.cc | 13 ------------- src/hb-subset-plan.cc | 2 +- src/hb-subset.h | 6 +----- test/api/test-subset-cff1.c | 10 +++++----- test/api/test-subset-cff2.c | 4 ++-- test/api/test-subset-glyf.c | 6 +++--- test/fuzzing/hb-subset-fuzzer.cc | 2 +- 7 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 647621d54..9907351de 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -326,19 +326,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, } } -HB_EXTERN void -hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, - hb_bool_t drop_hints) -{ - subset_input->drop_hints = drop_hints; -} - -HB_EXTERN hb_bool_t -hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input) -{ - return subset_input->drop_hints; -} - HB_EXTERN void hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, hb_bool_t desubroutinize) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index b13ec2862..1e3ea3d3d 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -428,7 +428,7 @@ hb_subset_plan_create (hb_face_t *face, plan->prune_unicode_ranges = !input->no_prune_unicode_ranges; plan->retain_all_layout_features = input->retain_all_layout_features; plan->unicodes = hb_set_create (); - plan->name_ids = hb_set_copy (plan->name_ids); + plan->name_ids = hb_set_copy (input->name_ids); _nameid_closure (face, plan->name_ids); plan->name_languages = hb_set_copy (input->name_languages); plan->layout_features = hb_set_copy (input->layout_features); diff --git a/src/hb-subset.h b/src/hb-subset.h index 6be93d28d..1c461d868 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -93,11 +93,7 @@ hb_subset_input_set_flag (hb_subset_input_t *input, // TODO(garretrieger): remove bool property get/set methods. -HB_EXTERN void -hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, - hb_bool_t drop_hints); -HB_EXTERN hb_bool_t -hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input); + HB_EXTERN void hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, diff --git a/test/api/test-subset-cff1.c b/test/api/test-subset-cff1.c index 8b4025d68..49ae97c4f 100644 --- a/test/api/test-subset-cff1.c +++ b/test/api/test-subset-cff1.c @@ -80,7 +80,7 @@ test_subset_cff1_strip_hints (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -126,7 +126,7 @@ test_subset_cff1_desubr_strip_hints (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); hb_subset_input_set_desubroutinize (input, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -170,7 +170,7 @@ test_subset_cff1_j_strip_hints (void) hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x4C2E); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); hb_set_destroy (codepoints); @@ -216,7 +216,7 @@ test_subset_cff1_j_desubr_strip_hints (void) hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x4C2E); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); hb_subset_input_set_desubroutinize (input, true); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); hb_set_destroy (codepoints); @@ -279,7 +279,7 @@ test_subset_cff1_dotsection (void) hb_face_t *face_test; hb_set_add (codepoints, 0x69); /* i */ input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_test = hb_subset_test_create_subset (face, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-cff2.c b/test/api/test-subset-cff2.c index 7ffcf5ea7..f7cba4fc3 100644 --- a/test/api/test-subset-cff2.c +++ b/test/api/test-subset-cff2.c @@ -80,7 +80,7 @@ test_subset_cff2_strip_hints (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -127,7 +127,7 @@ test_subset_cff2_desubr_strip_hints (void) hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); hb_subset_input_set_desubroutinize (input, true); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index 6be19e7c5..5f9f2507d 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -239,7 +239,7 @@ test_subset_glyf_strip_hints_simple (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -263,7 +263,7 @@ test_subset_glyf_strip_hints_composite (void) hb_face_t *face_generated_subset; hb_set_add (codepoints, 0x1fc); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_generated_subset = hb_subset_test_create_subset (face_components, input); hb_set_destroy (codepoints); @@ -298,7 +298,7 @@ test_subset_glyf_strip_hints_invalid (void) } input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_drop_hints (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); hb_set_destroy (codepoints); face_subset = hb_subset_test_create_subset (face, input); diff --git a/test/fuzzing/hb-subset-fuzzer.cc b/test/fuzzing/hb-subset-fuzzer.cc index f89d2f49b..e5a12c19d 100644 --- a/test/fuzzing/hb-subset-fuzzer.cc +++ b/test/fuzzing/hb-subset-fuzzer.cc @@ -17,7 +17,7 @@ trySubset (hb_face_t *face, { hb_subset_input_t *input = hb_subset_input_create_or_fail (); if (!input) return; - hb_subset_input_set_drop_hints (input, drop_hints); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, !drop_hints); hb_subset_input_set_retain_gids (input, retain_gids); hb_set_t *codepoints = hb_subset_input_unicode_set (input); From 77b4a1cd9634aafb6353b7d5e451d1f5a06e929b Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 14:11:17 -0700 Subject: [PATCH 07/22] [subset] Remove hb_subset_input_get/set_desubroutinize. --- src/hb-subset-input.cc | 13 ------------- src/hb-subset.h | 6 ------ test/api/test-subset-cff1.c | 8 ++++---- test/api/test-subset-cff2.c | 4 ++-- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 9907351de..c6fe54b2a 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -326,19 +326,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, } } -HB_EXTERN void -hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, - hb_bool_t desubroutinize) -{ - subset_input->desubroutinize = desubroutinize; -} - -HB_EXTERN hb_bool_t -hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input) -{ - return subset_input->desubroutinize; -} - /** * hb_subset_input_set_retain_gids: * @subset_input: a subset_input. diff --git a/src/hb-subset.h b/src/hb-subset.h index 1c461d868..31c69503f 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -95,12 +95,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, -HB_EXTERN void -hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, - hb_bool_t desubroutinize); -HB_EXTERN hb_bool_t -hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input); - HB_EXTERN void hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, hb_bool_t retain_gids); diff --git a/test/api/test-subset-cff1.c b/test/api/test-subset-cff1.c index 49ae97c4f..19f2ad6f6 100644 --- a/test/api/test-subset-cff1.c +++ b/test/api/test-subset-cff1.c @@ -103,7 +103,7 @@ test_subset_cff1_desubr (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -127,7 +127,7 @@ test_subset_cff1_desubr_strip_hints (void) hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -193,7 +193,7 @@ test_subset_cff1_j_desubr (void) hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x4C2E); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); hb_set_destroy (codepoints); @@ -217,7 +217,7 @@ test_subset_cff1_j_desubr_strip_hints (void) hb_set_add (codepoints, 0x4C2E); input = hb_subset_test_create_input (codepoints); hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-cff2.c b/test/api/test-subset-cff2.c index f7cba4fc3..72ebf0932 100644 --- a/test/api/test-subset-cff2.c +++ b/test/api/test-subset-cff2.c @@ -103,7 +103,7 @@ test_subset_cff2_desubr (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -126,7 +126,7 @@ test_subset_cff2_desubr_strip_hints (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_desubroutinize (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_DESUBROUTINIZE, true); hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); From 942636ae1300e56dfe599b5f961719f044bdf828 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 16:18:39 -0700 Subject: [PATCH 08/22] [subset] Remove hb_subset_input_get/set_retain_gids. --- src/hb-subset-input.cc | 24 ------------------------ src/hb-subset.h | 7 ------- test/api/test-subset-cff1.c | 4 ++-- test/api/test-subset-cff2.c | 2 +- test/api/test-subset-glyf.c | 4 ++-- test/api/test-subset-gvar.c | 2 +- test/api/test-subset-hvar.c | 4 ++-- test/api/test-subset-vvar.c | 2 +- test/fuzzing/hb-subset-fuzzer.cc | 2 +- 9 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index c6fe54b2a..cff0c0347 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -326,30 +326,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, } } -/** - * hb_subset_input_set_retain_gids: - * @subset_input: a subset_input. - * @retain_gids: If true the subsetter will not renumber glyph ids. - * Since: 2.4.0 - **/ -HB_EXTERN void -hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, - hb_bool_t retain_gids) -{ - subset_input->retain_gids = retain_gids; -} - -/** - * hb_subset_input_get_retain_gids: - * Returns: value of retain_gids. - * Since: 2.4.0 - **/ -HB_EXTERN hb_bool_t -hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input) -{ - return subset_input->retain_gids; -} - HB_EXTERN void hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, hb_bool_t name_legacy) diff --git a/src/hb-subset.h b/src/hb-subset.h index 31c69503f..0f918b19a 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -94,13 +94,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, // TODO(garretrieger): remove bool property get/set methods. - -HB_EXTERN void -hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, - hb_bool_t retain_gids); -HB_EXTERN hb_bool_t -hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input); - HB_EXTERN void hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, hb_bool_t name_legacy); diff --git a/test/api/test-subset-cff1.c b/test/api/test-subset-cff1.c index 19f2ad6f6..4f70f2d3b 100644 --- a/test/api/test-subset-cff1.c +++ b/test/api/test-subset-cff1.c @@ -302,7 +302,7 @@ test_subset_cff1_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -325,7 +325,7 @@ test_subset_cff1_j_retaingids (void) hb_set_add (codepoints, 0x41); hb_set_add (codepoints, 0x4C2E); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_41_3041_4c2e_subset = hb_subset_test_create_subset (face_41_3041_4c2e, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-cff2.c b/test/api/test-subset-cff2.c index 72ebf0932..835bdf3fc 100644 --- a/test/api/test-subset-cff2.c +++ b/test/api/test-subset-cff2.c @@ -150,7 +150,7 @@ test_subset_cff2_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index 5f9f2507d..73226437a 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -321,7 +321,7 @@ test_subset_glyf_retain_gids (void) hb_set_add (codepoints, 99); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -345,7 +345,7 @@ test_subset_glyf_retain_gids_truncates (void) hb_set_add (codepoints, 97); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-gvar.c b/test/api/test-subset-gvar.c index 991be8f83..fc5f7064c 100644 --- a/test/api/test-subset-gvar.c +++ b/test/api/test-subset-gvar.c @@ -79,7 +79,7 @@ test_subset_gvar_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-hvar.c b/test/api/test-subset-hvar.c index 2a6c2a977..847e61adc 100644 --- a/test/api/test-subset-hvar.c +++ b/test/api/test-subset-hvar.c @@ -79,7 +79,7 @@ test_subset_map_HVAR_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); @@ -160,7 +160,7 @@ test_subset_identity_HVAR_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/api/test-subset-vvar.c b/test/api/test-subset-vvar.c index 2b829a33f..6f4c9ade6 100644 --- a/test/api/test-subset-vvar.c +++ b/test/api/test-subset-vvar.c @@ -79,7 +79,7 @@ test_subset_VVAR_retaingids (void) hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'c'); hb_subset_input_t *input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_retain_gids (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, true); face_abc_subset = hb_subset_test_create_subset (face_abc, input); hb_set_destroy (codepoints); diff --git a/test/fuzzing/hb-subset-fuzzer.cc b/test/fuzzing/hb-subset-fuzzer.cc index e5a12c19d..692d18496 100644 --- a/test/fuzzing/hb-subset-fuzzer.cc +++ b/test/fuzzing/hb-subset-fuzzer.cc @@ -18,7 +18,7 @@ trySubset (hb_face_t *face, hb_subset_input_t *input = hb_subset_input_create_or_fail (); if (!input) return; hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, !drop_hints); - hb_subset_input_set_retain_gids (input, retain_gids); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_RETAIN_GIDS, retain_gids); hb_set_t *codepoints = hb_subset_input_unicode_set (input); if (!drop_layout) From 7d82191f61f79aba910d37aff74d45f4ca0d48e9 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 16:20:55 -0700 Subject: [PATCH 09/22] [subset] Remove hb_subset_input_get/set_name_legacy (). --- src/hb-subset-input.cc | 13 ------------- src/hb-subset.h | 6 ------ test/api/hb-subset-test.h | 2 +- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index cff0c0347..4c3b9c20b 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -326,19 +326,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, } } -HB_EXTERN void -hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, - hb_bool_t name_legacy) -{ - subset_input->name_legacy = name_legacy; -} - -HB_EXTERN hb_bool_t -hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input) -{ - return subset_input->name_legacy; -} - HB_EXTERN void hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, hb_bool_t overlaps_flag) diff --git a/src/hb-subset.h b/src/hb-subset.h index 0f918b19a..ec7281f74 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -94,12 +94,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, // TODO(garretrieger): remove bool property get/set methods. -HB_EXTERN void -hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, - hb_bool_t name_legacy); -HB_EXTERN hb_bool_t -hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input); - HB_EXTERN void hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, hb_bool_t overlaps_flag); diff --git a/test/api/hb-subset-test.h b/test/api/hb-subset-test.h index cdd41ed88..91968c3ad 100644 --- a/test/api/hb-subset-test.h +++ b/test/api/hb-subset-test.h @@ -75,7 +75,7 @@ hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids) hb_set_t *name_langids = hb_subset_input_namelangid_set (input); hb_set_add_range (name_langids, 0, 0x5FFF); - hb_subset_input_set_name_legacy (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_NAME_LEGACY, true); return input; } From aba2e13141c133091197adfcb1579de0a965a59d Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 16:23:35 -0700 Subject: [PATCH 10/22] [subset] Remove hb_subset_input_get/set_overlaps_flag (). --- src/hb-subset.h | 1 - test/api/test-subset-glyf.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hb-subset.h b/src/hb-subset.h index ec7281f74..8a895aec5 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -93,7 +93,6 @@ hb_subset_input_set_flag (hb_subset_input_t *input, // TODO(garretrieger): remove bool property get/set methods. - HB_EXTERN void hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, hb_bool_t overlaps_flag); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index 73226437a..3bad4fcf8 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -92,7 +92,7 @@ test_subset_glyf_set_overlaps_flag (void) hb_set_add (codepoints, 508); hb_subset_input_t* input = hb_subset_test_create_input (codepoints); - hb_subset_input_set_overlaps_flag (input, true); + hb_subset_input_set_flag (input, HB_SUBSET_FLAG_SET_OVERLAPS_FLAG, true); face_abcAE_subset = hb_subset_test_create_subset (face_abcAE, input); hb_set_destroy (codepoints); From 668f2bd93e3ea72e43e57ce10981d300f39a1967 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 16:33:50 -0700 Subject: [PATCH 11/22] [subset] Add hb_subset_or_fail () to public subset api. --- src/hb-subset.cc | 22 ++++++++++++++++++++-- src/hb-subset.h | 3 +++ util/hb-subset.cc | 10 ++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 1b8cc2967..74085a571 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -304,13 +304,31 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) **/ hb_face_t * hb_subset (hb_face_t *source, const hb_subset_input_t *input) +{ + hb_face_t* result = hb_subset_or_fail (source, input); + if (unlikely (!result)) return hb_face_get_empty (); + return result; +} + +/** + * hb_subset_or_fail: + * @source: font face data to be subset. + * @input: input to use for the subsetting. + * + * Subsets a font according to provided input. Returns nullptr + * if the subset operation fails. + * + * Since: REPLACE + **/ +hb_face_t * +hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input) { if (unlikely (!input || !source)) return hb_face_get_empty (); hb_subset_plan_t *plan = hb_subset_plan_create (source, input); if (unlikely (plan->in_error ())) { hb_subset_plan_destroy (plan); - return hb_face_get_empty (); + return nullptr; } hb_set_t tags_set; @@ -331,7 +349,7 @@ hb_subset (hb_face_t *source, const hb_subset_input_t *input) } end: - hb_face_t *result = success ? hb_face_reference (plan->dest) : hb_face_get_empty (); + hb_face_t *result = success ? hb_face_reference (plan->dest) : nullptr; hb_subset_plan_destroy (plan); return result; diff --git a/src/hb-subset.h b/src/hb-subset.h index 8a895aec5..51378f606 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -118,6 +118,9 @@ hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input); HB_EXTERN hb_face_t * hb_subset (hb_face_t *source, const hb_subset_input_t *input); +HB_EXTERN hb_face_t * +hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input); + HB_EXTERN hb_bool_t hb_subset_input_set_user_data (hb_subset_input_t *input, hb_user_data_key_t *key, diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 4f9557869..ad196a9ab 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -101,16 +101,18 @@ struct subset_consumer_t hb_face_t *new_face = nullptr; for (unsigned i = 0; i < subset_options.num_iterations; i++) { hb_face_destroy (new_face); - new_face = hb_subset (face, input); + new_face = hb_subset_or_fail (face, input); } - hb_blob_t *result = hb_face_reference_blob (new_face); - failed = !hb_blob_get_length (result); + failed = !new_face; if (!failed) + { + hb_blob_t *result = hb_face_reference_blob (new_face); write_file (options.output_file, result); + hb_blob_destroy (result); + } hb_subset_input_destroy (input); - hb_blob_destroy (result); hb_face_destroy (new_face); hb_font_destroy (font); } From a6c6cda48608e988a7debc3c18597186e3b4e2ee Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 9 Jun 2021 17:46:47 -0700 Subject: [PATCH 12/22] [subset] Add no subset tables and passthrough unrecognized tables to the subset api. Matches fontTools options. --- src/hb-subset-input.cc | 29 ++++++++++++++++++++++++++++- src/hb-subset-input.hh | 3 +++ src/hb-subset-plan.cc | 2 ++ src/hb-subset-plan.hh | 4 ++++ src/hb-subset.cc | 22 ++++++++++++++++++---- src/hb-subset.h | 15 +++++++++------ 6 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 4c3b9c20b..70f77a28e 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -50,6 +50,7 @@ hb_subset_input_create_or_fail () hb_set_add (input->name_languages, 0x0409); input->layout_features = hb_set_create (); input->drop_tables = hb_set_create (); + input->no_subset_tables = hb_set_create (); input->drop_hints = false; input->desubroutinize = false; input->retain_gids = false; @@ -58,6 +59,7 @@ hb_subset_input_create_or_fail () input->notdef_outline = false; input->no_prune_unicode_ranges = false; input->retain_all_layout_features = false; + input->passthrough_unrecognized = false; hb_tag_t default_drop_tables[] = { // Layout disabled by default @@ -83,9 +85,24 @@ hb_subset_input_create_or_fail () HB_TAG ('S', 'i', 'l', 'f'), HB_TAG ('S', 'i', 'l', 'l'), }; - input->drop_tables->add_array (default_drop_tables, ARRAY_LENGTH (default_drop_tables)); + hb_tag_t default_no_subset_tables[] = { + HB_TAG ('a', 'v', 'a', 'r'), + HB_TAG ('f', 'v', 'a', 'r'), + HB_TAG ('g', 'a', 's', 'p'), + HB_TAG ('c', 'v', 't', ' '), + HB_TAG ('f', 'p', 'g', 'm'), + HB_TAG ('p', 'r', 'e', 'p'), + HB_TAG ('V', 'D', 'M', 'X'), + HB_TAG ('D', 'S', 'I', 'G'), + HB_TAG ('M', 'V', 'A', 'R'), + HB_TAG ('c', 'v', 'a', 'r'), + HB_TAG ('S', 'T', 'A', 'T'), + }; + input->no_subset_tables->add_array (default_no_subset_tables, + ARRAY_LENGTH (default_no_subset_tables)); + //copied from _layout_features_groups in fonttools hb_tag_t default_layout_features[] = { // default shaper @@ -276,6 +293,11 @@ hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input) return subset_input->drop_tables; } +HB_EXTERN hb_set_t * +hb_subset_input_no_subset_tables_set (hb_subset_input_t *subset_input) +{ + return subset_input->no_subset_tables; +} HB_EXTERN hb_bool_t hb_subset_input_get_flag (hb_subset_input_t *input, @@ -293,6 +315,8 @@ hb_subset_input_get_flag (hb_subset_input_t *input, return input->name_legacy; case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: return input->overlaps_flag; + case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: + return input->passthrough_unrecognized; default: return false; } @@ -320,6 +344,9 @@ hb_subset_input_set_flag (hb_subset_input_t *input, case HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: input->overlaps_flag = value; break; + case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: + input->passthrough_unrecognized = value; + break; default: // Do nothing. break; diff --git a/src/hb-subset-input.hh b/src/hb-subset-input.hh index 40bf9a38a..6f76f999f 100644 --- a/src/hb-subset-input.hh +++ b/src/hb-subset-input.hh @@ -42,6 +42,7 @@ struct hb_subset_input_t hb_set_t *glyphs; hb_set_t *name_ids; hb_set_t *name_languages; + hb_set_t *no_subset_tables; hb_set_t *drop_tables; hb_set_t *layout_features; @@ -54,6 +55,8 @@ struct hb_subset_input_t hb_bool_t notdef_outline; hb_bool_t no_prune_unicode_ranges; hb_bool_t retain_all_layout_features; + hb_bool_t passthrough_unrecognized; + /* TODO * * features diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 1e3ea3d3d..59dc85071 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -427,6 +427,7 @@ hb_subset_plan_create (hb_face_t *face, plan->notdef_outline = input->notdef_outline; plan->prune_unicode_ranges = !input->no_prune_unicode_ranges; plan->retain_all_layout_features = input->retain_all_layout_features; + plan->passthrough_unrecognized = input->passthrough_unrecognized; plan->unicodes = hb_set_create (); plan->name_ids = hb_set_copy (input->name_ids); _nameid_closure (face, plan->name_ids); @@ -434,6 +435,7 @@ hb_subset_plan_create (hb_face_t *face, plan->layout_features = hb_set_copy (input->layout_features); plan->glyphs_requested = hb_set_copy (input->glyphs); plan->drop_tables = hb_set_copy (input->drop_tables); + plan->no_subset_tables = hb_set_copy (input->no_subset_tables); plan->source = hb_face_reference (face); plan->dest = hb_face_builder_create (); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 6f832ee42..cd449ba22 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -48,6 +48,7 @@ struct hb_subset_plan_t bool notdef_outline : 1; bool prune_unicode_ranges : 1; bool retain_all_layout_features : 1; + bool passthrough_unrecognized : 1; // For each cp that we'd like to retain maps to the corresponding gid. hb_set_t *unicodes; @@ -64,6 +65,9 @@ struct hb_subset_plan_t //glyph ids requested to retain hb_set_t *glyphs_requested; + // Tables which should not be processed, just pass them through. + hb_set_t *no_subset_tables; + // Tables which should be dropped. hb_set_t *drop_tables; diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 74085a571..c16bdeb9c 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -244,9 +244,22 @@ _should_drop_table (hb_subset_plan_t *plan, hb_tag_t tag) } } +static bool +_passthrough (hb_subset_plan_t *plan, hb_tag_t tag) +{ + hb_blob_t *source_table = hb_face_reference_table (plan->source, tag); + bool result = plan->add_table (tag, source_table); + hb_blob_destroy (source_table); + return result; +} + static bool _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) { + if (plan->no_subset_tables->has (tag)) { + return _passthrough (plan, tag); + } + DEBUG_MSG (SUBSET, nullptr, "subset %c%c%c%c", HB_UNTAG (tag)); switch (tag) { @@ -288,10 +301,11 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) #endif default: - hb_blob_t *source_table = hb_face_reference_table (plan->source, tag); - bool result = plan->add_table (tag, source_table); - hb_blob_destroy (source_table); - return result; + if (plan->passthrough_unrecognized) + return _passthrough (plan, tag); + + // Drop table + return true; } } diff --git a/src/hb-subset.h b/src/hb-subset.h index 51378f606..51df794fb 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -41,11 +41,12 @@ typedef struct hb_subset_input_t hb_subset_input_t; typedef enum { - HB_SUBSET_FLAG_HINTING = 1, - HB_SUBSET_FLAG_RETAIN_GIDS = 2, - HB_SUBSET_FLAG_DESUBROUTINIZE = 3, - HB_SUBSET_FLAG_NAME_LEGACY = 4, - HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, + HB_SUBSET_FLAG_HINTING = 1, + HB_SUBSET_FLAG_RETAIN_GIDS = 2, + HB_SUBSET_FLAG_DESUBROUTINIZE = 3, + HB_SUBSET_FLAG_NAME_LEGACY = 4, + HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, + HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED = 6, } hb_subset_flag_t; HB_EXTERN hb_subset_input_t * @@ -79,8 +80,10 @@ HB_EXTERN hb_bool_t hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input); HB_EXTERN hb_set_t * -hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input); +hb_subset_input_no_subset_tables_set (hb_subset_input_t *subset_input); +HB_EXTERN hb_set_t * +hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input); HB_EXTERN hb_bool_t hb_subset_input_get_flag (hb_subset_input_t *input, From 372722ceee3bb4d30df9edd78c5899dbd6bbd66c Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 23 Jun 2021 13:10:03 -0700 Subject: [PATCH 13/22] [subset] move notdef_outline to the subset input property enum. --- src/hb-subset-input.cc | 6 +++++- src/hb-subset.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 70f77a28e..121a6883e 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -101,7 +101,7 @@ hb_subset_input_create_or_fail () HB_TAG ('S', 'T', 'A', 'T'), }; input->no_subset_tables->add_array (default_no_subset_tables, - ARRAY_LENGTH (default_no_subset_tables)); + ARRAY_LENGTH (default_no_subset_tables)); //copied from _layout_features_groups in fonttools hb_tag_t default_layout_features[] = { @@ -317,6 +317,8 @@ hb_subset_input_get_flag (hb_subset_input_t *input, return input->overlaps_flag; case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: return input->passthrough_unrecognized; + case HB_SUBSET_FLAG_NOTDEF_OUTLINE: + return input->notdef_outline; default: return false; } @@ -347,6 +349,8 @@ hb_subset_input_set_flag (hb_subset_input_t *input, case HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: input->passthrough_unrecognized = value; break; + case HB_SUBSET_FLAG_NOTDEF_OUTLINE: + input->notdef_outline = value; default: // Do nothing. break; diff --git a/src/hb-subset.h b/src/hb-subset.h index 51df794fb..cdcc9bd2a 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -47,6 +47,7 @@ typedef enum HB_SUBSET_FLAG_NAME_LEGACY = 4, HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED = 6, + HB_SUBSET_FLAG_NOTDEF_OUTLINE = 7, } hb_subset_flag_t; HB_EXTERN hb_subset_input_t * From e5c887fc0fc5263c4c84b32c327f1334b3b0dffc Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 23 Jun 2021 13:19:25 -0700 Subject: [PATCH 14/22] [subset] add documentation for subset input flag enums. --- src/hb-subset.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/hb-subset.h b/src/hb-subset.h index cdcc9bd2a..be770e4a3 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -41,12 +41,32 @@ typedef struct hb_subset_input_t hb_subset_input_t; typedef enum { + // If set hinting instructions will be retained in the produced subset. + // Otherwise hinting instructions will be dropped. + // Defaults to true. HB_SUBSET_FLAG_HINTING = 1, + // If set glyph indices will not be modified in the produced subset. + // If glyphs are dropped their indices will be retained as an empty + // glyph. + // Defaults to false. HB_SUBSET_FLAG_RETAIN_GIDS = 2, + // If set and subsetting a CFF font the subsetter will attempt to + // remove subroutines from the CFF glyphs. + // Defaults to false. HB_SUBSET_FLAG_DESUBROUTINIZE = 3, + // If set non-unicode name records will be retained in the subset. + // Defaults to false. HB_SUBSET_FLAG_NAME_LEGACY = 4, + // If set the subsetter will set the OVERLAP_SIMPLE flag on each + // simple glyph. + // Defaults to false. HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, + // If set the subsetter will not drop unrecognized tables and instead + // pass them through untouched. + // Defaults to false. HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED = 6, + // If set the notdef glyph outline will be retained in the final subset. + // Defaults to false. HB_SUBSET_FLAG_NOTDEF_OUTLINE = 7, } hb_subset_flag_t; From 9ab751ac9ff139a7a1c286674f5560af386a7d23 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 23 Jun 2021 13:38:47 -0700 Subject: [PATCH 15/22] [subset] Remove hb_subset(). Leaving just hb_subset_or_fail(). --- src/hb-subset.cc | 15 --------------- src/hb-subset.h | 22 +++++++++++----------- test/api/hb-subset-test.h | 2 +- test/api/test-subset-drop-tables.c | 3 ++- test/api/test-subset-glyf.c | 7 +++---- test/api/test-subset-hdmx.c | 5 ++--- test/api/test-subset-hmtx.c | 5 ++--- test/api/test-subset.c | 12 +++++------- test/fuzzing/hb-subset-fuzzer.cc | 3 ++- 9 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index c16bdeb9c..dd6f16473 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -309,21 +309,6 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) } } -/** - * hb_subset: - * @source: font face data to be subset. - * @input: input to use for the subsetting. - * - * Subsets a font according to provided input. - **/ -hb_face_t * -hb_subset (hb_face_t *source, const hb_subset_input_t *input) -{ - hb_face_t* result = hb_subset_or_fail (source, input); - if (unlikely (!result)) return hb_face_get_empty (); - return result; -} - /** * hb_subset_or_fail: * @source: font face data to be subset. diff --git a/src/hb-subset.h b/src/hb-subset.h index be770e4a3..819045875 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -79,6 +79,17 @@ hb_subset_input_reference (hb_subset_input_t *subset_input); HB_EXTERN void hb_subset_input_destroy (hb_subset_input_t *subset_input); +HB_EXTERN hb_bool_t +hb_subset_input_set_user_data (hb_subset_input_t *input, + hb_user_data_key_t *key, + void * data, + hb_destroy_func_t destroy, + hb_bool_t replace); + +HB_EXTERN void * +hb_subset_input_get_user_data (const hb_subset_input_t *input, + hb_user_data_key_t *key); + HB_EXTERN hb_set_t * hb_subset_input_unicode_set (hb_subset_input_t *subset_input); @@ -145,17 +156,6 @@ hb_subset (hb_face_t *source, const hb_subset_input_t *input); HB_EXTERN hb_face_t * hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input); -HB_EXTERN hb_bool_t -hb_subset_input_set_user_data (hb_subset_input_t *input, - hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy, - hb_bool_t replace); - -HB_EXTERN void * -hb_subset_input_get_user_data (const hb_subset_input_t *input, - hb_user_data_key_t *key); - HB_END_DECLS #endif /* HB_SUBSET_H */ diff --git a/test/api/hb-subset-test.h b/test/api/hb-subset-test.h index 91968c3ad..1fc5a4828 100644 --- a/test/api/hb-subset-test.h +++ b/test/api/hb-subset-test.h @@ -83,7 +83,7 @@ static inline hb_face_t * hb_subset_test_create_subset (hb_face_t *source, hb_subset_input_t *input) { - hb_face_t *subset = hb_subset (source, input); + hb_face_t *subset = hb_subset_or_fail (source, input); g_assert (subset); hb_subset_input_destroy (input); diff --git a/test/api/test-subset-drop-tables.c b/test/api/test-subset-drop-tables.c index e23408008..b2c453a5a 100644 --- a/test/api/test-subset-drop-tables.c +++ b/test/api/test-subset-drop-tables.c @@ -42,7 +42,8 @@ test_subset_drop_tables (void) hb_set_add (hb_subset_input_drop_tables_set (input), HB_TAG ('h', 'm', 't', 'x')); hb_set_destroy (codepoints); - hb_face_t* subset = hb_subset (face, input); + hb_face_t* subset = hb_subset_or_fail (face, input); + g_assert (subset); hb_blob_t *hdmx = hb_face_reference_table (subset, HB_TAG ('h', 'd', 'm', 'x')); hb_blob_t *hmtx = hb_face_reference_table (subset, HB_TAG ('h', 'm', 't', 'x')); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index 3bad4fcf8..a6a6bbfc9 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -301,11 +301,10 @@ test_subset_glyf_strip_hints_invalid (void) hb_subset_input_set_flag (input, HB_SUBSET_FLAG_HINTING, false); hb_set_destroy (codepoints); - face_subset = hb_subset_test_create_subset (face, input); - g_assert (face_subset); - g_assert (face_subset == hb_face_get_empty ()); + face_subset = hb_subset_or_fail (face, input); + g_assert (!face_subset); - hb_face_destroy (face_subset); + hb_subset_input_destroy (input); hb_face_destroy (face); } diff --git a/test/api/test-subset-hdmx.c b/test/api/test-subset-hdmx.c index 7178833bc..c41a12114 100644 --- a/test/api/test-subset-hdmx.c +++ b/test/api/test-subset-hdmx.c @@ -82,9 +82,8 @@ test_subset_hdmx_invalid (void) hb_set_add (codepoints, 'b'); hb_set_add (codepoints, 'c'); - subset = hb_subset (face, input); - g_assert (subset); - g_assert (subset == hb_face_get_empty ()); + subset = hb_subset_or_fail (face, input); + g_assert (!subset); hb_subset_input_destroy (input); hb_face_destroy (subset); diff --git a/test/api/test-subset-hmtx.c b/test/api/test-subset-hmtx.c index 1b51dc2f8..28cca0084 100644 --- a/test/api/test-subset-hmtx.c +++ b/test/api/test-subset-hmtx.c @@ -162,9 +162,8 @@ test_subset_invalid_hmtx (void) hb_set_add (codepoints, 'b'); hb_set_add (codepoints, 'c'); - subset = hb_subset (face, input); - g_assert (subset); - g_assert (subset == hb_face_get_empty ()); + subset = hb_subset_or_fail (face, input); + g_assert (!subset); hb_subset_input_destroy (input); hb_face_destroy (subset); diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 85e4fdf1c..2c3560495 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -42,7 +42,7 @@ test_subset_32_tables (void) hb_set_add (codepoints, 'b'); hb_set_add (codepoints, 'c'); - subset = hb_subset (face, input); + subset = hb_subset_or_fail (face, input); g_assert (subset); g_assert (subset != hb_face_get_empty ()); @@ -64,9 +64,8 @@ test_subset_no_inf_loop (void) hb_set_add (codepoints, 'b'); hb_set_add (codepoints, 'c'); - subset = hb_subset (face, input); - g_assert (subset); - g_assert (subset == hb_face_get_empty ()); + subset = hb_subset_or_fail (face, input); + g_assert (!subset); hb_subset_input_destroy (input); hb_face_destroy (subset); @@ -86,9 +85,8 @@ test_subset_crash (void) hb_set_add (codepoints, 'b'); hb_set_add (codepoints, 'c'); - subset = hb_subset (face, input); - g_assert (subset); - g_assert (subset == hb_face_get_empty ()); + subset = hb_subset_or_fail (face, input); + g_assert (!subset); hb_subset_input_destroy (input); hb_face_destroy (subset); diff --git a/test/fuzzing/hb-subset-fuzzer.cc b/test/fuzzing/hb-subset-fuzzer.cc index 692d18496..c121301a6 100644 --- a/test/fuzzing/hb-subset-fuzzer.cc +++ b/test/fuzzing/hb-subset-fuzzer.cc @@ -31,7 +31,8 @@ trySubset (hb_face_t *face, for (int i = 0; i < text_length; i++) hb_set_add (codepoints, text[i]); - hb_face_t *result = hb_subset (face, input); + hb_face_t *result = hb_subset_or_fail (face, input); + if (result) { hb_blob_t *blob = hb_face_reference_blob (result); unsigned int length; From 8ce968341285be9dd5bf10a6bd5cf316995248cd Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 23 Jun 2021 13:55:11 -0700 Subject: [PATCH 16/22] [subset] add documentation for all hb-subset.h methods. --- src/hb-subset-input.cc | 71 ++++++++++++++++++++++++++++++++++++++++-- src/hb-subset.h | 59 +++++++++++++++++++---------------- 2 files changed, 100 insertions(+), 30 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 121a6883e..7a9b81d33 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -198,8 +198,6 @@ hb_subset_input_create_or_fail () * hb_subset_input_reference: (skip) * @subset_input: a subset_input. * - * - * * Return value: * * Since: 1.8.0 @@ -235,6 +233,8 @@ hb_subset_input_destroy (hb_subset_input_t *subset_input) * hb_subset_input_unicode_set: * @subset_input: a subset_input. * + * Return value: pointer to the set of unicode codepoints to retain. + * * Since: 1.8.0 **/ HB_EXTERN hb_set_t * @@ -247,6 +247,8 @@ hb_subset_input_unicode_set (hb_subset_input_t *subset_input) * hb_subset_input_glyph_set: * @subset_input: a subset_input. * + * Return value: pointer to the set of glyph ids to retain. + * * Since: 1.8.0 **/ HB_EXTERN hb_set_t * @@ -255,18 +257,43 @@ hb_subset_input_glyph_set (hb_subset_input_t *subset_input) return subset_input->glyphs; } +/** + * hb_subset_input_nameid_set: + * @subset_input: a subset_input. + * + * Return value: pointer to the set of name ids to retain. + * + * Since: REPLACE + **/ HB_EXTERN hb_set_t * hb_subset_input_nameid_set (hb_subset_input_t *subset_input) { return subset_input->name_ids; } +/** + * hb_subset_input_namelangid_set: + * @subset_input: a subset_input. + * + * Return value: pointer to the set of name language ids to retain. + * + * Since: REPLACE + **/ HB_EXTERN hb_set_t * hb_subset_input_namelangid_set (hb_subset_input_t *subset_input) { return subset_input->name_languages; } + +/** + * hb_subset_input_layout_features_set: + * @subset_input: a subset_input. + * + * Return value: pointer to the set of feature tags to retain. + * + * Since: REPLACE + **/ HB_EXTERN hb_set_t * hb_subset_input_layout_features_set (hb_subset_input_t *subset_input) { @@ -275,7 +302,7 @@ hb_subset_input_layout_features_set (hb_subset_input_t *subset_input) HB_EXTERN void hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, - hb_bool_t value) + hb_bool_t value) { subset_input->retain_all_layout_features = value; } @@ -287,18 +314,46 @@ hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input) } +/** + * hb_subset_input_drop_tabes_set: + * @subset_input: a subset_input. + * + * Return value: pointer to the set of table tags which specifies tables + * to be dropped. + * + * Since: REPLACE + **/ HB_EXTERN hb_set_t * hb_subset_input_drop_tables_set (hb_subset_input_t *subset_input) { return subset_input->drop_tables; } +/** + * hb_subset_input_no_subset_tabes_set: + * @subset_input: a subset_input. + * + * Return value: pointer to the set of table tags which specifies tables + * that should not have subsetting applied to them. + * + * Since: REPLACE + **/ HB_EXTERN hb_set_t * hb_subset_input_no_subset_tables_set (hb_subset_input_t *subset_input) { return subset_input->no_subset_tables; } + +/** + * hb_subset_input_get_flag: + * @subset_input: a subset_input. + * @flag: which flag to check. + * + * Return value: value of the specified flag. + * + * Since: REPLACE + **/ HB_EXTERN hb_bool_t hb_subset_input_get_flag (hb_subset_input_t *input, hb_subset_flag_t flag) @@ -324,6 +379,16 @@ hb_subset_input_get_flag (hb_subset_input_t *input, } } +/** + * hb_subset_input_set_flag: + * @subset_input: a subset_input. + * @flag: which flag to set. + * @value: new value for the flag. + * + * Set the specified flag to @value. + * + * Since: REPLACE + **/ HB_EXTERN void hb_subset_input_set_flag (hb_subset_input_t *input, hb_subset_flag_t flag, diff --git a/src/hb-subset.h b/src/hb-subset.h index 819045875..7fe4dcfd9 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -39,35 +39,40 @@ HB_BEGIN_DECLS typedef struct hb_subset_input_t hb_subset_input_t; +/** + * hb_subset_flag_t: + * @HB_SUBSET_FLAG_HINTING: If set hinting instructions will be retained in + * the produced subset. Otherwise hinting instructions will be dropped. + * Defaults to true. + * @HB_SUBSET_FLAG_RETAIN_GIDS: If set glyph indices will not be modified in + * the produced subset. If glyphs are dropped their indices will be retained + * as an empty glyph. Defaults to false. + * @HB_SUBSET_FLAG_DESUBROUTINIZE: If set and subsetting a CFF font the + * subsetter will attempt to remove subroutines from the CFF glyphs. + * Defaults to false. + * @HB_SUBSET_FLAG_NAME_LEGACY: If set non-unicode name records will be + * retained in the subset. Defaults to false. + * @HB_SUBSET_FLAG_SET_OVERLAPS_FLAG: If set the subsetter will set the + * OVERLAP_SIMPLE flag on each simple glyph. Defaults to false. + * @HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not + * drop unrecognized tables and instead pass them through untouched. + * Defaults to false. + * @HB_SUBSET_FLAG_NOTDEF_OUTLINE: If set the notdef glyph outline will be + * retained in the final subset. Defaults to false. + * + * List of boolean properties that can be configured on the subset input. + * + * Since: REPLACE + **/ typedef enum { - // If set hinting instructions will be retained in the produced subset. - // Otherwise hinting instructions will be dropped. - // Defaults to true. - HB_SUBSET_FLAG_HINTING = 1, - // If set glyph indices will not be modified in the produced subset. - // If glyphs are dropped their indices will be retained as an empty - // glyph. - // Defaults to false. - HB_SUBSET_FLAG_RETAIN_GIDS = 2, - // If set and subsetting a CFF font the subsetter will attempt to - // remove subroutines from the CFF glyphs. - // Defaults to false. - HB_SUBSET_FLAG_DESUBROUTINIZE = 3, - // If set non-unicode name records will be retained in the subset. - // Defaults to false. - HB_SUBSET_FLAG_NAME_LEGACY = 4, - // If set the subsetter will set the OVERLAP_SIMPLE flag on each - // simple glyph. - // Defaults to false. - HB_SUBSET_FLAG_SET_OVERLAPS_FLAG = 5, - // If set the subsetter will not drop unrecognized tables and instead - // pass them through untouched. - // Defaults to false. - HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED = 6, - // If set the notdef glyph outline will be retained in the final subset. - // Defaults to false. - HB_SUBSET_FLAG_NOTDEF_OUTLINE = 7, + HB_SUBSET_FLAG_HINTING = 0, + HB_SUBSET_FLAG_RETAIN_GIDS, + HB_SUBSET_FLAG_DESUBROUTINIZE, + HB_SUBSET_FLAG_NAME_LEGACY, + HB_SUBSET_FLAG_SET_OVERLAPS_FLAG, + HB_SUBSET_FLAG_PASSTHROUGH_UNRECOGNIZED, + HB_SUBSET_FLAG_NOTDEF_OUTLINE, } hb_subset_flag_t; HB_EXTERN hb_subset_input_t * From 1b6c1aa684df072a4212f9d350c78d9592f93413 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 28 Jun 2021 12:57:39 -0700 Subject: [PATCH 17/22] [subset] add hb-subset api to documentation generator. Standardize subset_input parameter to be input. --- docs/harfbuzz-docs.xml | 8 +++- docs/harfbuzz-sections.txt | 22 ++++++++++ src/hb-subset-input.cc | 84 +++++++++++++++++++------------------- src/hb-subset-plan.cc | 3 ++ src/hb-subset.h | 22 +++++----- 5 files changed, 85 insertions(+), 54 deletions(-) diff --git a/docs/harfbuzz-docs.xml b/docs/harfbuzz-docs.xml index db04c2fc7..4c9bcaa91 100644 --- a/docs/harfbuzz-docs.xml +++ b/docs/harfbuzz-docs.xml @@ -49,7 +49,7 @@ http://[SERVER]/libharfbuzz/.--> - + Reference manual Core API @@ -97,6 +97,12 @@ + + Subset API + + + +