Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ryan Bugden ryanbugden

🏠
Working from home
View GitHub Profile
@ryanbugden
ryanbugden / addMissingGlyphsFromClipboard.py
Created Aug 24, 2020
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.
View addMissingGlyphsFromClipboard.py
# 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()
@ryanbugden
ryanbugden / makeTwoLinesParallel.py
Last active Aug 21, 2020
Select four points. Make their line segments parallel by running.
View makeTwoLinesParallel.py
# 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()
View generateInstancesFromDesignspaces.py
# 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 / markUndrawnGlyphsFromSCRed.py
Last active Jul 23, 2020
Add sample text into Space Center. Run this script. Any glyphs that don't exist in the font will be highlighted red. Draw them!
View markUndrawnGlyphsFromSCRed.py
# 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:
@ryanbugden
ryanbugden / makeGNReadable.py
Created Jul 20, 2020
Script that goes through each glyph in the current font and—based on its unicode—sets its name according to AGL
View makeGNReadable.py
# 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 / openGlyphPreviewWindow.py
Last active Jul 15, 2020
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
View openGlyphPreviewWindow.py
# 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 / spaceCenterTuner.py
Created Jun 17, 2020
Fine-tune space center setting
View spaceCenterTuner.py
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 / scrambleSelectedGlyphs.py
Created Jun 8, 2020
Scramble up the glyphs you've selected
View scrambleSelectedGlyphs.py
# menuTitle : Scramble Selected Glyphs
from random import choice
f = CurrentFont()
# grab selection
gs = f.selectedGlyphNames
new_assign ={}
@ryanbugden
ryanbugden / resize_fo_16_cells.py
Created May 19, 2020
try to fit 16 columns perfectly into font overview, resize window accordingly
View resize_fo_16_cells.py
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 / spaceCenterTuner.py
Created May 18, 2020
A little vanilla window to help drastically change size, line-height, left padding, top padding
View spaceCenterTuner.py
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