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