Skip to content

Instantly share code, notes, and snippets.

@okay-type
okay-type / coalescingTest-hold.py
Last active May 11, 2022 17:35
testing event coalescing in robofont subscriber ... this one tries to wait until all button presses are done before firing
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 December 13, 2021 19:32
testing event coalescing in robofont subscriber
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 November 9, 2021 17:53
keep track of the last pair used in metrics machine
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 November 3, 2021 22:48
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 October 6, 2021 19:07
window position size test
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 July 20, 2021 17:29
toggle the size of the preview text in metrics machine between a custom value and a normal value
# 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()
# 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)
# "‚": "‘",
# "„": "“",
# "„": "”",
"‘": "’",
# "‛": "’",
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
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
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
class SimpleSubscriberTest(Subscriber):
debug = False
def build(self):
if self.debug == True:
print('SimpleSubscriberTest', 'SimpleSubscriberTestbuild!')