Issue:
How to install Python, RoboFab, TTX/FontTools and other add-ons to enable scripting in FontLab Studio 5
Solution:
(Note: these instructions do NOT apply to FontLab VI.) There are a host of utilities that can make the font making and editing experience easier and faster. Some work directly in FontLab Studio via the Python scripting language, and others are separate items. Here is how to install Python-related tools, and the many scripts and things they enable, to work with FontLab Studio 5.1/5.2 on Mac OS and Windows. (If you are using earlier versions, please upgrade to 5.1.x Mac and 5.2.x Windows. Upgrades from 5.0 and higher are free!)
You do not have to be a programmer to make use of these tools! While folks who are at least moderately geeky and technical will get more out of most of these tools, almost anybody who can use FontLab Studio will find value in tools such as TTX, and benefit from some scripts they can run “out of the box.” Once you get this stuff set up, you can install more macros/scripts just by dragging them to the FontLab macros folder, and restarting FontLab Studio.
Note: Hard core techno-geeks may want to just skip ahead to the “step by step” instructions for their OS of choice.
Thanks to Just van Rossum, Tal Leming, Erik van Blokland, Behdad Esfahbod, Guido van Rossum, and the entire awesome community of people who have contributed to these many pieces. Also thanks to Adam Twardoch for his October 2011 writeup on installation, from which I have stolen borrowed extensively.
Overview & Background
Installing some of these pieces will require “administrator” privileges on your computer. As long as you have this capability, the instructions below will cover how to doit. If you do not have admin privileges, you will have to get somebody who does to do it for you, or forego these tools and add-ons.
NOTE: Download links for exactly what you need to install will come later; links in this section are just for general info.
- What is Python? It is a programming and scripting language, invented by Guido van Rossum, which is increasingly popular for many tasks. But even if you do not want to write scripts yourself, it can be handy to use Python scripts in FontLab Studio, and the TTX program that installs with the Python FontTools library is of use to anybody who wants to investigate or hack fonts. The other bits described below are used by some third-party Python scripts for FontLab Studio, and while not strictly required can be useful if you want to write scripts yourself.
- The next most useful related piece is Robofab, a Python library that provides objects that deal with font-related data. May FontLab scripts and tools are dependent on RoboFab.
- TTX / Fonttools are a pair of related things. TTX is a tool to convert OpenType and TrueType fonts to and from XML. FontTools is a library for manipulating fonts, written in Python. TTX requires FontTools, and the two install together. These utilities were created a long time ago by Just van Rossum (brother of Guido), and their existence is the reason Python became the de facto standard reason for font processing and programming. A more actively updated version of TTX/Fonttools is maintained by Behdad Esfahbod.
- Vanilla is a Mac-only Python library developed by Tal Leming which makes it easy to build native Mac dialogs and interfaces with Python, which can work with FontLab Studio or other Mac OS X Cocoa applications that have a Python layer. It gives control over many kinds of GUI widgets such as windows, buttons, input fields, sliders etc. However, scripts designed to use Vanilla (without graceful fallback) will be Mac-only.
- DialogKit is a Python-only subset of Vanilla, which can work with FontLab Studio or other applications that have a Python layer.
Step by Step Mac Install
For a Mac user, we suggest installing Robofab, TTX/Fonttools, DialogKit and Vanilla. Mac users will already have Python installed. If you haveMac OS 10.7–10.9, you already have Python 2.7 (and NumPy), which you need to go along with FontLab Studio 5.1.x. Although there are all-in-one installers for the bits below, they are getting a bit old; we instead recommend:
Requirements:
- FontLab Studio 5.1.x (we have tested with 5.1, 5.1.2 and 5.1.4; FontLab Studio 5.0.x requires an earlier Python; we recommend upgrading to the most recent version of FontLab Studio.)
- Mac OS X 10.7, 10.8, or 10.9.
- Since the system Python 2.7 in Mac OS X 10.7 and later comes with pre-installed NumPy, it's no longer necessary to install NumPy.
Instructions:
- Quit FontLab Studio if it is open.
- Download these files:
- Note on license terms: All of the above software is licensed to you under “non-viral” open source licenses. DialogKit is under the MIT License and so is Vanilla. FontTools has a custom license. Robofab is under the BSD 3-clause license.
- In Finder, navigate to the location where you downloaded your files. Find each zip file and double-click to unzip it (if it hasn’t already happened). The four zip files and their resulting folders are:
- fonttools-master.zip file > folder named “fonttools-master”
- RoboFab_599_only.zip > folder named “RoboFab”
- vanilla-master.zip > folder named “vanilla-master”
- dialogKit-master.zip file > folder named “dialogKit-master”
- So now you have the four unzipped folders, right?
- Open the Terminal app
- In Terminal, type “cd ” (with a trailing space) but don’t hit Enter. Drag the “fonttools-master” folder to the Terminal window. You should see something like this in the Terminal window:
cd /users/[your username]/Downloads/fonttools-master - In Terminal, hit the Enter/Return key.
- In Terminal, do the following:
(Hit Enter after each line. After the first "sudo" you'll need to enter your administrator password.) sudo /usr/bin/python setup.py install
(enter your administrator password in response to the prompt)
cd ../RoboFab
sudo /usr/bin/python setup.py install
cd ../vanilla-master
sudo /usr/bin/python setup.py install
cd ../dialogKit-master
sudo mv Lib/dialogKit/ /Library/Python/2.7/site-packages/ - In Finder, do File > New Finder Window
- If you have enabled “Use custom locations for user data folders” in FontLab Studio > Preferences > General Options > Folders and paths, then navigate Finder to folder that you've set as the “FontLab Studio user data files” folder, and skip the next item.
- If you have not customized the location of your FontLab user data, then in Finder’s menu, choose Go / Go to Folder...
In the text box that appears, enter or paste the following:
~/Library/Application Support/FontLab/Studio 5/Macros
and click on Go. - Your Finder should now should show a Macro folder with at least three subfolders in it (Effects, Export and System).
- Switch to the Finder window that has the RoboFab folder, and open the subfolder RoboFab/Scripts folder that is inside.
- You should see a folder with several subfolders: "Contributed", "RoboFabIntro", "RoboFabUFO", "RoboFabUFO2", "RoboFabUtils".
- Select those folders and drag them to the Macro folder in the other Finder window.
- Start FontLab Studio. Go to Window > Panels > Edit Macro. In the Edit Macro panel type in these lines (each followed by Return/Enter):
import robofab
import dialogKit
import vanilla
If you don’t see an Output panel pop up with an error message in it, you have installed RoboFab and its FontLab macros and DialogKit successfully! If you get an error message, something is wrong. - We have a fabulous listing of ready-made scripts and such on the FontLab web site. Most are installed by dragging the script or folder of scripts into the “Macros” folder, just like steps 9–13 above.
- Optional for the moderately technically inclined... Make a drag-and-drop TTX! You will need to download an additional app to make a drag-and-drop app from the ttx.py file. Platypus works nicely and is libre (free open source software).
- Go to its Github site, scroll to the bottom and click on the latest app (not the “src” as that’s uncompiled source code).
- Select “view full file” to download the zip file.
- Double-click the zip in your downloads folder to unzip it.
- Go into the folder and control-click on the app, and select “Open.”
- Read the warning. Click “open” in the dialog.
- You will now get a big Platypus dialog
- For “script path” use the path to ttx.py on your computer. You can drag and drop into the path edit box, or use the “Select” button. (Note: You must do this ahead of other steps, or it will change other settings.)
- Name the app package (perhaps “TTX”)
- Change “Script Type” to “Python”
- Change “output” to “text window”
- (optional) Bump the “version” string to whatever the current ttx version is.
- Click on the checkbox to “Accept dropped items”
- Click the “Create” button to generate the app.
Step-by-step Windows Install
For a Windows user, we suggest installing Python, Robofab, DialogKit, and TTX/Fonttools. Vanilla is a Mac-only module. Python has to be installed because it does not come with Windows. NOTE: Windows users will have slightly fewer scripts available to them; some existing scripts written for Mac may fail due to dependencies on the Vanilla module.
Requirements:
- FontLab Studio 5.2.x (we have tested with 5.2.1; FontLab Studio 5.0.x requires an earlier Python; we recommend upgrading to the most recent version of FontLab Studio.)
- We have tested these instructions on Windows 7 and 8.1; they may work with Vista as well.
Instructions:
- Quit FontLab Studio if it is running.
- Go to the Python.org download page, and download the most recent 32-bit version of Python 2.7. Do not use a 64-bit version, even if you are on a 64-bit Windows. (Currently “Python 2.7.7 Windows installer”)
- Locate the downloaded installer file, such as “python-2.7.7.msi” and launch it. The default is to install all the bits of Python, which is fine as it is small. If a User Account Control dialog comes up asking you if you want to install it, click “Yes.” Note that the rest of these instructions assume you use the default install directory, C:\Python27\
- Fix the path variable.
- Open the Control Panel
- Select “System”
- Select the “Advanced” tab
- Select the “Environment Variables” button
- Click on the “Path” entry in the “System Variables” section
- Select the “Edit” button. The “Edit System Variable” dialog will open.
- In the small edit area of the dialog, get your cursor to the end (control-arrow may help)
- Paste “;C:\Python27\” (without the quotes) at the very end of the text in the edit area
- Select OK to close the dialog
- Select OK to close the remaining dialog
- Restart Windows so the change takes effect
- Launch FontLab Studio. You should see a small “properties” box appear that says “Python is installed.” Yay!
- Quit FontLab Studio again. :)
- Download these files to your “downloads” folder:
- Note on license terms: All of the above software is licensed to you under “non-viral” open source licenses. FontTools has a custom open source license. Robofab is under the BSD 3-clause license. DialogKit is under the MIT License. Python also has a custom open source license.
- In Windows Explorer, find where you downloaded the zip files, probably your “downloads” folder. Double-click on each file to get into the zip archive. Drag the folder from inside the zip archive to the “Downloads” folder root level on the left. The two zip files and their resulting folders are:
- fonttools-master.zip file > folder named “fonttools-master”
- RoboFab_599_only.zip > folder named “RoboFab”
- dialogKit-master.zip file > folder named “dialogKit-master”
- So now you have the three unzipped folders, right?
- Launch a command line with administrator privileges.
- Click Start, click All Programs, and then click Accessories.
- Right-click Command prompt, and then click Run as administrator.
- If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
- The command prompt should show “C:\Users\[yourname]”; now type the following (with a Return/Enter after each line, and waiting for the command prompt to return after each): cd downloads
cd fonttools-master
python setup.py install
cd ..\RoboFab
python setup.py install
cd ..\dialogKit-master
copy Lib\dialogKit C:\Python27\Lib\site-packages\ - Open a new window in Windows Explorer
- If you have enabled “Use custom locations for user data folders” in FontLab Studio (Tools > Options > General Options > Folders and paths), navigate to the folder that you've set as the “FontLab Studio user data files” folder, and skip the next step.
- If you have not customized the location of your FontLab user data, then in Windows Explorer click on the directory name in the pop-down at top left. Enter or paste the following:
C:\Users\[yourname]\Documents\FontLab\Studio 5\Macros
Change “yourname” to the actual name of your user folder. Then hit the Enter/Return key. - You should see a folder with at least three subfolders in it (Effects, Export and System).
- Switch to the Windows Explorer window that has the RoboFab folder, and open the subfolder RoboFab\Scripts folder that is inside.
- You should see a folder with several subfolders: "Contributed", "RoboFabIntro", "RoboFabUFO", "RoboFabUFO2", "RoboFabUtils".
- Select those folders and drag them to the Macros folder in the other window.
- Start FontLab Studio. Go to Window > Panels > Edit Macro. In the Edit Macro panel type in these lines (each followed by Return/Enter): import robofab
import dialogKit If you don’t see an Output panel pop up with an error message in it, you have installed RoboFab and its FontLab macros and DialogKit successfully! If you get an error message, something is wrong. - We have a fabulous listing of ready-made scripts and such on the FontLab web site. Most are installed by dragging the script or folder of scripts into the “Macros” folder, just like steps 11–16 above. Be careful, a few scripts are Mac only, due to dependency on Vanilla.
- Optional. Make a drag-and-drop TTX! It is a command-line tool, but usually you want it to just run with default settings, and often convert multiple files to or from the TTX XML format. You can do this by dragging and dropping files directly onto the ttx.py file. As it is buried deep in the directory tree, you might want to make an alias to it.
- In Windows Explorer, navigate to C:\Python27\Lib\site-packages\FontTools\fontTools (or wherever you put it)
- Right-click ttx.py, and select “Create Shortcut” from the pop-up menu.
- Drag the shortcut to your desktop or wherever is convenient to you.
- Now you can drag fonts onto TTX to create XML based files (with a .ttx extension), and drag .ttx files onto the app to generate font files.