287 lines
15 KiB
HTML
287 lines
15 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>FontLab Remote</title>
|
|
<link href="../default.css" type="text/css" rel="stylesheet" />
|
|
</head><body>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="http://www.google-analytics.com/urchin.js"></script>
|
|
<script type="text/javascript">
|
|
_uacct = "UA-2044310-2";
|
|
urchinTracker();
|
|
</script>
|
|
|
|
<div id="modellogo">
|
|
<img src="../img/drawmodel_header.jpg" width="595" height="112" />
|
|
</div>
|
|
<div class="leftcontent">
|
|
<h1 class="crb-seealso">
|
|
RoboFab
|
|
</h1>
|
|
<p class="menu">
|
|
<a href="../index.html">
|
|
Home
|
|
</a>
|
|
<br />
|
|
<a href="../download/index.html">
|
|
Download v1.1.1
|
|
</a>
|
|
<br />
|
|
<a href="../intro.html">
|
|
Intro
|
|
</a>
|
|
<br />
|
|
<a href="../install.html">
|
|
Install Notes
|
|
</a>
|
|
<br />
|
|
<a href="../history.html">
|
|
History
|
|
</a>
|
|
<br />
|
|
<a href="../executive.html">
|
|
Summary
|
|
</a>
|
|
</p>
|
|
|
|
<p class="menu">
|
|
<a href="index.html">
|
|
How to's
|
|
</a>
|
|
<br />
|
|
<a href="../talks/index.html">
|
|
Step by step
|
|
</a>
|
|
<br />
|
|
<a href="../tools/dialogs.html">
|
|
Fab Dialogs
|
|
</a>
|
|
<br />
|
|
<a href="../objects/index.html">
|
|
Object reference
|
|
</a>
|
|
<br />
|
|
<a href="../objects/model.html">
|
|
Object map
|
|
</a>
|
|
<br />
|
|
<a href="../tools/index.html">
|
|
Tools
|
|
</a>
|
|
<br />
|
|
<a href="../ufo/index.html">
|
|
UFO Overview
|
|
</a>
|
|
<br />
|
|
<a href="../ufo/specification.html">
|
|
UFO Spec
|
|
</a>
|
|
<br />
|
|
<a href="../limitations.html">
|
|
Fab Limitations
|
|
</a>
|
|
|
|
<a href="../links/index.html">
|
|
Links
|
|
</a>
|
|
<br />
|
|
<a href="../credits.html">
|
|
Credits
|
|
</a>
|
|
</p>
|
|
|
|
<h1 class="crb-seealso">
|
|
Support RoboFab
|
|
</h1>
|
|
|
|
|
|
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
|
<input type="hidden" name="cmd" value="_s-xclick">
|
|
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
|
|
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
|
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYCwSKfv3n+m7gMAQttRdiUdaGxSHt2oKSNvYzSFsBPjNsxmwva6gPCPUFV5sfJY1QJQuzQk8iXLqxb/mKmdoWc8Z2Eq7+rUtgo0149vBg35woLGv8zoMkgbghCcHJjdclAl/KOSqhjCOblpCsXpJwy9fs1wuxSOrbDwO5C26bXOkzELMAkGBSsOAwIaBQAwgcQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQItAyVpzgCAg2AgaA4Sx/oMTU9S7iN3M25nZ1ebqx2vt1UMGcUGtDmk13jLL1IO4lXmG1Lb/lTKJSg1d2Aj/OQJrOpL7T2yEGFkqK0yojO8+CUXHOihCJ+ovr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GkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMDYwNTA1MDk0MDI3WjAjBgkqhkiG9w0BCQQxFgQUuGyd1NYqa4RVlKQ48vrRVsRjTXYwDQYJKoZIhvcNAQEBBQAEgYC6ZiJbUzbugBCir8QnRYRas0tJrdMXcUXQnO3HlO5Zj7+F9cGT2NI73VgB5Vhpu+OaMjBcmc8f0LSP6/ns48YZiIki3+nilxKt/sEq3R0B9XeoB21nHxLmlWkFGMGKxPexWEkjJq0v3UNhS6mYDAIdLkrLE6RHRYAVvKET8hkzDw==-----END PKCS7-----
|
|
">
|
|
</form>
|
|
|
|
|
|
|
|
<h2 class="crb-seealso">
|
|
Up
|
|
</h2>
|
|
|
|
<p class="menu">
|
|
<p class="bonbon_uplink"><a href="index.html">Back to How To</a></p>
|
|
</p>
|
|
|
|
<h2 class="crb-seealso">
|
|
See also
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p class="menu">
|
|
<a href="../objects/lib.html">RLib</a><br /><a href="buildingaccents.html">Building accents</a><br /><a href="generatefonts.html">Generate Fonts</a><br /><a href="index.html">How To</a><br /><a href="interpolate.html">How to interpolate</a><br /><a href="lowlevel.html">How to get to FontLab stuff</a><br /><a href="scripting.html">Scripting</a><br /><a href="understandcontours.html">Understanding Contours</a><br /><a href="usepens.html">Using Pens</a><br /><a href="usethelib.html">Using the lib</a><br /><a href="world.html">The world module</a><br />
|
|
</p>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
<a href="../feedback.html">
|
|
Feedback
|
|
</a>
|
|
<br />
|
|
<a href="../map.html">
|
|
Sitemap
|
|
</a>
|
|
<br />
|
|
Please also refer to the
|
|
<a href="../download/license.html">
|
|
Legal
|
|
</a>
|
|
<br />
|
|
Copyright 2003-2006 RoboFab
|
|
<br />
|
|
version 1.1.1
|
|
</div>
|
|
|
|
<div class="google">
|
|
|
|
|
|
<h2>RoboFab Mailinglist</h2>
|
|
<p>
|
|
Join the RoboFab users community at Google groups.
|
|
</p>
|
|
|
|
|
|
<img src="http://groups.google.com/groups/img/3nb/groups_bar.gif" alt="Google Groups" height="26" width="132" />
|
|
|
|
<p>
|
|
<form action="http://groups.google.com/group/robofab/boxsubscribe">
|
|
Email: <input type="text" name="../email" />
|
|
<input type="submit" name="../sub" value="Subscribe" />
|
|
</form>
|
|
</p>
|
|
<p>
|
|
<a href="http://groups.google.com/group/robofab">Visit this group</a>
|
|
</p>
|
|
|
|
|
|
<h2>RoboFab Sponsors</h2>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
google_ad_client = "pub-3703953449723704";
|
|
google_ad_width = 120;
|
|
google_ad_height = 600;
|
|
google_ad_format = "120x600_as";
|
|
google_ad_type = "text_image";
|
|
google_ad_channel ="";
|
|
google_color_border = "336699";
|
|
google_color_bg = "FFFFFF";
|
|
google_color_link = "0000FF";
|
|
google_color_url = "008000";
|
|
google_color_text = "000000";
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="content">
|
|
<h1>FontLab Remote</h1>
|
|
<p>
|
|
A neat feature in RoboFab for FontLab on MacOS. RoboFab can install an AppleEvent handler in FontLab to make FontLab respond to calls from other applications. There is code to communicate with FontLab using this AppleEvent and to make it execute code and exchange data such as glyphs. How useful this remote stuff is depends on what you want to do with it. We thought it was cool. The 'remote' relates to one application controlling another. Both applications need to run on the same machine, it does not mean that FontLab is accepting commands over a network for instance. For that we need another tool.
|
|
</p>
|
|
<h2>How?</h2> <h3>Step 1: Start the remote stuff in FontLab</h3>
|
|
<p>
|
|
The first thing you need to do is start the AppleEvent support in FontLab. That's done by importing the remote module.
|
|
</p>
|
|
|
|
<div class="pythonsource"><pre># start the remote stuff in FontLab<br><span class="py_res">import</span> <span class="py_key">robofab</span>.<span class="py_key">tools</span>.<span class="py_key">remote</span></pre></div>
|
|
|
|
<div class="pythonoutput"><pre><span class="py_key">FontLabRemote</span> <span class="py_res">is</span> <span class="py_key">on</span>.</pre></div>
|
|
|
|
<h3>Step 2: Start the Python IDE</h3>
|
|
<p>
|
|
You can now send commands, bits of code and entire glyphs to FontLab from the Python IDE.
|
|
</p>
|
|
|
|
<div class="pythonsource"><pre># first, try a bit of python code<br><span class="py_res">from</span> <span class="py_key">robofab</span>.<span class="py_key">tools</span>.<span class="py_key">remote</span> <span class="py_res">import</span> <span class="py_key">runFontLabRemote</span><br><span class="py_res">print</span> <span class="py_key">runFontLabRemote</span>(<span class="py_str">"print 1+1"</span>)</pre></div>
|
|
|
|
|
|
<div class="pythonoutput"><pre><span class="py_num">2</span></pre></div>
|
|
|
|
<p>
|
|
The function runFontLabRemote() sends a piece of Python code to FontLab's python interpreter and has it executed. In this example the code is "print 1+1". The result, the output of FontLab running this piece of code is then returned to the Python IDE. Note that the output is always a string. Depending on the code you throw at FontLab it could even contain tracebacks or other output.
|
|
</p>
|
|
<p>
|
|
When FontLab receives and executes a remote command, it will print a note to the FontLab Output window.
|
|
</p>
|
|
|
|
|
|
<div class="pythonoutput"><pre>< <span class="py_key">executing</span> <span class="py_key">remote</span> <span class="py_key">command</span> ><br>< <span class="py_key">executing</span> <span class="py_key">remote</span> <span class="py_key">command</span> ><br>< <span class="py_key">executing</span> <span class="py_key">remote</span> <span class="py_key">command</span> ></pre></div>
|
|
|
|
<p>
|
|
That means that FontLab is doing remote stuff.
|
|
</p>
|
|
<h3>Step 3: Teleporting a Glyph</h3>
|
|
<p>
|
|
The remote module has support to send and receive Glyphs. For the next example open a new font in FontLab first (command N), then run the following code in the Python IDE. Make sure you have a UFO font handy somewhere.
|
|
</p>
|
|
|
|
|
|
<div class="pythonsource"><pre><span class="py_res">from</span> <span class="py_key">robofab</span>.<span class="py_key">tools</span>.<span class="py_key">remote</span> <span class="py_res">import</span> <span class="py_key">transmitGlyph</span><br> <br># Pick a UFO font:<br><span class="py_key">f</span> = <span class="py_key">OpenFont</span>()<br> <br># one to beam up, Scotty!<br><span class="py_key">transmitGlyph</span>(<span class="py_key">f</span>[<span class="py_str">'n'</span>])</pre></div>
|
|
|
|
<p>
|
|
If all went well, you now have the 'n' from your UFO copied to the right slot in your FontLab font. As noted earlier, if all you want to do is import some glyphs from a UFO into FontLab there is absolutely no need to use all this remote stuff.
|
|
</p>
|
|
<h2>Why?</h2>
|
|
<p>
|
|
The remote module only takes care of the communication with FontLab. Possible applications which could be built on top of this are:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
Use FontLab to perform outline operations such as remove overlap.
|
|
</li>
|
|
<li>
|
|
Use FontLab to batch process font generation.
|
|
</li>
|
|
<li>
|
|
Build an external editor to augment the functionality of FontLab
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
As noted before, the remote stuff only works on MacOS.
|
|
</p>
|
|
<h2>Example</h2>
|
|
<p>
|
|
Example in which a glyph from a UFO opened in plain Python is copied to FontLab. After removing overlap the glyph is returned and inserted in the UFO.
|
|
</p>
|
|
|
|
<div class="pythonsource"><pre># robofab manual<br># Fontlabremote howto<br># usage examples<br> <br><br>#FLM: Remove overlap from Remote Glyph.<br> <br><br><span class="py_res">from</span> <span class="py_key">robofab</span>.<span class="py_key">world</span> <span class="py_res">import</span> <span class="py_key">OpenFont</span><br><span class="py_res">from</span> <span class="py_key">robofab</span>.<span class="py_key">tools</span>.<span class="py_key">remote</span> <span class="py_res">import</span> <span class="py_key">transmitGlyph</span>, <span class="py_key">receiveGlyph</span>, <br><span class="py_key">runFontLabRemote</span><br> <br># Pick a UFO font:<br><span class="py_key">f</span> = <span class="py_key">OpenFont</span>()<br> <br><span class="py_res">print</span> <span class="py_str">"Number of contours before"</span>, <span class="py_key">len</span>(<span class="py_key">f</span>[<span class="py_str">'A'</span>])<br> <br><br># call FontLab to make a new font<br><span class="py_key">startNewFontCode</span> = <span class="py_str">"""from robofab.world import NewFont<br>f = NewFont()<br>f.info.fullName = 'Temporary Font generated by RoboFab Remote'"""</span><br> <br><span class="py_res">print</span> <span class="py_key">runFontLabRemote</span>(<span class="py_key">startNewFontCode</span>)<br> <br># send a glyph to FontLab,<br># it will be inserted in the CurrentFont.<br><span class="py_key">transmitGlyph</span>(<span class="py_key">f</span>[<span class="py_str">'A'</span>])<br><span class="py_key">f</span>.<span class="py_key">removeGlyph</span>(<span class="py_str">'A'</span>)<br> <br># send instructions to remove overlap for this glyph<br><span class="py_key">overlapCode</span> = <span class="py_str">"""from robofab.world import CurrentFont<br>from robofab.tools.remote import transmitGlyph<br>f = CurrentFont()<br>f["A"].removeOverlap()<br>f.update()<br>transmitGlyph(f['A'])<br>"""</span><br> <br># send the code and catch the output<br><span class="py_key">x</span> = <span class="py_key">runFontLabRemote</span>(<span class="py_key">overlapCode</span>)<br># interpret the output<br><span class="py_key">receiveGlyph</span>(<span class="py_key">x</span>, <span class="py_key">f</span>)<br><span class="py_res">print</span> <span class="py_str">"Number of contours after: "</span>, <span class="py_key">len</span>(<span class="py_key">f</span>[<span class="py_str">'A'</span>])<br> <br># send instructions to FontLab to close the font again.<br><span class="py_key">closeFontCode</span> = <span class="py_str">"""from robofab.world import CurrentFont<br>f = CurrentFont()<br>f.close(None)<br>"""</span><br><span class="py_res">print</span> <span class="py_key">runFontLabRemote</span>(<span class="py_key">closeFontCode</span>)<br><span class="py_res">print</span> <span class="py_str">'done!'</span><br> <br></pre></div><div class="pythonsourcetitle"><a href="examples/usageFlremote.py" target="new">download examples/usageFlremote.py</a></div>
|
|
|
|
<div class="pythonoutput"><pre># possible results:<br> <span class="py_key">Number</span> <span class="py_key">of</span> <span class="py_key">contours</span> <span class="py_key">before</span>: <span class="py_num">6</span><br> <span class="py_key">Number</span> <span class="py_key">of</span> <span class="py_key">contours</span> <span class="py_key">after</span>: <span class="py_num">4</span></pre></div>
|
|
|
|
<h2>Notes</h2>
|
|
<p>
|
|
While experimenting with robofab.tools.remote we found that after some time it's possible that FontLab grows weary of the remote fussing and the scripts stop working. Restarting FontLab usually solves that situation.
|
|
</p>
|
|
</div>
|
|
</body></html> |