[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,
|
||||
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
|
||||
unsigned prev = 0xFFFFu;
|
||||
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 prev_t = get_feature_tag (prev);
|
||||
if (t != prev_t)
|
||||
{
|
||||
prev_t = t;
|
||||
unique_features.clear ();
|
||||
unique_features.add (i);
|
||||
duplicate_feature_map->set (i, i);
|
||||
prev = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
const Feature& f = get_feature (i);
|
||||
const Feature& prev_f = get_feature (prev);
|
||||
bool found = false;
|
||||
|
||||
auto f_iter =
|
||||
+ hb_iter (f.lookupIndex)
|
||||
| hb_filter (lookup_indices)
|
||||
;
|
||||
|
||||
auto prev_iter =
|
||||
+ hb_iter (prev_f.lookupIndex)
|
||||
| hb_filter (lookup_indices)
|
||||
;
|
||||
|
||||
if (f_iter.len () != prev_iter.len ())
|
||||
for (unsigned other_f_index : unique_features.iter ())
|
||||
{
|
||||
duplicate_feature_map->set (i, i);
|
||||
prev = i;
|
||||
continue;
|
||||
const Feature& f = get_feature (i);
|
||||
const Feature& other_f = get_feature (other_f_index);
|
||||
|
||||
auto f_iter =
|
||||
+ hb_iter (f.lookupIndex)
|
||||
| hb_filter (lookup_indices)
|
||||
;
|
||||
|
||||
auto other_f_iter =
|
||||
+ hb_iter (other_f.lookupIndex)
|
||||
| hb_filter (lookup_indices)
|
||||
;
|
||||
|
||||
bool is_equal = true;
|
||||
for (; f_iter && other_f_iter; f_iter++, other_f_iter++)
|
||||
{
|
||||
unsigned a = *f_iter;
|
||||
unsigned b = *other_f_iter;
|
||||
if (a != b) { is_equal = false; break; }
|
||||
}
|
||||
|
||||
if (is_equal == false || f_iter || other_f_iter) continue;
|
||||
|
||||
found = true;
|
||||
duplicate_feature_map->set (i, other_f_index);
|
||||
break;
|
||||
}
|
||||
|
||||
bool is_equal = true;
|
||||
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);
|
||||
else
|
||||
|
||||
if (found == false)
|
||||
{
|
||||
unique_features.add (i);
|
||||
duplicate_feature_map->set (i, i);
|
||||
prev = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ EXTRA_DIST += \
|
|||
expected/layout.gdef-attachlist \
|
||||
expected/layout.notonastaliqurdu \
|
||||
expected/layout.tinos \
|
||||
expected/layout.duplicate_features \
|
||||
expected/cmap \
|
||||
expected/cmap14 \
|
||||
expected/sbix \
|
||||
|
|
|
@ -32,6 +32,7 @@ TESTS = \
|
|||
tests/layout.notonastaliqurdu.tests \
|
||||
tests/layout.tests \
|
||||
tests/layout.tinos.tests \
|
||||
tests/layout.duplicate_features.tests \
|
||||
tests/sbix.tests \
|
||||
tests/variable.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.notonastaliqurdu',
|
||||
'layout.tinos',
|
||||
'layout.duplicate_features',
|
||||
'cmap',
|
||||
'cmap14',
|
||||
'sbix',
|
||||
|
|
Loading…
Reference in New Issue