1from . import DefaultTable 2from . import ttProgram 3 4class table__f_p_g_m(DefaultTable.DefaultTable): 5 6 def decompile(self, data, ttFont): 7 program = ttProgram.Program() 8 program.fromBytecode(data) 9 self.program = program 10 11 def compile(self, ttFont): 12 return self.program.getBytecode() 13 14 def toXML(self, writer, ttFont): 15 self.program.toXML(writer, ttFont) 16 17 def fromXML(self, name, attrs, content, ttFont): 18 program = ttProgram.Program() 19 program.fromXML(name, attrs, content, ttFont) 20 self.program = program 21 22 def __bool__(self): 23 """ 24 >>> fpgm = table__f_p_g_m() 25 >>> bool(fpgm) 26 False 27 >>> p = ttProgram.Program() 28 >>> fpgm.program = p 29 >>> bool(fpgm) 30 False 31 >>> bc = bytearray([0]) 32 >>> p.fromBytecode(bc) 33 >>> bool(fpgm) 34 True 35 >>> p.bytecode.pop() 36 0 37 >>> bool(fpgm) 38 False 39 """ 40 return hasattr(self, 'program') and bool(self.program) 41 42 __nonzero__ = __bool__ 43 44 45if __name__ == "__main__": 46 import sys 47 import doctest 48 sys.exit(doctest.testmod().failed) 49