Skip to content

Instantly share code, notes, and snippets.

View arrowtype's full-sized avatar

Stephen Nixon arrowtype

View GitHub Profile
@arrowtype
arrowtype / remove-selected-glyphs-from-currentfont.py
Last active December 15, 2021 15:45
A script to nuke selected glyphs from the Current Font in RoboFont
"""
Removes currently selected glyphs from current font.
Also removes these glyphs from groups, kerning, and components.
Includes template glyphs in selection and removal.
"""
f = CurrentFont()
@arrowtype
arrowtype / italic-shift.py
Created December 1, 2021 22:46
A snippet to determine how much horizontal shift a point should get in an italic glyph, in a UFO font.
"""
Here’s a snippet to determine how much horizontal shift a point should get in an italic glyph.
In practical terms, I have just used this to shift anchors in a UFO font source, in order to prepare an oblique font.
Basically, how can we determine "x" below, given a height ("y") and an angle (italicAngle)?
x
• - - •
| /
@arrowtype
arrowtype / 1--orient-glyph-contours-UFOs_in_dir.py
Last active January 25, 2022 18:48
Go through UFOs in directory and orient contour paths in a counter-clockwise direction. See https://github.com/googlefonts/fontmake/issues/846
"""
⚠️⚠️⚠️
OOPS. Don’t use this. FontParts already has BaseGlyph.correctDirection()
⚠️⚠️⚠️
Go through UFOs in directory and orient contour paths in a counter-clockwise direction,
as they should be for cubic/postscript/CFF/"OTF" curves.
DEPENDENCIES:
@arrowtype
arrowtype / split-kerning-group-allfonts.py
Last active February 11, 2022 21:57
RoboFont script to split glyphs from a kern group, but keep kerning (so you can fix it without disrupting it too much)
"""
Split glyphs from a given kerning group, but keep kerning
so you don’t lose a bunch of almost-correct kerns.
(Slightly
E.g. If you need to split "e" glyphs out of the "o" group.
USAGE:
- set originalGroupName (group to split from)
@arrowtype
arrowtype / make-blank-glyphs-in-ttf.py
Last active February 28, 2022 23:05
A script to make all glyphs in a TTF blank, while leaving metrics, features, etc in place.
"""
A script to make all glyphs in a TTF blank, while leaving metrics, features, etc in place.
"""
from fontTools import ttLib
from fontTools.ttLib.tables._g_l_y_f import Glyph
from argparse import ArgumentParser
def eraseGlyphs(fontPath, inplace=False):
@arrowtype
arrowtype / copy-kerning-in-pair_list-without-metrics_machine.py
Created April 18, 2022 03:00
A script to quickly copy specific kerns between fonts. A bit kludgy... be sure to use Git to know what’s happening to your fonts!
"""
A script to run on UFO files from a command line. Go through a pair list and
copy kerns from one UFO to one other UFO, if those kern pairs are in the pair list.
What happens:
- copy groups from ufoToCopyFrom to ufoToCopyTo
- for each pair in the pair list, copy kern from ufoToCopyFrom to ufoToCopyTo
Usage:
@arrowtype
arrowtype / main.py
Created April 21, 2022 16:03
A MetricsMachine-based configuration for the dual encoder MiniKBD from @andyclymer
import board
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
import adafruit_dotstar as dotstar
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
from encoder import Encoder
import time
@arrowtype
arrowtype / pagecount-cheatsheet.py
Last active July 11, 2022 19:51
A quick little command line tool to copy a left/right page count to your clipboard. Maybe helpful for book design.
"""
Book page cheat sheet!
Alternate left/right alongside number for a given page count.
Example:
1 Right
2 Left
3 Right
@arrowtype
arrowtype / make-new-pairlist-of-kerned-pairs.py
Created July 19, 2022 20:10
RoboFont script to generate a simplified MetricsMachine pair list from an input font and pair list.
"""
Perhaps useful for kerning secondary sources once primary sources are kerned.
E.g. kern numerals to caps in your Regular, then run this, then kern the new list in your Bold.
Or maybe useful for a second pass at kerning, if you only want to view items which have already been kerned.
Basic approach:
- Take in UFO(s),
- Take in existing MetricsMachine kerning pair list,
- Go through kern pair list and check which pairs are kerned in the font,
@arrowtype
arrowtype / draw-glyph-outline.drawbot.glyphsapp.py
Last active August 20, 2024 23:42
For DrawBot in GlyphsApp: Draw a glyph's outlines & nodes, for presentation / social media purposes
"""
Script to create an image of a glyph in the current layer.
Instructions:
- Use within the Drawbot plugin of GlyphsApp.
- Get this plugin via Window > Plugin Manager, then search for "Drawbot" and install it.
- Then, go to File > New Drawbot, and paste in this code and run it.
- You may need to restart glyphs for the Plugin to work.