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