Skip to content

Instantly share code, notes, and snippets.

@okay-type
okay-type / SVGPathPenOverlapped.py
Created November 23, 2025 22:43
A fontTools pen that draws an interpolatable SVG (H and V segments are written as L, always adds the final point)
from typing import Callable
from fontTools.pens.basePen import BasePen
def pointToString(pt, ntos=str):
return " ".join(ntos(i) for i in pt)
@okay-type
okay-type / glyph_window_position_fix.py
Last active October 20, 2025 19:02
Force MacOS to open your Robofont Glyph Edit window at a specific position and size
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
class glyph_window_position_fix(Subscriber):
def glyphEditorWillOpen(self, info):
glyphEditor = info["glyphEditor"]
glyphEditorWindow = glyphEditor.window()
possize = glyphEditorWindow.getPosSize()
if possize[0] < 30:
possize = list(possize)
@okay-type
okay-type / syncMMwindows.py
Created September 1, 2025 16:06
syncMMwindows.py
import metricsMachine
from mm4.mmScripting import MetricsMachineScriptingError
from vanilla import FloatingWindow, List, CheckBox, PopUpButton
from mojo.events import addObserver, removeObserver
from AppKit import *
from mojo.UI import Message
class SyncMM:
def __init__(self):
@okay-type
okay-type / keno.py
Created April 17, 2025 18:25
random number proofer
from mojo.subscriber import Subscriber, WindowController
from mojo.subscriber import registerRoboFontSubscriber, unregisterRoboFontSubscriber, listRegisteredSubscribers
from mojo.UI import CurrentSpaceCenter, OpenSpaceCenter
import ezui
from random import randint
# based on a EvB snippet
@okay-type
okay-type / numeric_ice_cubes.py
Last active April 10, 2025 11:57
replace the fuzzy cell size slider with a crispy number field
from mojo.UI import AllFontWindows, NumberEditText
from mojo.subscriber import Subscriber, registerFontOverviewSubscriber
from AppKit import NSColor, NSTextAlignmentRight
from mojo.UI import CurrentFontWindow, getDefault, setDefault
'''
jackson@okaytype.com
for robofont
replace the fuzzy cell size slider with a crispy number field
set as a start up script
@okay-type
okay-type / current-ufo-to-front.py
Created November 12, 2024 00:44
easily switch between the current glyph edit window and the current font overview window
# menuTitle : Current UFO to Front
# shortCut : command+control+]
from AppKit import *
from mojo.UI import CurrentWindow, CurrentGlyphWindow, AllFontWindows, AllGlyphWindows
def current_to_front():
@okay-type
okay-type / nested-decompose-selected-glyphs.py
Created September 17, 2024 18:35
Decomposed nested components one level. In robofont, obvs.
f = CurrentFont()
for g in f.selectedGlyphs:
if len(g.components) > 0:
with g.undo('Nested Decompose ' + g.name):
for component in g.components:
baseGlyph = f[component.baseGlyph]
if len(baseGlyph.components) > 0:
pen = g.getPointPen()
baseGlyph.drawPoints(pen)
g.removeComponent(component)
# menuTitle: Sort Script Menu
import AppKit
from mojo.tools import CallbackWrapper
from mojo.subscriber import Subscriber, registerRoboFontSubscriber, registerSubscriberEvent, getRegisteredSubscriberEvents
class sort_script_menu(Subscriber):
@okay-type
okay-type / randomly-transform-each.jsx
Last active March 14, 2024 20:27
An InDesign script to randomly transform each selected object
// indesign script
// apply a random transformation to each selected objects
// 2024 [email protected]
function rotate_objects(params) {
var rotate_range = parseFloat(params[0])
var x_range = params[1]
@okay-type
okay-type / start_up_initial_script_placeholder.py
Created January 6, 2024 00:39
Open Robofont scripting windows with preset code
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
# set as a startup script
# open new scripting windows with preset code
# requires Robofont beta 2401051907 (5 January 2024) or later
# [email protected]
preset = '''# a = AllFonts()