From 093d6966be963fea9a9ca090ac6714e3f74458d8 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 21 May 2020 15:28:46 +0300 Subject: [PATCH] dwrite: Set feature indices before collecting lookups. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/opentype.c | 64 ++++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 0b863147af3..db3543d79ed 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -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 diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index f22cd7469b0..411b3df855e 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -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,42 +4133,57 @@ 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; + } + } - lookup_count = table_read_be_word(&table->table, table->feature_list + feature_offset + - FIELD_OFFSET(struct ot_feature, lookup_count)); - if (!lookup_count) + 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)); + if (!lookup_count) + continue; + + if (!dwrite_array_reserve((void **)&lookups->indexes, &lookups->capacity, lookups->count + lookup_count, + sizeof(*lookups->indexes))) + { + return; + } + + for (l = 0; l < lookup_count; ++l) + { + UINT16 lookup_index = table_read_be_word(&table->table, table->feature_list + feature_offset + + FIELD_OFFSET(struct ot_feature, lookuplist_index[l])); + + if (lookup_index >= total_lookup_count) continue; - if (!dwrite_array_reserve((void **)&lookups->indexes, &lookups->capacity, lookups->count + lookup_count, - sizeof(*lookups->indexes))) - { - return; - } - - for (l = 0; l < lookup_count; ++l) - { - UINT16 lookup_index = table_read_be_word(&table->table, table->feature_list + feature_offset + - FIELD_OFFSET(struct ot_feature, lookuplist_index[l])); - - if (lookup_index >= total_lookup_count) - continue; - - lookups->indexes[lookups->count++] = lookup_index; - } + lookups->indexes[lookups->count++] = lookup_index; } } }