Skip to content

Instantly share code, notes, and snippets.

@okay-type
okay-type / previousCurrentGlyph.py
Last active May 27, 2021 00:02
return to the previous CurrentGlyph rf4
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.UI import SetCurrentGlyphByName
'''
keep track of the most recent currentGlyph and return to it using ⇧+,
recent update:
no longer tied to the edit glyph window - you can now close a glyph, open a new glyph, and then ⇧+, back to the previous glyph
'''
@okay-type
okay-type / anchorHelper.py
Last active May 10, 2022 15:05
start of a rf4 anchor tool using merz and subscriber
from AppKit import NSScreen
from vanilla import *
import merz
import mojo.subscriber as subs
from mojo.subscriber import Subscriber, WindowController, registerCurrentGlyphSubscriber, registerGlyphEditorSubscriber, registerSubscriberEvent, getRegisteredSubscriberEvents, unregisterGlyphEditorSubscriber, listRegisteredSubscribers
from mojo.extensions import registerExtensionDefaults, setExtensionDefault, getExtensionDefault, removeExtensionDefault
from mojo.drawingTools import *
from math import radians, tan, pi
from AppKit import NSColor
from fontTools.pens.basePen import BasePen
@okay-type
okay-type / anchorNanny.py
Last active April 14, 2021 22:14
try to match anchors in dependent glyphs (small caps) to their parent glyphs
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
from vanilla import *
from AppKit import NSColor, NSAttributedString, NSForegroundColorAttributeName, NSFontAttributeName, NSFont, NSTextAlignmentLeft, NSTextAlignmentRight
'''
Lazily check the position of anchors in dependent glyphs, like small-caps
and tries to see if they match their position in the parent glyphs
it assumines a few things based on my workflow:
- assumes small-caps are named lowercase with a '.sc' suffix e.g.: A -> a.sc
@okay-type
okay-type / glyph-to-symbol.py
Last active April 10, 2021 21:13
dump a glyph into code to use as a custom merz symbol
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
@okay-type
okay-type / test-merzview-delegates.py
Last active October 13, 2021 17:05
Testing MerzView Delegates
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber
from vanilla import Button
import merz
class merzViewDelegateTest(Subscriber):
debug = True
def build(self):
@okay-type
okay-type / addOverlap-rf4.py
Last active April 5, 2021 17:50
quick and dirty udpate of addoverlap with ui for robofont 4
from vanilla import *
from mojo.UI import CurrentGlyphWindow
from mojo.events import addObserver, removeObserver
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
from merz import *
from AppKit import NSColor, NSTextAlignmentRight, NSTextAlignmentLeft
from fontTools.ufoLib.pointPen import AbstractPointPen
from mojo.extensions import setExtensionDefault, getExtensionDefault, registerExtensionDefaults
import math
import re
@okay-type
okay-type / mr-rogers.py
Last active February 14, 2022 18:49
rf4 version of the Ramsay Street Extension
# menuTitle : Mr Rogers
# shortCut : command+shift+k
import merz
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, registerSubscriberEvent, getRegisteredSubscriberEvents, listRegisteredSubscribers, unregisterGlyphEditorSubscriber
from mojo.UI import SetCurrentGlyphByName
from fontTools.pens.basePen import BasePen
from importlib import reload
import MrRogersData
@okay-type
okay-type / toggle-layer-visibility.py
Last active March 29, 2021 20:51
"forked" from thundernixon, but without the weight of the keydown observer
# menuTitle : Toggle layer visbility!
# shortCut : command+l
from mojo.roboFont import AllFonts
def showHideOption(displayOptionKey, currentDisplayOptionValue):
for layerName in f.layerOrder:
if not layerName == 'foreground':
f.getLayer(layerName).setDisplayOption(displayOptionKey, not currentDisplayOptionValue)
@okay-type
okay-type / removeOverlapPreview.py
Last active March 24, 2021 18:23 — forked from connordavenport/removeOverlapPreview.py
A startup script to preview a glyph with no overlap. Idea stolen from Glyphs (I still hate Glyphs)
from mojo.roboFont import RGlyph
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
from mojo.UI import getDefault, setDefault
from lib.tools.notifications import PostNotification
from fontTools.pens.basePen import BasePen
class MyCopyDecomposingPen(BasePen):
def __init__(self, glyphSet, outPen):
super(MyCopyDecomposingPen, self).__init__(glyphSet)
@okay-type
okay-type / syncAnchors.py
Last active March 23, 2021 17:13 — forked from connordavenport/syncAnchors.py
Sync Anchors
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
'''
A startup script to help keep anchors in-sync across glyphs
The script will not append anchors, only move existing anchors
To set a linked glyph, add 'LinkedGlyphs' in your main glyph's .note
Under that line add a comma separated list of glyph names (no spaces)
e.g.