~ubuntu-branches/ubuntu/feisty/fonttools/feisty

« back to all changes in this revision

Viewing changes to Lib/fontTools/ttLib/tables/DefaultTable.py

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Fok
  • Date: 2003-11-18 00:53:59 UTC
  • Revision ID: james.westby@ubuntu.com-20031118005359-pqirsxbgdz0f0xmx
Tags: upstream-1.99+2.0b1+cvs20031014
ImportĀ upstreamĀ versionĀ 1.99+2.0b1+cvs20031014

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import string
 
2
import sys
 
3
 
 
4
class 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):
 
18
                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()
 
23
                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
 
32
                if name <> "hexdata":
 
33
                        raise ttLib.TTLibError, "can't handle '%s' element" % name
 
34
                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):
 
40
                return cmp(self.__dict__, other.__dict__)
 
41