From 1f1c85a54aad8a25a67041cbb9c4277d28c1c761 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 11 Jan 2018 22:43:57 +0100 Subject: [PATCH] [aat] Remove 'mort' support It's dead, Jim! --- src/hb-aat-layout-common-private.hh | 55 ++++--------- src/hb-aat-layout-morx-table.hh | 122 ++++++++-------------------- 2 files changed, 46 insertions(+), 131 deletions(-) diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index fca74ea2cf5..2462701c770 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -477,33 +477,8 @@ struct Lookup }; -struct ClassTable -{ - inline unsigned int get_class (hb_codepoint_t glyph_id) const - { - return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? classArrayZ[glyph_id - firstGlyph] : 1; - } - - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && classArrayZ.sanitize (c, glyphCount)); - } - - protected: - GlyphID firstGlyph; /* First glyph index included in the trimmed array. */ - HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last - * glyph minus the value of firstGlyph plus 1). */ - UnsizedArrayOf - classArrayZ; /* The class codes (indexed by glyph index minus - * firstGlyph). */ - public: - DEFINE_SIZE_ARRAY (4, classArrayZ); -}; - - /* - * (Extended) State Table + * Extended State Table */ template @@ -545,16 +520,14 @@ struct Entry DEFINE_SIZE_STATIC (4); }; -template +template struct StateTable { - typedef typename Types::HBUINT HBUINT; - typedef typename Types::HBUSHORT HBUSHORT; - typedef typename Types::ClassType ClassType; - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const - { return (this+classTable).get_class (glyph_id, num_glyphs); } - + { + const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs); + return v ? *v : 1; + } inline const Entry *get_entries () const { @@ -565,7 +538,7 @@ struct StateTable { if (unlikely (klass >= nClasses)) return nullptr; - const HBUSHORT *states = (this+stateArrayTable).arrayZ; + const HBUINT16 *states = (this+stateArrayTable).arrayZ; const Entry *entries = (this+entryTable).arrayZ; unsigned int entry = states[state * nClasses + klass]; @@ -579,7 +552,7 @@ struct StateTable TRACE_SANITIZE (this); if (unlikely (!c->check_struct (this))) return_trace (false); - const HBUSHORT *states = (this+stateArrayTable).arrayZ; + const HBUINT16 *states = (this+stateArrayTable).arrayZ; const Entry *entries = (this+entryTable).arrayZ; unsigned int num_states = 1; @@ -594,8 +567,8 @@ struct StateTable nClasses * (num_states - state)))) return_trace (false); { /* Sweep new states. */ - const HBUSHORT *stop = &states[num_states * nClasses]; - for (const HBUSHORT *p = &states[state * nClasses]; p < stop; p++) + const HBUINT16 *stop = &states[num_states * nClasses]; + for (const HBUINT16 *p = &states[state * nClasses]; p < stop; p++) num_entries = MAX (num_entries, *p + 1); state = num_states; } @@ -619,13 +592,13 @@ struct StateTable } protected: - HBUINT nClasses; /* Number of classes, which is the number of indices + HBUINT32 nClasses; /* Number of classes, which is the number of indices * in a single line in the state array. */ - OffsetTo + OffsetTo, HBUINT32> classTable; /* Offset to the class table. */ - OffsetTo, HBUINT> + OffsetTo, HBUINT32> stateArrayTable;/* Offset to the state array. */ - OffsetTo >, HBUINT> + OffsetTo >, HBUINT32> entryTable; /* Offset to the entry array. */ public: diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index cc15fddb3ba..95f4245de8e 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -30,7 +30,6 @@ #include "hb-open-type-private.hh" #include "hb-aat-layout-common-private.hh" -#define HB_AAT_TAG_MORT HB_TAG('m','o','r','t') #define HB_AAT_TAG_MORX HB_TAG('m','o','r','x') @@ -39,7 +38,6 @@ namespace AAT { using namespace OT; -template struct RearrangementSubtable { enum Flags { @@ -171,16 +169,13 @@ struct RearrangementSubtable } protected: - StateTable machine; + StateTable machine; public: DEFINE_SIZE_MIN (2); }; -template struct ContextualSubtable { - typedef typename Types::HBUINT HBUINT; - enum Flags { SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ DontAdvance = 0x4000, /* If set, don't advance to the next glyph before @@ -206,7 +201,7 @@ struct ContextualSubtable bool ret = false; unsigned int num_glyphs = c->face->get_num_glyphs (); - const UnsizedOffsetListOf, HBUINT> &subs = this+substitutionTables; + const UnsizedOffsetListOf, HBUINT32> &subs = this+substitutionTables; unsigned int state = 0; unsigned int last_zero = 0; @@ -290,14 +285,13 @@ struct ContextualSubtable } protected: - StateTable machine; - OffsetTo, HBUINT>, HBUINT> - substitutionTables; + StateTable machine; + OffsetTo, HBUINT32>, HBUINT32> + substitutionTables; public: DEFINE_SIZE_MIN (2); }; -template struct LigatureSubtable { inline bool apply (hb_apply_context_t *c) const @@ -315,7 +309,6 @@ struct LigatureSubtable } }; -template struct NoncontextualSubtable { inline bool apply (hb_apply_context_t *c) const @@ -352,7 +345,6 @@ struct NoncontextualSubtable DEFINE_SIZE_MIN (2); }; -template struct InsertionSubtable { inline bool apply (hb_apply_context_t *c) const @@ -392,13 +384,9 @@ struct Feature }; -template struct ChainSubtable { - template struct Chain; - friend struct Chain; - - typedef typename Types::HBUINT HBUINT; + friend struct Chain; inline unsigned int get_size (void) const { return length; } inline unsigned int get_type (void) const { return coverage & 0xFF; } @@ -443,33 +431,30 @@ struct ChainSubtable } protected: - HBUINT length; /* Total subtable length, including this header. */ - HBUINT coverage; /* Coverage flags and subtable type. */ - HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */ + HBUINT32 length; /* Total subtable length, including this header. */ + HBUINT32 coverage; /* Coverage flags and subtable type. */ + HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */ union { - RearrangementSubtable rearrangement; - ContextualSubtable contextual; - LigatureSubtable ligature; - NoncontextualSubtable noncontextual; - InsertionSubtable insertion; + RearrangementSubtable rearrangement; + ContextualSubtable contextual; + LigatureSubtable ligature; + NoncontextualSubtable noncontextual; + InsertionSubtable insertion; } u; public: - DEFINE_SIZE_MIN (2 * sizeof (HBUINT) + 4); + DEFINE_SIZE_MIN (2 * sizeof (HBUINT32) + 4); }; -template struct Chain { - typedef typename Types::HBUINT HBUINT; - inline void apply (hb_apply_context_t *c) const { - const ChainSubtable *subtable = &StructAtOffset > (featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { subtable->apply (c); - subtable = &StructAfter > (*subtable); + subtable = &StructAfter (*subtable); } } @@ -486,13 +471,13 @@ struct Chain if (!c->check_array (featureZ, featureZ[0].static_size, featureCount)) return_trace (false); - const ChainSubtable *subtable = &StructAtOffset > (featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { if (!subtable->sanitize (c)) return_trace (false); - subtable = &StructAfter > (*subtable); + subtable = &StructAfter (*subtable); } return_trace (true); @@ -501,15 +486,15 @@ struct Chain protected: HBUINT32 defaultFlags; /* The default specification for subtables. */ HBUINT32 length; /* Total byte count, including this header. */ - HBUINT featureCount; /* Number of feature subtable entries. */ - HBUINT subtableCount; /* The number of subtables in the chain. */ + HBUINT32 featureCount; /* Number of feature subtable entries. */ + HBUINT32 subtableCount; /* The number of subtables in the chain. */ - Feature featureZ[VAR]; /* Features. */ - ChainSubtable subtableX[VAR]; /* Subtables. */ + Feature featureZ[VAR]; /* Features. */ + ChainSubtable subtableX[VAR]; /* Subtables. */ // subtableGlyphCoverageArray if major == 3 public: - DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT)); + DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT32)); }; @@ -517,22 +502,18 @@ struct Chain * The 'mort'/'morx' Tables */ -template -struct mortmorx +struct morx { - static const hb_tag_t mortTag = HB_AAT_TAG_MORT; - static const hb_tag_t morxTag = HB_AAT_TAG_MORX; - - typedef typename Types::HBUINT HBUINT; + static const hb_tag_t tableTag = HB_AAT_TAG_MORX; inline void apply (hb_apply_context_t *c) const { - const Chain *chain = chains; + const Chain *chain = chains; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { chain->apply (c); - chain = &StructAfter > (*chain); + chain = &StructAfter (*chain); } } @@ -540,17 +521,17 @@ struct mortmorx { TRACE_SANITIZE (this); if (!version.sanitize (c) || - (version.major >> (sizeof (HBUINT) == 4 ? 1 : 0)) != 1 || + (version.major >> (sizeof (HBUINT32) == 4 ? 1 : 0)) != 1 || !chainCount.sanitize (c)) return_trace (false); - const Chain *chain = chains; + const Chain *chain = chains; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { if (!chain->sanitize (c, version.major)) return_trace (false); - chain = &StructAfter > (*chain); + chain = &StructAfter (*chain); } return_trace (true); @@ -561,51 +542,12 @@ struct mortmorx * 1 for mort, 2 or 3 for morx. */ HBUINT32 chainCount; /* Number of metamorphosis chains contained in this * table. */ - Chain chains[VAR]; /* Chains. */ + Chain chains[VAR]; /* Chains. */ public: DEFINE_SIZE_MIN (8); }; -struct MortTypes -{ - static const bool extended = false; - typedef HBUINT16 HBUINT; - typedef HBUINT8 HBUSHORT; - struct ClassType : ClassTable - { - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs HB_UNUSED) const - { - return ClassTable::get_class (glyph_id); - } - }; -}; -struct MorxTypes -{ - static const bool extended = true; - typedef HBUINT32 HBUINT; - typedef HBUINT16 HBUSHORT; - struct ClassType : Lookup - { - inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const - { - const HBUINT16 *v = get_value (glyph_id, num_glyphs); - return v ? *v : 1; - } - }; -}; - -struct mort : mortmorx -{ - static const hb_tag_t tableTag = HB_AAT_TAG_MORT; -}; - -struct morx : mortmorx -{ - static const hb_tag_t tableTag = HB_AAT_TAG_MORX; -}; - - } /* namespace AAT */