[PATCH 2/5] dwrite: Set feature indices before collecting lookups.
Nikolay Sivov
nsivov at codeweavers.com
Thu May 21 07:28:46 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 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)
- 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;
}
}
}
--
2.26.2
More information about the wine-devel
mailing list