Shuffle code around, remove shape_plan from complex shapers
This commit is contained in:
parent
e88bff9b4d
commit
76f76812ac
|
@ -151,7 +151,7 @@ static const struct arabic_state_table_entry {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_ot_shape_complex_collect_features_arabic (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props)
|
_hb_ot_shape_complex_collect_features_arabic (hb_ot_map_builder_t *map, const hb_segment_properties_t *props)
|
||||||
{
|
{
|
||||||
/* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init together,
|
/* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init together,
|
||||||
* then rlig and calt each in their own stage. This makes IranNastaliq's ALLAH
|
* then rlig and calt each in their own stage. This makes IranNastaliq's ALLAH
|
||||||
|
@ -163,57 +163,57 @@ _hb_ot_shape_complex_collect_features_arabic (hb_ot_shape_planner_t *planner, co
|
||||||
* TODO: Add test cases for these two.
|
* TODO: Add test cases for these two.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
planner->map.add_gsub_pause (NULL, NULL);
|
map->add_gsub_pause (NULL, NULL);
|
||||||
|
|
||||||
unsigned int num_features = props->script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
unsigned int num_features = props->script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
||||||
for (unsigned int i = 0; i < num_features; i++)
|
for (unsigned int i = 0; i < num_features; i++)
|
||||||
planner->map.add_bool_feature (arabic_syriac_features[i], false);
|
map->add_bool_feature (arabic_syriac_features[i], false);
|
||||||
|
|
||||||
planner->map.add_gsub_pause (NULL, NULL);
|
map->add_gsub_pause (NULL, NULL);
|
||||||
|
|
||||||
planner->map.add_bool_feature (HB_TAG('r','l','i','g'));
|
map->add_bool_feature (HB_TAG('r','l','i','g'));
|
||||||
planner->map.add_gsub_pause (NULL, NULL);
|
map->add_gsub_pause (NULL, NULL);
|
||||||
|
|
||||||
planner->map.add_bool_feature (HB_TAG('c','a','l','t'));
|
map->add_bool_feature (HB_TAG('c','a','l','t'));
|
||||||
planner->map.add_gsub_pause (NULL, NULL);
|
map->add_gsub_pause (NULL, NULL);
|
||||||
|
|
||||||
/* ArabicOT spec enables 'cswh' for Arabic where as for basic shaper it's disabled by default. */
|
/* ArabicOT spec enables 'cswh' for Arabic where as for basic shaper it's disabled by default. */
|
||||||
planner->map.add_bool_feature (HB_TAG('c','s','w','h'));
|
map->add_bool_feature (HB_TAG('c','s','w','h'));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c)
|
_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
unsigned int count = c->buffer->len;
|
unsigned int count = buffer->len;
|
||||||
unsigned int prev = 0, state = 0;
|
unsigned int prev = 0, state = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
unsigned int this_type = get_joining_type (c->buffer->info[i].codepoint, (hb_unicode_general_category_t) c->buffer->info[i].general_category());
|
unsigned int this_type = get_joining_type (buffer->info[i].codepoint, (hb_unicode_general_category_t) buffer->info[i].general_category());
|
||||||
|
|
||||||
if (unlikely (this_type == JOINING_TYPE_T)) {
|
if (unlikely (this_type == JOINING_TYPE_T)) {
|
||||||
c->buffer->info[i].arabic_shaping_action() = NONE;
|
buffer->info[i].arabic_shaping_action() = NONE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
|
const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
|
||||||
|
|
||||||
if (entry->prev_action != NONE)
|
if (entry->prev_action != NONE)
|
||||||
c->buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
||||||
|
|
||||||
c->buffer->info[i].arabic_shaping_action() = entry->curr_action;
|
buffer->info[i].arabic_shaping_action() = entry->curr_action;
|
||||||
|
|
||||||
prev = i;
|
prev = i;
|
||||||
state = entry->next_state;
|
state = entry->next_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_mask_t mask_array[TOTAL_NUM_FEATURES + 1] = {0};
|
hb_mask_t mask_array[TOTAL_NUM_FEATURES + 1] = {0};
|
||||||
unsigned int num_masks = c->buffer->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
unsigned int num_masks = buffer->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
||||||
for (unsigned int i = 0; i < num_masks; i++)
|
for (unsigned int i = 0; i < num_masks; i++)
|
||||||
mask_array[i] = c->plan->map.get_1_mask (arabic_syriac_features[i]);
|
mask_array[i] = map->get_1_mask (arabic_syriac_features[i]);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
c->buffer->info[i].mask |= mask_array[c->buffer->info[i].arabic_shaping_action()];
|
buffer->info[i].mask |= mask_array[buffer->info[i].arabic_shaping_action()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,12 @@ z = ZWJ|ZWNJ;
|
||||||
matra_group = M N? H?;
|
matra_group = M N? H?;
|
||||||
syllable_tail = SM? (VD VD?)?;
|
syllable_tail = SM? (VD VD?)?;
|
||||||
|
|
||||||
action matched_syllable {
|
action found_syllable {
|
||||||
matched_syllable (c, last, p);
|
found_syllable (map, buffer, last, p);
|
||||||
last = p;
|
last = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
consonant_syllable = (c.N? (z.H|H.z?))* c.N? A? (H.z? | matra_group*)? syllable_tail %(matched_syllable);
|
consonant_syllable = (c.N? (z.H|H.z?))* c.N? A? (H.z? | matra_group*)? syllable_tail %(found_syllable);
|
||||||
vowel_syllable = (Ra H)? V N? (z.H.c | ZWJ.c)? matra_group* syllable_tail;
|
vowel_syllable = (Ra H)? V N? (z.H.c | ZWJ.c)? matra_group* syllable_tail;
|
||||||
standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail;
|
standalone_cluster = (Ra H)? NBSP N? (z? H c)? matra_group* syllable_tail;
|
||||||
non_indic = X;
|
non_indic = X;
|
||||||
|
@ -85,17 +85,17 @@ main := syllable**;
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
find_syllables (hb_ot_shape_context_t *c)
|
find_syllables (hb_ot_map_t *map, hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
unsigned int p, pe, eof;
|
unsigned int p, pe, eof;
|
||||||
int cs;
|
int cs;
|
||||||
%%{
|
%%{
|
||||||
write init;
|
write init;
|
||||||
getkey c->buffer->info[p].indic_category();
|
getkey buffer->info[p].indic_category();
|
||||||
}%%
|
}%%
|
||||||
|
|
||||||
p = 0;
|
p = 0;
|
||||||
pe = eof = c->buffer->len;
|
pe = eof = buffer->len;
|
||||||
|
|
||||||
unsigned int last = 0;
|
unsigned int last = 0;
|
||||||
%%{
|
%%{
|
||||||
|
|
|
@ -283,20 +283,19 @@ static const hb_tag_t indic_other_features[] =
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_ot_shape_complex_collect_features_indic (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props HB_UNUSED)
|
_hb_ot_shape_complex_collect_features_indic (hb_ot_map_builder_t *map, const hb_segment_properties_t *props)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++)
|
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++)
|
||||||
planner->map.add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global);
|
map->add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++)
|
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++)
|
||||||
planner->map.add_bool_feature (indic_other_features[i], true);
|
map->add_bool_feature (indic_other_features[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
matched_syllable (hb_ot_shape_context_t *c,
|
found_syllable (hb_ot_map_t *map, hb_buffer_t *buffer,
|
||||||
unsigned int start,
|
unsigned int start, unsigned int end)
|
||||||
unsigned int end)
|
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "%d %d\n", start, end);
|
//fprintf (stderr, "%d %d\n", start, end);
|
||||||
}
|
}
|
||||||
|
@ -305,24 +304,24 @@ matched_syllable (hb_ot_shape_context_t *c,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_ot_shape_complex_setup_masks_indic (hb_ot_shape_context_t *c)
|
_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
unsigned int count = c->buffer->len;
|
unsigned int count = buffer->len;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
unsigned int type = get_indic_categories (c->buffer->info[i].codepoint);
|
unsigned int type = get_indic_categories (buffer->info[i].codepoint);
|
||||||
|
|
||||||
c->buffer->info[i].indic_category() = type & 0x0F;
|
buffer->info[i].indic_category() = type & 0x0F;
|
||||||
c->buffer->info[i].indic_position() = type >> 4;
|
buffer->info[i].indic_position() = type >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
find_syllables (c);
|
find_syllables (map, buffer);
|
||||||
|
|
||||||
hb_mask_t mask_array[ARRAY_LENGTH (indic_basic_features)] = {0};
|
hb_mask_t mask_array[ARRAY_LENGTH (indic_basic_features)] = {0};
|
||||||
unsigned int num_masks = ARRAY_LENGTH (indic_basic_features);
|
unsigned int num_masks = ARRAY_LENGTH (indic_basic_features);
|
||||||
for (unsigned int i = 0; i < num_masks; i++)
|
for (unsigned int i = 0; i < num_masks; i++)
|
||||||
mask_array[i] = c->plan->map.get_1_mask (indic_basic_features[i].tag);
|
mask_array[i] = map->get_1_mask (indic_basic_features[i].tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,22 @@
|
||||||
|
|
||||||
#include "hb-private.hh"
|
#include "hb-private.hh"
|
||||||
|
|
||||||
#include "hb-ot-shape-private.hh"
|
#include "hb-ot-map-private.hh"
|
||||||
|
|
||||||
HB_BEGIN_DECLS
|
HB_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
|
/* buffer var allocations, used by all shapers */
|
||||||
|
#define general_category() var1.u8[0] /* unicode general_category (hb_unicode_general_category_t) */
|
||||||
|
#define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */
|
||||||
|
|
||||||
|
|
||||||
|
enum hb_ot_complex_shaper_t {
|
||||||
|
hb_ot_complex_shaper_none,
|
||||||
|
hb_ot_complex_shaper_arabic,
|
||||||
|
hb_ot_complex_shaper_indic
|
||||||
|
};
|
||||||
|
|
||||||
static inline hb_ot_complex_shaper_t
|
static inline hb_ot_complex_shaper_t
|
||||||
hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
|
hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
|
||||||
{
|
{
|
||||||
|
@ -104,20 +115,21 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
|
||||||
*
|
*
|
||||||
* Called during shape_plan().
|
* Called during shape_plan().
|
||||||
*
|
*
|
||||||
* Shapers should use plan->map to add their features.
|
* Shapers should use map to add their features and callbacks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_shape_planner_t *plan, const hb_segment_properties_t *props);
|
typedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_map_builder_t *map, const hb_segment_properties_t *props);
|
||||||
HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_arabic;
|
HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_arabic;
|
||||||
HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_indic;
|
HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_indic;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
hb_ot_shape_complex_collect_features (hb_ot_shape_planner_t *planner,
|
hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
|
||||||
|
hb_ot_map_builder_t *map,
|
||||||
const hb_segment_properties_t *props)
|
const hb_segment_properties_t *props)
|
||||||
{
|
{
|
||||||
switch (planner->shaper) {
|
switch (shaper) {
|
||||||
case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_collect_features_arabic (planner, props); return;
|
case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_collect_features_arabic (map, props); return;
|
||||||
case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_collect_features_indic (planner, props); return;
|
case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_collect_features_indic (map, props); return;
|
||||||
case hb_ot_complex_shaper_none: default: return;
|
case hb_ot_complex_shaper_none: default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,19 +139,21 @@ hb_ot_shape_complex_collect_features (hb_ot_shape_planner_t *planner,
|
||||||
*
|
*
|
||||||
* Called during shape_execute().
|
* Called during shape_execute().
|
||||||
*
|
*
|
||||||
* Shapers should use c->plan.map to get feature masks and set on buffer.
|
* Shapers should use map to get feature masks and set on buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_shape_context_t *c);
|
typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer);
|
||||||
HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_arabic;
|
HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_arabic;
|
||||||
HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_indic;
|
HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_indic;
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
hb_ot_shape_complex_setup_masks (hb_ot_shape_context_t *c)
|
hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
|
||||||
|
hb_ot_map_t *map,
|
||||||
|
hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
switch (c->plan->shaper) {
|
switch (shaper) {
|
||||||
case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_setup_masks_arabic (c); return;
|
case hb_ot_complex_shaper_arabic: _hb_ot_shape_complex_setup_masks_arabic (map, buffer); return;
|
||||||
case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_setup_masks_indic (c); return;
|
case hb_ot_complex_shaper_indic: _hb_ot_shape_complex_setup_masks_indic (map, buffer); return;
|
||||||
case hb_ot_complex_shaper_none: default: return;
|
case hb_ot_complex_shaper_none: default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,12 @@
|
||||||
#include "hb-ot-shape.h"
|
#include "hb-ot-shape.h"
|
||||||
|
|
||||||
#include "hb-ot-map-private.hh"
|
#include "hb-ot-map-private.hh"
|
||||||
|
#include "hb-ot-shape-complex-private.hh"
|
||||||
|
|
||||||
HB_BEGIN_DECLS
|
HB_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
/* buffer var allocations */
|
enum hb_ot_complex_shaper_t;
|
||||||
#define general_category() var1.u8[0] /* unicode general_category (hb_unicode_general_category_t) */
|
|
||||||
#define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */
|
|
||||||
|
|
||||||
|
|
||||||
enum hb_ot_complex_shaper_t {
|
|
||||||
hb_ot_complex_shaper_none,
|
|
||||||
hb_ot_complex_shaper_arabic,
|
|
||||||
hb_ot_complex_shaper_indic
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct hb_ot_shape_plan_t
|
struct hb_ot_shape_plan_t
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,7 +96,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
|
||||||
|
|
||||||
ADD_FEATURES (early_features);
|
ADD_FEATURES (early_features);
|
||||||
|
|
||||||
hb_ot_shape_complex_collect_features (planner, props);
|
hb_ot_shape_complex_collect_features (planner->shaper, &planner->map, props);
|
||||||
|
|
||||||
ADD_FEATURES (common_features);
|
ADD_FEATURES (common_features);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
|
||||||
hb_mask_t global_mask = c->plan->map.get_global_mask ();
|
hb_mask_t global_mask = c->plan->map.get_global_mask ();
|
||||||
c->buffer->reset_masks (global_mask);
|
c->buffer->reset_masks (global_mask);
|
||||||
|
|
||||||
hb_ot_shape_complex_setup_masks (c); /* BUFFER: Clobbers var2 */
|
hb_ot_shape_complex_setup_masks (c->plan->shaper, &c->plan->map, c->buffer); /* BUFFER: Clobbers var2 */
|
||||||
|
|
||||||
for (unsigned int i = 0; i < c->num_user_features; i++)
|
for (unsigned int i = 0; i < c->num_user_features; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue