Skip to content

Instantly share code, notes, and snippets.

View frankrolf's full-sized avatar
😸
meow

Frank Grießhammer frankrolf

😸
meow
View GitHub Profile
@frankrolf
frankrolf / lemonvetica.py
Last active September 26, 2024 06:58
Example on how to show a given letter’s off-curve points in DrawBot
# it’s easy to access a letter’s contours through a BezierPath object:
bp = BezierPath()
bp.text(
's',
font='SFProDisplay-Heavy',
fontSize=1200)
# Fill the letter, and offset the whole canvas so it sits in the middle.
fill(1, 1, 0)
letter_width = bp.bounds()[-2] - bp.bounds()[0]
@frankrolf
frankrolf / RoboFontDefconExample.py
Created December 17, 2019 19:16 — forked from typoman/RoboFontDefconExample.py
An example to show how to make defcon notifications in RoboFont
from mojo.events import addObserver, removeObserver
from vanilla import Window
class RoboFontDefconExample():
def __init__(self):
self.w = Window((300, 120), "Debuggin window")
self.fonts = {}
for f in AllFonts():
self._addFont(f)
@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)
@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 / 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 / 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 / floatObserver.py
Last active September 7, 2020 20:32
Robofont observer to avoid writing fractional coordinates.
from mojo.events import addObserver
import mojo
VERSION = mojo.roboFont.version
class FloatObserver(object):
def __init__(self):
# addObserver(self, 'saveCallback', 'fontWillClose')
addObserver(self, 'saveCallback', 'fontWillSave')
@frankrolf
frankrolf / toggle.py
Last active March 20, 2024 17:06
Robofont: toggle current glyph window and space center window, if open
'''
TikToggle
- toggle glyph windows
- toggle the current space center to correspond to the frontmost glyph
suggested shortcut: ctrl - ↑
toggle_backward.py also exists:
suggested shortcut: ctrl - ↓
@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 / flip_phrase.py
Last active September 3, 2020 11:09
Table-flip any phrase you like! (╯°□°)╯︵ ǝsɐɹɥd
'''
table-flip any phrase you like!
If the expression contains spaces, please use quotes.
python flip_phrase.py fontlab
>>> (╯°□°)╯︵ qɐlʇuoɟ
'''
import sys
import unicodedata