dwrite: Append enabled user features that apply to whole text.

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:48 +03:00 committed by Alexandre Julliard
parent b9f580c990
commit bd0abb5968
3 changed files with 36 additions and 3 deletions

View File

@ -1256,6 +1256,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
context.u.subst.max_glyph_count = max_glyph_count;
context.glyph_count = g;
context.language_tag = get_opentype_language(locale);
context.user_features.features = features;
context.user_features.range_lengths = feature_range_lengths;
context.user_features.range_count = feature_ranges;
script = analysis->script > Script_LastId ? Script_Unknown : analysis->script;
scriptprops = &dwritescripts_properties[script];
@ -1321,6 +1324,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphPlacements(IDWriteTextAnalyzer2
context.advances = advances;
context.offsets = offsets;
context.language_tag = get_opentype_language(locale);
context.user_features.features = features;
context.user_features.range_lengths = feature_range_lengths;
context.user_features.range_count = feature_ranges;
return shape_get_positions(&context, scriptprops->scripttags);
}
@ -1380,6 +1386,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGdiCompatibleGlyphPlacements(IDWrite
context.advances = advances;
context.offsets = offsets;
context.language_tag = get_opentype_language(locale);
context.user_features.features = features;
context.user_features.range_lengths = feature_range_lengths;
context.user_features.range_count = feature_ranges;
return shape_get_positions(&context, scriptprops->scripttags);
}

View File

@ -486,6 +486,13 @@ struct scriptshaping_context
} subst;
} u;
struct
{
const DWRITE_TYPOGRAPHIC_FEATURES **features;
const unsigned int *range_lengths;
unsigned int range_count;
} user_features;
unsigned int glyph_count;
float emsize;
DWRITE_MEASURING_MODE measuring_mode;

View File

@ -223,10 +223,27 @@ static int features_sorting_compare(const void *a, const void *b)
return left->tag != right->tag ? (left->tag < right->tag ? -1 : 1) : 0;
};
static void shape_merge_features(struct shaping_features *features)
static void shape_merge_features(struct scriptshaping_context *context, struct shaping_features *features)
{
const DWRITE_TYPOGRAPHIC_FEATURES **user_features = context->user_features.features;
unsigned int j = 0, i;
/* For now only consider global, enabled user features. */
if (user_features && context->user_features.range_lengths && context->user_features.range_count == 1)
{
for (i = 0; i < context->user_features.range_count; ++i)
{
if (context->user_features.range_lengths[i] != context->length)
break;
for (j = 0; j < user_features[i]->featureCount; ++j)
{
if (user_features[i]->features[j].parameter == 1)
shape_add_feature(features, user_features[i]->features[j].nameTag);
}
}
}
/* Sort and merge duplicates. */
qsort(features->features, features->count, sizeof(*features->features), features_sorting_compare);
@ -267,7 +284,7 @@ HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigne
shape_add_feature(&features, horizontal_features[i]);
}
shape_merge_features(&features);
shape_merge_features(context, &features);
/* Resolve script tag to actually supported script. */
if (cache->gpos.table.data)
@ -354,7 +371,7 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i
else
shape_add_feature_flags(&features, DWRITE_MAKE_OPENTYPE_TAG('v','e','r','t'), FEATURE_GLOBAL_SEARCH);
shape_merge_features(&features);
shape_merge_features(context, &features);
/* Resolve script tag to actually supported script. */
if (cache->gsub.table.data)