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 / 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 / DarkConnor.roboFontTheme
Last active April 24, 2023 02:01
A dark theme for the RoboFont extension Theme Editor, based on the default "Connor’s Theme," but adjusted for a dark background. Updated April 2023.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>glyphViewAlternateFillColor</key>
<array>
<real>0.0</real>
<real>0.0</real>
<real>0.0</real>
<real>0.6027</real>
@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 / 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 / getting-started-in-type-design.md
Last active September 22, 2022 03:08
Some tips for getting started in type design, plus a few favorite extensions and tools

Getting started in Type Design (and possible next steps)

So, you’re interested in type design, but you are still figuring out how & where to start or get to the next step. This post is a non-exhaustive attempt to share an overview of how you might learn some basics, how you can get started with font editing software, and where you might consider growing your skills after that. It reflects my bias and (some of) my personal experience, and it completely skips important topics like formal education, calligraphy and sketching, bezier drawing tips, and more.

This started as an email listing my favorite RoboFont extensions, and then I thought that it would be worth sharing publicly, and then I added more and it turned into a bigger post. In the future, I hope to bring it onto a proper blog as a collection of separate, more-focused topics.

General learning

Useful Internet resources

@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 / README.md
Last active July 28, 2022 05:38
This is a set of Python I use many times I wish to make an animation or multipage doc with Drawbot, but coded in my preferred editor (currently, VS Code)

Using Drawbot in an external editor

This is a set of Python I use many times I wish to make an animation or multipage doc with Drawbot, but code in my preferred editor (currently, VS Code) rather than in the Drawbot app.

Usage

First, install DrawBot as a module:

pip install git+https://github.com/typemytype/drawbot