Skip to content

Commit 1f1c85a

Browse files
committed
[aat] Remove 'mort' support
It's dead, Jim!
1 parent 7e2fed6 commit 1f1c85a

File tree

2 files changed

+46
-131
lines changed

2 files changed

+46
-131
lines changed

src/hb-aat-layout-common-private.hh

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -477,33 +477,8 @@ struct Lookup
477477
};
478478

479479

480-
struct ClassTable
481-
{
482-
inline unsigned int get_class (hb_codepoint_t glyph_id) const
483-
{
484-
return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? classArrayZ[glyph_id - firstGlyph] : 1;
485-
}
486-
487-
inline bool sanitize (hb_sanitize_context_t *c) const
488-
{
489-
TRACE_SANITIZE (this);
490-
return_trace (c->check_struct (this) && classArrayZ.sanitize (c, glyphCount));
491-
}
492-
493-
protected:
494-
GlyphID firstGlyph; /* First glyph index included in the trimmed array. */
495-
HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last
496-
* glyph minus the value of firstGlyph plus 1). */
497-
UnsizedArrayOf<HBUINT8>
498-
classArrayZ; /* The class codes (indexed by glyph index minus
499-
* firstGlyph). */
500-
public:
501-
DEFINE_SIZE_ARRAY (4, classArrayZ);
502-
};
503-
504-
505480
/*
506-
* (Extended) State Table
481+
* Extended State Table
507482
*/
508483

509484
template <typename T>
@@ -545,16 +520,14 @@ struct Entry<void>
545520
DEFINE_SIZE_STATIC (4);
546521
};
547522

548-
template <typename Types, typename Extra>
523+
template <typename Extra>
549524
struct StateTable
550525
{
551-
typedef typename Types::HBUINT HBUINT;
552-
typedef typename Types::HBUSHORT HBUSHORT;
553-
typedef typename Types::ClassType ClassType;
554-
555526
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
556-
{ return (this+classTable).get_class (glyph_id, num_glyphs); }
557-
527+
{
528+
const HBUINT16 *v = (this+classTable).get_value (glyph_id, num_glyphs);
529+
return v ? *v : 1;
530+
}
558531

559532
inline const Entry<Extra> *get_entries () const
560533
{
@@ -565,7 +538,7 @@ struct StateTable
565538
{
566539
if (unlikely (klass >= nClasses)) return nullptr;
567540

568-
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
541+
const HBUINT16 *states = (this+stateArrayTable).arrayZ;
569542
const Entry<Extra> *entries = (this+entryTable).arrayZ;
570543

571544
unsigned int entry = states[state * nClasses + klass];
@@ -579,7 +552,7 @@ struct StateTable
579552
TRACE_SANITIZE (this);
580553
if (unlikely (!c->check_struct (this))) return_trace (false);
581554

582-
const HBUSHORT *states = (this+stateArrayTable).arrayZ;
555+
const HBUINT16 *states = (this+stateArrayTable).arrayZ;
583556
const Entry<Extra> *entries = (this+entryTable).arrayZ;
584557

585558
unsigned int num_states = 1;
@@ -594,8 +567,8 @@ struct StateTable
594567
nClasses * (num_states - state))))
595568
return_trace (false);
596569
{ /* Sweep new states. */
597-
const HBUSHORT *stop = &states[num_states * nClasses];
598-
for (const HBUSHORT *p = &states[state * nClasses]; p < stop; p++)
570+
const HBUINT16 *stop = &states[num_states * nClasses];
571+
for (const HBUINT16 *p = &states[state * nClasses]; p < stop; p++)
599572
num_entries = MAX<unsigned int> (num_entries, *p + 1);
600573
state = num_states;
601574
}
@@ -619,13 +592,13 @@ struct StateTable
619592
}
620593

621594
protected:
622-
HBUINT nClasses; /* Number of classes, which is the number of indices
595+
HBUINT32 nClasses; /* Number of classes, which is the number of indices
623596
* in a single line in the state array. */
624-
OffsetTo<ClassType, HBUINT>
597+
OffsetTo<Lookup<HBUINT16>, HBUINT32>
625598
classTable; /* Offset to the class table. */
626-
OffsetTo<UnsizedArrayOf<HBUSHORT>, HBUINT>
599+
OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32>
627600
stateArrayTable;/* Offset to the state array. */
628-
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT>
601+
OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT32>
629602
entryTable; /* Offset to the entry array. */
630603

631604
public:

src/hb-aat-layout-morx-table.hh

Lines changed: 32 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "hb-open-type-private.hh"
3131
#include "hb-aat-layout-common-private.hh"
3232

33-
#define HB_AAT_TAG_MORT HB_TAG('m','o','r','t')
3433
#define HB_AAT_TAG_MORX HB_TAG('m','o','r','x')
3534

