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 / 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 / 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 / consolidate_selected_point_pairs.py
Last active January 9, 2024 02:02
Looks at selected points, attempts to pair them up, and consolidates each pair into one point (attempts to preserve curve)
# menuTitle: Consolidate Selected Point Pairs
# shortCut : shift + control + f
from fontTools.misc.fixedTools import otRound
MAKE_INTO_ONE_POINT = True
def average(lst):
@ryanbugden
ryanbugden / unicorn.py
Last active January 9, 2024 02:03
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 / rotate_180-all_layers.py
Created August 3, 2023 02:29
See docstring in the script for description.
# menuTitle: Rotate 180 - All Layers
# shortCut: shift + command + r
'''
A script that rotates your glyph and all of its layers.
It does its best to rotate it in a helpful way, not
necessarily just around the body of the contours themselves.
Use your preferred shortcut in line 2.
Ryan Bugden
@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.
# 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 / accept_figma_svg.py
Last active August 3, 2023 02:43
RF start-up scripts for moving SVGs to and from Figma (or other apps) via pasteboard.
# menuTitle: Accept SVGs from Figma (Start-up script)
'''
An RF start-up script that allows inbound SVG data from Figma via pasteboard.
Should work on simple shapes, might not work for others.
Ryan Bugden
'''
import AppKit
@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()