* is identical to the ligature ID of the found ligature. If yes, we
* can directly use the component index. If not, we attach the mark
* glyph to the last component of the ligature. */
- if (c->buffer->info[j].lig_id() && c->buffer->info[j].lig_id() == c->buffer->info[c->buffer->idx].lig_id() && c->buffer->info[c->buffer->idx].lig_comp())
+ if (get_lig_id (c->buffer->info[j]) &&
+ get_lig_id (c->buffer->info[j]) == get_lig_id (c->buffer->info[c->buffer->idx]) &&
+ get_lig_comp (c->buffer->info[c->buffer->idx]) > 0)
{
- comp_index = c->buffer->info[c->buffer->idx].lig_comp() - 1;
+ comp_index = get_lig_comp (c->buffer->info[c->buffer->idx]) - 1;
if (comp_index >= comp_count)
comp_index = comp_count - 1;
}
/* Two marks match only if they belong to the same base, or same component
* of the same ligature. That is, the component numbers must match, and
* if those are non-zero, the ligid number should also match. */
- if ((c->buffer->info[j].lig_comp() != c->buffer->info[c->buffer->idx].lig_comp()) ||
- (c->buffer->info[j].lig_comp() && c->buffer->info[j].lig_id() != c->buffer->info[c->buffer->idx].lig_id()))
+ if ((get_lig_comp (c->buffer->info[j]) != get_lig_comp (c->buffer->info[c->buffer->idx])) ||
+ (get_lig_comp (c->buffer->info[j]) > 0 &&
+ get_lig_id (c->buffer->info[j]) != get_lig_id (c->buffer->info[c->buffer->idx])))
return false;
unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
for (unsigned int i = 0; i < len; i++)
fix_mark_attachment (pos, i, direction);
- HB_BUFFER_DEALLOCATE_VAR (buffer, lig_comp);
- HB_BUFFER_DEALLOCATE_VAR (buffer, lig_id);
+ HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_DEALLOCATE_VAR (buffer, props_cache);
}
/* Allocate new ligature id */
unsigned int lig_id = allocate_lig_id (c->buffer);
- c->buffer->info[c->buffer->idx].lig_comp() = 0;
- c->buffer->info[c->buffer->idx].lig_id() = lig_id;
+ set_lig_props (c->buffer->info[c->buffer->idx], lig_id, 0);
if (skippy_iter.idx < c->buffer->idx + count) /* No input glyphs skipped */
{
{
while (c->should_mark_skip_current_glyph ())
{
- c->buffer->info[c->buffer->idx].lig_comp() = i;
- c->buffer->info[c->buffer->idx].lig_id() = lig_id;
+ set_lig_props (c->buffer->info[c->buffer->idx], lig_id, i);
c->replace_glyph (c->buffer->info[c->buffer->idx].codepoint);
}
GSUB::substitute_start (hb_buffer_t *buffer)
{
HB_BUFFER_ALLOCATE_VAR (buffer, props_cache);
- HB_BUFFER_ALLOCATE_VAR (buffer, lig_id);
- HB_BUFFER_ALLOCATE_VAR (buffer, lig_comp);
+ HB_BUFFER_ALLOCATE_VAR (buffer, lig_props);
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
- buffer->info[i].props_cache() = buffer->info[i].lig_id() = buffer->info[i].lig_comp() = 0;
+ buffer->info[i].props_cache() = buffer->info[i].lig_props() = 0;
}
void
/* buffer var allocations */
-#define lig_id() var2.u8[2] /* unique ligature id */
-#define lig_comp() var2.u8[3] /* component number in the ligature (0 = base) */
+#define lig_props() var2.u8[3]
+
+/* unique ligature id */
+/* component number in the ligature (0 = base) */
+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);
+}
+static inline unsigned int
+get_lig_id (hb_glyph_info_t &info)
+{
+ return info.lig_props() >> 4;
+}
+static inline unsigned int
+get_lig_comp (hb_glyph_info_t &info)
+{
+ return info.lig_props() & 0x0F;
+}
static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) {
- uint8_t lig_id = buffer->next_serial ();
- if (unlikely (!lig_id)) lig_id = buffer->next_serial (); /* in case of overflow */
+ uint8_t lig_id = buffer->next_serial () & 0x0F;
+ if (unlikely (!lig_id))
+ lig_id = allocate_lig_id (buffer); /* in case of overflow */
return lig_id;
}