More massaging

This commit is contained in:
Behdad Esfahbod 2012-08-02 09:44:18 -04:00
parent 16c6a27b4b
commit 3e38c0f288
4 changed files with 27 additions and 36 deletions

View File

@ -62,15 +62,11 @@ struct hb_ot_map_t
{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
};
typedef void (*pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb_buffer_t *buffer, void *user_data);
typedef struct {
pause_func_t func;
void *user_data;
} pause_callback_t;
typedef void (*pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb_buffer_t *buffer);
struct pause_map_t {
unsigned int num_lookups; /* Cumulative */
pause_callback_t callback;
pause_func_t callback;
};
@ -156,10 +152,10 @@ struct hb_ot_map_builder_t
inline void add_bool_feature (hb_tag_t tag, bool global = true)
{ add_feature (tag, 1, global); }
inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func, void *user_data)
{ add_pause (0, pause_func, user_data); }
inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func, void *user_data)
{ add_pause (1, pause_func, user_data); }
inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func)
{ add_pause (0, pause_func); }
inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func)
{ add_pause (1, pause_func); }
HB_INTERNAL void compile (hb_face_t *face,
const hb_segment_properties_t *props,
@ -187,10 +183,10 @@ struct hb_ot_map_builder_t
struct pause_info_t {
unsigned int stage;
hb_ot_map_t::pause_callback_t callback;
hb_ot_map_t::pause_func_t callback;
};
HB_INTERNAL void add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func, void *user_data);
HB_INTERNAL void add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func);
unsigned int current_stage[2]; /* GSUB/GPOS */
hb_prealloced_array_t<feature_info_t,16> feature_infos;

View File

@ -87,8 +87,8 @@ void hb_ot_map_t::substitute (hb_font_t *font, hb_buffer_t *buffer) const
buffer->clear_output ();
if (pause->callback.func)
pause->callback.func (this, font, buffer, pause->callback.user_data);
if (pause->callback)
pause->callback (this, font, buffer);
}
for (; i < lookups[table_index].len; i++)
@ -105,8 +105,8 @@ void hb_ot_map_t::position (hb_font_t *font, hb_buffer_t *buffer) const
for (; i < pause->num_lookups; i++)
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
if (pause->callback.func)
pause->callback.func (this, font, buffer, pause->callback.user_data);
if (pause->callback)
pause->callback (this, font, buffer);
}
for (; i < lookups[table_index].len; i++)
@ -129,13 +129,12 @@ void hb_ot_map_t::substitute_closure (hb_face_t *face,
hb_ot_layout_substitute_closure_lookup (face, glyphs, lookups[table_index][i].index);
}
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func, void *user_data)
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
{
pause_info_t *p = pauses[table_index].push ();
if (likely (p)) {
p->stage = current_stage[table_index];
p->callback.func = pause_func;
p->callback.user_data = user_data;
p->callback = pause_func;
}
current_stage[table_index]++;
@ -249,8 +248,8 @@ hb_ot_map_builder_t::compile (hb_face_t *face,
feature_infos.shrink (0); /* Done with these */
add_gsub_pause (NULL, NULL);
add_gpos_pause (NULL, NULL);
add_gsub_pause (NULL);
add_gpos_pause (NULL);
for (unsigned int table_index = 0; table_index < 2; table_index++) {
hb_tag_t table_tag = table_tags[table_index];

View File

@ -182,19 +182,19 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
map->add_bool_feature (HB_TAG('c','c','m','p'));
map->add_bool_feature (HB_TAG('l','o','c','l'));
map->add_gsub_pause (NULL, NULL);
map->add_gsub_pause (NULL);
unsigned int num_features = plan->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
for (unsigned int i = 0; i < num_features; i++)
map->add_bool_feature (arabic_syriac_features[i], false);
map->add_gsub_pause (NULL, NULL);
map->add_gsub_pause (NULL);
map->add_bool_feature (HB_TAG('r','l','i','g'));
map->add_gsub_pause (NULL, NULL);
map->add_gsub_pause (NULL);
map->add_bool_feature (HB_TAG('c','a','l','t'));
map->add_gsub_pause (NULL, NULL);
map->add_gsub_pause (NULL);
/* ArabicOT spec enables 'cswh' for Arabic where as for basic shaper it's disabled by default. */
map->add_bool_feature (HB_TAG('c','s','w','h'));

View File

@ -194,13 +194,11 @@ indic_other_features[] =
static void
initial_reordering (const hb_ot_map_t *map,
hb_font_t *font,
hb_buffer_t *buffer,
void *user_data HB_UNUSED);
hb_buffer_t *buffer);
static void
final_reordering (const hb_ot_map_t *map,
hb_font_t *font,
hb_buffer_t *buffer,
void *user_data HB_UNUSED);
hb_buffer_t *buffer);
static void
collect_features_indic (hb_ot_shape_planner_t *plan)
@ -212,14 +210,14 @@ collect_features_indic (hb_ot_shape_planner_t *plan)
* there is a use of it, it's typically at the beginning. */
map->add_bool_feature (HB_TAG('c','c','m','p'));
map->add_gsub_pause (initial_reordering, NULL);
map->add_gsub_pause (initial_reordering);
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++) {
map->add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global);
map->add_gsub_pause (NULL, NULL);
map->add_gsub_pause (NULL);
}
map->add_gsub_pause (final_reordering, NULL);
map->add_gsub_pause (final_reordering);
for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++)
map->add_bool_feature (indic_other_features[i].tag, indic_other_features[i].is_global);
@ -697,8 +695,7 @@ initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
static void
initial_reordering (const hb_ot_map_t *map,
hb_font_t *font,
hb_buffer_t *buffer,
void *user_data HB_UNUSED)
hb_buffer_t *buffer)
{
update_consonant_positions (map, buffer, font);
@ -1062,8 +1059,7 @@ final_reordering_syllable (hb_buffer_t *buffer,
static void
final_reordering (const hb_ot_map_t *map,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer,
void *user_data HB_UNUSED)
hb_buffer_t *buffer)
{
unsigned int count = buffer->len;
if (!count) return;