Implement GDEF MarkGlyphSetsDef
Aka. "Mark filtering sets".
Fixes https://github.com/behdad/fonttools/issues/39
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 758aa3c..4eb74ac 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -555,6 +555,8 @@
l.append(conv.read(reader, font, table))
table[conv.name] = l
else:
+ if conv.aux and not eval(conv.aux, None, table):
+ continue
table[conv.name] = conv.read(reader, font, table)
if conv.isPropagatedCount:
reader.setCount(conv.name, table[conv.name])
@@ -607,6 +609,8 @@
else:
table[conv.name] = ref
else:
+ if conv.aux and not eval(conv.aux, None, table):
+ continue
conv.write(writer, font, table, value)
def readFormat(self, reader):
@@ -639,13 +643,16 @@
# This is because in TTX our parent writes our main tag, and in otBase.py we
# do it ourselves. I think I'm getting schizophrenic...
for conv in self.getConverters():
- value = getattr(self, conv.name)
if conv.repeat:
+ value = getattr(self, conv.name)
for i in range(len(value)):
item = value[i]
conv.xmlWrite(xmlWriter, font, item, conv.name,
[("index", i)])
else:
+ if conv.aux and not eval(conv.aux, None, vars(self)):
+ continue
+ value = getattr(self, conv.name)
conv.xmlWrite(xmlWriter, font, value, conv.name, [])
def fromXML(self, (name, attrs, content), font):
diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py
index da65c6f..fc0a707 100644
--- a/Lib/fontTools/ttLib/tables/otData.py
+++ b/Lib/fontTools/ttLib/tables/otData.py
@@ -611,6 +611,7 @@
('Offset', 'AttachList', None, None, 'Offset to list of glyphs with attachment points-from beginning of GDEF header (may be NULL)'),
('Offset', 'LigCaretList', None, None, 'Offset to list of positioning points for ligature carets-from beginning of GDEF header (may be NULL)'),
('Offset', 'MarkAttachClassDef', None, None, 'Offset to class definition table for mark attachment type-from beginning of GDEF header (may be NULL)'),
+ ('Offset', 'MarkGlyphSetsDef', None, 'Version >= 0x00010002 / float(0x10000)', 'Offset to the table of mark set definitions-from beginning of GDEF header (may be NULL)'),
]),
('AttachList', [
@@ -651,6 +652,11 @@
('Offset', 'DeviceTable', None, None, 'Offset to Device table for X or Y value-from beginning of CaretValue table'),
]),
+ ('MarkGlyphSetsDef', [
+ ('uint16', 'MarkSetTableFormat', None, None, 'Format identifier == 1'),
+ ('uint16', 'MarkSetCount', None, None, 'Number of mark sets defined'),
+ ('LOffset', 'Coverage', 'MarkSetCount', 0, 'Array of offsets to mark set coverage tables.'),
+ ]),
#
# base