Skip to content

Instantly share code, notes, and snippets.

View connordavenport's full-sized avatar

Connor Davenport connordavenport

View GitHub Profile
@connordavenport
connordavenport / open_font_with_ttx.py
Created June 17, 2025 16:33
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):
import more_itertools
def _as_list(item):
return list(more_itertools.always_iterable(item))
def _get_designspaces(self) -> list[str]:
return _as_list(self.lib.get('public.designspaces', []))
def _set_designspaces(self, new_designspace:str | list[str]):
self.lib['public.designspaces'] = _as_list(new_designspaces)
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
from mojo.UI import inDarkMode
class anchor_scrubber(Subscriber):
debug = False
def build(self):
editor = self.getGlyphEditor()
@connordavenport
connordavenport / space_center_alt_manager.py
Created April 24, 2025 16:27
swap out individual alternates in space center
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.UI import GlyphRecord
class space_center_alts_manager(Subscriber):
def started(self):
self.glyph = None
self.alternates = []
self.space_center = None
@connordavenport
connordavenport / real_world_pair_list.py
Last active March 18, 2025 13:20
a script to check if a touching pair exists in the real world
from touche import Touche
# uses Ondrej Jób's source data from Context of Diacritics via Setup Type
# and Nina Stössinger's Touche to check touching pairs in the current font.
# https://www.setuptype.com/x/cod/source/lists
real_world_pairs = '''
a aacute
a adieresis
a agrave
@connordavenport
connordavenport / custom_xHeight_manager.py
Last active March 10, 2025 16:09
draw custom metric guides in the glyph view
import math
from mojo.events import postEvent
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
from lib.tools.defaults import getDefault
from fontTools.misc import transform
border = getDefault("glyphViewVerticalPadding")
fontsize = getDefault("textFontSize")
metricsStroke = getDefault("glyphViewFontMetricsStrokeColor")
@connordavenport
connordavenport / RGlyph_Export.py
Created February 21, 2025 21:28
RGlyph getter/setter for skip export
from mojo.roboFont import RGlyph
def _setExport(self, export):
skipExportGlyphs = set(self.font.lib.get("public.skipExportGlyphs", []))
if export == False:
skipExportGlyphs.add(self.name)
elif export == True:
if self.name in skipExportGlyphs:
skipExportGlyphs.remove(self.name)
else:
@connordavenport
connordavenport / set_contextual_mark_colors.py
Last active February 21, 2025 18:56
a contextual menu for setting glyph mark colors
from mojo.subscriber import Subscriber, registerRoboFontSubscriber, unregisterRoboFontSubscriber
from mojo.UI import getDefault
from AppKit import NSMenuItem
from mojo.tools import CallbackWrapper
import ezui
class set_contextual_mark_colors(Subscriber):
debug = True
@connordavenport
connordavenport / RGlyph_FullBounds.py
Created February 20, 2025 19:24
Custom RGlyph `bounds` property that takes anchors into account
'''
Custom RGlyph `bounds` property that takes anchors into account
'''
@property
def full_bounds(self):
bounds = list(self.bounds)
for anchor in self.anchors:
if anchor.x < bounds[0]:
bounds[0] = anchor.x
if anchor.x > bounds[2]:
@connordavenport
connordavenport / set_feature_smart_sets_on_open.py
Created February 19, 2025 18:29
add smart sets from internal feature file on opening
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from vanilla import *
import AppKit
import os
from compositor.textUtilities import convertCase
from defconAppKit.windows.baseWindow import BaseWindowController
from defconAppKit.controls.openTypeControlsView import OpenTypeControlsView
from defconAppKit.controls.glyphSequenceEditText import GlyphSequenceEditText