Skip to content

Instantly share code, notes, and snippets.

View frankrolf's full-sized avatar
😸
meow

Frank Grießhammer frankrolf

😸
meow
View GitHub Profile

EZML Syntax Basics

# comment
whitespace has no meaning except single spaces used to separate important things
@ is an identifier
() means button of some sort
[__] means text entry of some sort (except checkbox)
{} means image
- means line
@frankrolf
frankrolf / redraw_for_start_point.py
Last active January 10, 2023 18:03
Avoid off-curve start points in UFO files
'''
Avoid offcurve start points
'''
from fontTools.ufoLib.pointPen import PointToSegmentPen
def find_offcurve_start(glyph):
'''
compare coordinates of first bPoint to coordinates of first point
@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)]
@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 / 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 / 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)
'''
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 / 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()
@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 / 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):