Example #1
0
 def testDecompileToXML(self):
     a = otTables.InsertionMorphAction()
     actionReader = OTTableReader(
         deHexStr("DEAD BEEF 0002 0001 0004 0002 0003 DEAD BEEF"))
     a.decompile(OTTableReader(deHexStr("1234 FC43 0005 0002")), self.font,
                 actionReader)
     toXML = lambda w, f: a.toXML(w, f, {"Test": "Foo"}, "Transition")
     self.assertEqual(getXML(toXML, self.font), self.MORPH_ACTION_XML)
Example #2
0
 def testCompileFromXML(self):
     a = otTables.InsertionMorphAction()
     for name, attrs, content in parseXML(self.MORPH_ACTION_XML):
         a.fromXML(name, attrs, content, self.font)
     writer = OTTableWriter()
     a.compile(writer,
               self.font,
               actionIndex={
                   ('B', 'C'): 9,
                   ('B', 'A', 'D'): 7
               })
     self.assertEqual(hexStr(writer.getAllData()), "1234fc4300090007")
Example #3
0
 def testCompileActions_shouldShareSubsequences(self):
     state = otTables.AATState()
     t = state.Transitions = {
         i: otTables.InsertionMorphAction()
         for i in range(3)
     }
     t[1].CurrentInsertionAction = []
     t[0].MarkedInsertionAction = ['A']
     t[1].CurrentInsertionAction = ['C', 'D']
     t[1].MarkedInsertionAction = ['B']
     t[2].CurrentInsertionAction = ['B', 'C', 'D']
     t[2].MarkedInsertionAction = ['C', 'D']
     actions, actionIndex = t[0].compileActions(self.font, [state])
     self.assertEqual(actions, deHexStr('0002 0003 0004 0001'))
     self.assertEqual(
         actionIndex, {
             ('A', ): 3,
             ('B', ): 0,
             ('B', 'C'): 0,
             ('B', 'C', 'D'): 0,
             ('C', ): 1,
             ('C', 'D'): 1,
             ('D', ): 2,
         })
Example #4
0
 def testCompileActions_empty(self):
     act = otTables.InsertionMorphAction()
     actions, actionIndex = act.compileActions(self.font, [])
     self.assertEqual(actions, b'')
     self.assertEqual(actionIndex, {})