[AAT] Minor

This commit is contained in:
Behdad Esfahbod 2019-01-24 17:21:41 +01:00
parent 299eca0c3b
commit 1ec90514f6
3 changed files with 59 additions and 59 deletions

View File

@ -753,7 +753,7 @@ struct StateTableDriver
machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) : machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
(unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT; (unsigned) StateTable<Types, EntryData>::CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx); DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const Entry<EntryData> *entry = &machine.get_entry (state, klass); const Entry<EntryData> &entry = machine.get_entry (state, klass);
/* Unsafe-to-break before this if not in state 0, as things might /* Unsafe-to-break before this if not in state 0, as things might
* go differently if we start from state 0 here. * go differently if we start from state 0 here.
@ -764,15 +764,15 @@ struct StateTableDriver
/* If there's no action and we're just epsilon-transitioning to state 0, /* If there's no action and we're just epsilon-transitioning to state 0,
* safe to break. */ * safe to break. */
if (c->is_actionable (this, entry) || if (c->is_actionable (this, entry) ||
!(entry->newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT && !(entry.newState == StateTable<Types, EntryData>::STATE_START_OF_TEXT &&
entry->flags == context_t::DontAdvance)) entry.flags == context_t::DontAdvance))
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1); buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
} }
/* Unsafe-to-break if end-of-text would kick in here. */ /* Unsafe-to-break if end-of-text would kick in here. */
if (buffer->idx + 2 <= buffer->len) if (buffer->idx + 2 <= buffer->len)
{ {
const Entry<EntryData> *end_entry = &machine.get_entry (state, StateTable<Types, EntryData>::CLASS_END_OF_TEXT); const Entry<EntryData> &end_entry = machine.get_entry (state, StateTable<Types, EntryData>::CLASS_END_OF_TEXT);
if (c->is_actionable (this, end_entry)) if (c->is_actionable (this, end_entry))
buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); buffer->unsafe_to_break (buffer->idx, buffer->idx + 2);
} }
@ -780,13 +780,13 @@ struct StateTableDriver
if (unlikely (!c->transition (this, entry))) if (unlikely (!c->transition (this, entry)))
break; break;
state = machine.new_state (entry->newState); state = machine.new_state (entry.newState);
DEBUG_MSG (APPLY, nullptr, "s%d", state); DEBUG_MSG (APPLY, nullptr, "s%d", state);
if (buffer->idx == buffer->len) if (buffer->idx == buffer->len)
break; break;
if (!(entry->flags & context_t::DontAdvance) || buffer->max_ops-- <= 0) if (!(entry.flags & context_t::DontAdvance) || buffer->max_ops-- <= 0)
buffer->next_glyph (); buffer->next_glyph ();
} }

View File

