[subset] layout_features filtering fix

we should not use get_size (), which returns length * item_size
This commit is contained in:
Qunxin Liu 2021-11-15 19:58:33 -08:00 committed by Behdad Esfahbod
parent 3160789701
commit 903a6baece
12 changed files with 29 additions and 3 deletions

View File

@ -100,11 +100,23 @@ static void _collect_layout_indices (hb_face_t *face,
if (!features.alloc (table.get_feature_count () + 1)) if (!features.alloc (table.get_feature_count () + 1))
return; return;
hb_set_t visited_features;
bool retain_all_features = true;
for (unsigned i = 0; i < table.get_feature_count (); i++) for (unsigned i = 0; i < table.get_feature_count (); i++)
{ {
hb_tag_t tag = table.get_feature_tag (i); hb_tag_t tag = table.get_feature_tag (i);
if (tag && layout_features_to_retain->has (tag)) if (!tag) continue;
features.push (tag); if (!layout_features_to_retain->has (tag))
{
retain_all_features = false;
continue;
}
if (visited_features.has (tag))
continue;
features.push (tag);
visited_features.add (tag);
} }
if (!features) if (!features)
@ -113,7 +125,7 @@ static void _collect_layout_indices (hb_face_t *face,
// The collect function needs a null element to signal end of the array. // The collect function needs a null element to signal end of the array.
features.push (0); features.push (0);
if (features.get_size () == table.get_feature_count () + 1) if (retain_all_features)
{ {
// Looking for all features, trigger the faster collection method. // Looking for all features, trigger the faster collection method.
layout_collect_func (face, layout_collect_func (face,

View File

@ -38,6 +38,7 @@ EXTRA_DIST += \
expected/layout.gdef-attachlist \ expected/layout.gdef-attachlist \
expected/layout.notonastaliqurdu \ expected/layout.notonastaliqurdu \
expected/layout.tinos \ expected/layout.tinos \
expected/layout.default_features \
expected/layout.duplicate_features \ expected/layout.duplicate_features \
expected/layout.unsorted_featurelist \ expected/layout.unsorted_featurelist \
expected/layout.drop_feature \ expected/layout.drop_feature \

View File

@ -36,6 +36,7 @@ TESTS = \
tests/layout.notonastaliqurdu.tests \ tests/layout.notonastaliqurdu.tests \
tests/layout.tests \ tests/layout.tests \
tests/layout.tinos.tests \ tests/layout.tinos.tests \
tests/layout.default_features.tests \
tests/layout.duplicate_features.tests \ tests/layout.duplicate_features.tests \
tests/layout.unsorted_featurelist.tests \ tests/layout.unsorted_featurelist.tests \
tests/layout.drop_feature.tests \ tests/layout.drop_feature.tests \

Binary file not shown.

View File

@ -0,0 +1,11 @@
FONTS:
FranklinGothic-Regular.ttf
PROFILES:
layout-test.txt
default.txt
retain-gids.txt
SUBSETS:
achi
*

View File

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