Skip to content

Instantly share code, notes, and snippets.

View arrowtype's full-sized avatar

Stephen Nixon arrowtype

View GitHub Profile
@arrowtype
arrowtype / github-details-bash-alias.sh
Created November 11, 2019 15:46
Get a handy summary+details dropdown to copy into HTML, markdown, and GitHub Issues/PRs/readme files
# add the line below to your ~/.bash_profile or ~/.profile
alias deets="printf \"<details>\n<summary><b><!-------->Dropdown title<!--------></b> (Click to expand)</summary>\n\n<!-------->\nDropdown details\n<!-------->\n\n</details>\" | pbcopy && echo \"github-ready <details> element copied to clipboard\""
@arrowtype
arrowtype / lemonvetica.py
Created December 11, 2019 16:16 — forked from frankrolf/lemonvetica.py
Example on how to show a given letter’s off-curve points in DrawBot
# it’s easy to access a letter’s contours through a BezierPath object:
bp = BezierPath()
bp.text(
's',
font='.SFNSDisplayCondensed-Black',
fontSize=1200)
# Fill the letter, and offset the whole canvas so it sits in the middle.
fill(1, 1, 0)
letter_width = bp.bounds()[-2] - bp.bounds()[0]
@arrowtype
arrowtype / minecraft-cubes-and-towers.py
Last active March 5, 2021 15:23
Python experiments for Minecraft API (mcpi) to make ridiculous cubes & towers.
"""
Make cubes and towers in Minecraft, with Python.
Really fun way to introduce a kid to Python (or yourself to Minecraft, as I've learned).
Setup instructions for Minecraft + macOS + Python: https://gist.github.com/noahcoad/fc9d3984a5d4d61648269c0a9477c622
Additional setup:
- Activate correct Java version: `export JAVA_HOME=`/usr/libexec/java_home -v 11.0.5``
- Activate spigot `cd spigot; java -jar spigot.jar`
@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
@arrowtype
arrowtype / MM2SpaceCenter_v4.9.py
Created March 16, 2020 10:55 — forked from cjdunn/MM2SpaceCenter_v4.9.py
MM2SpaceCenter_v4.9.py
# MM2SpaceCenter by CJ Dunn, 2019, and licensed under the MIT license. Thanks to Tal Leming, Andy Clymer, David Jonathan Ross, Jackson Cavanaugh, Nina Stössinger for help and inspiration with this script
# #when pair changes: get pair and set to space center
#you must have a UFO open and have MetricsMachine open
import sys, os
import random
from mojo.UI import CurrentSpaceCenter, OpenSpaceCenter
@arrowtype
arrowtype / README.md
Last active October 8, 2021 13:15
The basics of working with unicode values in Python

Unicode values in Python

Unicodes can either be integers (“A” is 65, “B” is 66, etc) or hex (“A” is 0x41, “B” is 0x42, etc).

When scripting with RoboFont or FontTools, a hard thing at first is that different styles come up in different contexts. For example, integers will often be used in scripts, but hex values are shown in UIs and in the TTX output of cmap (the table that maps unicode values to glyphs). So, it's helpful to know how to go between them to do different types of work.

To go from a string to an unicode integer, you can use ord(), like:

&gt;&gt;&gt; ord("A")
@arrowtype
arrowtype / compute-remaining-unicodes.py
Last active June 26, 2023 17:03
A command-line tool to produce a "trial font" for input OTF or TTF font files, using Python 3 & FontTools
"""
From
https://github.com/arrowtype/recursive/blob/eb821735e66402b4b485ce97ed32b09a8555341e/src/build-scripts/make-release/compute-remaining-unicodes-in-font.py
The FontTools Subsetter expects unicode ranges for *inclusion*, but
often you just know which ranges you want to *exclude* from a font subset.
So, this script will accept a font, then report what Unicode values
it includes *beyond* given Unicode ranges.
@arrowtype
arrowtype / set-new-mark-opacity.robofont.py
Created May 3, 2020 17:57
RoboFont script to help set new mark opacity for a selected mark
"""
Get the mark color of currently-selected glyphs and change the
opacity of it in the current font.
Useful for changing the Font View to a "dark theme," where
the wrong mark opacity can suddenly disrupt a system of colors.
"""
f = CurrentFont()
@arrowtype
arrowtype / 00-toggle-darkmode.robofont.py
Last active February 3, 2022 05:57
A script to toggle darkmode in RoboFont, for app UI and Font View. Also includes a dark theme for the RoboFont Theme Editor.
"""
Toggle a dark mode in RoboFont.
For a dark mode in the Glyph Edit view, install Theme Editor:
https://github.com/connordavenport/Theme-Manager
...and import the "Dark Connor" theme from this Gist
(https://gist.github.com/arrowtype/ce0cee426f47c2fe7e82aa07d1e0a450).
Also offers to edit the markColor of glyphs with a high opacity in their markColor,
which will disrupt the visual effect of a dark mode on the Font View. However,
@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