3635

@@ -39,7 +38,6 @@ namespace AAT {
3938
using namespace OT;
4039

4140

42-
template <typename Types>
4341
struct RearrangementSubtable
4442
{
4543
enum Flags {
@@ -171,16 +169,13 @@ struct RearrangementSubtable
171169
}
172170

173171
protected:
174-
StateTable<Types, void> machine;
172+
StateTable<void> machine;
175173
public:
176174
DEFINE_SIZE_MIN (2);
177175
};
178176

179-
template <typename Types>
180177
struct ContextualSubtable
181178
{
182-
typedef typename Types::HBUINT HBUINT;
183-
184179
enum Flags {
185180
SetMark = 0x8000, /* If set, make the current glyph the marked glyph. */
186181
DontAdvance = 0x4000, /* If set, don't advance to the next glyph before
@@ -206,7 +201,7 @@ struct ContextualSubtable
206201
bool ret = false;
207202
unsigned int num_glyphs = c->face->get_num_glyphs ();
208203

209-
const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT> &subs = this+substitutionTables;
204+
const UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32> &subs = this+substitutionTables;
210205

211206
unsigned int state = 0;
212207
unsigned int last_zero = 0;
@@ -290,14 +285,13 @@ struct ContextualSubtable
290285
}
291286

292287
protected:
293-
StateTable<Types, EntryData> machine;
294-
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT>, HBUINT>
295-
substitutionTables;
288+
StateTable<EntryData> machine;
289+
OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, HBUINT32>
290+
substitutionTables;
296291
public:
297292
DEFINE_SIZE_MIN (2);
298293
};
299294

300-
template <typename Types>
301295
struct LigatureSubtable
302296
{
303297
inline bool apply (hb_apply_context_t *c) const
@@ -315,7 +309,6 @@ struct LigatureSubtable
315309
}
316310
};
317311

318-
template <typename Types>
319312
struct NoncontextualSubtable
320313
{
321314
inline bool apply (hb_apply_context_t *c) const
@@ -352,7 +345,6 @@ struct NoncontextualSubtable
352345
DEFINE_SIZE_MIN (2);
353346
};
354347

355-
template <typename Types>
356348
struct InsertionSubtable
357349
{
358350
inline bool apply (hb_apply_context_t *c) const
@@ -392,13 +384,9 @@ struct Feature
392384
};
393385

394386

395-
template <typename Types>
396387
struct ChainSubtable
397388
{
398-
template <typename> struct Chain;
399-
friend struct Chain<Types>;
400-
401-
typedef typename Types::HBUINT HBUINT;
389+
friend struct Chain;
402390

403391
inline unsigned int get_size (void) const { return length; }
404392
inline unsigned int get_type (void) const { return coverage & 0xFF; }
@@ -443,33 +431,30 @@ struct ChainSubtable
443431
}
444432

445433
protected:
446-
HBUINT length; /* Total subtable length, including this header. */
447-
HBUINT coverage; /* Coverage flags and subtable type. */
448-
HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */
434+
HBUINT32 length; /* Total subtable length, including this header. */
435+
HBUINT32 coverage; /* Coverage flags and subtable type. */
436+
HBUINT32 subFeatureFlags;/* The 32-bit mask identifying which subtable this is. */
449437
union {
450-
RearrangementSubtable<Types> rearrangement;
451-
ContextualSubtable<Types> contextual;
452-
LigatureSubtable<Types> ligature;
453-
NoncontextualSubtable<Types> noncontextual;
454-
InsertionSubtable<Types> insertion;
438+
RearrangementSubtable rearrangement;
439+
ContextualSubtable contextual;
440+
LigatureSubtable ligature;
441+
NoncontextualSubtable noncontextual;
442+
InsertionSubtable insertion;
455443
} u;
456444
public:
457-
DEFINE_SIZE_MIN (2 * sizeof (HBUINT) + 4);
445+
DEFINE_SIZE_MIN (2 * sizeof (HBUINT32) + 4);
458446
};
459447

460-
template <typename Types>
461448
struct Chain
462449
{
463-
typedef typename Types::HBUINT HBUINT;
464-
465450
inline void apply (hb_apply_context_t *c) const
466451
{
467-
const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (featureZ, featureZ[0].static_size * featureCount);
452+
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
468453
unsigned int count = subtableCount;
469454
for (unsigned int i = 0; i < count; i++)
470455
{
471456
subtable->apply (c);
472-
subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
457+
subtable = &StructAfter<ChainSubtable> (*subtable);
473458
}
474459
}
475460

@@ -486,13 +471,13 @@ struct Chain
486471
if (!c->check_array (featureZ, featureZ[0].static_size, featureCount))
487472
return_trace (false);
488473

489-
const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (featureZ, featureZ[0].static_size * featureCount);
474+
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
490475
unsigned int count = subtableCount;
491476
for (unsigned int i = 0; i < count; i++)
492477
{
493478
if (!subtable->sanitize (c))
494479
return_trace (false);
495-
subtable = &StructAfter<ChainSubtable<Types> > (*subtable);
480+
subtable = &StructAfter<ChainSubtable> (*subtable);
496481
}
497482

498483
return_trace (true);
@@ -501,56 +486,52 @@ struct Chain
501486
protected:
502487
HBUINT32 defaultFlags; /* The default specification for subtables. */
503488
HBUINT32 length; /* Total byte count, including this header. */
504-
HBUINT featureCount; /* Number of feature subtable entries. */
505-
HBUINT subtableCount; /* The number of subtables in the chain. */
489+
HBUINT32 featureCount; /* Number of feature subtable entries. */
490+
HBUINT32 subtableCount; /* The number of subtables in the chain. */
506491

507-
Feature featureZ[VAR]; /* Features. */
508-
ChainSubtable<Types> subtableX[VAR]; /* Subtables. */
492+
Feature featureZ[VAR]; /* Features. */
493+
ChainSubtable subtableX[VAR]; /* Subtables. */
509494
// subtableGlyphCoverageArray if major == 3
510495

511496
public:
512-
DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT));
497+
DEFINE_SIZE_MIN (8 + 2 * sizeof (HBUINT32));
513498
};
514499

