Skip to content

Instantly share code, notes, and snippets.

View connordavenport's full-sized avatar

Connor Davenport connordavenport

View GitHub Profile
from lib.tools.extremePoints import *
g = CurrentGlyph()
with g.undo():
g.rotateBy((-g.font.info.italicAngle))
extremePoints(g.naked(), [c.naked() for c in g.selectedContours], 1, True)
g.rotateBy((g.font.info.italicAngle))
g.round()
import metricsMachine as mm
import datetime
import time
import os
ts = time.time()
d = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m%d-%H%M%S')
f = mm.CurrentFont()
path = f.path.replace(os.path.splitext(f.path)[-1], f"-kern_{d}.fea")
@connordavenport
connordavenport / moveBy_italicAngle.py
Last active July 21, 2026 22:13
a hack to add italic constraint to the fontparts' base object
import math
import mojo.roboFont as rf
from fontParts.fontshell import RBPoint
from fontParts.base import normalizers
IntFloatType = int | float
Coordinate = tuple[IntFloatType, IntFloatType]
CoordinateLike = list[IntFloatType] | Coordinate
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
import pandas as pd
from AppKit import NSPasteboardTypeString, NSPasteboard
ATTRIBUTES = "name unicode width angledLeftMargin angledRightMargin".split(" ")
class contextual_auto_unicodes(Subscriber):
debug = True
@connordavenport
connordavenport / force_same_window.py
Created March 24, 2026 14:29
when opening a new glyph window, with shift down, force glyph to use current glyph window, regardless of the font
from mojo.subscriber import Subscriber, registerRoboFontSubscriber, unregisterRoboFontSubscriber
from mojo.UI import CurrentGlyphWindow
import AppKit
class force_same_window(Subscriber):
debug = True
def build(self):
self.windowToClose = None
@connordavenport
connordavenport / glyph_editor_component_breadcrumbs.py
Last active March 4, 2026 22:11
add breadcrumb trail when traversing nested components, based on Counterpunch's features
from mojo.subscriber import *
from vanilla import *
from mojo.UI import CurrentGlyphWindow, SetCurrentGlyphByName
class crumbponents(Subscriber):
def started(self):
self._path = [] # keep the path as a list and join on set
self.glyph = None # Current Glyph to keep track of
self.editor = CurrentGlyphWindow()
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
import AppKit
class MargielaTabs(Subscriber):
def fontDocumentWantsToolbarItems(self, info):
image = AppKit.NSImage.imageWithSystemSymbolName_accessibilityDescription_("arrow.trianglehead.merge", "")
newItem = {'itemIdentifier': 'MargielaTabsButton',
'label': 'Margiela',
@connordavenport
connordavenport / new_font_manager.py
Last active October 17, 2025 13:50
custom manager for opening new fonts
import ezui
from mojo.UI import getDefault
from mojo.subscriber import *
import AppKit
from lib.fontObjects.doodleFont import DoodleFont
CHARACTER_SETS = getDefault("charsets")
WIDTH, HEIGHT = 400, 400
@connordavenport
connordavenport / untitled_tabs.py
Created August 15, 2025 15:53
rename all tabs + unsaved fonts with valid attrs
from mojo.subscriber import Subscriber, registerRoboFontSubscriber, registerCurrentFontSubscriber, unregisterRoboFontSubscriber, unregisterCurrentFontSubscriber
import AppKit
class BASE:
def update_tabs(self, font):
if font:
has_values = True
for val in "familyName styleName".split(" "):
if not hasattr(font.info, val):
has_values = False
@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):