Last active
March 25, 2021 14:48
-
-
Save thundernixon/588273076abfee345ad17c21a6b70389 to your computer and use it in GitHub Desktop.
Run RoboFont script from VS Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "Run in RoboFont", | |
"type": "shell", | |
"command": "robofont", | |
"args": [ | |
"-p", | |
"${file}" | |
], | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
} | |
} | |
] | |
} |
If you wish to bring up the RoboFont Output Window when you run the script (for instance, to view the result of print()
statements), update the task's args
list to:
"args": [
"-p",
"${file}",
"-c",
"from mojo.UI import OutputWindow",
"-c",
"OutputWindow().show()"
],
Hi Stephen, I'm attempting to use this command and I'm getting this result:
zsh: parse error near `()'
The terminal process "/bin/zsh '-c', 'robofont -p '/Users/eat/Library/Application Support/RoboFont/scripts/info.py' -c 'from mojo.UI import OutputWindow' -c OutputWindow().show()'" terminated with exit code: 1.
Do you know what does it mean?
Thank you in advance.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run RoboFont script from VS Code
Have you ever wanted to write Python scripts in VS Code and make them execute inside RoboFont?
First, make sure you have installed RoboFont as shell command by going to RoboFont Preferences > Extensions > Shell and click on the install button. To make sure that its installed correctly, run
robofont -h
in the terminal and hit return. For RoboFont shell command to work correctly you probably need to install PyObjC in terminal using pip3.In VS Code, open a folder that you wish to run scripts from. This might be a type project, the central RoboFont scripts folder, or somewhere else. VS Code calls this a "workspace," and you can give it specific settings in a
.vscode
folder.Use the shortcut
command+shift+p
to open the Command Palette. Then, search "Tasks: Configure Default Build Task" and select it. Next, select "Create tasks.json file from template," and finally "Other." This will create the filetasks.json
in a.vscode
workspace folder.Paste the above
tasks.json
code in place of the template*.Now, when you have a Python script in VS Code**, you can hit
command+shift+b
to instantly run your script in RoboFont.If you are managing the workspace as a Git project, you should probably add
.vscode
to your.gitignore
file.* Yes, the version number should be
2.0.0
, because it refers to VS Code's task system.** You need to be working in a saved Python file for this to work. So, start new files by saving them.
Inspired by @typoman's Gist, Robofont.sublime-build