169 lines
13 KiB
HTML
169 lines
13 KiB
HTML
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module robofab.ufoLib</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="robofab.html"><font color="#ffffff">robofab</font></a>.ufoLib</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/projects/robofab/Lib/robofab/ufoLib.py">/code/projects/robofab/Lib/robofab/ufoLib.py</a></font></td></tr></table>
|
|
<p><tt>"<br>
|
|
A library for importing .ufo files and their descendants.<br>
|
|
This library works with robofab objects. Using the magic of the<br>
|
|
U.F.O., common attributes are exported to and read from .plist files.<br>
|
|
<br>
|
|
It contains two very simple classes for reading and writing the<br>
|
|
various components of the .ufo. Currently, the .ufo supports the<br>
|
|
files detailed below. But, these files are not absolutely required.<br>
|
|
If the a file is not included in the .ufo, it is implied that the data<br>
|
|
of that file is empty.<br>
|
|
<br>
|
|
FontName.ufo/<br>
|
|
metainfo.plist # meta info about the .ufo bundle, most impartantly the<br>
|
|
# format version number.<br>
|
|
glyphs/<br>
|
|
contents.plist # a plist mapping all glyph names to file names<br>
|
|
a.glif # a glif file<br>
|
|
...etc...<br>
|
|
fontinfo.plist # font names, versions, copyright, dimentions, etc.<br>
|
|
kerning.plist # kerning<br>
|
|
lib.plist # user definable data<br>
|
|
groups.plist # glyph group definitions</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="os.html">os</a><br>
|
|
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></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="__builtin__.html#object">__builtin__.object</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="robofab.ufoLib.html#UFOReader">UFOReader</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="robofab.ufoLib.html#UFOWriter">UFOWriter</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
</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="UFOReader">class <strong>UFOReader</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>read the various components of the .ufo<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="UFOReader-__init__"><strong>__init__</strong></a>(self, path)</dt></dl>
|
|
|
|
<dl><dt><a name="UFOReader-getCharacterMapping"><strong>getCharacterMapping</strong></a>(self)</dt><dd><tt>Return a dictionary that maps unicode values (ints) to<br>
|
|
lists of glyph names.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-getGlyphSet"><strong>getGlyphSet</strong></a>(self)</dt><dd><tt>return the GlyphSet associated with the<br>
|
|
glyphs directory in the .ufo</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-readGroups"><strong>readGroups</strong></a>(self)</dt><dd><tt>read groups.plist. returns a dict that should<br>
|
|
be applied to a font.groups <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-readInfo"><strong>readInfo</strong></a>(self, info)</dt><dd><tt>read info.plist. it requires a font.info <a href="__builtin__.html#object">object</a><br>
|
|
as an argument. this will write the attributes<br>
|
|
defined in the file into the info <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-readKerning"><strong>readKerning</strong></a>(self)</dt><dd><tt>read kerning.plist. returns a dict that should<br>
|
|
be applied to a font.kerning <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-readLib"><strong>readLib</strong></a>(self)</dt><dd><tt>read lib.plist. returns a dict that should<br>
|
|
be applied to a font.lib <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOReader-readMetaInfo"><strong>readMetaInfo</strong></a>(self)</dt><dd><tt>read metainfo.plist. mostly used<br>
|
|
for internal operations</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>__dict__</strong> = <dictproxy object at 0x1665bf0><dd><tt>dictionary for instance variables (if defined)</tt></dl>
|
|
|
|
<dl><dt><strong>__weakref__</strong> = <attribute '__weakref__' of 'UFOReader' objects><dd><tt>list of weak references to the <a href="__builtin__.html#object">object</a> (if defined)</tt></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="UFOWriter">class <strong>UFOWriter</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>write the various components of the .ufo<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="UFOWriter-__init__"><strong>__init__</strong></a>(self, path)</dt></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-getGlyphSet"><strong>getGlyphSet</strong></a>(self, glyphNameToFileNameFunc<font color="#909090">=None</font>)</dt><dd><tt>return the GlyphSet associated with the<br>
|
|
glyphs directory in the .ufo</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-makeGlyphPath"><strong>makeGlyphPath</strong></a>(self)</dt><dd><tt>make the glyphs directory in the .ufo<br>
|
|
returns the path of the directory created</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-writeGroups"><strong>writeGroups</strong></a>(self, groups)</dt><dd><tt>write groups.plist. this method requires a<br>
|
|
dict of glyph groups as an argument.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-writeInfo"><strong>writeInfo</strong></a>(self, info)</dt><dd><tt>write info.plist. this method requires a<br>
|
|
font.info <a href="__builtin__.html#object">object</a>. attributes will be taken from<br>
|
|
the given <a href="__builtin__.html#object">object</a> and written into the file</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-writeKerning"><strong>writeKerning</strong></a>(self, kerning)</dt><dd><tt>write kerning.plist. this method requires a<br>
|
|
dict of kerning pairs as an argument</tt></dd></dl>
|
|
|
|
<dl><dt><a name="UFOWriter-writeLib"><strong>writeLib</strong></a>(self, libDict)</dt><dd><tt>write lib.plist. this method requires a<br>
|
|
lib dict as an argument</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>__dict__</strong> = <dictproxy object at 0x1669fb0><dd><tt>dictionary for instance variables (if defined)</tt></dl>
|
|
|
|
<dl><dt><strong>__weakref__</strong> = <attribute '__weakref__' of 'UFOWriter' objects><dd><tt>list of weak references to the <a href="__builtin__.html#object">object</a> (if defined)</tt></dl>
|
|
|
|
<dl><dt><strong>fileCreator</strong> = 'org.robofab.ufoLib'</dl>
|
|
|
|
<dl><dt><strong>formatVersion</strong> = 1</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="-StringIO"><strong>StringIO</strong></a>(...)</dt><dd><tt><a href="#-StringIO">StringIO</a>([s]) -- Return a StringIO-like stream for reading or writing</tt></dd></dl>
|
|
<dl><dt><a name="-makeUFOPath"><strong>makeUFOPath</strong></a>(fontPath)</dt><dd><tt>return a .ufo pathname based on a .vfb pathname</tt></dd></dl>
|
|
<dl><dt><a name="-writePlistAtomically"><strong>writePlistAtomically</strong></a>(obj, path)</dt><dd><tt>Write a plist for 'obj' to 'path'. Do this sort of atomically,<br>
|
|
making it harder to cause corrupt files, for example when writePlist<br>
|
|
encounters an error halfway during write. Also: don't write out the<br>
|
|
file if it would be identical to what's already there, meaning the<br>
|
|
modification date won't get stomped when writing the same data.</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>FONTINFO_FILENAME</strong> = 'fontinfo.plist'<br>
|
|
<strong>GLYPHS_DIRNAME</strong> = 'glyphs'<br>
|
|
<strong>GROUPS_FILENAME</strong> = 'groups.plist'<br>
|
|
<strong>KERNING_FILENAME</strong> = 'kerning.plist'<br>
|
|
<strong>LIB_FILENAME</strong> = 'lib.plist'<br>
|
|
<strong>METAINFO_FILENAME</strong> = 'metainfo.plist'<br>
|
|
<strong>READ_MODE</strong> = 'r'<br>
|
|
<strong>WRITE_MODE</strong> = 'w'<br>
|
|
<strong>fontInfoAttrs</strong> = ['familyName', 'styleName', 'fullName', 'fontName', 'menuName', 'fontStyle', 'note', 'versionMajor', 'versionMinor', 'year', 'copyright', 'notice', 'trademark', 'license', 'licenseURL', 'createdBy', 'designer', 'designerURL', 'vendorURL', 'unitsPerEm', ...]</td></tr></table>
|
|
</body></html> |