Skip to content

Instantly share code, notes, and snippets.

View ryanbugden's full-sized avatar
🏠
Working from home

Ryan Bugden ryanbugden

🏠
Working from home
View GitHub Profile
@ryanbugden
ryanbugden / unicorn.py
Last active May 16, 2024 17:36
A simple window to manipulate unicode stuff across your font(s).
# menuTitle: Unicorn
import ezui
from mojo.extensions import setExtensionDefault, getExtensionDefault
from glyphNameFormatter.reader import u2n, u2U, U2u, n2u
EXTENSION_KEY = "com.ryanbugden.unicorn.settings"
class Unicorn(ezui.WindowController):
@ryanbugden
ryanbugden / glyph_recipes.py
Created April 12, 2024 18:14
Make new glyphs (ligatures?) with given input glyphs.
# menuTitle: Glyph Recipes
recipes = {
# Desired name, and recipe of what glyphs go in there
"fi": ('f', 'i'),
"f_l": ('f', 'l')
}
f = CurrentFont()
@ryanbugden
ryanbugden / scale_while_slanted.py
Last active January 25, 2024 16:48
Honor the italic angle when scaling disproportionately.
# menuTitle: Scale While Slanted
import ezui
from mojo.extensions import getExtensionDefault, setExtensionDefault
from fontTools.misc.transform import Transform
from math import radians
EXTENSION_KEY = "com.ryanbugden.scaleWhileSlanted.settings"
EXTENSION_DEFAULTS = {
@ryanbugden
ryanbugden / event_subscriber.py
Last active January 23, 2024 16:11
A Subscriber-based version of eventObserver. Useful for tracking internal notifications and using it for tool-building.
# menuTitle: Event Subscriber
'''
A Subscriber-based version of eventObserver.
Useful for tracking internal notifications and using it for tool-building.
2024.01.22 — Ryan Bugden
2024.01.23 — Made a lot faster by Tal Leming. Thanks!
'''
@ryanbugden
ryanbugden / cherry_picker.py
Last active January 15, 2024 18:27
Selectively load individual extensions from the comfort of Safe Mode. (Requires 5.2b 2401121414)
# menuTitle: Cherry Picker
import ezui
from mojo.extensions import ExtensionBundle
from AppKit import NSApp
def safe_mode_state():
obj = NSApp().mainMenu().itemWithTitle_("Safe Mode...")
@ryanbugden
ryanbugden / set_latest_kern_value.py
Last active January 9, 2024 02:05
Save the kern value from the last pair you were on, for quick application to your current pair (with the Page-Down key). Install "store..." as a start-up script, and "set...py" as a normal script in the script folder.
# menuTitle: Set the Latest Kern Value
# shortCut: pagedown
from mojo.UI import getDefault
import metricsMachine as mm
KERN_VALUE_LIB_KEY = 'com.ryanbugden.storeLatestKernValue.kernValue'
def get_kern_group(f, glyph, side):
if side == 'left':
@ryanbugden
ryanbugden / menu-toggle_skip_export.py
Created March 21, 2023 17:05
A font overview contextual menu item that allows you to toggle skip-export for selected glyphs. Install as start-up script.
from mojo.subscriber import Subscriber, registerFontOverviewSubscriber
class ToggleSkipExportMenu(Subscriber):
'''
A contextual menu item:
Go through all selected glyphs, and change whether they are set to export or non-export,
based on the opposite of the state of the first glyph.
@ryanbugden
ryanbugden / i_finished_the_typeface.py
Created April 12, 2023 19:19
When you finish your typeface, run this and look to the font overview for a congratulatory message.
# menuTitle: I Finished the Typeface.
from mojo.UI import CurrentFontWindow
import math
import time
f = CurrentFont()
fo = CurrentFontWindow().fontOverview
v = fo.getGlyphCollection().getGlyphCellView()
# menuTitle: Delete Glyphs from Layer - Contextual Menu
import ezui
from mojo.subscriber import Subscriber, registerFontOverviewSubscriber
from mojo.UI import CurrentFontWindow
'''
(Start-up script)
A contextual menu in the Font Overview. Right click selected glyphs
to delete them from a specified layer.
@ryanbugden
ryanbugden / menu_item-close_all_fonts.py
Created July 24, 2023 15:49
Adds a Close All Fonts menu item
from AppKit import NSApp, NSMenuItem, NSAlternateKeyMask, NSCommandKeyMask
from mojo.tools import CallbackWrapper
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.UI import PutFile, AskYesNoCancel
class close_all_fonts_menu_item(Subscriber):
'''
A startup script that places a menu item in the File dropdown menu.