Skip to content

Commit

Permalink
[aat] Remove 'mort' support
Browse files Browse the repository at this point in the history
It's dead, Jim!
  • Loading branch information
behdad committed Jan 11, 2018
1 parent 7e2fed6 commit 1f1c85a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 131 deletions.
55 changes: 14 additions & 41 deletions src/hb-aat-layout-common-private.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -545,16 +520,14 @@ struct Entry<void>
DEFINE_SIZE_STATIC (4);
};

template <typename Types, typename Extra>
template <typename Extra>
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<Extra> *get_entries () const
{
Expand All @@ -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<Extra> *entries = (this+entryTable).arrayZ;

unsigned int entry = states[state * nClasses + klass];
Expand All @@ -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<Extra> *entries = (this+entryTable).arrayZ;

unsigned int num_states = 1;
Expand All @@ -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<unsigned int> (num_entries, *p + 1);
state = num_states;
}
Expand All @@ -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<ClassType, HBUINT>
OffsetTo<Lookup<HBUINT16>, HBUINT32>
classTable; /* Offset to the class table. */
OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT>
OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32>
stateArrayTable;/* Offset to the state array. */
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT>
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT32>
entryTable; /* Offset to the entry array. */

public:
Expand Down
122 changes: 32 additions & 90 deletions src/hb-aat-layout-morx-table.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand All @@ -39,7 +38,6 @@ namespace AAT {
using namespace OT;


template <typename Types>
struct RearrangementSubtable
{
enum Flags {
Expand Down Expand Up @@ -171,16 +169,13 @@ struct RearrangementSubtable
}

protected:
StateTable<Types, void> machine;
StateTable<void> machine;
public:
DEFINE_SIZE_MIN (2);
};

template <typename Types>
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
Expand All @@ -206,7 +201,7 @@ struct ContextualSubtable
bool ret = false;
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 last_zero = 0;
Expand Down Expand Up @@ -290,14 +285,13 @@ struct ContextualSubtable
}

protected:
StateTable<Types, EntryData> machine;
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT>, HBUINT>
substitutionTables;
StateTable<EntryData> machine;
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, HBUINT32>
substitutionTables;
public:
DEFINE_SIZE_MIN (2);
};

template <typename Types>
struct LigatureSubtable
{
inline bool apply (hb_apply_context_t *c) const
Expand All @@ -315,7 +309,6 @@ struct LigatureSubtable
}
};

template <typename Types>
struct NoncontextualSubtable
{
inline bool apply (hb_apply_context_t *c) const
Expand Down Expand Up @@ -352,7 +345,6 @@ struct NoncontextualSubtable
DEFINE_SIZE_MIN (2);
};

template <typename Types>
struct InsertionSubtable
{
inline bool apply (hb_apply_context_t *c) const
Expand Down Expand Up @@ -392,13 +384,9 @@ struct Feature
};


template <typename Types>
struct ChainSubtable
{
template <typename> struct Chain;
friend struct Chain<Types>;

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; }
Expand Down Expand Up @@ -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<Types> rearrangement;
ContextualSubtable<Types> contextual;
LigatureSubtable<Types> ligature;
NoncontextualSubtable<Types> noncontextual;
InsertionSubtable<Types> 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 <typename Types>
struct Chain
{
typedef typename Types::HBUINT HBUINT;

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;
for (unsigned int i = 0; i < count; i++)
{
subtable->apply (c);
subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
subtable = &StructAfter<ChainSubtable> (*subtable);
}
}

Expand All @@ -486,13 +471,13 @@ struct Chain
if (!c->check_array (featureZ, featureZ[0].static_size, featureCount))
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;
for (unsigned int i = 0; i < count; i++)
{
if (!subtable->sanitize (c))
return_trace (false);
subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
subtable = &StructAfter<ChainSubtable> (*subtable);
}

return_trace (true);
Expand All @@ -501,56 +486,52 @@ 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<Types> 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));
};


/*
* The 'mort'/'morx' Tables
*/

template <typename Types>
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<Types> *chain = chains;
const Chain *chain = chains;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
chain->apply (c);
chain = &StructAfter<Chain<Types> > (*chain);
chain = &StructAfter<Chain> (*chain);
}
}

inline bool sanitize (hb_sanitize_context_t *c) const
{
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<Types> *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<Types> > (*chain);
chain = &StructAfter<Chain> (*chain);
}

return_trace (true);
Expand All @@ -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<Types> 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<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 */


Expand Down

3 comments on commit 1f1c85a

@ebraminio
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 10.11.5 there was 7 fonts with mort https://gist.github.com/ebraminio/3ff370da82f0e33b489752cc178cfcd0 but now that I am checking 10.13.2 there is none

