Skip to content

Instantly share code, notes, and snippets.

@thundernixon thundernixon/tasks.json
Last active Apr 29, 2019

Embed
What would you like to do?
Run RoboFont script from VS Code
{
"version": "2.0.0",
"tasks": [
{
"label": "Run in RoboFont",
"type": "shell",
"command": "robofont",
"args": [
"-p",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
@thundernixon

This comment has been minimized.

Copy link
Owner Author

commented Apr 29, 2019

Run RoboFont script from VS Code

Have you ever wanted to write Python scripts in VS Code and make them execute inside RoboFont?

  1. 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.

  2. 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.

  3. 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 file tasks.json in a .vscode workspace folder.

  4. Paste the above tasks.json code in place of the template*.

  5. Now, when you have a Python script in VS Code**, you can hit command+shift+b to instantly run your script in RoboFont.

  6. 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

@thundernixon

This comment has been minimized.

Copy link
Owner Author

commented Apr 29, 2019

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()"
        ],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.