[aat] Remove 'mort' support

It's dead, Jim!
This commit is contained in:
Behdad Esfahbod 2018-01-11 22:43:57 +01:00
parent 7e2fed6d73
commit 1f1c85a54a
2 changed files with 46 additions and 131 deletions

View File

@ -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<HBUINT8>
classArrayZ; /* The class codes (indexed by glyph index minus
* firstGlyph). */
public:
DEFINE_SIZE_ARRAY (4, classArrayZ);
};
/* /*
* (Extended) State Table * Extended State Table
*/ */
template <typename T> template <typename T>
@ -545,16 +520,14 @@ struct Entry<void>
DEFINE_SIZE_STATIC (4); DEFINE_SIZE_STATIC (4);
}; };
template <typename Types, typename Extra> template <typename Extra>
struct StateTable 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 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<Extra> *get_entries () const inline const Entry<Extra> *get_entries () const
{ {
@ -565,7 +538,7 @@ struct StateTable
{ {
if (unlikely (klass >= nClasses)) return nullptr; if (unlikely (klass >= nClasses)) return nullptr;
const HBUSHORT *states = (this+stateArrayTable).arrayZ; const HBUINT16 *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ;
unsigned int entry = states[state * nClasses + klass]; unsigned int entry = states[state * nClasses + klass];
@ -579,7 +552,7 @@ struct StateTable
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (unlikely (!c->check_struct (this))) return_trace (false); if (unlikely (!c->check_struct (this))) return_trace (false);
const HBUSHORT *states = (this+stateArrayTable).arrayZ; const HBUINT16 *states = (this+stateArrayTable).arrayZ;
const Entry<Extra> *entries = (this+entryTable).arrayZ; const Entry<Extra> *entries = (this+entryTable).arrayZ;
unsigned int num_states = 1; unsigned int num_states = 1;
@ -594,8 +567,8 @@ struct StateTable
nClasses * (num_states - state)))) nClasses * (num_states - state))))
return_trace (false); return_trace (false);
{ /* Sweep new states. */ { /* Sweep new states. */
const HBUSHORT *stop = &states[num_states * nClasses]; const HBUINT16 *stop = &states[num_states * nClasses];
for (const HBUSHORT *p = &states[state * nClasses]; p < stop; p++) for (const HBUINT16 *p = &states[state * nClasses]; p < stop; p++)
num_entries = MAX<unsigned int> (num_entries, *p + 1); num_entries = MAX<unsigned int> (num_entries, *p + 1);
state = num_states; state = num_states;
} }
@ -619,13 +592,13 @@ struct StateTable
} }
protected: 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. */ * in a single line in the state array. */
OffsetTo<ClassType, HBUINT> OffsetTo<Lookup<HBUINT16>, HBUINT32>
classTable; /* Offset to the class table. */ classTable; /* Offset to the class table. */
OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT> OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32>
stateArrayTable;/* Offset to the state array. */ stateArrayTable;/* Offset to the state array. */
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT> OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT32>
entryTable; /* Offset to the entry array. */ entryTable; /* Offset to the entry array. */
public: public:

View File

