129 lines
8.5 KiB
HTML
129 lines
8.5 KiB
HTML
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module fontTools.ttLib.sfnt</title>
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="#7799ee">
|
|
<td valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="fontTools.html"><font color="#ffffff">fontTools</font></a>.<a href="fontTools.ttLib.html"><font color="#ffffff">ttLib</font></a>.sfnt</strong></big></big></font></td
|
|
><td align=right valign=bottom
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/code/fontTools/Lib/fontTools/ttLib/sfnt.py">/code/fontTools/Lib/fontTools/ttLib/sfnt.py</a></font></td></tr></table>
|
|
<p><tt>ttLib/sfnt.py -- low-level module to deal with the sfnt file format.<br>
|
|
<br>
|
|
Defines two public classes:<br>
|
|
<a href="#SFNTReader">SFNTReader</a><br>
|
|
<a href="#SFNTWriter">SFNTWriter</a><br>
|
|
<br>
|
|
(Normally you don't have to use these classes explicitly; they are <br>
|
|
used automatically by ttLib.TTFont.)<br>
|
|
<br>
|
|
The reading and writing of sfnt files is separated in two distinct <br>
|
|
classes, since whenever to number of tables changes or whenever<br>
|
|
a table's length chages you need to rewrite the whole file anyway.</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#aa55cc">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="Numeric.html">Numeric</a><br>
|
|
</td><td width="25%" valign=top><a href="os.html">os</a><br>
|
|
</td><td width="25%" valign=top><a href="sstruct.html">sstruct</a><br>
|
|
</td><td width="25%" valign=top><a href="struct.html">struct</a><br>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ee77aa">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl>
|
|
<dt><font face="helvetica, arial"><a href="fontTools.ttLib.sfnt.html#SFNTDirectoryEntry">SFNTDirectoryEntry</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="fontTools.ttLib.sfnt.html#SFNTReader">SFNTReader</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="fontTools.ttLib.sfnt.html#SFNTWriter">SFNTWriter</a>
|
|
</font></dt></dl>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="SFNTDirectoryEntry">class <strong>SFNTDirectoryEntry</strong></a></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="SFNTDirectoryEntry-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTDirectoryEntry-fromFile"><strong>fromFile</strong></a>(self, file)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTDirectoryEntry-fromString"><strong>fromString</strong></a>(self, str)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTDirectoryEntry-toString"><strong>toString</strong></a>(self)</dt></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="SFNTReader">class <strong>SFNTReader</strong></a></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="SFNTReader-__delitem__"><strong>__delitem__</strong></a>(self, tag)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTReader-__getitem__"><strong>__getitem__</strong></a>(self, tag)</dt><dd><tt>Fetch the raw table data.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SFNTReader-__init__"><strong>__init__</strong></a>(self, file, checkChecksums<font color="#909090">=1</font>)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTReader-close"><strong>close</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTReader-has_key"><strong>has_key</strong></a>(self, tag)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTReader-keys"><strong>keys</strong></a>(self)</dt></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="SFNTWriter">class <strong>SFNTWriter</strong></a></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="SFNTWriter-__init__"><strong>__init__</strong></a>(self, file, numTables, sfntVersion<font color="#909090">='<font color="#c040c0">\x00\x01\x00\x00</font>'</font>)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTWriter-__setitem__"><strong>__setitem__</strong></a>(self, tag, data)</dt><dd><tt>Write raw table data to disk.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SFNTWriter-calcMasterChecksum"><strong>calcMasterChecksum</strong></a>(self, directory)</dt></dl>
|
|
|
|
<dl><dt><a name="SFNTWriter-close"><strong>close</strong></a>(self)</dt><dd><tt>All tables must have been written to disk. Now write the<br>
|
|
directory.</tt></dd></dl>
|
|
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#eeaa77">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl><dt><a name="-calcChecksum"><strong>calcChecksum</strong></a>(data, start<font color="#909090">=0</font>)</dt><dd><tt>Calculate the checksum for an arbitrary block of data.<br>
|
|
Optionally takes a 'start' argument, which allows you to<br>
|
|
calculate a checksum in chunks by feeding it a previous<br>
|
|
result.<br>
|
|
<br>
|
|
If the data length is not a multiple of four, it assumes<br>
|
|
it is to be padded with null byte.</tt></dd></dl>
|
|
<dl><dt><a name="-getSearchRange"><strong>getSearchRange</strong></a>(n)</dt><dd><tt>Calculate searchRange, entrySelector, rangeShift for the<br>
|
|
sfnt directory. 'n' is the number of tables.</tt></dd></dl>
|
|
<dl><dt><a name="-maxPowerOfTwo"><strong>maxPowerOfTwo</strong></a>(x)</dt><dd><tt>Return the highest exponent of two, so that<br>
|
|
(2 ** exponent) <= x</tt></dd></dl>
|
|
</td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#55aa55">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
<td width="100%"><strong>sfntDirectoryEntryFormat</strong> = '<font color="#c040c0">\n\t\t</font>> # big endian<font color="#c040c0">\n\t\t</font>tag: 4s<font color="#c040c0">\n\t\t</font>checkSum: l<font color="#c040c0">\n\t\t</font>offset: l<font color="#c040c0">\n\t\t</font>length: l<font color="#c040c0">\n</font>'<br>
|
|
<strong>sfntDirectoryEntrySize</strong> = 16<br>
|
|
<strong>sfntDirectoryFormat</strong> = '<font color="#c040c0">\n\t\t</font>> # big endian<font color="#c040c0">\n\t\t</font>sfntVersion: 4s<font color="#c040c0">\n\t\t</font>numTabl...<font color="#c040c0">\t</font>rangeShift: H # numTables*16-searchRange<font color="#c040c0">\n</font>'<br>
|
|
<strong>sfntDirectorySize</strong> = 12</td></tr></table>
|
|
</body></html> |