예제 #1
0
파일: sfnt.py 프로젝트: GaZ3ll3/enable
        def close(self, closeStream=1):
                """All tables must have been written to disk. Now write the
                directory.
                """
                tables = self.tables.items()
                tables.sort()
                if len(tables) <> self.numTables:
                        from kiva.fonttools.fontTools import ttLib
                        raise ttLib.TTLibError, "wrong number of tables; expected %d, found %d" % (self.numTables, len(tables))

                directory = sstruct.pack(sfntDirectoryFormat, self)

                self.file.seek(sfntDirectorySize)
                for tag, entry in tables:
                        directory = directory + entry.toString()
                self.calcMasterChecksum(directory)
                self.file.seek(0)
                self.file.write(directory)
                if closeStream:
                        self.file.close()
예제 #2
0
파일: _n_a_m_e.py 프로젝트: GaZ3ll3/enable
 def compile(self, ttFont):
         if not hasattr(self, "names"):
                 # only happens when there are NO name table entries read
                 # from the TTX file
                 self.names = []
         self.names.sort()  # sort according to the spec; see NameRecord.__cmp__()
         stringData = ""
         format = 0
         n = len(self.names)
         stringoffset = 6 + n * sstruct.calcsize(nameRecordFormat)
         data = struct.pack(">HHH", format, n, stringoffset)
         lastoffset = 0
         done = {}  # remember the data so we can reuse the "pointers"
         for name in self.names:
                 if done.has_key(name.string):
                         name.offset, name.length = done[name.string]
                 else:
                         name.offset, name.length = done[name.string] = len(stringData), len(name.string)
                         stringData = stringData + name.string
                 data = data + sstruct.pack(nameRecordFormat, name)
         return data + stringData
예제 #3
0
파일: sfnt.py 프로젝트: GaZ3ll3/enable
 def toString(self):
         return sstruct.pack(sfntDirectoryEntryFormat, self)