@ -170,11 +170,11 @@ struct Format1Entry<true>
DEFINE_SIZE_STATIC (2); DEFINE_SIZE_STATIC (2);
}; };
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->data.kernActionIndex != 0xFFFF; } { return entry.data.kernActionIndex != 0xFFFF; }
static unsigned int kernActionIndex (const Entry<EntryData> *entry) static unsigned int kernActionIndex (const Entry<EntryData> &entry)
{ return entry->data.kernActionIndex; } { return entry.data.kernActionIndex; }
}; };
template <> template <>
struct Format1Entry<false> struct Format1Entry<false>
@ -192,11 +192,11 @@ struct Format1Entry<false>
typedef void EntryData; typedef void EntryData;
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
static unsigned int kernActionIndex (const Entry<EntryData> *entry) static unsigned int kernActionIndex (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
}; };
template <typename KernSubTableHeader> template <typename KernSubTableHeader>
@ -228,15 +228,15 @@ struct KerxSubTableFormat1
crossStream (table->header.coverage & table->header.CrossStream) {} crossStream (table->header.coverage & table->header.CrossStream) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return Format1EntryT::performAction (entry); return Format1EntryT::performAction (entry);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
if (flags & Format1EntryT::Reset) if (flags & Format1EntryT::Reset)
depth = 0; depth = 0;
@ -498,16 +498,16 @@ struct KerxSubTableFormat4
mark (0) {} mark (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return entry->data.ankrActionIndex != 0xFFFF; return entry.data.ankrActionIndex != 0xFFFF;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
if (mark_set && entry->data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len) if (mark_set && entry.data.ankrActionIndex != 0xFFFF && buffer->idx < buffer->len)
{ {
hb_glyph_position_t &o = buffer->cur_pos(); hb_glyph_position_t &o = buffer->cur_pos();
switch (action_type) switch (action_type)
@ -515,7 +515,7 @@ struct KerxSubTableFormat4
case 0: /* Control Point Actions.*/ case 0: /* Control Point Actions.*/
{ {
/* indexed into glyph outline. */ /* indexed into glyph outline. */
const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 2)) if (!c->sanitizer.check_array (data, 2))
return false; return false;
HB_UNUSED unsigned int markControlPoint = *data++; HB_UNUSED unsigned int markControlPoint = *data++;
@ -542,7 +542,7 @@ struct KerxSubTableFormat4
case 1: /* Anchor Point Actions. */ case 1: /* Anchor Point Actions. */
{ {
/* Indexed into 'ankr' table. */ /* Indexed into 'ankr' table. */
const HBUINT16 *data = &ankrData[entry->data.ankrActionIndex]; const HBUINT16 *data = &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 2)) if (!c->sanitizer.check_array (data, 2))
return false; return false;
unsigned int markAnchorPoint = *data++; unsigned int markAnchorPoint = *data++;
@ -561,7 +561,7 @@ struct KerxSubTableFormat4
case 2: /* Control Point Coordinate Actions. */ case 2: /* Control Point Coordinate Actions. */
{ {
const FWORD *data = (const FWORD *) &ankrData[entry->data.ankrActionIndex]; const FWORD *data = (const FWORD *) &ankrData[entry.data.ankrActionIndex];
if (!c->sanitizer.check_array (data, 4)) if (!c->sanitizer.check_array (data, 4))
return false; return false;
int markX = *data++; int markX = *data++;
@ -579,7 +579,7 @@ struct KerxSubTableFormat4
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT; buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
} }
if (entry->flags & Mark) if (entry.flags & Mark)
{ {
mark_set = true; mark_set = true;
mark = buffer->idx; mark = buffer->idx;

View File

@ -74,15 +74,15 @@ struct RearrangementSubtable
start (0), end (0) {} start (0), end (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return (entry->flags & Verb) && start < end; return (entry.flags & Verb) && start < end;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
if (flags & MarkFirst) if (flags & MarkFirst)
start = buffer->idx; start = buffer->idx;
@ -223,17 +223,17 @@ struct ContextualSubtable
subs (table+table->substitutionTables) {} subs (table+table->substitutionTables) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver, bool is_actionable (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
if (buffer->idx == buffer->len && !mark_set) if (buffer->idx == buffer->len && !mark_set)
return false; return false;
return entry->data.markIndex != 0xFFFF || entry->data.currentIndex != 0xFFFF; return entry.data.markIndex != 0xFFFF || entry.data.currentIndex != 0xFFFF;
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
@ -247,15 +247,15 @@ struct ContextualSubtable
replacement = nullptr; replacement = nullptr;
if (Types::extended) if (Types::extended)
{ {
if (entry->data.markIndex != 0xFFFF) if (entry.data.markIndex != 0xFFFF)
{ {
const Lookup<GlyphID> &lookup = subs[entry->data.markIndex]; const Lookup<GlyphID> &lookup = subs[entry.data.markIndex];
replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs); replacement = lookup.get_value (buffer->info[mark].codepoint, driver->num_glyphs);
} }
} }
else else
{ {
unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint; unsigned int offset = entry.data.markIndex + buffer->info[mark].codepoint;
const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
if (!replacement->sanitize (&c->sanitizer) || !*replacement) if (!replacement->sanitize (&c->sanitizer) || !*replacement)
@ -272,15 +272,15 @@ struct ContextualSubtable
unsigned int idx = MIN (buffer->idx, buffer->len - 1); unsigned int idx = MIN (buffer->idx, buffer->len - 1);
if (Types::extended) if (Types::extended)
{ {
if (entry->data.currentIndex != 0xFFFF) if (entry.data.currentIndex != 0xFFFF)
{ {
const Lookup<GlyphID> &lookup = subs[entry->data.currentIndex]; const Lookup<GlyphID> &lookup = subs[entry.data.currentIndex];
replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs); replacement = lookup.get_value (buffer->info[idx].codepoint, driver->num_glyphs);
} }
} }
else else
{ {
unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint; unsigned int offset = entry.data.currentIndex + buffer->info[idx].codepoint;
const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs; const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)]; replacement = &subs_old[Types::wordOffsetToIndex (offset, table, subs_old.arrayZ)];
if (!replacement->sanitize (&c->sanitizer) || !*replacement) if (!replacement->sanitize (&c->sanitizer) || !*replacement)
@ -292,7 +292,7 @@ struct ContextualSubtable
ret = true; ret = true;
} }
if (entry->flags & SetMark) if (entry.flags & SetMark)
{ {
mark_set = true; mark_set = true;
mark = buffer->idx; mark = buffer->idx;
@ -385,11 +385,11 @@ struct LigatureEntry<true>
DEFINE_SIZE_STATIC (2); DEFINE_SIZE_STATIC (2);
}; };
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & PerformAction; } { return entry.flags & PerformAction; }
static unsigned int ligActionIndex (const Entry<EntryData> *entry) static unsigned int ligActionIndex (const Entry<EntryData> &entry)
{ return entry->data.ligActionIndex; } { return entry.data.ligActionIndex; }
}; };
template <> template <>
struct LigatureEntry<false> struct LigatureEntry<false>
@ -407,11 +407,11 @@ struct LigatureEntry<false>
typedef void EntryData; typedef void EntryData;
static bool performAction (const Entry<EntryData> *entry) static bool performAction (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
static unsigned int ligActionIndex (const Entry<EntryData> *entry) static unsigned int ligActionIndex (const Entry<EntryData> &entry)
{ return entry->flags & Offset; } { return entry.flags & Offset; }
}; };
@ -453,17 +453,17 @@ struct LigatureSubtable
match_length (0) {} match_length (0) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return LigatureEntryT::performAction (entry); return LigatureEntryT::performAction (entry);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
DEBUG_MSG (APPLY, nullptr, "Ligature transition at %u", buffer->idx); DEBUG_MSG (APPLY, nullptr, "Ligature transition at %u", buffer->idx);
if (entry->flags & LigatureEntryT::SetComponent) if (entry.flags & LigatureEntryT::SetComponent)
{ {
if (unlikely (match_length >= ARRAY_LENGTH (match_positions))) if (unlikely (match_length >= ARRAY_LENGTH (match_positions)))
return false; return false;
@ -718,23 +718,23 @@ struct InsertionSubtable
insertionAction (table+table->insertionAction) {} insertionAction (table+table->insertionAction) {}
bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
return (entry->flags & (CurrentInsertCount | MarkedInsertCount)) && return (entry.flags & (CurrentInsertCount | MarkedInsertCount)) &&
(entry->data.currentInsertIndex != 0xFFFF ||entry->data.markedInsertIndex != 0xFFFF); (entry.data.currentInsertIndex != 0xFFFF ||entry.data.markedInsertIndex != 0xFFFF);
} }
bool transition (StateTableDriver<Types, EntryData> *driver, bool transition (StateTableDriver<Types, EntryData> *driver,
const Entry<EntryData> *entry) const Entry<EntryData> &entry)
{ {
hb_buffer_t *buffer = driver->buffer; hb_buffer_t *buffer = driver->buffer;
unsigned int flags = entry->flags; unsigned int flags = entry.flags;
unsigned mark_loc = buffer->out_len; unsigned mark_loc = buffer->out_len;
if (entry->data.markedInsertIndex != 0xFFFF) if (entry.data.markedInsertIndex != 0xFFFF)
{ {
unsigned int count = (flags & MarkedInsertCount); unsigned int count = (flags & MarkedInsertCount);
unsigned int start = entry->data.markedInsertIndex; unsigned int start = entry.data.markedInsertIndex;
const GlyphID *glyphs = &insertionAction[start]; const GlyphID *glyphs = &insertionAction[start];
if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false; if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false;
@ -759,10 +759,10 @@ struct InsertionSubtable
if (flags & SetMark) if (flags & SetMark)
mark = mark_loc; mark = mark_loc;
if (entry->data.currentInsertIndex != 0xFFFF) if (entry.data.currentInsertIndex != 0xFFFF)
{ {
unsigned int count = (flags & CurrentInsertCount) >> 5; unsigned int count = (flags & CurrentInsertCount) >> 5;
unsigned int start = entry->data.currentInsertIndex; unsigned int start = entry.data.currentInsertIndex;
const GlyphID *glyphs = &insertionAction[start]; const GlyphID *glyphs = &insertionAction[start];
if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false; if (unlikely (!c->sanitizer.check_array (glyphs, count))) return false;