From fe263272a2b26204bc39829a94d90ab537517f3f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Oct 2010 16:51:02 -0400 Subject: [PATCH] Move setting lig_id/component out of buffer and to the gsub code --- src/hb-buffer-private.hh | 30 ++++++------------ src/hb-buffer.cc | 52 ++++++-------------------------- src/hb-ot-layout-gsub-private.hh | 27 ++++++++++------- 3 files changed, 34 insertions(+), 75 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index b5ba57d87..97da61037 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -62,23 +62,17 @@ HB_INTERNAL void _hb_buffer_add_output_glyphs (hb_buffer_t *buffer, unsigned int num_in, unsigned int num_out, - const hb_codepoint_t *glyph_data, - unsigned short component, - unsigned short ligID); + const hb_codepoint_t *glyph_data); HB_INTERNAL void _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, unsigned int num_in, unsigned int num_out, - const uint16_t *glyph_data_be, - unsigned short component, - unsigned short ligID); + const uint16_t *glyph_data_be); HB_INTERNAL void _hb_buffer_add_output_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index, - unsigned short component, - unsigned short ligID); + hb_codepoint_t glyph_index); HB_INTERNAL void _hb_buffer_next_glyph (hb_buffer_t *buffer); @@ -136,20 +130,14 @@ struct _hb_buffer_t { inline void next_glyph (void) { _hb_buffer_next_glyph (this); } inline void add_output_glyphs (unsigned int num_in, unsigned int num_out, - const hb_codepoint_t *glyph_data, - unsigned short component, - unsigned short ligID) - { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); } + const hb_codepoint_t *glyph_data) + { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data); } inline void add_output_glyphs_be16 (unsigned int num_in, unsigned int num_out, - const uint16_t *glyph_data_be, - unsigned short component, - unsigned short ligID) - { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); } - inline void add_output_glyph (hb_codepoint_t glyph_index, - unsigned short component = 0xFFFF, - unsigned short ligID = 0xFFFF) - { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); } + const uint16_t *glyph_data_be) + { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be); } + inline void add_output_glyph (hb_codepoint_t glyph_index) + { _hb_buffer_add_output_glyph (this, glyph_index); } inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); } inline void reset_masks (hb_mask_t mask) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 7b15de480..7eb037069 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -314,14 +314,8 @@ void _hb_buffer_add_output_glyphs (hb_buffer_t *buffer, unsigned int num_in, unsigned int num_out, - const hb_codepoint_t *glyph_data, - unsigned short component, - unsigned short lig_id) + const hb_codepoint_t *glyph_data) { - unsigned int i; - unsigned int mask; - unsigned int cluster; - if (buffer->out_info != buffer->info || buffer->out_len + num_out > buffer->i + num_in) { @@ -329,21 +323,13 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer, return; } - mask = buffer->info[buffer->i].mask; - cluster = buffer->info[buffer->i].cluster; - if (component == 0xFFFF) - component = buffer->info[buffer->i].component(); - if (lig_id == 0xFFFF) - lig_id = buffer->info[buffer->i].lig_id(); + hb_glyph_info_t orig_info = buffer->info[buffer->i]; - for (i = 0; i < num_out; i++) + for (unsigned int i = 0; i < num_out; i++) { hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; + *info = orig_info; info->codepoint = glyph_data[i]; - info->mask = mask; - info->cluster = cluster; - info->component() = component; - info->lig_id() = lig_id; info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; } @@ -355,14 +341,8 @@ void _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, unsigned int num_in, unsigned int num_out, - const uint16_t *glyph_data_be, - unsigned short component, - unsigned short lig_id) + const uint16_t *glyph_data_be) { - unsigned int i; - unsigned int mask; - unsigned int cluster; - if (buffer->out_info != buffer->info || buffer->out_len + num_out > buffer->i + num_in) { @@ -370,21 +350,13 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, return; } - mask = buffer->info[buffer->i].mask; - cluster = buffer->info[buffer->i].cluster; - if (component == 0xFFFF) - component = buffer->info[buffer->i].component(); - if (lig_id == 0xFFFF) - lig_id = buffer->info[buffer->i].lig_id(); + hb_glyph_info_t orig_info = buffer->info[buffer->i]; - for (i = 0; i < num_out; i++) + for (unsigned int i = 0; i < num_out; i++) { hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; + *info = orig_info; info->codepoint = hb_be_uint16 (glyph_data_be[i]); - info->mask = mask; - info->cluster = cluster; - info->component() = component; - info->lig_id() = lig_id; info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; } @@ -394,9 +366,7 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, void _hb_buffer_add_output_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index, - unsigned short component, - unsigned short lig_id) + hb_codepoint_t glyph_index) { hb_glyph_info_t *info; @@ -410,10 +380,6 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer, info = &buffer->out_info[buffer->out_len]; info->codepoint = glyph_index; - if (component != 0xFFFF) - info->component() = component; - if (lig_id != 0xFFFF) - info->lig_id() = lig_id; info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; buffer->i++; diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index 89d2fb47b..829217c9e 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -164,9 +164,7 @@ struct Sequence if (unlikely (!substitute.len)) return false; - c->buffer->add_output_glyphs_be16 (1, - substitute.len, (const uint16_t *) substitute.array, - 0xFFFF, 0xFFFF); + c->buffer->add_output_glyphs_be16 (1, substitute.len, (const uint16_t *) substitute.array); /* This is a guess only ... */ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face)) @@ -392,15 +390,18 @@ struct Ligature is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE); + /* Allocate new ligature id */ + unsigned int lig_id = c->buffer->allocate_lig_id (); + c->buffer->info[c->buffer->i].component() = 0; + c->buffer->info[c->buffer->i].lig_id() = lig_id; + if (j == c->buffer->i + i) /* No input glyphs skipped */ - c->buffer->add_output_glyphs_be16 (i, - 1, (const uint16_t *) &ligGlyph, - 0, - c->buffer->allocate_lig_id ()); + { + c->buffer->add_output_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph); + } else { - unsigned int lig_id = c->buffer->allocate_lig_id (); - c->buffer->add_output_glyph (ligGlyph, 0, lig_id); + c->buffer->add_output_glyph (ligGlyph); /* Now we must do a second loop to copy the skipped glyphs to `out' and assign component values to it. We start with the @@ -409,10 +410,14 @@ struct Ligature value it is later possible to check whether a specific component value really belongs to a given ligature. */ - for ( i = 1; i < count; i++ ) + for (i = 1; i < count; i++) { while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, NULL)) - c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint, i, lig_id); + { + c->buffer->info[c->buffer->i].component() = i; + c->buffer->info[c->buffer->i].lig_id() = lig_id; + c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint); + } /* Skip the base glyph */ c->buffer->i++;