284 lines
16 KiB
HTML
284 lines
16 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>The RoboFab world</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/K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
|
||
|
|
||
|
|
||
|
<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="buildingaccents.html">Building accents</a><br /><a href="fontlabremote.html">FontLab Remote</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 />
|
||
|
</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>What is this robofab.world thing?</h1>
|
||
|
<p>
|
||
|
RoboFab can operate in many different environments. When RoboFab is running in FontLab it needs to do different things than when you're using it on for instance Linux or Windows or OSX Python. robofab.world is a module which helps you by providing the objects and functions which are appropriate for the environment you're working in.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<h2>Portable code</h2>
|
||
|
<p>
|
||
|
Rather than include code in your scripts which try to figure out what functionality is available, and what machine, Python version etc. just ask RoboFab.world. Run a script in FontLab and you'll get RoboFab objects that interface with the FontLab fonts and glyphs. Run the same script outside FontLab, and you need objects that interface with UFO files. robofab.world makes the choosing of the right objects a bit more transparent. Just import from the world module and it will pick the right one.
|
||
|
</p>
|
||
|
<p>
|
||
|
Using robofab.world is not compulsory - you can load the objects from the modules yourself. In some cases robofab.world doesn't even load the objects you might need. But scripts that import from robofab.world can actually work in FontLab, but also outside of it. With a bit of care, your scripts can work on UFO and FontLab fonts without ever noticing the difference. That saves a lot of time and effort.
|
||
|
</p>
|
||
|
<h2>Stuff in robofab.world</h2>
|
||
|
<p>
|
||
|
Here are the objects and functions you can import from robofab.world. if you want to see exactly when and which object are selected, have a look in the robofab.world source.
|
||
|
</p>
|
||
|
<h3>robofab.world.world</h3>
|
||
|
<p>
|
||
|
A collection of parameters about the world RoboFab works in. When the robofab.world module is loaded, the first time you call for it, it creates an instance of a special object which catalogs as much as possible about the environment it woke up in. This object is also called world. It's simpler than it sounds really, have a look at the examples.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<div class="pythonsource"><pre># in the Python IDE it looks like this:<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">world</span><br><span class="py_res">print</span> <span class="py_key">world</span><br> <br># in a FontLab macro (Mac FontLab) it looks like this:<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">world</span><br><span class="py_res">print</span> <span class="py_key">world</span></pre></div>
|
||
|
|
||
|
<div class="pythonoutput"><pre>[<span class="py_key">Robofab</span> <span class="py_res">is</span> <span class="py_key">running</span> <span class="py_key">on</span> <span class="py_key">darwin</span>.<br><span class="py_key">Python</span> <span class="py_key">version</span>: <span class="py_num">2.3</span>, <br><span class="py_key">Mac</span> <span class="py_key">stuff</span>: <span class="py_key">X</span>, <br><span class="py_key">PC</span> <span class="py_key">stuff</span>: <span class="py_key">None</span>, <br><span class="py_key">FontLab</span> <span class="py_key">stuff</span>: <span class="py_key">False</span>, <br><span class="py_key">FLversion</span>: <span class="py_key">None</span>]<br> <br>[<span class="py_key">Robofab</span> <span class="py_res">is</span> <span class="py_key">running</span> <span class="py_key">on</span> <span class="py_key">mac</span>.<br><span class="py_key">Python</span> <span class="py_key">version</span>: <span class="py_num">2.3</span>,<br><span class="py_key">Mac</span> <span class="py_key">stuff</span>: <span class="py_key">pre</span>-<span class="py_key">X</span>,<br><span class="py_key">PC</span> <span class="py_key">stuff</span>: <span class="py_key">None</span>,<br><span class="py_key">FontLab</span> <span class="py_key">stuff</span>: <span class="py_key">True</span>,<br><span class="py_key">FLversion</span>: <span class="py_num">4.6</span><span class="py_num">.1</span>/<span class="py_key">Mac</span>]<br> <br># see the difference?</pre></div>
|
||
|
|
||
|
<h3>OpenFont(path)</h3>
|
||
|
<p>
|
||
|
OpenFont is a function which opens a font. When called with a path it will open the font at that location. Without a path it will try to offer some appropriate interface to pick a font. In FontLab, OpenFont() gives you the standard font-opening-interface, and OpenFont(path) will open a FontLab fontwindow for that font. Outside FontLab, for instance in the Python IDE, you get a file dialog to point at a UFO package. If you look at the source code of OpenFont, you'll see that it is not just one function, there are several for different kinds of environments. By importing OpenFont from robofab.world, your script always has the right one and you don't have to change it when the script moves from one environment to the other.
|
||
|
</p>
|
||
|
|
||
|
<p class="note">
|
||
|
In places where there is no UI available, for instance when RoboFab is running on a Linux server, OpenFont(path) might try to import UI parts and fail. If you already know the path of a font, use <strong>RFont(path)</strong> instead.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<div class="pythonsource"><pre><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_key">f</span> = <span class="py_key">OpenFont</span>()<br># dialog appears<br><span class="py_res">print</span> <span class="py_key">f</span></pre></div>
|
||
|
|
||
|
<div class="pythonoutput"><pre>< <span class="py_key">Font</span> <span class="py_key">MyFont</span> ></pre></div>
|
||
|
|
||
|
<h3>CurrentFont()</h3>
|
||
|
<p>
|
||
|
CurrentFont is an old favorite from RoboFog. It returns a font object for the top most font or the last imported font. It is very useful to write short scripts that manipulate the current font in one way or the other, so you don't have to enter the font's name.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<div class="pythonsource"><pre><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">CurrentFont</span><br><span class="py_key">f</span> = <span class="py_key">CurrentFont</span>()</pre></div>
|
||
|
|
||
|
<div class="pythonoutput"><pre>< <span class="py_key">RFont</span> <span class="py_key">font</span> <span class="py_res">for</span> <span class="py_key">MyFontOT</span>-<span class="py_key">Regular</span> ></pre></div>
|
||
|
|
||
|
<h3>CurrentGlyph()</h3>
|
||
|
<p>
|
||
|
CurrentGlyph similar to CurrentFont, except that it return the top most glyph. CurrentGlyph returns None when there isn't a glyphwindow open.
|
||
|
</p>
|
||
|
|
||
|
<div class="pythonsource"><pre><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">CurrentGlyph</span><br><span class="py_key">c</span> = <span class="py_key">CurrentGlyph</span>()</pre></div>
|
||
|
|
||
|
<div class="pythonoutput"><pre>< <span class="py_key">RGlyph</span> <span class="py_res">for</span> <span class="py_key">unnamed_font</span>.<span class="py_key">L</span> ></pre></div>
|
||
|
|
||
|
<h3>AllFonts()</h3>
|
||
|
<p>
|
||
|
AllFonts returns a list with font objects for all fonts which are 'open' at the moment. In FontLab that means one RFont object for each font window. Outside FontLab it means a list of all font objects that exist at the moment. Note: it is possible to have more than one font object for the same UFO, so if you use AllFonts for UFOs you need to take that into account. AllFonts is easy if you want to do something to all open fonts.</p>
|
||
|
|
||
|
|
||
|
<div class="pythonsource"><pre><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">AllFonts</span><br><span class="py_res">for</span> <span class="py_key">f</span> <span class="py_res">in</span> <span class="py_key">AllFonts</span>():<br> <span class="py_res">print</span> <span class="py_key">f</span></pre></div>
|
||
|
|
||
|
<div class="pythonoutput"><pre>< <span class="py_key">RFont</span> <span class="py_res">for</span> <span class="py_key">aFont</span>-<span class="py_key">Plain</span><span class="py_num">.00</span> ><br>< <span class="py_key">RFont</span> <span class="py_res">for</span> <span class="py_key">aFont</span>-<span class="py_key">Italic</span><span class="py_num">.00</span> ><br>< <span class="py_key">RFont</span> <span class="py_res">for</span> <span class="py_key">aFont</span>-<span class="py_key">Bold</span><span class="py_num">.00</span> ></pre></div>
|
||
|
|
||
|
<h3>RFont, RGlyph</h3>
|
||
|
<p>
|
||
|
RFont and RGlyph classes are also loaded by robofab.world. In FontLab these objects will be imported from objectsFL.py (the FontLab implementation of the Unified Font Objects), and otherwise from objectsRF.py, the UFO objects.
|
||
|
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
</body></html>
|