diff --git a/Lib/fontTools/ttLib/tables/__init__.py b/Lib/fontTools/ttLib/tables/__init__.py index 22f8b8d05..063628f15 100644 --- a/Lib/fontTools/ttLib/tables/__init__.py +++ b/Lib/fontTools/ttLib/tables/__init__.py @@ -69,6 +69,7 @@ def _moduleFinderHint(): from . import _l_t_a_g from . import _m_a_x_p from . import _m_e_t_a + from . import _m_o_r_x from . import _n_a_m_e from . import _p_o_s_t from . import _p_r_e_p diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index 52d5b59f6..b01d08b90 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -605,7 +605,7 @@ class BaseTable(object): if conv.name == "FeatureParams": conv = conv.getConverter(reader["FeatureTag"]) if conv.name == "SubStruct": - conv = conv.getConverter(reader.globalState.tableType, + conv = conv.getConverter(reader.tableTag, table["MorphType"]) if conv.repeat: if conv.repeat in table: diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py index e542b3729..0088f3b7f 100755 --- a/Lib/fontTools/ttLib/tables/otData.py +++ b/Lib/fontTools/ttLib/tables/otData.py @@ -1179,6 +1179,12 @@ otData = [ ## Apple Advanced Typography (AAT) tables ## + ('AATLookupSegment', [ + ('uint16', 'lastGlyph', None, None, 'Last glyph index in this segment.'), + ('uint16', 'firstGlyph', None, None, 'First glyph index in this segment.'), + ('uint16', 'value', None, None, 'A 16-bit offset from the start of the table to the data.'), + ]), + # # feat # @@ -1212,4 +1218,83 @@ otData = [ ('NameID', 'SettingNameID', None, None, 'The name table index for the setting name.'), ]), + # + # morx + # + + # TODO: use 'struct' when field.type == field.name + + ('morx', [ + ('uint16', 'Version', None, None, 'Version of the morx table.'), + ('uint16', 'Reserved', None, None, 'Reserved (set to zero).'), + ('uint32', 'ChainCount', None, None, 'Number of MorphChains.'), + ('MorphChain', 'MorphChain', 'ChainCount', 0, 'Array of MorphChains.'), + ]), + + ('MorphChain', [ + ('Flags32', 'DefaultFlags', None, None, 'The default specification for subtables.'), + ('uint32', 'StructLength', None, None, 'Total byte count, including this header; must be a multiple of 4.'), + ('uint32', 'MorphFeatureCount', None, None, 'Number of feature subtable entries.'), + ('uint32', 'MorphSubtableCount', None, None, 'The number of subtables in the chain.'), + ('MorphFeature', 'MorphFeature', 'MorphFeatureCount', 0, 'Array of MorphFeatures.'), + ('MorphSubtable', 'MorphSubtable', 'MorphSubtableCount', 0, 'Array of MorphSubtables.'), + ]), + + ('MorphFeature', [ + ('uint16', 'FeatureType', None, None, 'The type of feature.'), + ('uint16', 'FeatureSetting', None, None, "The feature's setting (aka selector)."), + ('Flags32', 'EnableFlags', None, None, 'Flags for the settings that this feature and setting enables.'), + ('Flags32', 'DisableFlags', None, None, 'Complement of flags for the settings that this feature and setting disable.'), + ]), + + ('MorphSubtable', [ + ('uint32', 'StructLength', None, None, 'Total subtable length, including this header.'), + ('uint8', 'CoverageFlags', None, None, 'Most significant byte of coverage flags.'), + ('uint8', 'Reserved', None, None, 'Unused.'), + ('uint16', 'MorphType', None, None, 'Subtable type.'), + ('Flags32', 'SubFeatureFlags', None, None, 'The 32-bit mask identifying which subtable this is (the subtable being executed if the AND of this value and the processed defaultFlags is nonzero).'), + ('SubStruct', 'SubStruct', None, None, 'SubTable.'), + ]), + + ('StateHeader', [ + ('uint32', 'ClassCount', None, None, 'Number of classes, which is the number of 16-bit entry indices in a single line in the state array.'), + ('uint32', 'MorphClass', None, None, 'Offset from the start of this state table header to the start of the class table.'), + ('uint32', 'StateArrayOffset', None, None, 'Offset from the start of this state table header to the start of the state array.'), + ('uint32', 'EntryTableOffset', None, None, 'Offset from the start of this state table header to the start of the entry table.'), + ]), + + ('RearrangementMorph', [ + ('struct', 'StateHeader', None, None, 'Header.'), + ]), + + ('ContextualMorph', [ + ('struct', 'StateHeader', None, None, 'Header.'), + # TODO: Add missing parts. + ]), + + ('LigatureMorph', [ + ('struct', 'StateHeader', None, None, 'Header.'), + ('uint32', 'LigActionOffset', None, None, 'Byte offset from stateHeader to the start of the ligature action table.'), + ('uint32', 'ComponentOffset', None, None, 'Byte offset from stateHeader to the start of the component table.'), + ('uint32', 'LigatureOffset', None, None, 'Byte offset from stateHeader to the start of the actual ligature lists.'), + ]), + + ('NoncontextualMorph', [ + ('AATLookup', 'mapping', None, None, 'The noncontextual glyph substitution table.'), + ]), + + ('InsertionMorph', [ + ('struct', 'StateHeader', None, None, 'Header.'), + # TODO: Add missing parts. + ]), + + ('MorphClass', [ + ('uint16', 'FirstGlyph', None, None, 'Glyph index of the first glyph in the class table.'), + #('uint16', 'GlyphCount', None, None, 'Number of glyphs in class table.'), + #('uint8', 'GlyphClass', 'GlyphCount', 0, 'The class codes (indexed by glyph index minus firstGlyph). Class codes range from 0 to the value of stateSize minus 1.'), + ]), + + # If the 'morx' table version is 3 or greater, then the last subtable in the chain is followed by a subtableGlyphCoverageArray, as described below. + # ('Offset', 'MarkGlyphSetsDef', None, 'int(round(Version*0x10000)) >= 0x00010002', 'Offset to the table of mark set definitions-from beginning of GDEF header (may be NULL)'), + ] diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py index 0b26cff96..2c6ca24b7 100644 --- a/Lib/fontTools/ttLib/tables/otTables.py +++ b/Lib/fontTools/ttLib/tables/otTables.py @@ -991,6 +991,14 @@ def _buildClasses(): 8: ChainContextPos, 9: ExtensionPos, }, + 'morx': { + 0: RearrangementMorph, + 1: ContextualMorph, + 2: LigatureMorph, + # 3: Reserved, + 4: NoncontextualMorph, + 5: InsertionMorph, + }, } lookupTypes['JSTF'] = lookupTypes['GPOS'] # JSTF contains GPOS for lookupEnum in lookupTypes.values(): diff --git a/README.rst b/README.rst index 2d578720e..2dd59ca91 100644 --- a/README.rst +++ b/README.rst @@ -102,8 +102,8 @@ The following tables are currently supported: OS/2, SING, STAT, SVG, TSI0, TSI1, TSI2, TSI3, TSI5, TSIB, TSID, TSIJ, TSIP, TSIS, TSIV, TTFA, VDMX, VORG, VVAR, avar, cmap, cvar, cvt, feat, fpgm, fvar, gasp, glyf, gvar, hdmx, head, hhea, hmtx, - kern, loca, ltag, maxp, meta, name, post, prep, sbix, trak, vhea - and vmtx + kern, loca, ltag, maxp, meta, morx, name, post, prep, sbix, trak, + vhea and vmtx .. end table list Other tables are dumped as hexadecimal data.