~ubuntu-branches/ubuntu/maverick/fonttools/maverick

« back to all changes in this revision

Viewing changes to Lib/fontTools/ttLib/tables/C_F_F_.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 DefaultTable
 
2
from fontTools import cffLib
 
3
 
 
4
 
 
5
class table_C_F_F_(DefaultTable.DefaultTable):
 
6
        
 
7
        def __init__(self, tag):
 
8
                DefaultTable.DefaultTable.__init__(self, tag)
 
9
                self.cff = cffLib.CFFFontSet()
 
10
                self._gaveGlyphOrder = 0
 
11
        
 
12
        def decompile(self, data, otFont):
 
13
                from cStringIO import StringIO
 
14
                self.cff.decompile(StringIO(data), otFont)
 
15
                assert len(self.cff) == 1, "can't deal with multi-font CFF tables."
 
16
        
 
17
        def compile(self, otFont):
 
18
                from cStringIO import StringIO
 
19
                f = StringIO()
 
20
                self.cff.compile(f, otFont)
 
21
                return f.getvalue()
 
22
        
 
23
        def haveGlyphNames(self):
 
24
                if hasattr(self.cff[self.cff.fontNames[0]], "ROS"):
 
25
                        return 0  # CID-keyed font
 
26
                else:
 
27
                        return 1
 
28
        
 
29
        def getGlyphOrder(self):
 
30
                if self._gaveGlyphOrder:
 
31
                        from fontTools import ttLib
 
32
                        raise ttLib.TTLibError, "illegal use of getGlyphOrder()"
 
33
                self._gaveGlyphOrder = 1
 
34
                return self.cff[self.cff.fontNames[0]].getGlyphOrder()
 
35
        
 
36
        def setGlyphOrder(self, glyphOrder):
 
37
                pass
 
38
                # XXX
 
39
                #self.cff[self.cff.fontNames[0]].setGlyphOrder(glyphOrder)
 
40
        
 
41
        def toXML(self, writer, otFont, progress=None):
 
42
                self.cff.toXML(writer, progress)
 
43
        
 
44
        def fromXML(self, (name, attrs, content), otFont):
 
45
                if not hasattr(self, "cff"):
 
46
                        self.cff = cffLib.CFFFontSet()
 
47
                self.cff.fromXML((name, attrs, content))
 
48