2014-01-14 15:07:50 +08:00
|
|
|
from __future__ import print_function, division, absolute_import
|
2013-11-27 15:16:28 -05:00
|
|
|
from fontTools.misc.py23 import *
|
2014-03-28 14:04:01 -07:00
|
|
|
from fontTools.ttLib import getClassTag
|
1999-12-16 21:34:53 +00:00
|
|
|
|
2013-11-28 14:26:58 -05:00
|
|
|
class DefaultTable(object):
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
dependencies = []
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2014-03-28 14:04:01 -07:00
|
|
|
def __init__(self, tag=None):
|
|
|
|
if tag is None:
|
|
|
|
tag = getClassTag(self.__class__)
|
2013-11-27 18:16:43 -05:00
|
|
|
self.tableTag = Tag(tag)
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def decompile(self, data, ttFont):
|
|
|
|
self.data = data
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def compile(self, ttFont):
|
|
|
|
return self.data
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2013-12-01 04:05:40 -05:00
|
|
|
def toXML(self, writer, ttFont, progress=None):
|
2000-01-03 23:00:10 +00:00
|
|
|
if hasattr(self, "ERROR"):
|
|
|
|
writer.comment("An error occurred during the decompilation of this table")
|
|
|
|
writer.newline()
|
|
|
|
writer.comment(self.ERROR)
|
|
|
|
writer.newline()
|
1999-12-16 21:34:53 +00:00
|
|
|
writer.begintag("hexdata")
|
|
|
|
writer.newline()
|
|
|
|
writer.dumphex(self.compile(ttFont))
|
|
|
|
writer.endtag("hexdata")
|
|
|
|
writer.newline()
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2013-11-27 03:19:32 -05:00
|
|
|
def fromXML(self, name, attrs, content, ttFont):
|
1999-12-16 21:34:53 +00:00
|
|
|
from fontTools.misc.textTools import readHex
|
|
|
|
from fontTools import ttLib
|
2013-11-27 02:40:30 -05:00
|
|
|
if name != "hexdata":
|
2013-11-27 02:42:28 -05:00
|
|
|
raise ttLib.TTLibError("can't handle '%s' element" % name)
|
1999-12-16 21:34:53 +00:00
|
|
|
self.decompile(readHex(content), ttFont)
|
2015-04-26 02:01:01 -04:00
|
|
|
|
1999-12-16 21:34:53 +00:00
|
|
|
def __repr__(self):
|
|
|
|
return "<'%s' table at %x>" % (self.tableTag, id(self))
|
2015-04-26 02:01:01 -04:00
|
|
|
|
2013-12-06 22:25:48 -05:00
|
|
|
def __ne__(self, other):
|
|
|
|
return not self.__eq__(other)
|
2013-11-27 18:58:45 -05:00
|
|
|
def __eq__(self, other):
|
|
|
|
if type(self) != type(other):
|
2013-12-07 03:40:44 -05:00
|
|
|
return NotImplemented
|
2013-11-27 18:58:45 -05:00
|
|
|
return self.__dict__ == other.__dict__
|