def testDecompileToXML(self): a = otTables.LigatureMorphAction() actionReader = OTTableReader(deHexStr("DEADBEEF 7FFFFFFE 80000003")) a.decompile(OTTableReader(deHexStr("1234FAB30001")), self.font, actionReader) toXML = lambda w, f: a.toXML(w, f, {"Test": "Foo"}, "Transition") self.assertEqual( getXML(toXML, self.font), [ '<Transition Test="Foo">', ' <NewState value="4660"/>', # 0x1234 = 4660 ' <Flags value="SetComponent,DontAdvance"/>', ' <ReservedFlags value="0x1AB3"/>', ' <Action GlyphIndexDelta="-2" Flags="Store"/>', ' <Action GlyphIndexDelta="3"/>', '</Transition>', ])
def testCompileActions_shouldShareSubsequences(self): state = otTables.AATState() t = state.Transitions = { i: otTables.LigatureMorphAction() for i in range(3) } ligs = [otTables.LigAction() for _ in range(3)] for i, lig in enumerate(ligs): lig.GlyphIndexDelta = i t[0].Actions = ligs[1:2] t[1].Actions = ligs[0:3] t[2].Actions = ligs[1:3] actions, actionIndex = t[0].compileActions(self.font, [state]) self.assertEqual(actions, deHexStr("00000000 00000001 80000002 80000001")) self.assertEqual( actionIndex, { deHexStr("00000000 00000001 80000002"): 0, deHexStr("00000001 80000002"): 1, deHexStr("80000002"): 2, deHexStr("80000001"): 3, })
def testCompileActions_empty(self): act = otTables.LigatureMorphAction() actions, actionIndex = act.compileActions(self.font, []) self.assertEqual(actions, b'') self.assertEqual(actionIndex, {})