Enable 'rtlm' mirroring

This commit is contained in:
Behdad Esfahbod 2010-10-08 20:27:38 -04:00
parent 36925f695d
commit aa9c450bb2
2 changed files with 20 additions and 19 deletions

View File

@ -105,9 +105,7 @@ struct hb_ot_map_t {
hb_ot_map_t (void) : feature_count (0) {} hb_ot_map_t (void) : feature_count (0) {}
void add_feature (hb_tag_t tag, void add_feature (hb_tag_t tag, unsigned int value, bool global)
unsigned int value,
bool global)
{ {
feature_info_t *info = &feature_infos[feature_count++]; feature_info_t *info = &feature_infos[feature_count++];
info->tag = tag; info->tag = tag;
@ -116,11 +114,14 @@ struct hb_ot_map_t {
info->global = global; info->global = global;
} }
inline void add_bool_feature (hb_tag_t tag, bool global = true)
{ add_feature (tag, 1, global); }
HB_INTERNAL void compile (hb_ot_shape_context_t *c); HB_INTERNAL void compile (hb_ot_shape_context_t *c);
hb_mask_t get_global_mask (void) const { return global_mask; } hb_mask_t get_global_mask (void) const { return global_mask; }
hb_mask_t get_mask (hb_tag_t tag, unsigned int *shift) const { hb_mask_t get_mask (hb_tag_t tag, unsigned int *shift = NULL) const {
const feature_map_t *map = (const feature_map_t *) bsearch (&tag, feature_maps, feature_count, sizeof (feature_maps[0]), (hb_compare_func_t) feature_map_t::cmp); const feature_map_t *map = (const feature_map_t *) bsearch (&tag, feature_maps, feature_count, sizeof (feature_maps[0]), (hb_compare_func_t) feature_map_t::cmp);
if (shift) *shift = map ? map->shift : 0; if (shift) *shift = map ? map->shift : 0;
return map ? map->mask : 0; return map ? map->mask : 0;

View File

@ -53,12 +53,12 @@ hb_ot_shape_collect_features (hb_ot_shape_context_t *c)
{ {
switch (c->original_direction) { switch (c->original_direction) {
case HB_DIRECTION_LTR: case HB_DIRECTION_LTR:
c->map->add_feature (HB_TAG ('l','t','r','a'), 1, true); c->map->add_bool_feature (HB_TAG ('l','t','r','a'));
c->map->add_feature (HB_TAG ('l','t','r','m'), 1, true); c->map->add_bool_feature (HB_TAG ('l','t','r','m'));
break; break;
case HB_DIRECTION_RTL: case HB_DIRECTION_RTL:
c->map->add_feature (HB_TAG ('r','t','l','a'), 1, true); c->map->add_bool_feature (HB_TAG ('r','t','l','a'));
c->map->add_feature (HB_TAG ('r','t','l','m'), 1, false); c->map->add_bool_feature (HB_TAG ('r','t','l','m'), false);
break; break;
case HB_DIRECTION_TTB: case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT: case HB_DIRECTION_BTT:
@ -67,7 +67,7 @@ hb_ot_shape_collect_features (hb_ot_shape_context_t *c)
} }
for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++) for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++)
c->map->add_feature (default_features[i], 1, true); c->map->add_bool_feature (default_features[i]);
/* complex */ /* complex */
@ -173,22 +173,22 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
/* Substitute */ /* Substitute */
static void static void
hb_mirror_chars (hb_buffer_t *buffer) hb_mirror_chars (hb_ot_shape_context_t *c)
{ {
hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->v.get_mirroring; hb_unicode_get_mirroring_func_t get_mirroring = c->buffer->unicode->v.get_mirroring;
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) if (HB_DIRECTION_IS_FORWARD (c->buffer->props.direction))
return; return;
// map = c->map.find_feature (HB_TAG ('r','t','l','m')); hb_mask_t rtlm_mask = c->map->get_mask (HB_TAG ('r','t','l','m'));
unsigned int count = buffer->len; unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
hb_codepoint_t codepoint = get_mirroring (buffer->info[i].codepoint); hb_codepoint_t codepoint = get_mirroring (c->buffer->info[i].codepoint);
if (likely (codepoint == buffer->info[i].codepoint)) if (likely (codepoint == c->buffer->info[i].codepoint))
;// buffer->info[i].mask |= map->mask; c->buffer->info[i].mask |= rtlm_mask;
else else
buffer->info[i].codepoint = codepoint; c->buffer->info[i].codepoint = codepoint;
} }
} }
@ -287,7 +287,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
c->buffer->clear_masks (); c->buffer->clear_masks ();
/* Mirroring needs to see the original direction */ /* Mirroring needs to see the original direction */
hb_mirror_chars (c->buffer); hb_mirror_chars (c);
hb_ensure_native_direction (c->buffer); hb_ensure_native_direction (c->buffer);