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 / spaceCenterTuner.py
Created May 18, 2020 18:49
A little vanilla window to help drastically change size, line-height, left padding, top padding
from mojo.UI import CurrentSpaceCenter
from vanilla import FloatingWindow, Slider, TextBox
class SpaceCenterTuner():
"""
Fine-tune Space Center sizing and spacing.
Ryan Bugden
2020.05.18
2019.06.02
@ryanbugden
ryanbugden / resize_fo_16_cells.py
Created May 19, 2020 17:11
try to fit 16 columns perfectly into font overview, resize window accordingly
from mojo.UI import CurrentFontWindow
from lib.tools.defaults import getDefault
'''
trying to perfectly fit 16 columns of cells across the font overview
'''
fo = CurrentFontWindow().fontOverview
gc = fo.getGlyphCollection()
v = gc.getGlyphCellView()
@ryanbugden
ryanbugden / scrambleSelectedGlyphs.py
Created June 8, 2020 19:25
Scramble up the glyphs you've selected
# menuTitle : Scramble Selected Glyphs
from random import choice
f = CurrentFont()
# grab selection
gs = f.selectedGlyphNames
new_assign ={}
@ryanbugden
ryanbugden / spaceCenterTuner.py
Created June 17, 2020 21:20
Fine-tune space center setting
from mojo.UI import CurrentSpaceCenter
from vanilla import FloatingWindow, Slider, TextBox
from AppKit import NSColor
from mojo.events import addObserver, removeObserver
class SpaceCenterTuner():
"""
Fine-tune Space Center sizing and spacing.
Ryan Bugden
@ryanbugden
ryanbugden / openGlyphPreviewWindow.py
Last active July 15, 2020 20:55
Opens a slick glyph preview for when you're working. Thanks Juan for the idea; RoboFont.com for the example code on which this is based
# menuTitle : Open Glyph Preview Window
from vanilla import FloatingWindow
from mojo.glyphPreview import GlyphPreview
from mojo.roboFont import OpenWindow
from mojo.events import addObserver, removeObserver
from lib.tools.misc import rgbaToNSColor
class GlyphPreviewWindow:
@ryanbugden
ryanbugden / makeGNReadable.py
Created July 20, 2020 21:24
Script that goes through each glyph in the current font and—based on its unicode—sets its name according to AGL
# menuTitle : Make All Glyph Names Human Readable
from lib.tools.unicodeTools import GN2UV
def get_key(val, di):
for key, value in di.items():
if val == value:
return key
f = CurrentFont()
@ryanbugden
ryanbugden / markUndrawnGlyphsFromSCRed.py
Last active July 23, 2020 20:27
Add sample text into Space Center. Run this script. Any glyphs that don't exist in the font will be highlighted red. Draw them!
# menuTitle : Mark Undrawn Glyphs from SC Red
from mojo.UI import CurrentSpaceCenter
from glyphNameFormatter.tools import charToUnicode
f, csc = CurrentFont(), CurrentSpaceCenter()
text = csc.getRaw()
color = (1, 0, 0, 1) #red
for letter in text:
# menuTitle : Generate Instances from Designspaces
from ufoProcessor import build
from mojo.UI import GetFile
paths = GetFile(
message='Select all designspaces, the instances of which you want to generate.',
title='Generate Instances',
allowsMultipleSelection=True
)
@ryanbugden
ryanbugden / makeTwoLinesParallel.py
Last active August 21, 2020 17:12
Select four points. Make their line segments parallel by running.
# menuTitle : Make Two Selected Lines Parallel
import math
def sortTuple(tup):
# sort line coordinates in ascending y order
tup.sort(key = lambda x: x[1])
return tup
g = CurrentGlyph()
@ryanbugden
ryanbugden / addMissingGlyphsFromClipboard.py
Created August 24, 2020 21:43
Copy the text sample you'd like to fulfill to your clipboard. Run this script. Font overview will add more template glyphs for the glyphs you still need to draw.
# menuTitle: Add Missing Characters from Clipboard Text
import collections
from glyphNameFormatter import GlyphName
from AppKit import NSPasteboard, NSPasteboardTypeString
f = CurrentFont()
templ_gs = f.templateGlyphOrder
pasteboard = NSPasteboard.generalPasteboard()