def parseAttachList(lines, font): points = {} with lines.between('attachment list'): for line in lines: glyph = makeGlyph(line[0]) assert glyph not in points, glyph points[glyph] = [int(i) for i in line[1:]] return otl.buildAttachList(points, font.getReverseGlyphMap())
def buildGDEF(self): gdef = otTables.GDEF() gdef.GlyphClassDef = self.buildGDEFGlyphClassDef_() gdef.AttachList = otl.buildAttachList(self.attachPoints_, self.glyphMap) gdef.LigCaretList = otl.buildLigCaretList(self.ligCaretCoords_, self.ligCaretPoints_, self.glyphMap) gdef.MarkAttachClassDef = self.buildGDEFMarkAttachClassDef_() gdef.MarkGlyphSetsDef = self.buildGDEFMarkGlyphSetsDef_() gdef.Version = 0x00010002 if gdef.MarkGlyphSetsDef else 1.0 if any( (gdef.GlyphClassDef, gdef.AttachList, gdef.LigCaretList, gdef.MarkAttachClassDef, gdef.MarkGlyphSetsDef) ): result = getTableClass("GDEF")() result.table = gdef return result else: return None
def buildGDEF(self): gdef = otTables.GDEF() gdef.GlyphClassDef = self.buildGDEFGlyphClassDef_() gdef.AttachList = \ otl.buildAttachList(self.attachPoints_, self.glyphMap) gdef.LigCaretList = \ otl.buildLigCaretList(self.ligCaretCoords_, self.ligCaretPoints_, self.glyphMap) gdef.MarkAttachClassDef = self.buildGDEFMarkAttachClassDef_() gdef.MarkGlyphSetsDef = self.buildGDEFMarkGlyphSetsDef_() gdef.Version = 0x00010002 if gdef.MarkGlyphSetsDef else 1.0 if any((gdef.GlyphClassDef, gdef.AttachList, gdef.LigCaretList, gdef.MarkAttachClassDef, gdef.MarkGlyphSetsDef)): result = getTableClass("GDEF")() result.table = gdef return result else: return None
def test_buildAttachList(self): attachList = builder.buildAttachList({ "zero": [23, 7], "one": [1], }, self.GLYPHMAP) self.assertEqual(getXML(attachList.toXML), '<AttachList>' ' <Coverage>' ' <Glyph value="zero"/>' ' <Glyph value="one"/>' ' </Coverage>' ' <!-- GlyphCount=2 -->' ' <AttachPoint index="0">' ' <!-- PointCount=2 -->' ' <PointIndex index="0" value="7"/>' ' <PointIndex index="1" value="23"/>' ' </AttachPoint>' ' <AttachPoint index="1">' ' <!-- PointCount=1 -->' ' <PointIndex index="0" value="1"/>' ' </AttachPoint>' '</AttachList>')
def test_buildAttachList(self): attachList = builder.buildAttachList({ "zero": [23, 7], "one": [1] }, self.GLYPHMAP) assert getXML(attachList.toXML) == [ "<AttachList>", " <Coverage>", ' <Glyph value="zero"/>', ' <Glyph value="one"/>', " </Coverage>", " <!-- GlyphCount=2 -->", ' <AttachPoint index="0">', " <!-- PointCount=2 -->", ' <PointIndex index="0" value="7"/>', ' <PointIndex index="1" value="23"/>', " </AttachPoint>", ' <AttachPoint index="1">', " <!-- PointCount=1 -->", ' <PointIndex index="0" value="1"/>', " </AttachPoint>", "</AttachList>", ]
def test_buildAttachList_empty(self): assert builder.buildAttachList({}, self.GLYPHMAP) is None
def test_buildAttachList_empty(self): self.assertIsNone(builder.buildAttachList({}, self.GLYPHMAP))