From 52110f13b02678c24daa3c1b588683a8fb13e125 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 1 Jan 2023 16:22:02 -0700 Subject: [PATCH] [subset-input] Refactor copy-pasta code --- src/hb-subset-input.cc | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 7154b12e2..5752b2297 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -482,37 +482,26 @@ hb_subset_preprocess (hb_face_t *source) if (!input) return hb_face_reference (source); - hb_set_clear (hb_subset_input_set(input, HB_SUBSET_SETS_UNICODE)); - hb_set_invert (hb_subset_input_set(input, HB_SUBSET_SETS_UNICODE)); + const hb_subset_sets_t indices[] = {HB_SUBSET_SETS_UNICODE, + HB_SUBSET_SETS_GLYPH_INDEX, + HB_SUBSET_SETS_NAME_ID, + HB_SUBSET_SETS_NAME_LANG_ID, + HB_SUBSET_SETS_LAYOUT_FEATURE_TAG, + HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG}; - hb_set_clear (hb_subset_input_set(input, HB_SUBSET_SETS_GLYPH_INDEX)); - hb_set_invert (hb_subset_input_set(input, HB_SUBSET_SETS_GLYPH_INDEX)); - - hb_set_clear (hb_subset_input_set(input, - HB_SUBSET_SETS_LAYOUT_FEATURE_TAG)); - hb_set_invert (hb_subset_input_set(input, - HB_SUBSET_SETS_LAYOUT_FEATURE_TAG)); - - hb_set_clear (hb_subset_input_set(input, - HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG)); - hb_set_invert (hb_subset_input_set(input, - HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG)); - - hb_set_clear (hb_subset_input_set(input, - HB_SUBSET_SETS_NAME_ID)); - hb_set_invert (hb_subset_input_set(input, - HB_SUBSET_SETS_NAME_ID)); - - hb_set_clear (hb_subset_input_set(input, - HB_SUBSET_SETS_NAME_LANG_ID)); - hb_set_invert (hb_subset_input_set(input, - HB_SUBSET_SETS_NAME_LANG_ID)); + for (auto idx : hb_iter (indices)) + { + hb_set_t *set = hb_subset_input_set (input, idx); + hb_set_clear (set); + hb_set_invert (set); + } hb_subset_input_set_flags(input, HB_SUBSET_FLAGS_NOTDEF_OUTLINE | HB_SUBSET_FLAGS_GLYPH_NAMES | HB_SUBSET_FLAGS_RETAIN_GIDS | HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES); + input->attach_accelerator_data = true; // Always use long loca in the preprocessed version. This allows