Skip to content

Instantly share code, notes, and snippets.

View arrowtype's full-sized avatar

Stephen Nixon arrowtype

View GitHub Profile
@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 / 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 / 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 / set-default-wght-to-400.py
Last active January 10, 2025 01:36
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 / limit-fvar-to-default-opsz-instances.py
Last active November 26, 2022 20:54
Remove instances with a non-default opsz location from a variable font, as a workaround to a current Safari bug (https://bugs.webkit.org/show_bug.cgi?id=247987)
"""
Remove instances with a non-default opsz location from a variable font,
in order to avoid Safari v16 bug (https://bugs.webkit.org/show_bug.cgi?id=247987)
NOTE: seems to trigger another Safari issue for wght + opsz fonts, so I’m currently only
using this on an opsz-only font. Do your own testing!
Assumes:
- exactly one font path is being fed in
- it’s a variable font
@arrowtype
arrowtype / count-word-frequency.py
Last active March 1, 2023 23:42
A simple Python script to count and rank the frequency of words in a text file, e.g. for verifying that you are kerning important pairs for specific content
"""
Simple Python script to count word frequency in a given text document.
Started from
https://www.geeksforgeeks.org/python-count-occurrences-of-each-word-in-given-text-file/
Usage: Update the file path below, then run in the command line.
"""
# Relative path to a .txt file
@arrowtype
arrowtype / calculate-stripe-fee.py
Last active February 28, 2023 17:36
A quick Python script to compute Stripe fees, for invoicing customers
"""
A simple Python3 script to take in a project price, and output the fee Stripe will charge on an invoice.
See also:
https://support.stripe.com/questions/passing-the-stripe-fee-on-to-customers
USAGE - Call the script with Python3 and its path, and give your project/goal price as an arg:
python3 calculate-stripe-fee.py 95.00
@arrowtype
arrowtype / zipit.sh
Created June 7, 2023 22:04
A shell function to zip folders, excluding macOS metadata files. Add to your .bash_profile (or similar) to have a "zipit" command.
function zipit {
currentDir=$(pwd) # get current dir so you can return later
cd $(dirname $1) # change to target’s dir (works better for zip)
target=$(basename $1) # get target’s name
zip -r $target.zip $target -x '*/.DS_Store' # make a zip of the target, excluding macOS metadata
echo "zip made of " $1 # announce completion
cd $currentDir # return to where you were
}
@arrowtype
arrowtype / README.md
Last active June 27, 2023 16:48
Example script that helps keep support sources up to date between full sources of a designspace.
@arrowtype
arrowtype / fonttools-recording-pen-example.py
Created June 23, 2023 22:05
Basic example of how to use the FontTools Recording Pen
"""
A basic example of how to open a UFO and print out the bezier curve values from a glyph.
Example expanded from:
https://fonttools.readthedocs.io/en/latest/pens/recordingPen.html
Requires FontTools and FontParts.
"""
from fontParts.fontshell import RFont as Font