[morx] Change MorphType to uint8, to comply with the spec

This commit is contained in:
Sascha Brawer 2017-06-07 14:19:34 +02:00
parent b00e2dfec4
commit 7f774ae84c
2 changed files with 13 additions and 4 deletions

View File

@ -24,8 +24,11 @@ def buildConverters(tableSpec, tableNamespace):
assert tp == "uint16"
converterClass = ValueFormat
elif name.endswith("Count") or name == "MorphType":
assert tp in ("uint16", "uint32")
converterClass = ComputedUShort if tp == 'uint16' else ComputedULong
converterClass = {
"uint8": ComputedUInt8,
"uint16": ComputedUShort,
"uint32": ComputedULong,
}[tp]
elif name == "SubTable":
converterClass = SubTable
elif name == "ExtSubTable":
@ -218,6 +221,8 @@ class ComputedInt(IntValue):
xmlWriter.comment("%s=%s" % (name, value))
xmlWriter.newline()
class ComputedUInt8(ComputedInt, UInt8):
pass
class ComputedUShort(ComputedInt, UShort):
pass
class ComputedULong(ComputedInt, ULong):

View File

@ -1,3 +1,4 @@
# coding: utf-8
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
@ -1247,11 +1248,14 @@ otData = [
('Flags32', 'DisableFlags', None, None, 'Complement of flags for the settings that this feature and setting disable.'),
]),
# Apple TrueType Reference Manual, chapter “The morx table”,
# section “Metamorphosis Subtables”.
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
('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.'),
('uint16', 'Reserved', None, None, 'Unused.'),
('uint8', '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.'),
]),