Module: wine Branch: master Commit: 093d6966be963fea9a9ca090ac6714e3f74458d8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=093d6966be963fea9a9ca090a...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Thu May 21 15:28:46 2020 +0300
dwrite: Set feature indices before collecting lookups.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/opentype.c | 60 ++++++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 0b863147af..db3543d79e 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 f22cd7469b..411b3df855 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) - continue; + if (!found) + features->features[i].index = 0xffff; + }
- if (!dwrite_array_reserve((void **)&lookups->indexes, &lookups->capacity, lookups->count + lookup_count, - sizeof(*lookups->indexes))) - { - return; - } + /* 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;
- 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])); + 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 (lookup_index >= total_lookup_count) + continue;
- lookups->indexes[lookups->count++] = lookup_index; - } + lookups->indexes[lookups->count++] = lookup_index; } } }