515500

516501
/*
517502
* The 'mort'/'morx' Tables
518503
*/
519504

520-
template <typename Types>
521-
struct mortmorx
505+
struct morx
522506
{
523-
static const hb_tag_t mortTag = HB_AAT_TAG_MORT;
524-
static const hb_tag_t morxTag = HB_AAT_TAG_MORX;
525-
526-
typedef typename Types::HBUINT HBUINT;
507+
static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
527508

528509
inline void apply (hb_apply_context_t *c) const
529510
{
530-
const Chain<Types> *chain = chains;
511+
const Chain *chain = chains;
531512
unsigned int count = chainCount;
532513
for (unsigned int i = 0; i < count; i++)
533514
{
534515
chain->apply (c);
535-
chain = &StructAfter<Chain<Types> > (*chain);
516+
chain = &StructAfter<Chain> (*chain);
536517
}
537518
}
538519

539520
inline bool sanitize (hb_sanitize_context_t *c) const
540521
{
541522
TRACE_SANITIZE (this);
542523
if (!version.sanitize (c) ||
543-
(version.major >> (sizeof (HBUINT) == 4 ? 1 : 0)) != 1 ||
524+
(version.major >> (sizeof (HBUINT32) == 4 ? 1 : 0)) != 1 ||
544525
!chainCount.sanitize (c))
545526
return_trace (false);
546527

547-
const Chain<Types> *chain = chains;
528+
const Chain *chain = chains;
548529
unsigned int count = chainCount;
549530
for (unsigned int i = 0; i < count; i++)
550531
{
551532
if (!chain->sanitize (c, version.major))
552533
return_trace (false);
553-
chain = &StructAfter<Chain<Types> > (*chain);
534+
chain = &StructAfter<Chain> (*chain);
554535
}
555536

556537
return_trace (true);
@@ -561,51 +542,12 @@ struct mortmorx
561542
* 1 for mort, 2 or 3 for morx. */
562543
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
563544
* table. */
564-
Chain<Types> chains[VAR]; /* Chains. */
545+
Chain chains[VAR]; /* Chains. */
565546

566547
public:
567548
DEFINE_SIZE_MIN (8);
568549
};
569550

570-
struct MortTypes
571-
{
572-
static const bool extended = false;
573-
typedef HBUINT16 HBUINT;
574-
typedef HBUINT8 HBUSHORT;
575-
struct ClassType : ClassTable
576-
{
577-
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs HB_UNUSED) const
578-
{
579-
return ClassTable::get_class (glyph_id);
580-
}
581-
};
582-
};
583-
struct MorxTypes
584-
{
585-
static const bool extended = true;
586-
typedef HBUINT32 HBUINT;
587-
typedef HBUINT16 HBUSHORT;
588-
struct ClassType : Lookup<HBUINT16>
589-
{
590-
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs) const
591-
{
592-
const HBUINT16 *v = get_value (glyph_id, num_glyphs);
593-
return v ? *v : 1;
594-
}
595-
};
596-
};
597-
598-
struct mort : mortmorx<MortTypes>
599-
{
600-
static const hb_tag_t tableTag = HB_AAT_TAG_MORT;
601-
};
602-
603-
struct morx : mortmorx<MorxTypes>
604-
{
605-
static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
606-
};
607-
608-
609551
} /* namespace AAT */
610552

611553

0 commit comments

Comments
 (0)