[mort] Some more

This commit is contained in:
Behdad Esfahbod 2018-10-31 15:06:12 -07:00
parent 3087046d31
commit cbaff4ef19
1 changed files with 16 additions and 18 deletions

View File

@ -45,6 +45,14 @@ namespace AAT {
using namespace OT; using namespace OT;
template <typename T>
static inline unsigned int offsetToIndex (unsigned int offset,
const void *base,
const T *array)
{
return (offset - ((const char *) array - (const char *) base)) / sizeof (T);
}
template <typename Types> template <typename Types>
struct RearrangementSubtable struct RearrangementSubtable
{ {
@ -255,11 +263,10 @@ struct ContextualSubtable
} }
else else
{ {
unsigned int offset = 2 * (entry->data.markIndex + buffer->info[mark].codepoint); unsigned int offset = entry->data.markIndex + buffer->info[mark].codepoint;
replacement = &StructAtOffset<GlyphID> (table, offset); const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
if ((const void *) replacement < (const void *) subs || replacement = &subs_old[offsetToIndex (offset * 2, table, subs_old.arrayZ)];
!replacement->sanitize (&c->sanitizer) || if (!replacement->sanitize (&c->sanitizer) || !*replacement)
!*replacement)
replacement = nullptr; replacement = nullptr;
} }
if (replacement) if (replacement)
@ -281,11 +288,10 @@ struct ContextualSubtable
} }
else else
{ {
unsigned int offset = 2 * (entry->data.currentIndex + buffer->info[idx].codepoint); unsigned int offset = entry->data.currentIndex + buffer->info[idx].codepoint;
replacement = &StructAtOffset<GlyphID> (table, offset); const UnsizedArrayOf<GlyphID> &subs_old = (const UnsizedArrayOf<GlyphID> &) subs;
if ((const void *) replacement < (const void *) subs || replacement = &subs_old[offsetToIndex (offset * 2, table, subs_old.arrayZ)];
!replacement->sanitize (&c->sanitizer) || if (!replacement->sanitize (&c->sanitizer) || !*replacement)
!*replacement)
replacement = nullptr; replacement = nullptr;
} }
if (replacement) if (replacement)
@ -457,14 +463,6 @@ struct LigatureSubtable
ligature (table+table->ligature), ligature (table+table->ligature),
match_length (0) {} match_length (0) {}
template <typename T>
static inline unsigned int offsetToIndex (unsigned int offset,
const void *base,
const T *array)
{
return (offset - ((const char *) array - (const char *) base)) / sizeof (T);
}
inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED, inline bool is_actionable (StateTableDriver<Types, EntryData> *driver HB_UNUSED,
const Entry<EntryData> *entry) const Entry<EntryData> *entry)
{ {