Skip to content

Instantly share code, notes, and snippets.

View arrowtype's full-sized avatar

Stephen Nixon arrowtype

View GitHub Profile
@arrowtype
arrowtype / set-default-wght-to-400.py
Last active May 29, 2023 21:55
A Python script to set the default instance of a variable font’s Weight axis to 400 (Regular).
"""
A script to set the default instance of a variable font’s wght axis to 400 (Regular).
From https://gist.github.com/arrowtype/9fefe9633cae500bbaf0000230f6a3ed
This can perhaps be more intuitive to designers who expect "Regular" to be the default weight of a variable font,
or for web developers who don’t set a weight range in their @font-face webfont setup.
This could be easily adapted to set defaults along other axes. It simply uses the FontTools Instancer module.
@arrowtype
arrowtype / prep-faux-italics.robofont.py
Last active September 18, 2022 12:36
RoboFont script: generate faux-italic fonts as a starting point for designing an Italic companion to a Roman font
"""
DISCLAIMERS:
- WORK IN PROGRESS – works pretty well, but could use a few more improvements
- May or may not work for your particular project
- Always read scripts before you run them, and back up your work before you run scripts
DESCRIPTION:
A script to take the sources of Name Sans and output slanted versions of these,
for the purposes of A) prototyping & B) jumpstarting the italic drawings.
@arrowtype
arrowtype / make-kerning-string.py
Last active July 28, 2022 15:48
Several useful spacing & kerning strings, plus a simple way to make your own!
"""
A simple way to make some kerning strings, for kerning and/or proofing your kerning.
Change the "side1Names" to glyphs you want on the left side of pairs, and change side2Names to glyphs you want on the right side of pairs.
INSTRUCTIONS:
1. Copy space-separated list(s) of glyph names from a font editor, then paste into side1Names and side2Names below
- In GlyphsApp, select the glyphs you want, right-click (or control-click) and select Copy Glyph Names > Space Separated
- In RoboFont, select the glyphs you want, then press OPTION + COMMAND + C
2. Paste those names in the glyphNames variable below, between the quotes
@arrowtype
arrowtype / draw-selected-glyphs.robofont.drawbot.py
Last active May 4, 2023 11:08
Example of how to use DrawBot in RoboFont
'''
Glyph Proofer
This must be used within the Drawbot extension for RoboFont.
'''
from datetime import datetime
timestamp = datetime.now().strftime("%Y_%m_%d")
@arrowtype
arrowtype / draw-glyph-outline.drawbot.glyphsapp.py
Last active March 29, 2024 16:51
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.
@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 / 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 / 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 / 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 / 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):