Skip to content

Instantly share code, notes, and snippets.

View frankrolf's full-sized avatar
😸
meow

Frank Grießhammer frankrolf

😸
meow
View GitHub Profile
'''
Open different space centers based on figure figure_suffixes given below
'''
from mojo import UI
from AppKit import NSApp, NSScreen, NSMakeRect
# figure_suffixes = ('', '.lf', '.tosf', '.osf', '.sc', '.sups')
figure_suffixes = ('', '.lf', '.tosf', '.osf')
@frankrolf
frankrolf / which_kerning_group.py
Created August 12, 2020 09:30
Robofont: startup script to find out which kerning group the selected glyph belongs to
'''
Robofont startup script to find out which kerning group
the selected glyph belongs to.
'''
import AppKit
from mojo.UI import CurrentFontWindow
from mojo.events import addObserver
from mojo.roboFont import CurrentFont
@frankrolf
frankrolf / skew_selected_segments_to_italic_angle.py
Created August 21, 2020 17:33
Robofont: skew selected segments to Italic angle
import math
def calc_vector(p1, p2):
x1, y1 = p1
x2, y2 = p2
return x2 - x1, y2 - y1
def calc_distance(p1, p2):
@frankrolf
frankrolf / segment_structure.py
Last active November 8, 2020 17:22
Robofont script to validate segment structure across fonts
'''
Print out segment structure for current glyph in all open fonts.
If the structure matches, only one line will be printed:
a 0 ⤴️📈📈⤴️⤴️⤴️⤴️📈⤴️⤴️⤴️ 1 ⤴️📈⤴️⤴️📈⤴️⤴️⤴️⤴️📈📈⤴️⤴️📈📈⤴️ ✔
If it does not, the structure of all open fonts will be printed for comparison:
@frankrolf
frankrolf / mm_toggle.py
Last active January 17, 2023 13:09
Toggle Metrics Machine pair list
'''
Toggle the pair list of an open MetricsMachine (extension) window
from all kerning pairs (sorted by glyph order) to exceptions and back.
'''
import metricsMachine
import mm4
f = CurrentFont()
'''
for https://github.com/adobe-fonts/source-code-pro/issues/247
check character support requests against code points present in font
'''
import sys
import unicodedata
from fontTools import ttLib
@frankrolf
frankrolf / rf_version_number.py
Created January 22, 2021 17:02
Robofont version number in menu bar
import AppKit
from mojo.roboFont import version
menu = AppKit.NSApp().mainMenu()
roboFontItem = menu.itemWithTitle_("RoboFont")
if roboFontItem:
# roboFontItem.submenu().setTitle_("RoboFont %s THIS IS THE OLD VERSION, WATCH OUT FRANK!" % version)
roboFontItem.submenu().setTitle_("RoboFont %s" % version)
@frankrolf
frankrolf / uniranges.py
Created February 10, 2021 22:24
See/select supported Unicode ranges in Robofont
from mojo.UI import CurrentFontWindow
import AppKit
import unicodedata
from vanilla import CheckBox, FloatingWindow, List, LevelIndicatorListCell
import glyphNameFormatter
f = CurrentFont()
u_ranges = glyphNameFormatter.unicodeRangeNames.unicodeRangeNames
reverse_ranges = {v: k for k, v in u_ranges.items()}
@frankrolf
frankrolf / glyph_move_selection_backward.py
Created March 16, 2021 13:47
Robofont: move selection around contour
from importlib import reload
import glyph_move_selection_forward
reload(glyph_move_selection_forward)
g = CurrentGlyph()
glyph_move_selection_forward.move_index(g, -1)
@frankrolf
frankrolf / toggle_bcp_selection.py
Created October 1, 2021 16:41
toggle selected off-curve point(s)
'''
toggle bcp selection
'''
def toggle_bcp_selection(bcp):
pts = bcp.contour.points
p_prev = pts[(bcp.index - 1) % len(pts)]
p_prev_2 = pts[(bcp.index - 2) % len(pts)]
p_next = pts[(bcp.index + 1) % len(pts)]