From 4ae8191ee9755c0bda1d2ac3341a08e3c2b0d9fc Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 22 Jan 2021 15:25:22 +0300 Subject: [PATCH] dwrite/arabic: Set per-glyph mask. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/dwrite_private.h | 2 ++ dlls/dwrite/opentype.c | 6 ++++++ dlls/dwrite/shapers/arabic.c | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 3f48c189a13..ac870fd215c 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -590,6 +590,8 @@ extern void shape_enable_feature(struct shaping_features *features, unsigned int unsigned int flags) DECLSPEC_HIDDEN; extern void shape_add_feature_full(struct shaping_features *features, unsigned int tag, unsigned int flags, unsigned int value) DECLSPEC_HIDDEN; +extern unsigned int shape_get_feature_1_mask(const struct shaping_features *features, + unsigned int tag) DECLSPEC_HIDDEN; extern void shape_start_next_stage(struct shaping_features *features, stage_func func) DECLSPEC_HIDDEN; struct scriptshaping_context diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 6fe85dd4991..7d89851bbaa 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -4632,6 +4632,12 @@ static unsigned int shaping_features_get_mask(const struct shaping_features *fea return feature->mask; } +unsigned int shape_get_feature_1_mask(const struct shaping_features *features, unsigned int tag) +{ + unsigned int shift, mask = shaping_features_get_mask(features, tag, &shift); + return (1 << shift) & mask; +} + static void opentype_layout_get_glyph_range_for_text(struct scriptshaping_context *context, unsigned int start_char, unsigned int end_char, unsigned int *start_glyph, unsigned int *end_glyph) { diff --git a/dlls/dwrite/shapers/arabic.c b/dlls/dwrite/shapers/arabic.c index aaf57da42e4..cc701150a56 100644 --- a/dlls/dwrite/shapers/arabic.c +++ b/dlls/dwrite/shapers/arabic.c @@ -41,6 +41,7 @@ enum arabic_shaping_action MED2, INIT, NONE, + NUM_FEATURES = NONE, }; static BOOL feature_is_syriac(unsigned int tag) @@ -134,10 +135,17 @@ static void arabic_set_shaping_action(struct scriptshaping_context *context, context->glyph_infos[idx].props |= (action & 0xf) << 16; } +static enum arabic_shaping_action arabic_get_shaping_action(const struct scriptshaping_context *context, + unsigned int idx) +{ + return (context->glyph_infos[idx].props >> 16) & 0xf; +} + static void arabic_setup_masks(struct scriptshaping_context *context, const struct shaping_features *features) { unsigned int i, prev = ~0u, state = 0; + unsigned int masks[NUM_FEATURES]; for (i = 0; i < context->length; ++i) { @@ -160,6 +168,13 @@ static void arabic_setup_masks(struct scriptshaping_context *context, prev = i; state = entry->next_state; } + + for (i = 0; i < ARRAY_SIZE(masks); ++i) + masks[i] = shape_get_feature_1_mask(features, arabic_features[i]); + + /* Unaffected glyphs get action NONE with zero mask. */ + for (i = 0; i < context->length; ++i) + context->glyph_infos[i].mask |= masks[arabic_get_shaping_action(context, i)]; } const struct shaper arabic_shaper =