mort morx Font Name
x /System/Library/Fonts/AppleSDGothicNeo.ttc
x /System/Library/Fonts/Menlo.ttc
x /System/Library/Fonts/STHeiti Medium.ttc
x /System/Library/Fonts/HelveticaNeue.ttc
x /System/Library/Fonts/Optima.ttc
x /System/Library/Fonts/Monaco.dfont
x /System/Library/Fonts/HelveticaNeueDeskInterface.ttc
x /System/Library/Fonts/LucidaGrande.ttc
x /System/Library/Fonts/Thonburi.ttc
x /System/Library/Fonts/AquaKana.ttc
x /System/Library/Fonts/Palatino.ttc
x /System/Library/Fonts/Apple Symbols.ttf
x /System/Library/Fonts/STHeiti Light.ttc
x /System/Library/Fonts/GeezaPro.ttc
x /System/Library/Fonts/Courier.dfont
x /System/Library/Fonts/Times.ttc
x /System/Library/Fonts/MarkerFelt.ttc
x /System/Library/Fonts/Keyboard.ttf
x /System/Library/Fonts/Geneva.dfont
x /System/Library/Fonts/ArialHB.ttc
x /System/Library/Fonts/Apple Color Emoji.ttc
x /System/Library/Fonts/Helvetica.ttc
x /Library/Fonts/AlBayan.ttc
x /Library/Fonts/Zapfino.ttf
x /Library/Fonts/Silom.ttf
x /Library/Fonts/Kefa.ttc
x /Library/Fonts/Nadeem.ttc
x /Library/Fonts/KufiStandardGK.ttc
x /Library/Fonts/Kannada Sangam MN.ttc
x /Library/Fonts/Papyrus.ttc
x /Library/Fonts/AppleGothic.ttf
x /Library/Fonts/Kailasa.ttc
x /Library/Fonts/Farisi.ttf
x /Library/Fonts/Mishafi.ttf
x /Library/Fonts/Marion.ttc
x /Library/Fonts/Trattatello.ttf
x /Library/Fonts/Sinhala MN.ttc
x /Library/Fonts/Corsiva.ttc
x /Library/Fonts/BigCaslon.ttf
x /Library/Fonts/Al Nile.ttc
x /Library/Fonts/Baghdad.ttc
x /Library/Fonts/Athelas.ttc
x /Library/Fonts/AmericanTypewriter.ttc
x /Library/Fonts/Lao Sangam MN.ttf
x /Library/Fonts/Malayalam MN.ttc
x /Library/Fonts/Muna.ttc
x /Library/Fonts/Brush Script.ttf
x /Library/Fonts/Myanmar MN.ttc
x /Library/Fonts/Telugu MN.ttc
x /Library/Fonts/Myanmar Sangam MN.ttc
x /Library/Fonts/Devanagari Sangam MN.ttc
x /Library/Fonts/Apple Chancery.ttf
x /Library/Fonts/Futura.ttc
x /Library/Fonts/Copperplate.ttc
x /Library/Fonts/Farah.ttc
x /Library/Fonts/Malayalam Sangam MN.ttc
x /Library/Fonts/ChalkboardSE.ttc
x /Library/Fonts/Bangla MN.ttc
x /Library/Fonts/Bangla Sangam MN.ttc
x /Library/Fonts/Tamil MN.ttc
x /Library/Fonts/Gurmukhi Sangam MN.ttc
x /Library/Fonts/GujaratiMT.ttc
x /Library/Fonts/Diwan Kufi.ttc
x /Library/Fonts/Tamil Sangam MN.ttc
x /Library/Fonts/Cochin.ttc
x /Library/Fonts/Skia.ttf
x /Library/Fonts/DevanagariMT.ttc
x /Library/Fonts/Kannada MN.ttc
x /Library/Fonts/Beirut.ttc
x /Library/Fonts/Kokonor.ttf
x /Library/Fonts/NewPeninimMT.ttc
x /Library/Fonts/Gurmukhi MN.ttc
x /Library/Fonts/Diwan Thuluth.ttf
x /Library/Fonts/Ayuthaya.ttf
x /Library/Fonts/Sinhala Sangam MN.ttc
x /Library/Fonts/Khmer Sangam MN.ttf
x /Library/Fonts/Chalkboard.ttc
x /Library/Fonts/Mshtakan.ttc
x /Library/Fonts/Lao MN.ttc
x /Library/Fonts/Sana.ttc
x /Library/Fonts/Baskerville.ttc
x /Library/Fonts/InaiMathi-MN.ttc
x /Library/Fonts/Telugu Sangam MN.ttc
x /Library/Fonts/Hoefler Text.ttc
x /Library/Fonts/Sathu.ttf
x /Library/Fonts/Gujarati Sangam MN.ttc
x /Library/Fonts/PlantagenetCherokee.ttf
x /Library/Fonts/Didot.ttc
x /Library/Fonts/Khmer MN.ttc
x /Library/Fonts/Krungthep.ttf
x /Library/Fonts/Oriya MN.ttc
x /Library/Fonts/Gurmukhi.ttf
x /Library/Fonts/Al Tarikh.ttc
x /Library/Fonts/Raanana.ttc
x /Library/Fonts/GillSans.ttc
x /Library/Fonts/Mishafi Gold.ttf
x /Library/Fonts/Herculanum.ttf
x /Library/Fonts/Damascus.ttc
x /Library/Fonts/Waseem.ttc
x /Library/Fonts/Oriya Sangam MN.ttc
x /Library/Fonts/DecoTypeNaskh.ttc

@ebraminio
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some other fonts on /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Support/FontSubsets/, for example "Osaka" which had mort is moved there but none of the fonts there seem to have mort/morx now.

@behdad
Copy link
Member Author

@behdad behdad commented on 1f1c85a Jan 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Correct, 10.13 has none. iOS never support mort. The spec is so unclear and fonttools doesn't have complete mort, so would have been significantly more work to verify it works. So I just removed it.

Please sign in to comment.