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 / 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 / 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 / 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 / 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 / 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()
@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 / 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 / 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...")