[morx] Add a few debug messages to Ligature chain

This commit is contained in:
Behdad Esfahbod 2018-10-23 01:32:08 -07:00
parent 0e5bcdef7f
commit 531f9822b2
1 changed files with 10 additions and 0 deletions

View File

@ -373,6 +373,7 @@ struct LigatureSubtable
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry->flags;
DEBUG_MSG (APPLY, nullptr, "Ligature transition at %d", buffer->idx);
if (flags & SetComponent) if (flags & SetComponent)
{ {
if (unlikely (match_length >= ARRAY_LENGTH (match_positions))) if (unlikely (match_length >= ARRAY_LENGTH (match_positions)))
@ -383,10 +384,12 @@ struct LigatureSubtable
match_length--; match_length--;
match_positions[match_length++] = buffer->out_len; match_positions[match_length++] = buffer->out_len;
DEBUG_MSG (APPLY, nullptr, "Set component at %d", buffer->out_len);
} }
if (flags & PerformAction) if (flags & PerformAction)
{ {
DEBUG_MSG (APPLY, nullptr, "Perform action with %d", match_length);
unsigned int end = buffer->out_len; unsigned int end = buffer->out_len;
unsigned int action_idx = entry->data.ligActionIndex; unsigned int action_idx = entry->data.ligActionIndex;
unsigned int action; unsigned int action;
@ -404,10 +407,12 @@ struct LigatureSubtable
if (unlikely (!cursor)) if (unlikely (!cursor))
{ {
/* Stack underflow. Clear the stack. */ /* Stack underflow. Clear the stack. */
DEBUG_MSG (APPLY, nullptr, "Stack underflow");
match_length = 0; match_length = 0;
break; break;
} }
DEBUG_MSG (APPLY, nullptr, "Moving to stack position %d", cursor - 1);
buffer->move_to (match_positions[--cursor]); buffer->move_to (match_positions[--cursor]);
const HBUINT32 &actionData = ligAction[action_idx]; const HBUINT32 &actionData = ligAction[action_idx];
@ -426,17 +431,22 @@ struct LigatureSubtable
if (unlikely (!componentData.sanitize (&c->sanitizer))) return false; if (unlikely (!componentData.sanitize (&c->sanitizer))) return false;
ligature_idx += componentData; ligature_idx += componentData;
DEBUG_MSG (APPLY, nullptr, "Action store %d last %d",
bool (action & LigActionStore),
bool (action & LigActionLast));
if (action & (LigActionStore | LigActionLast)) if (action & (LigActionStore | LigActionLast))
{ {
const GlyphID &ligatureData = ligature[ligature_idx]; const GlyphID &ligatureData = ligature[ligature_idx];
if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false; if (unlikely (!ligatureData.sanitize (&c->sanitizer))) return false;
hb_codepoint_t lig = ligatureData; hb_codepoint_t lig = ligatureData;
DEBUG_MSG (APPLY, nullptr, "Produced ligature %d", lig);
buffer->replace_glyph (lig); buffer->replace_glyph (lig);
/* Now go and delete all subsequent components. */ /* Now go and delete all subsequent components. */
while (match_length - 1 > cursor) while (match_length - 1 > cursor)
{ {
DEBUG_MSG (APPLY, nullptr, "Skipping ligature component");
buffer->move_to (match_positions[--match_length]); buffer->move_to (match_positions[--match_length]);
buffer->skip_glyph (); buffer->skip_glyph ();
end--; end--;