dwrite: Set feature indices before collecting lookups.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Nikolay Sivov 2020-05-21 15:28:46 +03:00 committed by Alexandre Julliard
parent 2aaa6d1af9
commit 093d6966be
2 changed files with 41 additions and 24 deletions

View File

@ -508,6 +508,7 @@ extern struct scriptshaping_cache *fontface_get_shaping_cache(struct dwrite_font
struct shaping_feature
{
unsigned int tag;
unsigned int index;
};
struct shaping_features

View File

@ -4099,6 +4099,7 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex
{
UINT16 table_offset, langsys_offset, script_feature_count, total_feature_count, total_lookup_count;
const struct ot_feature_list *feature_list;
UINT16 feature_index;
unsigned int i, j, l;
/* ScriptTable offset. */
@ -4132,20 +4133,36 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex
if (!feature_list)
return;
/* Collect lookups for all given features. */
for (i = 0; i < features->count; ++i)
{
BOOL found = FALSE;
for (j = 0; j < script_feature_count; ++j)
{
UINT16 feature_index = table_read_be_word(&table->table, table->script_list + table_offset +
feature_index = table_read_be_word(&table->table, table->script_list + table_offset +
langsys_offset + FIELD_OFFSET(struct ot_langsys, feature_index[j]));
if (feature_index >= total_feature_count)
continue;
if (feature_list->features[feature_index].tag == features->features[i].tag)
{
WORD feature_offset = GET_BE_WORD(feature_list->features[feature_index].offset);
WORD lookup_count;
found = TRUE;
features->features[i].index = feature_index;
break;
}
}
if (!found)
features->features[i].index = 0xffff;
}
/* Collect lookups for all given features. */
for (i = 0; i < features->count; ++i)
{
feature_index = features->features[i].index;
if (feature_index != 0xffff)
{
UINT16 feature_offset = GET_BE_WORD(feature_list->features[feature_index].offset);
UINT16 lookup_count;
lookup_count = table_read_be_word(&table->table, table->feature_list + feature_offset +
FIELD_OFFSET(struct ot_feature, lookup_count));
@ -4170,7 +4187,6 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex
}
}
}
}
/* Sort lookups. */
qsort(lookups->indexes, lookups->count, sizeof(*lookups->indexes), lookups_sorting_compare);