[PATCH 1/5] dwrite: Remove feature duplicates before applying them.
Nikolay Sivov
nsivov at codeweavers.com
Thu May 21 07:28:45 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dwrite/shape.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/dlls/dwrite/shape.c b/dlls/dwrite/shape.c
index 0372d739b56..82ad3a2a1e7 100644
--- a/dlls/dwrite/shape.c
+++ b/dlls/dwrite/shape.c
@@ -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)
{
--
2.26.2
More information about the wine-devel
mailing list