Skip to content

Instantly share code, notes, and snippets.

@connordavenport
Created June 17, 2025 16:33
Show Gist options
  • Save connordavenport/e8e8597156c36b6d5a19bef8e520b780 to your computer and use it in GitHub Desktop.
Save connordavenport/e8e8597156c36b6d5a19bef8e520b780 to your computer and use it in GitHub Desktop.
a plugin for sublime text to open and edit a binary font as a ttx file
import sublime
import sublime_plugin
import os
import tempfile
from fontTools import ttx
PREFIX = ".st3_ttx."
SFNT_SUFFIXES = ".otf .ttf .woff .woff2".split(" ")
class OpenTTX(sublime_plugin.EventListener):
def on_load_async(self, view):
fn = view.file_name()
di,fi = os.path.split(fn)
if os.path.splitext(fn)[-1] in SFNT_SUFFIXES:
dumped = f"{di}/{PREFIX}{fi}.ttx"
ttx.ttDump(fn,dumped,ttx.Options([], 1))
view.window().focus_group(0)
view.window().open_file(dumped)
def on_pre_save_async(self, view):
n = view.file_name()
if PREFIX in n:
path = n.replace(PREFIX, "").replace(".ttx", "")
ttx.ttCompile(n, path, ttx.Options([], 1))
def on_close(self, view):
if PREFIX in view.file_name():
os.remove(view.file_name())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment