def build(self): st = otTables.CursivePos() st.Format = 1 st.Coverage = self.buildCoverage_(self.attachments.keys()) st.EntryExitCount = len(self.attachments) st.EntryExitRecord = [] for glyph in st.Coverage.glyphs: location, entryAnchor, exitAnchor = self.attachments[glyph] rec = otTables.EntryExitRecord() st.EntryExitRecord.append(rec) rec.EntryAnchor = entryAnchor rec.ExitAnchor = exitAnchor return self.buildLookup_([st])
def buildCursivePosSubtable(attach, glyphMap): """{"alef": (entry, exit)} --> otTables.CursivePos""" if not attach: return None self = ot.CursivePos() self.Format = 1 self.Coverage = buildCoverage(attach.keys(), glyphMap) self.EntryExitRecord = [] for glyph in self.Coverage.glyphs: entryAnchor, exitAnchor = attach[glyph] rec = ot.EntryExitRecord() rec.EntryAnchor = entryAnchor rec.ExitAnchor = exitAnchor self.EntryExitRecord.append(rec) self.EntryExitCount = len(self.EntryExitRecord) return self
def parseCursive(self, lines, font, _lookupMap=None): self.Format = 1 self.EntryExitRecord = [] records = {} for line in lines: assert len(line) in [3,4], line idx,klass = { 'entry': (0,ot.EntryAnchor), 'exit': (1,ot.ExitAnchor), }[line[0]] glyph = makeGlyph(line[1]) if glyph not in records: records[glyph] = [None,None] assert records[glyph][idx] is None, (glyph, idx) records[glyph][idx] = makeAnchor(line[2:], klass) self.Coverage = makeCoverage(records.keys(), font) recs = self.EntryExitRecord = [] for glyph in self.Coverage.glyphs: rec = ot.EntryExitRecord() rec.EntryAnchor,rec.ExitAnchor = records[glyph] recs.append(rec) self.EntryExitCount = len(self.EntryExitRecord)