2014-01-14 15:07:50 +08:00
|
|
|
from __future__ import print_function, division, absolute_import
|
2013-11-27 17:27:45 -05:00
|
|
|
from fontTools.misc.py23 import *
|
2013-11-27 02:34:11 -05:00
|
|
|
from . import DefaultTable
|
|
|
|
from . import ttProgram
|
1999-12-16 21:34:53 +00:00
|
|
|
|
|
|
|
class table__f_p_g_m(DefaultTable.DefaultTable):
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def decompile(self, data, ttFont):
|
2000-02-01 15:31:18 +00:00
|
|
|
program = ttProgram.Program()
|
|
|
|
program.fromBytecode(data)
|
|
|
|
self.program = program
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def compile(self, ttFont):
|
2000-02-01 15:31:18 +00:00
|
|
|
return self.program.getBytecode()
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2000-02-01 15:31:18 +00:00
|
|
|
def toXML(self, writer, ttFont):
|
|
|
|
self.program.toXML(writer, ttFont)
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2013-11-27 03:19:32 -05:00
|
|
|
def fromXML(self, name, attrs, content, ttFont):
|
2000-02-01 15:31:18 +00:00
|
|
|
program = ttProgram.Program()
|
2013-11-27 03:19:32 -05:00
|
|
|
program.fromXML(name, attrs, content, ttFont)
|
2000-02-01 15:31:18 +00:00
|
|
|
self.program = program
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2015-06-25 18:26:23 +01:00
|
|
|
def __bool__(self):
|
2015-06-25 19:22:01 +01:00
|
|
|
"""
|
|
|
|
>>> fpgm = table__f_p_g_m()
|
|
|
|
>>> bool(fpgm)
|
|
|
|
False
|
|
|
|
>>> p = ttProgram.Program()
|
|
|
|
>>> fpgm.program = p
|
|
|
|
>>> bool(fpgm)
|
|
|
|
False
|
|
|
|
>>> bc = bytearray([0])
|
|
|
|
>>> p.fromBytecode(bc)
|
|
|
|
>>> bool(fpgm)
|
|
|
|
True
|
|
|
|
>>> p.bytecode.pop()
|
|
|
|
0
|
|
|
|
>>> bool(fpgm)
|
|
|
|
False
|
|
|
|
"""
|
2015-06-25 18:26:23 +01:00
|
|
|
return hasattr(self, 'program') and bool(self.program)
|
|
|
|
|
|
|
|
__nonzero__ = __bool__
|
2015-06-25 19:22:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
import sys
|
|
|
|
import doctest
|
|
|
|
sys.exit(doctest.testmod().failed)
|