[subset] fix find_duplicate_features
We should check each feature against all other features with the same tag for duplicates.
This commit is contained in:
parent
1afc3874e0
commit
8c5c81746d
|
@ -3678,55 +3678,57 @@ struct GSUBGPOS
|
||||||
const hb_set_t *feature_indices,
|
const hb_set_t *feature_indices,
|
||||||
hb_map_t *duplicate_feature_map /* OUT */) const
|
hb_map_t *duplicate_feature_map /* OUT */) const
|
||||||
{
|
{
|
||||||
|
hb_set_t unique_features;
|
||||||
|
hb_tag_t prev_t = get_feature_tag (feature_indices->get_min ());
|
||||||
//find out duplicate features after subset
|
//find out duplicate features after subset
|
||||||
unsigned prev = 0xFFFFu;
|
|
||||||
for (unsigned i : feature_indices->iter ())
|
for (unsigned i : feature_indices->iter ())
|
||||||
{
|
{
|
||||||
if (prev == 0xFFFFu)
|
|
||||||
{
|
|
||||||
duplicate_feature_map->set (i, i);
|
|
||||||
prev = i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_tag_t t = get_feature_tag (i);
|
hb_tag_t t = get_feature_tag (i);
|
||||||
hb_tag_t prev_t = get_feature_tag (prev);
|
|
||||||
if (t != prev_t)
|
if (t != prev_t)
|
||||||
{
|
{
|
||||||
|
prev_t = t;
|
||||||
|
unique_features.clear ();
|
||||||
|
unique_features.add (i);
|
||||||
duplicate_feature_map->set (i, i);
|
duplicate_feature_map->set (i, i);
|
||||||
prev = i;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
for (unsigned other_f_index : unique_features.iter ())
|
||||||
|
{
|
||||||
const Feature& f = get_feature (i);
|
const Feature& f = get_feature (i);
|
||||||
const Feature& prev_f = get_feature (prev);
|
const Feature& other_f = get_feature (other_f_index);
|
||||||
|
|
||||||
auto f_iter =
|
auto f_iter =
|
||||||
+ hb_iter (f.lookupIndex)
|
+ hb_iter (f.lookupIndex)
|
||||||
| hb_filter (lookup_indices)
|
| hb_filter (lookup_indices)
|
||||||
;
|
;
|
||||||
|
|
||||||
auto prev_iter =
|
auto other_f_iter =
|
||||||
+ hb_iter (prev_f.lookupIndex)
|
+ hb_iter (other_f.lookupIndex)
|
||||||
| hb_filter (lookup_indices)
|
| hb_filter (lookup_indices)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (f_iter.len () != prev_iter.len ())
|
bool is_equal = true;
|
||||||
|
for (; f_iter && other_f_iter; f_iter++, other_f_iter++)
|
||||||
{
|
{
|
||||||
duplicate_feature_map->set (i, i);
|
unsigned a = *f_iter;
|
||||||
prev = i;
|
unsigned b = *other_f_iter;
|
||||||
continue;
|
if (a != b) { is_equal = false; break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_equal = true;
|
if (is_equal == false || f_iter || other_f_iter) continue;
|
||||||
for (auto _ : + hb_zip (f_iter, prev_iter))
|
|
||||||
if (_.first != _.second) { is_equal = false; break; }
|
|
||||||
|
|
||||||
if (is_equal == true) duplicate_feature_map->set (i, prev);
|
found = true;
|
||||||
else
|
duplicate_feature_map->set (i, other_f_index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found == false)
|
||||||
{
|
{
|
||||||
|
unique_features.add (i);
|
||||||
duplicate_feature_map->set (i, i);
|
duplicate_feature_map->set (i, i);
|
||||||
prev = i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,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.duplicate_features \
|
||||||
expected/cmap \
|
expected/cmap \
|
||||||
expected/cmap14 \
|
expected/cmap14 \
|
||||||
expected/sbix \
|
expected/sbix \
|
||||||
|
|
|
@ -32,6 +32,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.duplicate_features.tests \
|
||||||
tests/sbix.tests \
|
tests/sbix.tests \
|
||||||
tests/variable.tests \
|
tests/variable.tests \
|
||||||
tests/glyph_names.tests \
|
tests/glyph_names.tests \
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
||||||
|
FONTS:
|
||||||
|
AlegreyaSans-BlackItalic.ttf
|
||||||
|
|
||||||
|
PROFILES:
|
||||||
|
default.txt
|
||||||
|
glyph-names.txt
|
||||||
|
notdef-outline.txt
|
||||||
|
|
||||||
|
SUBSETS:
|
||||||
|
U+20,U+2f,U+38,U+49,U+4c,U+51,U+53,U+66,U+67,U+6f,U+b4,U+2044
|
||||||
|
*
|
|
@ -27,6 +27,7 @@ tests = [
|
||||||
'layout.gdef-attachlist',
|
'layout.gdef-attachlist',
|
||||||
'layout.notonastaliqurdu',
|
'layout.notonastaliqurdu',
|
||||||
'layout.tinos',
|
'layout.tinos',
|
||||||
|
'layout.duplicate_features',
|
||||||
'cmap',
|
'cmap',
|
||||||
'cmap14',
|
'cmap14',
|
||||||
'sbix',
|
'sbix',
|
||||||
|
|
Loading…
Reference in New Issue