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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.5 KiB
Python
Raw Normal View History

from fontTools.misc.textTools import Tag
from fontTools.ttLib import getClassTag
2022-12-13 11:26:36 +00:00
class DefaultTable(object):
dependencies = []
2022-12-13 11:26:36 +00: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)
2022-12-13 11:26:36 +00:00
def decompile(self, data, ttFont):
self.data = data
2022-12-13 11:26:36 +00:00
def compile(self, ttFont):
return self.data
2022-12-13 11:26:36 +00:00
def toXML(self, writer, ttFont, **kwargs):
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()
2022-12-13 11:26:36 +00:00
def fromXML(self, name, attrs, content, ttFont):
from fontTools.misc.textTools import readHex
from fontTools import ttLib
2022-12-13 11:26:36 +00:00
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)
2022-12-13 11:26:36 +00:00
def __repr__(self):
return "<'%s' table at %x>" % (self.tableTag, id(self))
2022-12-13 11:26:36 +00: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__
2022-12-13 11:26:36 +00:00
def __ne__(self, other):
result = self.__eq__(other)
return result if result is NotImplemented else not result