diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index a30fa9d94..f1a3cc0ea 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -295,7 +295,7 @@ _closure_glyphs_lookups_features (hb_subset_plan_t *plan, feature_record_cond_idx_map, feature_substitutes_map); - if (table_tag == HB_OT_TAG_GSUB) + if (table_tag == HB_OT_TAG_GSUB && !(plan->flags & HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE)) hb_ot_layout_lookups_substitute_closure (plan->source, &lookup_indices, gids_to_retain); diff --git a/src/hb-subset.h b/src/hb-subset.h index c14b1b180..d64ea7b06 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -71,6 +71,8 @@ typedef struct hb_subset_plan_t hb_subset_plan_t; * in the final subset. * @HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in * OS/2 will not be recalculated. + * @HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE: If set don't perform glyph closure on layout + * tables (GSUB, GPOS, GDEF). * * List of boolean properties that can be configured on the subset input. * @@ -87,6 +89,7 @@ typedef enum { /*< flags >*/ HB_SUBSET_FLAGS_NOTDEF_OUTLINE = 0x00000040u, HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u, HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u, + HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE = 0x00000200u, } hb_subset_flags_t; /** diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am index db2bf7f44..980bddb07 100644 --- a/test/subset/data/Makefile.am +++ b/test/subset/data/Makefile.am @@ -44,6 +44,7 @@ EXTRA_DIST += \ expected/layout.duplicate_features \ expected/layout.unsorted_featurelist \ expected/layout.drop_feature \ + expected/no_layout_closure \ expected/cmap \ expected/cmap14 \ expected/sbix \ diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index d0662d928..919ec7391 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -43,6 +43,7 @@ TESTS = \ tests/layout.duplicate_features.tests \ tests/layout.unsorted_featurelist.tests \ tests/layout.drop_feature.tests \ + tests/no_layout_closure.tests \ tests/sbix.tests \ tests/variable.tests \ tests/glyph_names.tests \ diff --git a/test/subset/data/expected/no_layout_closure/Roboto-Regular.no-layout-closure-gids.no-unicodes.ttf b/test/subset/data/expected/no_layout_closure/Roboto-Regular.no-layout-closure-gids.no-unicodes.ttf new file mode 100644 index 000000000..73458aa7f Binary files /dev/null and b/test/subset/data/expected/no_layout_closure/Roboto-Regular.no-layout-closure-gids.no-unicodes.ttf differ diff --git a/test/subset/data/profiles/no-layout-closure-gids.txt b/test/subset/data/profiles/no-layout-closure-gids.txt new file mode 100644 index 000000000..ca56cf146 --- /dev/null +++ b/test/subset/data/profiles/no-layout-closure-gids.txt @@ -0,0 +1,2 @@ +--no-layout-closure +--gids=74,77,446 diff --git a/test/subset/data/tests/no_layout_closure.tests b/test/subset/data/tests/no_layout_closure.tests new file mode 100644 index 000000000..34628aa16 --- /dev/null +++ b/test/subset/data/tests/no_layout_closure.tests @@ -0,0 +1,8 @@ +FONTS: +Roboto-Regular.ttf + +PROFILES: +no-layout-closure-gids.txt + +SUBSETS: +no-unicodes diff --git a/test/subset/generate-expected-outputs.py b/test/subset/generate-expected-outputs.py index fd0800293..201fe4a78 100755 --- a/test/subset/generate-expected-outputs.py +++ b/test/subset/generate-expected-outputs.py @@ -47,8 +47,10 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags args.extend(["--drop-tables+=DSIG", "--drop-tables-=sbix", "--no-harfbuzz-repacker", # disable harfbuzz repacker so we aren't comparing to ourself. - "--unicodes=%s" % unicodes, "--output-file=%s" % fonttools_path]) + if unicodes != "": + args.extend(["--unicodes=%s" % unicodes,]) + args.extend(profile_flags) if not no_fonttools: check_call(args) @@ -63,9 +65,10 @@ def generate_expected_output(input_file, unicodes, profile_flags, instance_flags hb_subset, "--font-file=" + input_file, "--output-file=" + harfbuzz_path, - "--unicodes=%s" % unicodes, "--drop-tables+=DSIG", "--drop-tables-=sbix"] + if unicodes != "": + args.extend(["--unicodes=%s" % unicodes,]) args.extend(profile_flags) if instance_flags: args.extend(["--instance=%s" % ','.join(instance_flags)]) diff --git a/test/subset/meson.build b/test/subset/meson.build index 5c96982f9..45cd70ed0 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -34,6 +34,7 @@ tests = [ 'layout.duplicate_features', 'layout.unsorted_featurelist', 'layout.drop_feature', + 'no_layout_closure', 'cmap', 'cmap14', 'sbix', diff --git a/test/subset/subset_test_suite.py b/test/subset/subset_test_suite.py index 3329e3f5a..b755e4e6b 100644 --- a/test/subset/subset_test_suite.py +++ b/test/subset/subset_test_suite.py @@ -16,6 +16,8 @@ class Test: import re if self.subset == '*': return self.subset[0] + elif self.subset == "no-unicodes": + return "" elif re.match("^U\+", self.subset): s = re.sub (r"U\+", "", self.subset) return s @@ -49,6 +51,11 @@ class Test: profile_name, self.instance_name(), font_base_name_parts[1]) + elif self.unicodes() == "": + return "%s.%s.no-unicodes%s%s" % (font_base_name_parts[0], + profile_name, + self.instance_name(), + font_base_name_parts[1]) else: return "%s.%s.%s%s%s" % (font_base_name_parts[0], profile_name, diff --git a/util/hb-subset.cc b/util/hb-subset.cc index bc1df6bcf..1c2485d63 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -941,6 +941,7 @@ subset_main_t::add_options () {"set-overlaps-flag", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Set the overlaps flag on each glyph.", nullptr}, {"notdef-outline", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep the outline of \'.notdef\' glyph", nullptr}, {"no-prune-unicode-ranges", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Don't change the 'OS/2 ulUnicodeRange*' bits.", nullptr}, + {"no-layout-closure", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Don't perform glyph closure for layout tables (GSUB, GPOS, GDEF).", nullptr}, {"glyph-names", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Keep PS glyph names in TT-flavored fonts. ", nullptr}, {"passthrough-tables", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Do not drop tables that the tool does not know how to subset.", nullptr}, {"preprocess-face", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &this->preprocess,