[subset] add --no-layout-closure flag.

Disables layout glyph closure. Fixes #4192.
This commit is contained in:
Garret Rieger 2023-04-14 20:44:15 +00:00 committed by Behdad Esfahbod
parent 9c258936e7
commit 14b9d8d534
11 changed files with 30 additions and 3 deletions

View File

@ -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);

View File

@ -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;
/**

View File

@ -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 \

View File

@ -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 \

View File

@ -0,0 +1,2 @@
--no-layout-closure
--gids=74,77,446

View File

@ -0,0 +1,8 @@
FONTS:
Roboto-Regular.ttf
PROFILES:
no-layout-closure-gids.txt
SUBSETS:
no-unicodes

View File

@ -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)])

View File

@ -34,6 +34,7 @@ tests = [
'layout.duplicate_features',
'layout.unsorted_featurelist',
'layout.drop_feature',
'no_layout_closure',
'cmap',
'cmap14',
'sbix',

View File

@ -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,

View File

@ -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<HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG>, "Set the overlaps flag on each glyph.", nullptr},
{"notdef-outline", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag<HB_SUBSET_FLAGS_NOTDEF_OUTLINE>, "Keep the outline of \'.notdef\' glyph", nullptr},
{"no-prune-unicode-ranges", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag<HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES>, "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<HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE>, "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<HB_SUBSET_FLAGS_GLYPH_NAMES>, "Keep PS glyph names in TT-flavored fonts. ", nullptr},
{"passthrough-tables", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag<HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED>, "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,