API Reference for Enthought Tool Suite 3.0.1
ttLib/sfnt.py -- low-level module to deal with the sfnt file format.
(Normally you don't have to use these classes explicitly; they are used automatically by ttLib.TTFont.)
The reading and writing of sfnt files is separated in two distinct classes, since whenever to number of tables changes or whenever a table's length chages you need to rewrite the whole file anyway.
magic value corresponding to 0xb1b0afba; used in lieu of the hex constant to avoid signedness issues with python 2.4
CHECKSUM_MAGIC = -Const(1313820742)
sfntDirectoryEntryFormat = """ > # big endian tag: 4s checkSum: l offset: l length: l """
sfntDirectoryEntrySize = sstruct.calcsize(sfntDirectoryEntryFormat)
sfntDirectoryFormat = """ > # big endian sfntVersion: 4s numTables: H # number of tables searchRange: H # (max2 <= numTables)*16 entrySelector: H # log2(max2 <= numTables) rangeShift: H # numTables*16-searchRange """
sfntDirectorySize = sstruct.calcsize(sfntDirectoryFormat)
Calculate the checksum for an arbitrary block of data. Optionally takes a 'start' argument, which allows you to calculate a checksum in chunks by feeding it a previous result.
If the data length is not a multiple of four, it assumes it is to be padded with null byte.
Calculate searchRange, entrySelector, rangeShift for the sfnt directory. 'n' is the number of tables.
Return the highest exponent of two, so that (2 ** exponent) <= x
| Local name | Refers to |
|---|---|
| numpy | numpy |
| os | os |
| struct | struct |
© Copyright 2002-2008 Enthought, Inc.