blob: 2578eb7c19455cf04dfac02e364ded0daf16a26d [file] [log] [blame]
Just7842e561999-12-16 21:34:53 +00001import string
2import sys
3
4class DefaultTable:
5
6 dependencies = []
7
8 def __init__(self, tag):
9 self.tableTag = tag
10
11 def decompile(self, data, ttFont):
12 self.data = data
13
14 def compile(self, ttFont):
15 return self.data
16
17 def toXML(self, writer, ttFont):
Justf8fd4772000-01-03 23:00:10 +000018 if hasattr(self, "ERROR"):
19 writer.comment("An error occurred during the decompilation of this table")
20 writer.newline()
21 writer.comment(self.ERROR)
22 writer.newline()
Just7842e561999-12-16 21:34:53 +000023 writer.begintag("hexdata")
24 writer.newline()
25 writer.dumphex(self.compile(ttFont))
26 writer.endtag("hexdata")
27 writer.newline()
28
29 def fromXML(self, (name, attrs, content), ttFont):
30 from fontTools.misc.textTools import readHex
31 from fontTools import ttLib
Behdad Esfahbod180ace62013-11-27 02:40:30 -050032 if name != "hexdata":
Behdad Esfahbodcd5aad92013-11-27 02:42:28 -050033 raise ttLib.TTLibError("can't handle '%s' element" % name)
Just7842e561999-12-16 21:34:53 +000034 self.decompile(readHex(content), ttFont)
35
36 def __repr__(self):
37 return "<'%s' table at %x>" % (self.tableTag, id(self))
38
39 def __cmp__(self, other):
Behdad Esfahbod0ba7aa72013-10-28 12:07:15 +010040 if type(self) != type(other): return cmp(type(self), type(other))
41 if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
Behdad Esfahbod96b321c2013-08-17 11:11:22 -040042
Just7842e561999-12-16 21:34:53 +000043 return cmp(self.__dict__, other.__dict__)
44