fonttools/Lib/fontTools/ttLib/tables/DefaultTable.py

50 lines
1.3 KiB
Python
Raw Normal View History

from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
from fontTools.ttLib import getClassTag
class DefaultTable(object):
2015-04-26 02:01:01 -04:00
dependencies = []
2015-04-26 02:01:01 -04: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
def decompile(self, data, ttFont):
self.data = data
2015-04-26 02:01:01 -04:00
def compile(self, ttFont):
return self.data
2015-04-26 02:01:01 -04:00
def toXML(self, writer, ttFont):
if hasattr(self, "ERROR"):
writer.comment("An error occurred during the decompilation of this table")
writer.newline()
writer.comment(self.ERROR)
writer.newline()
writer.begintag("hexdata")
writer.newline()
writer.dumphex(self.compile(ttFont))
writer.endtag("hexdata")
writer.newline()
2015-04-26 02:01:01 -04:00
def fromXML(self, name, attrs, content, ttFont):
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)
self.decompile(readHex(content), ttFont)
2015-04-26 02:01:01 -04:00
def __repr__(self):
return "<'%s' table at %x>" % (self.tableTag, id(self))
2015-04-26 02:01:01 -04:00
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__
def __ne__(self, other):
result = self.__eq__(other)
return result if result is NotImplemented else not result