diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index a74f70750..2c76ae0e8 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -215,7 +215,7 @@ struct Sequence unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE ? HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH : 0; unsigned int count = substitute.len; for (unsigned int i = 0; i < count; i++) { - set_lig_props (c->buffer->cur(), 0, i); + set_lig_props_for_component (c->buffer->cur(), i); c->output_glyph (substitute.array[i], klass); } c->buffer->skip_glyph (); @@ -512,7 +512,7 @@ struct Ligature /* Allocate new ligature id */ unsigned int lig_id = is_a_mark_ligature ? 0 : allocate_lig_id (c->buffer); if (!is_a_mark_ligature) - set_lig_props (c->buffer->cur(), lig_id, 0); + set_lig_props_for_ligature (c->buffer->cur(), lig_id, count); if (skippy_iter.idx < c->buffer->idx + count) /* No input glyphs skipped */ { @@ -536,7 +536,7 @@ struct Ligature while (c->should_mark_skip_current_glyph ()) { if (!is_a_mark_ligature) - set_lig_props (c->buffer->cur(), lig_id, i); + set_lig_props_for_mark (c->buffer->cur(), lig_id, i); c->buffer->next_glyph (); } diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 1c108e042..62ba8d7c4 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -94,17 +94,44 @@ _hb_ot_layout_skip_mark (hb_face_t *face, static inline void set_lig_props (hb_glyph_info_t &info, unsigned int lig_id, unsigned int lig_comp) { - info.lig_props() = (lig_id << 4) | (lig_comp & 0x0F); + info.lig_props() = (lig_id << 5) | (lig_comp & 0x0F); } +static inline void +set_lig_props_for_ligature (hb_glyph_info_t &info, unsigned int lig_id, unsigned int lig_num_comps) +{ + info.lig_props() = (lig_id << 5) | 0x10 | (lig_num_comps & 0x0F); +} +static inline void +set_lig_props_for_mark (hb_glyph_info_t &info, unsigned int lig_id, unsigned int lig_comp) +{ + info.lig_props() = (lig_id << 5) | (lig_comp & 0x0F); +} +static inline void +set_lig_props_for_component (hb_glyph_info_t &info, unsigned int comp) +{ + set_lig_props_for_mark (info, 0, comp); +} + static inline unsigned int get_lig_id (const hb_glyph_info_t &info) { - return info.lig_props() >> 4; + return info.lig_props() >> 5; } static inline unsigned int get_lig_comp (const hb_glyph_info_t &info) { - return info.lig_props() & 0x0F; + if (info.lig_props() & 0x10) + return 0; + else + return info.lig_props() & 0x0F; +} +static inline unsigned int +get_lig_num_comps (const hb_glyph_info_t &info) +{ + if (info.lig_props() & 0x10) + return info.lig_props() & 0x0F; + else + return 1; } static inline bool is_a_ligature (const hb_glyph_info_t &info) @@ -113,7 +140,7 @@ is_a_ligature (const hb_glyph_info_t &info) } static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) { - uint8_t lig_id = buffer->next_serial () & 0x0F; + uint8_t lig_id = buffer->next_serial () & 0x07; if (unlikely (!lig_id)) lig_id = allocate_lig_id (buffer); /* in case of overflow */ return lig_id;