[otlLib] Move building of ComponentRecords from feaLib to otlLib
This commit is contained in:
parent
15ca8bb0a0
commit
f42d312580
@ -1014,13 +1014,13 @@ class MarkLigPosBuilder(LookupBuilder):
|
||||
return result
|
||||
|
||||
def build(self):
|
||||
markClasses = self.buildMarkClasses_(self.marks)
|
||||
markClassList = sorted(markClasses.keys(), key=markClasses.get)
|
||||
st = otTables.MarkLigPos()
|
||||
st.Format = 1
|
||||
st.MarkCoverage = otl.buildCoverage(self.marks, self.glyphMap)
|
||||
markClasses = self.buildMarkClasses_(self.marks)
|
||||
st.ClassCount = len(markClasses)
|
||||
st.MarkArray = self.buildMarkArray_(self.marks, markClasses)
|
||||
|
||||
st.LigatureCoverage = otl.buildCoverage(self.ligatures, self.glyphMap)
|
||||
st.LigatureArray = otTables.LigatureArray()
|
||||
st.LigatureArray.LigatureCount = len(self.ligatures)
|
||||
@ -1031,12 +1031,9 @@ class MarkLigPosBuilder(LookupBuilder):
|
||||
attach.ComponentCount = len(components)
|
||||
attach.ComponentRecord = []
|
||||
for component in components:
|
||||
crec = otTables.ComponentRecord()
|
||||
attach.ComponentRecord.append(crec)
|
||||
crec.LigatureAnchor = []
|
||||
for markClass in sorted(markClasses.keys(),
|
||||
key=markClasses.get):
|
||||
crec.LigatureAnchor.append(component.get(markClass))
|
||||
anchors = [component.get(mc) for mc in markClassList]
|
||||
attach.ComponentRecord.append(
|
||||
otl.buildComponentRecord(anchors))
|
||||
st.LigatureArray.LigatureAttach.append(attach)
|
||||
|
||||
return self.buildLookup_([st])
|
||||
|
@ -110,6 +110,13 @@ def buildAnchor(x, y, point=None, deviceX=None, deviceY=None):
|
||||
return self
|
||||
|
||||
|
||||
def buildComponentRecord(anchors):
|
||||
"""[otTables.Anchor, otTables.Anchor, ...] --> otTables.ComponentRecord"""
|
||||
self = ot.ComponentRecord()
|
||||
self.LigatureAnchor = anchors
|
||||
return self
|
||||
|
||||
|
||||
def buildCursivePos(attach, glyphMap):
|
||||
"""{"alef": (entry, exit)} --> otTables.CursivePos"""
|
||||
self = ot.CursivePos()
|
||||
|
@ -109,6 +109,22 @@ class BuilderTest(unittest.TestCase):
|
||||
' <CaretValuePoint value="23"/>'
|
||||
'</CaretValue>')
|
||||
|
||||
def test_buildComponentRecord(self):
|
||||
a = builder.buildAnchor
|
||||
rec = builder.buildComponentRecord([a(500, -20), None, a(300, -15)])
|
||||
self.assertEqual(getXML(rec.toXML),
|
||||
'<ComponentRecord>'
|
||||
' <LigatureAnchor index="0" Format="1">'
|
||||
' <XCoordinate value="500"/>'
|
||||
' <YCoordinate value="-20"/>'
|
||||
' </LigatureAnchor>'
|
||||
' <LigatureAnchor index="1" empty="1"/>'
|
||||
' <LigatureAnchor index="2" Format="1">'
|
||||
' <XCoordinate value="300"/>'
|
||||
' <YCoordinate value="-15"/>'
|
||||
' </LigatureAnchor>'
|
||||
'</ComponentRecord>')
|
||||
|
||||
def test_buildCoverage(self):
|
||||
cov = builder.buildCoverage({"two", "four"}, {"two": 2, "four": 4})
|
||||
self.assertEqual(getXML(cov.toXML),
|
||||
|
Loading…
x
Reference in New Issue
Block a user