Last active
September 28, 2023 20:15
-
-
Save connordavenport/5c242deba24153b8cc8bd80a52e081f2 to your computer and use it in GitHub Desktop.
A startup script for RoboFont that will automatically group/tabulate your fonts by info.familyName
This file contains hidden or 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 mojo.subscriber import Subscriber, registerRoboFontSubscriber | |
| import AppKit | |
| class MargielaTabs(Subscriber): | |
| def fontDocumentDidOpen(self,info): | |
| newFont = info["lowLevelEvents"][0]["font"] | |
| windowsMap = {} | |
| allFonts = {f.info.familyName:AllFonts().getFontsByFamilyName(f.info.familyName) for f in AllFonts()} | |
| for familyName,fonts in allFonts.items(): | |
| windowsMap[familyName] = [w for w in AppKit.NSApp().orderedWindows() if hasattr(w, "windowName") and "FontWindow" in w.windowName() and w.document().font.info.familyName == familyName] | |
| windows = windowsMap.get(newFont.info.familyName) | |
| if windows and len(windows) > 1: | |
| ''' | |
| we cant select the first one because that is the | |
| newest font and it would move the other font windows. | |
| ''' | |
| main = next((window for window in windows if window.document().font.path != newFont.path), -1) | |
| if main in windows: windows.remove(main) | |
| for window in windows: | |
| if window.document().font.path == newFont.path: | |
| main.addTabbedWindow_ordered_(window, AppKit.NSWindowAbove) | |
| registerRoboFontSubscriber(MargielaTabs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@connordavenport changing line 11 to the following makes it work for Single Window Mode as well: