dwrite: Remove feature duplicates before applying them.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-05-21 15:28:45 +03:00 committed by Alexandre Julliard
parent 0e30815636
commit 2aaa6d1af9
1 changed files with 25 additions and 0 deletions

View File

@ -210,6 +210,27 @@ static void shape_add_feature(struct shaping_features *features, unsigned int ta
features->features[features->count++].tag = tag;
}
static int features_sorting_compare(const void *a, const void *b)
{
const struct shaping_feature *left = a, *right = b;
return left->tag != right->tag ? (left->tag < right->tag ? -1 : 1) : 0;
};
static void shape_merge_features(struct shaping_features *features)
{
unsigned int j = 0, i;
/* Sort and merge duplicates. */
qsort(features->features, features->count, sizeof(*features->features), features_sorting_compare);
for (i = 1; i < features->count; ++i)
{
if (features->features[i].tag != features->features[j].tag)
features->features[++j] = features->features[i];
}
features->count = j + 1;
}
HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigned int *scripts)
{
static const unsigned int common_features[] =
@ -239,6 +260,8 @@ HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigne
shape_add_feature(&features, horizontal_features[i]);
}
shape_merge_features(&features);
/* Resolve script tag to actually supported script. */
if (cache->gpos.table.data)
{
@ -322,6 +345,8 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i
shape_add_feature(&features, horizontal_features[i]);
}
shape_merge_features(&features);
/* Resolve script tag to actually supported script. */
if (cache->gsub.table.data)
{