222 lines
18 KiB
HTML
222 lines
18 KiB
HTML
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module robofab.objects.featureLib</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>.<a href="robofab.objects.html"><font color="#ffffff">objects</font></a>.featureLib</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/objects/featureLib.py">/code/projects/robofab/Lib/robofab/objects/featureLib.py</a></font></td></tr></table>
|
|
<p></p>
|
|
<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="robofab.objects.featureLib.html#Feature">Feature</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="__builtin__.html#dict">__builtin__.dict</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="robofab.objects.featureLib.html#FeatureSet">FeatureSet</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="Feature">class <strong>Feature</strong></a></font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt><a href="#Feature">Feature</a> contains one single feature, of any flavor.<br>
|
|
Read from feature script<br>
|
|
Write to feature script<br>
|
|
Read from simple <a href="__builtin__.html#dict">dict</a><br>
|
|
Write to simple <a href="__builtin__.html#dict">dict</a><br>
|
|
Parse some of the lines<br>
|
|
Accept edits and additions<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="Feature-__init__"><strong>__init__</strong></a>(self, name<font color="#909090">=None</font>, text<font color="#909090">=None</font>, data<font color="#909090">=None</font>, interpret<font color="#909090">=True</font>)</dt></dl>
|
|
|
|
<dl><dt><a name="Feature-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="Feature-addPos"><strong>addPos</strong></a>(self, itemOne, itemTwo, offset)</dt><dd><tt>Add a positioning statement</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-addSub"><strong>addSub</strong></a>(self, itemsIn, itemsOut, subType<font color="#909090">=0</font>)</dt><dd><tt>Add a substitution statement</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-asDict"><strong>asDict</strong></a>(self)</dt><dd><tt>Return the data of this feature as a plist ready dictionary</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-fromDict"><strong>fromDict</strong></a>(self, aDict)</dt><dd><tt>Read the data from a <a href="__builtin__.html#dict">dict</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-hasPos"><strong>hasPos</strong></a>(self)</dt><dd><tt>Return True if this feature has positioning defined.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-hasSubs"><strong>hasSubs</strong></a>(self)</dt><dd><tt>Return True if this feature has substitutions defined.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-parse"><strong>parse</strong></a>(self, featureText)</dt><dd><tt>bluntly split the lines of feature code as they come from fontlab<br>
|
|
This doesn't by any means parse all of the possible combinations <br>
|
|
in a .fea file. It parses the pos and sub lines defines within a feature.<br>
|
|
Something higher up should parse the seperate features from the .fea.<br>
|
|
<br>
|
|
It doesn't check for validity of the lines.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-readFeatureText"><strong>readFeatureText</strong></a>(self, featureText, interpret<font color="#909090">=True</font>)</dt><dd><tt>Read the feature text and try to make sense of it.<br>
|
|
<br>
|
|
Note: Should you want to preserve the actual featuretext<br>
|
|
rather than the intrepreted data, set interpret = False<br>
|
|
<br>
|
|
In case the feature text isn't properly interpreted<br>
|
|
(possible) or because the feature text is hand edited<br>
|
|
and you just want it to round trip to UFO.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Feature-writeFeatureText"><strong>writeFeatureText</strong></a>(self, wrapped<font color="#909090">=True</font>)</dt><dd><tt>return the feature as an OpenType feature string <br>
|
|
wrapped = True: wrapped with featurename { feature items; }<br>
|
|
wrapped = False: similar to that produced by FontLab</tt></dd></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="FeatureSet">class <strong>FeatureSet</strong></a>(<a href="__builtin__.html#dict">__builtin__.dict</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>A <a href="__builtin__.html#dict">dict</a> to combine all features, and write them to various places<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="robofab.objects.featureLib.html#FeatureSet">FeatureSet</a></dd>
|
|
<dd><a href="__builtin__.html#dict">__builtin__.dict</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="FeatureSet-__init__"><strong>__init__</strong></a>(self, interpret<font color="#909090">=True</font>)</dt></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-append"><strong>append</strong></a>(self, aFeature)</dt><dd><tt>Append a feature object to this set</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-asDict"><strong>asDict</strong></a>(self)</dt><dd><tt>Return a <a href="__builtin__.html#dict">dict</a> with all features also written out as dicts. Not the same as self.<br>
|
|
Data is ready for writing to plist</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-newFeature"><strong>newFeature</strong></a>(self, name)</dt><dd><tt>Add a new feature and return it</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-readFL"><strong>readFL</strong></a>(self, aFont)</dt><dd><tt>Read the feature stuff from a RFont in FL context.<br>
|
|
This can be structured better I think, but let's get <br>
|
|
something working first.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-readLib"><strong>readLib</strong></a>(self, aFont)</dt><dd><tt>Read the feature stuff from the font lib.<br>
|
|
Rather than add all this to yet another file in the UFO,<br>
|
|
just store it in the lib. UFO users will be able to read<br>
|
|
the data anyway.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-update"><strong>update</strong></a>(self, aDict)</dt><dd><tt>Accept a dictionary with all features written out as dicts.<br>
|
|
Ready for data read from plist</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-writeFL"><strong>writeFL</strong></a>(self, aFont, featureName<font color="#909090">=None</font>)</dt><dd><tt>Write one or all features back</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-writeLib"><strong>writeLib</strong></a>(self, aFont)</dt></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>__dict__</strong> = <dictproxy object at 0x129c650><dd><tt>dictionary for instance variables (if defined)</tt></dl>
|
|
|
|
<dl><dt><strong>__weakref__</strong> = <attribute '__weakref__' of 'FeatureSet' objects><dd><tt>list of weak references to the object (if defined)</tt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
|
|
<dl><dt><a name="FeatureSet-__cmp__"><strong>__cmp__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__cmp__">__cmp__</a>(y) <==> cmp(x,y)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__contains__">__contains__</a>(y) <==> y in x</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__delitem__"><strong>__delitem__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__delitem__">__delitem__</a>(y) <==> del x[y]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__eq__"><strong>__eq__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__eq__">__eq__</a>(y) <==> x==y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__ge__">__ge__</a>(y) <==> x>=y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__gt__">__gt__</a>(y) <==> x>y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__hash__"><strong>__hash__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__hash__">__hash__</a>() <==> hash(x)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__iter__"><strong>__iter__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__iter__">__iter__</a>() <==> iter(x)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__le__">__le__</a>(y) <==> x<=y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__len__">__len__</a>() <==> len(x)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__lt__">__lt__</a>(y) <==> x<y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__ne__"><strong>__ne__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__ne__">__ne__</a>(y) <==> x!=y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-__setitem__"><strong>__setitem__</strong></a>(...)</dt><dd><tt>x.<a href="#FeatureSet-__setitem__">__setitem__</a>(i, y) <==> x[i]=y</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-clear">clear</a>() -> None. Remove all items from D.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-copy"><strong>copy</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-copy">copy</a>() -> a shallow copy of D</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-get">get</a>(k[,d]) -> D[k] if k in D, else d. d defaults to None.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-has_key"><strong>has_key</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-has_key">has_key</a>(k) -> True if D has a key k, else False</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-items">items</a>() -> list of D's (key, value) pairs, as 2-tuples</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-iteritems"><strong>iteritems</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-iteritems">iteritems</a>() -> an iterator over the (key, value) items of D</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-iterkeys"><strong>iterkeys</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-iterkeys">iterkeys</a>() -> an iterator over the keys of D</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-itervalues"><strong>itervalues</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-itervalues">itervalues</a>() -> an iterator over the values of D</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-keys">keys</a>() -> list of D's keys</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-pop"><strong>pop</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-pop">pop</a>(k[,d]) -> v, remove specified key and return the corresponding value<br>
|
|
If key is not found, d is returned if given, otherwise KeyError is raised</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-popitem">popitem</a>() -> (k, v), remove and return some (key, value) pair as a<br>
|
|
2-tuple; but raise KeyError if D is empty</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-setdefault"><strong>setdefault</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-setdefault">setdefault</a>(k[,d]) -> D.<a href="#FeatureSet-get">get</a>(k,d), also set D[k]=d if k not in D</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FeatureSet-values"><strong>values</strong></a>(...)</dt><dd><tt>D.<a href="#FeatureSet-values">values</a>() -> list of D's values</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data and other attributes inherited from <a href="__builtin__.html#dict">__builtin__.dict</a>:<br>
|
|
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object at 0xa866d054><dd><tt>T.<a href="#FeatureSet-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
|
|
|
|
<dl><dt><strong>fromkeys</strong> = <built-in method fromkeys of type object at 0x115f420><dd><tt><a href="__builtin__.html#dict">dict</a>.<a href="#FeatureSet-fromkeys">fromkeys</a>(S[,v]) -> New <a href="__builtin__.html#dict">dict</a> with keys from S and values equal to v.<br>
|
|
v defaults to None.</tt></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="-extractFLFeatures"><strong>extractFLFeatures</strong></a>(aFont, interpret<font color="#909090">=True</font>)</dt><dd><tt>FontLab specific: copy features from the font to the font.lib</tt></dd></dl>
|
|
<dl><dt><a name="-getFeaturesLib"><strong>getFeaturesLib</strong></a>(aFont, interpret<font color="#909090">=True</font>)</dt><dd><tt>Get the featureset from a lib.</tt></dd></dl>
|
|
<dl><dt><a name="-putFeaturesLib"><strong>putFeaturesLib</strong></a>(aFont, featureSet)</dt><dd><tt>Put the features in the appropriate place in the font.lib</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>DEBUG</strong> = True<br>
|
|
<strong>DEFAULTNAME</strong> = 'xxxx'<br>
|
|
<strong>__all__</strong> = ['Feature', 'FeatureSet', 'many_to_many', 'one_from_many', 'simple_pair', 'extractFLFeatures', 'putFeaturesLib', 'getFeaturesLib']<br>
|
|
<strong>__warningregistry__</strong> = {('featureLib.py is deprecated.', <class exceptions.DeprecationWarning at 0x370c0>, 2): 1}<br>
|
|
<strong>featureLibKey</strong> = 'org.robofab.features'<br>
|
|
<strong>many_to_many</strong> = 0<br>
|
|
<strong>one_from_many</strong> = 1<br>
|
|
<strong>simple_pair</strong> = 0</td></tr></table>
|
|
</body></html> |