Skip to content

Instantly share code, notes, and snippets.

@frankrolf
frankrolf / arrange_stickies.scpt
Last active May 7, 2020 22:00
Applescript: distribute all stickies evenly on the main screen, with optional padding
# Distribute all stickies evenly on the main screen, with optional padding
# how many columns?
set num_columns to 7
# how many pixels of padding between the stickies?
set padding to 20
# Find the dimensions of the main screen
# https://stackoverflow.com/questions/1866912/applescript-how-to-get-current-display-resolution
@frankrolf
frankrolf / tiny.py
Last active June 27, 2023 16:09 — forked from okay-type/tinyscript.py
Refireable Tiny Script Window
# menuTitle : Tiny Script Window
import tempfile
import time
from pathlib import Path
from AppKit import NSApp
from vanilla import FloatingWindow, SplitView
from lib.scripting.scriptingWindow import PyTextEditor, OutPutEditor
from mojo.events import addObserver, removeObserver
from mojo.extensions import (
setExtensionDefault, getExtensionDefault,
@frankrolf
frankrolf / glyph_smart_close_paths.py
Last active May 15, 2024 17:43
Robofont: close paths based on distance
'''
Robofont: Smart Close Paths
The idea is closing open contours based on point distance rather than
membership of a given contour.
'''
import itertools
import math
from fontTools.pens.basePen import BasePen
@frankrolf
frankrolf / find_shortkeys.py
Last active May 25, 2020 12:28
Robofont: which shortkeys are assigned to what action?
'''
Robofont: which shortkeys are assigned to what action?
'''
import AppKit
import itertools
import mojo
modifiers = {
AppKit.NSEventModifierFlagOption: '⌥',
@frankrolf
frankrolf / deep_query.py
Created April 16, 2020 10:50
Robofont: Set search query of frontmost font window for all font windows
'''
Set search query of frontmost font window in all font windows
'''
from mojo.UI import AllFontWindows, CurrentFontWindow
current_window = CurrentFontWindow()
current_query = current_window.getGlyphCollection().getQuery()
for font_window in AllFontWindows():
font_window.getGlyphCollection().setQuery(current_query)
@gferreira
gferreira / InterpolationPreviewSpaceCenter.py
Last active April 5, 2020 19:49
Preview interpolation result in the Space Center using representations.
'''
just a proof of concept, name of the second master is hard-coded at the bottom
'''
from vanilla import FloatingWindow, CheckBox, Slider
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo.events import addObserver, removeObserver
from mojo.UI import CurrentSpaceCenter
import mojo.drawingTools as ctx
@cjdunn
cjdunn / MM2SpaceCenter_v4.9.py
Last active March 16, 2020 10:55
MM2SpaceCenter_v4.9.py
# MM2SpaceCenter by CJ Dunn, 2019, and licensed under the MIT license. Thanks to Tal Leming, Andy Clymer, David Jonathan Ross, Jackson Cavanaugh, Nina Stössinger for help and inspiration with this script
# #when pair changes: get pair and set to space center
#you must have a UFO open and have MetricsMachine open
import sys, os
import random
from mojo.UI import CurrentSpaceCenter, OpenSpaceCenter
@typoman
typoman / roboFontCompDoubleClick.py
Last active May 21, 2022 09:56
RoboFont startup script to enable jump to base glyph of componets by double clicking on the component in glyph view.
from defconAppKit.windows.baseWindow import BaseWindowController
from vanilla import FloatingWindow
from mojo.events import addObserver, removeObserver
from mojo.UI import SetCurrentGlyphByName
"""
RoboFont Helper
Type: Start up
Purpose: After it's run, if you double click on a component it will jump to its base glyph.
"""
@typoman
typoman / roboFontPerformanceTests.py
Last active September 8, 2020 10:09
This can be used to find faster ways to perform tasks in RoboFont using python
import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
else:
@frankrolf
frankrolf / anchorBaby.py
Last active April 16, 2020 15:16
RoboFont observer for keeping anchors consistent.
'''
## anchorBaby.py
RoboFont script for keeping anchors consistent.
Inspired by an idea from James T. Edmondson, this script will take note of
anchor movement in a given glyph, and replicate that movement in all
dependent glyphs.
For instance, if a font has the glyphs `a` `a.init` and `a.fina`; and all three