Commit bd0abb59 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent b9f580c9
...@@ -1256,6 +1256,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface, ...@@ -1256,6 +1256,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
context.u.subst.max_glyph_count = max_glyph_count; context.u.subst.max_glyph_count = max_glyph_count;
context.glyph_count = g; context.glyph_count = g;
context.language_tag = get_opentype_language(locale); 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; script = analysis->script > Script_LastId ? Script_Unknown : analysis->script;
scriptprops = &dwritescripts_properties[script]; scriptprops = &dwritescripts_properties[script];
...@@ -1321,6 +1324,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphPlacements(IDWriteTextAnalyzer2 ...@@ -1321,6 +1324,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphPlacements(IDWriteTextAnalyzer2
context.advances = advances; context.advances = advances;
context.offsets = offsets; context.offsets = offsets;
context.language_tag = get_opentype_language(locale); 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); return shape_get_positions(&context, scriptprops->scripttags);
} }
...@@ -1380,6 +1386,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGdiCompatibleGlyphPlacements(IDWrite ...@@ -1380,6 +1386,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGdiCompatibleGlyphPlacements(IDWrite
context.advances = advances; context.advances = advances;
context.offsets = offsets; context.offsets = offsets;
context.language_tag = get_opentype_language(locale); 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); return shape_get_positions(&context, scriptprops->scripttags);
} }
......
...@@ -486,6 +486,13 @@ struct scriptshaping_context ...@@ -486,6 +486,13 @@ struct scriptshaping_context
} subst; } subst;
} u; } u;
struct
{
const DWRITE_TYPOGRAPHIC_FEATURES **features;
const unsigned int *range_lengths;
unsigned int range_count;
} user_features;
unsigned int glyph_count; unsigned int glyph_count;
float emsize; float emsize;
DWRITE_MEASURING_MODE measuring_mode; DWRITE_MEASURING_MODE measuring_mode;
......
...@@ -223,10 +223,27 @@ static int features_sorting_compare(const void *a, const void *b) ...@@ -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; 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; 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. */ /* Sort and merge duplicates. */
qsort(features->features, features->count, sizeof(*features->features), features_sorting_compare); 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 ...@@ -267,7 +284,7 @@ HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigne
shape_add_feature(&features, horizontal_features[i]); shape_add_feature(&features, horizontal_features[i]);
} }
shape_merge_features(&features); shape_merge_features(context, &features);
/* Resolve script tag to actually supported script. */ /* Resolve script tag to actually supported script. */
if (cache->gpos.table.data) if (cache->gpos.table.data)
...@@ -354,7 +371,7 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i ...@@ -354,7 +371,7 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i
else else
shape_add_feature_flags(&features, DWRITE_MAKE_OPENTYPE_TAG('v','e','r','t'), FEATURE_GLOBAL_SEARCH); 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. */ /* Resolve script tag to actually supported script. */
if (cache->gsub.table.data) if (cache->gsub.table.data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment