Fontlab and a few Pythons
I’ve been playing around with Fontlab Studio 5 and was intrigued at the possibility of using Python scripts with it. Unfortunately Fontlab is unable to see my install because I’m running the current Python 2.5 version and Fontlab is only able to work with 2.4. Simply installing both does not work because Fontlab insists that Python 2.4 be the system default, a concession I’m unwilling to make since it will break other things I’m working with.
This may be a case of software trying to be a little too clever for its own good. Instead of Fontlab simply allowing the user to find the location of the Python interpreter in the preferences menu, it assumes that Python is in our system path and calls it directly — and if the versions don’t match up it complains that Python is not installed.
So we’ll create a “helper script” that temporarily modifies our path to include the location of the older version of Python that Fontlab finds more palatable. This also keeps Python 2.5 as the default for the rest of the system so other programs should run as intended.
In Windows XP we can find out what’s in the path variable by clicking “Control Panel” > System > “Advanced” tab > “Environmental Variables”. Then in the lower box named “System variables”, scroll down till you find “Path”, click it and hit the “Edit” button. Copy the “Variable value” to your clipboard.
In Windows create a simple batch file (.bat) that includes the location of Python 2.4 with the rest of the “Variable value” you copied in the previous step:
set path="C:\WINDOWS\system32;C:\usr\local\python_2-4-4\;C:\usr\local\python_2-4-4\Tools\Scripts\;" "C:\Program Files\FontLab\Studio5\Studio5.exe"
Piece of cake. Of course you can use any type of shell script you want to accomplish this. We’re simply modifying our environment and then making a call to Fontlab to run in it. Here’s a more pythonic approach:
import os path = "C:\WINDOWS\system32;C:\usr\local\python_2-4-4\;C:\usr\local\python_2-4-4\Tools\Scripts\;" os.environ['PATH'] = path fontlab = r' c:\"Program Files"\Fontlab\Studio5\Studio5.exe' os.system( fontlab )
The madness of it all, using Python 2.5 to tell Fontlab to use Python 2.4. This doesn’t fit into any of the definitions of irony, so we’ll just have to call it silly.
awesome! any tips for doing the same thing on a mac? i have the same problem, but i’m not sure how to change the PATH variable
Comment by mat — August 7, 2009 @ 10:17 am