Commit dfb94e6f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Add per shaping stage functions.

parent 3c0836bf
...@@ -559,12 +559,23 @@ struct shaping_feature ...@@ -559,12 +559,23 @@ struct shaping_feature
unsigned int stage; unsigned int stage;
}; };
#define MAX_SHAPING_STAGE 16
typedef void (*stage_func)(struct scriptshaping_context *context);
struct shaping_stage
{
stage_func func;
unsigned int last_lookup;
};
struct shaping_features struct shaping_features
{ {
struct shaping_feature *features; struct shaping_feature *features;
size_t count; size_t count;
size_t capacity; size_t capacity;
unsigned int stage; unsigned int stage;
struct shaping_stage stages[MAX_SHAPING_STAGE];
}; };
struct shaper struct shaper
...@@ -577,9 +588,9 @@ extern const struct shaper arabic_shaper DECLSPEC_HIDDEN; ...@@ -577,9 +588,9 @@ extern const struct shaper arabic_shaper DECLSPEC_HIDDEN;
extern void shape_enable_feature(struct shaping_features *features, unsigned int tag, extern void shape_enable_feature(struct shaping_features *features, unsigned int tag,
unsigned int flags) DECLSPEC_HIDDEN; unsigned int flags) DECLSPEC_HIDDEN;
extern void shape_add_feature_full(struct shaping_features *features, unsigned int tag, unsigned int flags, extern void shape_add_feature_full(struct shaping_features *features, unsigned int tag,
unsigned int value) DECLSPEC_HIDDEN; unsigned int flags, unsigned int value) DECLSPEC_HIDDEN;
extern void shape_start_next_stage(struct shaping_features *features) DECLSPEC_HIDDEN; extern void shape_start_next_stage(struct shaping_features *features, stage_func func) DECLSPEC_HIDDEN;
struct scriptshaping_context struct scriptshaping_context
{ {
...@@ -667,9 +678,9 @@ extern DWORD opentype_layout_find_script(const struct scriptshaping_cache *cache ...@@ -667,9 +678,9 @@ extern DWORD opentype_layout_find_script(const struct scriptshaping_cache *cache
extern DWORD opentype_layout_find_language(const struct scriptshaping_cache *cache, DWORD kind, DWORD tag, extern DWORD opentype_layout_find_language(const struct scriptshaping_cache *cache, DWORD kind, DWORD tag,
unsigned int script_index, unsigned int *language_index) DECLSPEC_HIDDEN; unsigned int script_index, unsigned int *language_index) DECLSPEC_HIDDEN;
extern void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index, extern void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, const struct shaping_features *features) DECLSPEC_HIDDEN; unsigned int language_index, struct shaping_features *features) DECLSPEC_HIDDEN;
extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index, extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, const struct shaping_features *features) DECLSPEC_HIDDEN; unsigned int language_index, struct shaping_features *features) DECLSPEC_HIDDEN;
extern BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsigned int script_index, extern BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, struct shaping_feature *feature, unsigned int glyph_count, unsigned int language_index, struct shaping_feature *feature, unsigned int glyph_count,
const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN; const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN;
......
...@@ -4442,7 +4442,7 @@ static void opentype_layout_add_lookups(const struct ot_feature_list *feature_li ...@@ -4442,7 +4442,7 @@ static void opentype_layout_add_lookups(const struct ot_feature_list *feature_li
} }
static void opentype_layout_collect_lookups(struct scriptshaping_context *context, unsigned int script_index, static void opentype_layout_collect_lookups(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, const struct shaping_features *features, const struct ot_gsubgpos_table *table, unsigned int language_index, struct shaping_features *features, const struct ot_gsubgpos_table *table,
struct lookups *lookups) struct lookups *lookups)
{ {
unsigned int last_num_lookups = 0, stage, script_feature_count = 0; unsigned int last_num_lookups = 0, stage, script_feature_count = 0;
...@@ -4607,6 +4607,7 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex ...@@ -4607,6 +4607,7 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex
} }
last_num_lookups = lookups->count; last_num_lookups = lookups->count;
features->stages[stage].last_lookup = last_num_lookups;
} }
} }
...@@ -4688,7 +4689,7 @@ static void opentype_layout_apply_gpos_context_lookup(struct scriptshaping_conte ...@@ -4688,7 +4689,7 @@ static void opentype_layout_apply_gpos_context_lookup(struct scriptshaping_conte
} }
void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index, void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, const struct shaping_features *features) unsigned int language_index, struct shaping_features *features)
{ {
struct lookups lookups = { 0 }; struct lookups lookups = { 0 };
unsigned int i; unsigned int i;
...@@ -5791,7 +5792,7 @@ static void opentype_layout_apply_gsub_context_lookup(struct scriptshaping_conte ...@@ -5791,7 +5792,7 @@ static void opentype_layout_apply_gsub_context_lookup(struct scriptshaping_conte
} }
void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index, void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, unsigned int script_index,
unsigned int language_index, const struct shaping_features *features) unsigned int language_index, struct shaping_features *features)
{ {
struct lookups lookups = { 0 }; struct lookups lookups = { 0 };
unsigned int i, j, start_idx; unsigned int i, j, start_idx;
......
...@@ -142,8 +142,9 @@ void shape_enable_feature(struct shaping_features *features, unsigned int tag, ...@@ -142,8 +142,9 @@ void shape_enable_feature(struct shaping_features *features, unsigned int tag,
shape_add_feature_full(features, tag, FEATURE_GLOBAL | flags, 1); shape_add_feature_full(features, tag, FEATURE_GLOBAL | flags, 1);
} }
void shape_start_next_stage(struct shaping_features *features) void shape_start_next_stage(struct shaping_features *features, stage_func func)
{ {
features->stages[features->stage].func = func;
features->stage++; features->stage++;
} }
......
...@@ -56,21 +56,21 @@ static void arabic_collect_features(struct scriptshaping_context *context, ...@@ -56,21 +56,21 @@ static void arabic_collect_features(struct scriptshaping_context *context,
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('c','c','m','p'), 0); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('c','c','m','p'), 0);
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('l','o','c','l'), 0); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('l','o','c','l'), 0);
shape_start_next_stage(features); shape_start_next_stage(features, NULL);
for (i = 0; i < ARRAY_SIZE(arabic_features); ++i) for (i = 0; i < ARRAY_SIZE(arabic_features); ++i)
{ {
unsigned int flags = context->script == Script_Arabic && !feature_is_syriac(arabic_features[i]) ? unsigned int flags = context->script == Script_Arabic && !feature_is_syriac(arabic_features[i]) ?
FEATURE_HAS_FALLBACK : 0; FEATURE_HAS_FALLBACK : 0;
shape_add_feature_full(features, arabic_features[i], flags, 1); shape_add_feature_full(features, arabic_features[i], flags, 1);
shape_start_next_stage(features); shape_start_next_stage(features, NULL);
} }
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('r','l','i','g'), FEATURE_MANUAL_ZWJ | FEATURE_HAS_FALLBACK); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('r','l','i','g'), FEATURE_MANUAL_ZWJ | FEATURE_HAS_FALLBACK);
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('r','c','l','t'), FEATURE_MANUAL_ZWJ); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('r','c','l','t'), FEATURE_MANUAL_ZWJ);
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('c','a','l','t'), FEATURE_MANUAL_ZWJ); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('c','a','l','t'), FEATURE_MANUAL_ZWJ);
shape_start_next_stage(features); shape_start_next_stage(features, NULL);
shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('m','s','e','t'), 0); shape_enable_feature(features, DWRITE_MAKE_OPENTYPE_TAG('m','s','e','t'), 0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment