diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index 8e98f87f4..66ad5a5c5 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -172,6 +172,7 @@ struct OS2 TRACE_SUBSET (this); OS2 *os2_prime = c->serializer->embed (this); if (unlikely (!os2_prime)) return_trace (false); + if (!c->plan->prune_unicode_ranges) return_trace (true); hb_set_t unicodes; if (!c->plan->glyphs_requested->is_empty ()) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 50cbb2f36..88ff5ef94 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -56,6 +56,7 @@ hb_subset_input_create_or_fail () input->name_legacy = false; input->overlaps_flag = false; input->notdef_outline = false; + input->no_prune_unicode_ranges = false; input->retain_all_layout_features = false; hb_tag_t default_drop_tables[] = { @@ -364,3 +365,16 @@ hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input) return subset_input->notdef_outline; } +HB_EXTERN void +hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input, + hb_bool_t no_prune_unicode_ranges) +{ + subset_input->no_prune_unicode_ranges = no_prune_unicode_ranges; +} + +HB_EXTERN hb_bool_t +hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input) +{ + return subset_input->no_prune_unicode_ranges; +} + diff --git a/src/hb-subset-input.hh b/src/hb-subset-input.hh index f48ce0fe7..40bf9a38a 100644 --- a/src/hb-subset-input.hh +++ b/src/hb-subset-input.hh @@ -52,6 +52,7 @@ struct hb_subset_input_t hb_bool_t name_legacy; hb_bool_t overlaps_flag; hb_bool_t notdef_outline; + hb_bool_t no_prune_unicode_ranges; hb_bool_t retain_all_layout_features; /* TODO * diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index f5aaaafc2..195378d0e 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -403,6 +403,7 @@ hb_subset_plan_create (hb_face_t *face, plan->name_legacy = input->name_legacy; plan->overlaps_flag = input->overlaps_flag; 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->unicodes = hb_set_create (); plan->name_ids = hb_set_reference (input->name_ids); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 5df9e76e6..01117f4b0 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -46,6 +46,7 @@ struct hb_subset_plan_t bool name_legacy : 1; bool overlaps_flag : 1; bool notdef_outline : 1; + bool prune_unicode_ranges : 1; bool retain_all_layout_features : 1; // For each cp that we'd like to retain maps to the corresponding gid. diff --git a/src/hb-subset.h b/src/hb-subset.h index b604c48b5..249540f02 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -110,6 +110,13 @@ hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input, HB_EXTERN hb_bool_t hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input); +HB_EXTERN void +hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input, + hb_bool_t no_prune_unicode_ranges); + +HB_EXTERN hb_bool_t +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); diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,62,63.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,62,63.ttf new file mode 100644 index 000000000..b57dfc824 Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,62,63.ttf differ diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,63.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,63.ttf new file mode 100644 index 000000000..001e8378c Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61,63.ttf differ diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61.ttf new file mode 100644 index 000000000..4ef564582 Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.61.ttf differ diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.62.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.62.ttf new file mode 100644 index 000000000..1864c034b Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.62.ttf differ diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.63.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.63.ttf new file mode 100644 index 000000000..90917545e Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.63.ttf differ diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.retain-all-codepoint.ttf new file mode 100644 index 000000000..92a8c8582 Binary files /dev/null and b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.retain-all-codepoint.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,62,63.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,62,63.ttf new file mode 100644 index 000000000..9b0a9e411 Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,62,63.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,63.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,63.ttf new file mode 100644 index 000000000..432b3b20f Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61,63.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61.ttf new file mode 100644 index 000000000..d2402b475 Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.61.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.62.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.62.ttf new file mode 100644 index 000000000..907e8f76f Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.62.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.63.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.63.ttf new file mode 100644 index 000000000..741520c3a Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.63.ttf differ diff --git a/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.retain-all-codepoint.ttf b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.retain-all-codepoint.ttf new file mode 100644 index 000000000..9744bc31d Binary files /dev/null and b/test/subset/data/expected/basics/NanumMyeongjo-Regular-subset.no-prune-unicode-ranges.retain-all-codepoint.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,62,63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,62,63.ttf new file mode 100644 index 000000000..712674fa2 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,62,63.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,63.ttf new file mode 100644 index 000000000..f4b4a0852 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61,63.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61.ttf new file mode 100644 index 000000000..691ce2e24 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.61.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.62.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.62.ttf new file mode 100644 index 000000000..97913a4a5 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.62.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.63.ttf new file mode 100644 index 000000000..085db0235 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.63.ttf differ diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.retain-all-codepoint.ttf new file mode 100644 index 000000000..712674fa2 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.no-prune-unicode-ranges.retain-all-codepoint.ttf differ diff --git a/test/subset/data/profiles/no-prune-unicode-ranges.txt b/test/subset/data/profiles/no-prune-unicode-ranges.txt new file mode 100644 index 000000000..4d6872a43 --- /dev/null +++ b/test/subset/data/profiles/no-prune-unicode-ranges.txt @@ -0,0 +1 @@ +--no-prune-unicode-ranges diff --git a/test/subset/data/tests/basics.tests b/test/subset/data/tests/basics.tests index 79a784c03..2e86e218f 100644 --- a/test/subset/data/tests/basics.tests +++ b/test/subset/data/tests/basics.tests @@ -15,6 +15,7 @@ name-legacy.txt gids.txt layout-features.txt keep-all-layout-features.txt +no-prune-unicode-ranges.txt SUBSETS: abc diff --git a/util/options-subset.cc b/util/options-subset.cc index 36516aee8..2b0314aac 100644 --- a/util/options-subset.cc +++ b/util/options-subset.cc @@ -311,6 +311,7 @@ subset_options_t::add_options (option_parser_t *parser) {"set-overlaps-flag", 0, 0, G_OPTION_ARG_NONE, &this->input->overlaps_flag, "Set the overlaps flag on each glyph.", nullptr}, {"notdef-outline", 0, 0, G_OPTION_ARG_NONE, &this->input->notdef_outline, "Keep the outline of \'.notdef\' glyph", nullptr}, + {"no-prune-unicode-ranges", 0, 0, G_OPTION_ARG_NONE, &this->input->no_prune_unicode_ranges, "Don't change the 'OS/2 ulUnicodeRange*' bits.", nullptr}, {nullptr} }; parser->add_group (entries,