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,