Skip to content

Instantly share code, notes, and snippets.

Avatar

Jackson okay-type

View GitHub Profile
@okay-type
okay-type / All-UI.py
Last active Feb 2, 2022
Simple Robofont interface to controlling a list of open ufos and their UI windows.
View All-UI.py
from mojo.subscriber import Subscriber, WindowController
from mojo.subscriber import registerRoboFontSubscriber
from vanilla import Window, List, CheckBoxListCell, Group, Button
from AppKit import NSDragOperationMove, NSDragOperationCopy, NSFilenamesPboardType
from mojo.UI import AskYesNoCancel, OpenSpaceCenter, OpenFontInfoSheet, OpenGlyphWindow
from os import path as ospath
from mojo.roboFont import AllFonts, OpenFont, FontsList
from defconAppKit.controls.fontInfoView import FontInfoView
from mojo.UI import OutputWindow
@okay-type
okay-type / coalescingTest-hold.py
Last active May 11, 2022
testing event coalescing in robofont subscriber ... this one tries to wait until all button presses are done before firing
View coalescingTest-hold.py
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.subscriber import registerSubscriberEvent, roboFontSubscriberEventRegistry
from mojo.subscriber import WindowController
from mojo.events import postEvent
from vanilla import Window, Button
coalescingTestKey = 'okay.coalescingTest'
class coalescingTest(Subscriber, WindowController):
@okay-type
okay-type / coalescingTest.py
Last active Dec 13, 2021
testing event coalescing in robofont subscriber
View coalescingTest.py
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.subscriber import registerSubscriberEvent, roboFontSubscriberEventRegistry
from mojo.subscriber import WindowController
from mojo.events import postEvent
from vanilla import Window, Button
coalescingTestKey = 'okay.coalescingTest.testDidIncrement'
class coalescingTest(Subscriber, WindowController):
@okay-type
okay-type / mm-save-last-pair.py
Last active Nov 9, 2021
keep track of the last pair used in metrics machine
View mm-save-last-pair.py
from mojo.subscriber import Subscriber, registerRoboFontSubscriber, registerSubscriberEvent, roboFontSubscriberEventRegistry
from mojo.extensions import setExtensionDefault, getExtensionDefault, registerExtensionDefaults, removeExtensionDefault
from vanilla import Window, Button, TextBox
#
# IMPORTANT
#
# As far as i can tell, there's no way to default way detect when a new MM window is opened
# instead
# this requires modifying the Metrics Machine extension's launch.py (3.7 version)
#
@okay-type
okay-type / MM-quick-compare-kerning.py
Last active Nov 3, 2021
MM-quick-compare-kerning.py
View MM-quick-compare-kerning.py
import metricsMachine as mm
from vanilla import *
from mojo.events import addObserver, removeObserver, postEvent
from mojo.UI import GetFile
import merz
from fontTools.pens.basePen import BasePen
# this update lets you do basic edits to the current kern value
def _getMainWindowControllerForFont(font=None):
@okay-type
okay-type / PossizeTest.py
Created Oct 6, 2021
window position size test
View PossizeTest.py
from vanilla import Window
from mojo.extensions import setExtensionDefault, getExtensionDefault, registerExtensionDefaults, removeExtensionDefault
class PossizeTest:
def __init__(self):
self.prefKey = 'com.developer.window.test'
w = Window((333, 666), title='Window PosSize Test')
w.open()
@okay-type
okay-type / kerning-toggle-MM-size.py
Created Jul 20, 2021
toggle the size of the preview text in metrics machine between a custom value and a normal value
View kerning-toggle-MM-size.py
# menuTitle : MM Toggle size 42-50
# shortCut : \
# works, should probaby add the custom size to the size popup list because there is a traceback complaining it's not there
import metricsMachine as mm
def _getMainWindowControllerForFont(font=None):
if font is None:
font = CurrentFont()
View kern-flip-openclose-pairs.py
# menuTitle : MM Flip Pair Mirror
# shortCut : control+6
openclosepairs = {
# initial/final punctuation (from https://www.compart.com/en/unicode/category/Pi and https://www.compart.com/en/unicode/category/Pf)
# "‚": "‘",
# "„": "“",
# "„": "”",
"‘": "’",
# "‛": "’",
View glyph-to-merz-symbol.py
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
from vanilla import Button
import merz
from merz.tools.drawingTools import NSImageDrawingTools
'''
[ Print Glyph ]
dumps code to draw the current glyph as a symbol
copy/paste it into the symbol factory at the bottom
View kerning-pairlist-tuner.py
from mojo.UI import GetFolder
from glyphNameFormatter import GlyphName
import metricsMachine as mm
from vanilla import *
from vanilla.dialogs import putFile
from mojo.events import addObserver, removeObserver, postEvent
from AppKit import NSColor, NSFloatingWindowLevel, NSWindowStyleMaskClosable, NSFullSizeContentViewWindowMask, NSTitledWindowMask
from mojo.extensions import registerExtensionDefaults, setExtensionDefault, getExtensionDefault, removeExtensionDefault
from AppKit import NSApp