@ -30,7 +30,6 @@
#include "hb-open-type-private.hh" #include "hb-open-type-private.hh"
#include "hb-aat-layout-common-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') #define HB_AAT_TAG_MORX HB_TAG('m','o','r','x')
@ -39,7 +38,6 @@ namespace AAT {
using namespace OT; using namespace OT;
template <typename Types>
struct RearrangementSubtable struct RearrangementSubtable
{ {
enum Flags { enum Flags {
@ -171,16 +169,13 @@ struct RearrangementSubtable
} }
protected: protected:
StateTable<Types, void> machine; StateTable<void> machine;
public: public:
DEFINE_SIZE_MIN (2); DEFINE_SIZE_MIN (2);
}; };
template <typename Types>
struct ContextualSubtable struct ContextualSubtable
{ {
typedef typename Types::HBUINT HBUINT;
enum Flags { enum Flags {
SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */ SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */
DontAdvance = 0x4000, /* If set, don't advance to the next glyph before DontAdvance = 0x4000, /* If set, don't advance to the next glyph before
@ -206,7 +201,7 @@ struct ContextualSubtable
bool ret = false; bool ret = false;
unsigned int num_glyphs = c->face->get_num_glyphs (); unsigned int num_glyphs = c->face->get_num_glyphs ();
const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT> &subs = this+substitutionTables; const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32> &subs = this+substitutionTables;
unsigned int state = 0; unsigned int state = 0;
unsigned int last_zero = 0; unsigned int last_zero = 0;
@ -290,14 +285,13 @@ struct ContextualSubtable
} }
protected: protected:
StateTable<Types, EntryData> machine; StateTable<EntryData> machine;
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT>, HBUINT> OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, HBUINT32>
substitutionTables; substitutionTables;
public: public:
DEFINE_SIZE_MIN (2); DEFINE_SIZE_MIN (2);
}; };
template <typename Types>
struct LigatureSubtable struct LigatureSubtable
{ {
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
@ -315,7 +309,6 @@ struct LigatureSubtable
} }
}; };
template <typename Types>
struct NoncontextualSubtable struct NoncontextualSubtable
{ {
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
@ -352,7 +345,6 @@ struct NoncontextualSubtable
DEFINE_SIZE_MIN (2); DEFINE_SIZE_MIN (2);
}; };
template <typename Types>
struct InsertionSubtable struct InsertionSubtable
{ {
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
@ -392,13 +384,9 @@ struct Feature
}; };
template <typename Types>
struct ChainSubtable struct ChainSubtable
{ {
template <typename> struct Chain; friend struct Chain;
friend struct Chain<Types>;
typedef typename Types::HBUINT HBUINT;
inline unsigned int get_size (void) const { return length; } inline unsigned int get_size (void) const { return length; }
inline unsigned int get_type (void) const { return coverage & 0xFF; } inline unsigned int get_type (void) const { return coverage & 0xFF; }
@ -443,33 +431,30 @@ struct ChainSubtable
} }
protected: protected:
HBUINT length; /* Total subtable length, including this header. */ HBUINT32 length; /* Total subtable length, including this header. */
HBUINT coverage; /* Coverage flags and subtable type. */ HBUINT32 coverage; /* Coverage flags and subtable type. */
HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */ HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */
union { union {
RearrangementSubtable<Types> rearrangement; RearrangementSubtable rearrangement;
ContextualSubtable<Types> contextual; ContextualSubtable contextual;
LigatureSubtable<Types> ligature; LigatureSubtable ligature;
NoncontextualSubtable<Types> noncontextual; NoncontextualSubtable noncontextual;
InsertionSubtable<Types> insertion; InsertionSubtable insertion;
} u; } u;
public: public:
DEFINE_SIZE_MIN (2 * sizeof (HBUINT) + 4); DEFINE_SIZE_MIN (2 * sizeof (HBUINT32) + 4);
}; };
template <typename Types>
struct Chain struct Chain
{ {
typedef typename Types::HBUINT HBUINT;
inline void apply (hb_apply_context_t *c) const inline void apply (hb_apply_context_t *c) const
{ {
const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (featureZ, featureZ[0].static_size * featureCount); const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
unsigned int count = subtableCount; unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
subtable->apply (c); subtable->apply (c);
subtable = &StructAfter<ChainSubtable<Types> > (*subtable); subtable = &StructAfter<ChainSubtable> (*subtable);
} }
} }
@ -486,13 +471,13 @@ struct Chain
if (!c->check_array (featureZ, featureZ[0].static_size, featureCount)) if (!c->check_array (featureZ, featureZ[0].static_size, featureCount))
return_trace (false); return_trace (false);
const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (featureZ, featureZ[0].static_size * featureCount); const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
unsigned int count = subtableCount; unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!subtable->sanitize (c)) if (!subtable->sanitize (c))
return_trace (false); return_trace (false);
subtable = &StructAfter<ChainSubtable<Types> > (*subtable); subtable = &StructAfter<ChainSubtable> (*subtable);
} }
return_trace (true); return_trace (true);
@ -501,15 +486,15 @@ struct Chain
protected: protected:
HBUINT32 defaultFlags; /* The default specification for subtables. */ HBUINT32 defaultFlags; /* The default specification for subtables. */
HBUINT32 length; /* Total byte count, including this header. */ HBUINT32 length; /* Total byte count, including this header. */
HBUINT featureCount; /* Number of feature subtable entries. */ HBUINT32 featureCount; /* Number of feature subtable entries. */
HBUINT subtableCount; /* The number of subtables in the chain. */ HBUINT32 subtableCount; /* The number of subtables in the chain. */
Feature featureZ[VAR]; /* Features. */ Feature featureZ[VAR]; /* Features. */
ChainSubtable<Types> subtableX[VAR]; /* Subtables. */ ChainSubtable subtableX[VAR]; /* Subtables. */
// subtableGlyphCoverageArray if major == 3 // subtableGlyphCoverageArray if major == 3
public: 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 * The 'mort'/'morx' Tables
*/ */
template <typename Types> struct morx
struct mortmorx
{ {
static const hb_tag_t mortTag = HB_AAT_TAG_MORT; static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
static const hb_tag_t morxTag = HB_AAT_TAG_MORX;
typedef typename Types::HBUINT HBUINT;
inline void apply (hb_apply_context_t *c) const inline void apply (hb_apply_context_t *c) const
{ {
const Chain<Types> *chain = chains; const Chain *chain = chains;
unsigned int count = chainCount; unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
chain->apply (c); chain->apply (c);
chain = &StructAfter<Chain<Types> > (*chain); chain = &StructAfter<Chain> (*chain);
} }
} }
@ -540,17 +521,17 @@ struct mortmorx
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
if (!version.sanitize (c) || if (!version.sanitize (c) ||
(version.major >> (sizeof (HBUINT) == 4 ? 1 : 0)) != 1 || (version.major >> (sizeof (HBUINT32) == 4 ? 1 : 0)) != 1 ||
!chainCount.sanitize (c)) !chainCount.sanitize (c))
return_trace (false); return_trace (false);
const Chain<Types> *chain = chains; const Chain *chain = chains;
unsigned int count = chainCount; unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!chain->sanitize (c, version.major)) if (!chain->sanitize (c, version.major))
return_trace (false); return_trace (false);
chain = &StructAfter<Chain<Types> > (*chain); chain = &StructAfter<Chain> (*chain);
} }
return_trace (true); return_trace (true);
@ -561,51 +542,12 @@ struct mortmorx
* 1 for mort, 2 or 3 for morx. */ * 1 for mort, 2 or 3 for morx. */
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
* table. */ * table. */
Chain<Types> chains[VAR]; /* Chains. */ Chain chains[VAR]; /* Chains. */
public: public:
DEFINE_SIZE_MIN (8); 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<HBUINT16>
{
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<MortTypes>
{
static const hb_tag_t tableTag = HB_AAT_TAG_MORT;
};
struct morx : mortmorx<MorxTypes>
{
static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
};
} /* namespace AAT */ } /* namespace AAT */