Last active
May 21, 2022 09:56
-
-
Save typoman/4169203c4507f23400b6c58140f0cf92 to your computer and use it in GitHub Desktop.
RoboFont startup script to enable jump to base glyph of componets by double clicking on the component in glyph view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from defconAppKit.windows.baseWindow import BaseWindowController | |
from vanilla import FloatingWindow | |
from mojo.events import addObserver, removeObserver | |
from mojo.UI import SetCurrentGlyphByName | |
""" | |
RoboFont Helper | |
Type: Start up | |
Purpose: After it's run, if you double click on a component it will jump to its base glyph. | |
""" | |
class CompJumper(): | |
def __init__(self): | |
addObserver(self, "_mouseDown", "mouseDown") | |
def destroy(self, sender): | |
removeObserver(self, "mouseDown") | |
def _mouseDown(self, info): | |
p = info["point"] | |
if info['clickCount'] == 2: | |
g = CurrentGlyph() | |
for c in g.components: | |
path = c.naked().getRepresentation("defconAppKit.NSBezierPath") | |
if path.containsPoint_((p.x, p.y)): | |
SetCurrentGlyphByName(c.baseGlyph) | |
return | |
# class DebuggerWindow(BaseWindowController): | |
# def __init__(self): | |
# self.w = FloatingWindow((123, 44), 'debug!') | |
# cj = CompJumper() | |
# self.w.open() | |
# self.w.bind("close", cj.destroy) | |
# DebuggerWindow() | |
CompJumper() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update for RF 4: