Skip to content

Instantly share code, notes, and snippets.

View arrowtype's full-sized avatar

Stephen Nixon arrowtype

View GitHub Profile
@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:

>>> ord("A")
@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 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 / 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 / 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 / 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\""