This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In honor of https://www.instagram.com/p/C_iATyCiGu0/ | |
# John Hinton / Dying (Pelican originals; Studies in social pathology) | |
# Designer unknown | |
def circle(x, y, d): | |
r = d / 2 | |
oval(x - r, y - r, d, d) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import singledispatch | |
from io import StringIO | |
from fontTools.feaLib import ast | |
from fontTools.feaLib.error import FeatureLibError | |
from fontTools.feaLib.parser import Parser | |
def renameGlyphs(feaSource, renameFunc, glyphNames=()): | |
features = Parser(StringIO(feaSource), glyphNames=glyphNames).parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from itertools import product | |
import sys | |
from fontTools.designspaceLib import DesignSpaceDocument | |
def main(): | |
parser = argparse.ArgumentParser( | |
description="Makes new named instances based on the axis labels" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import sys | |
from fontTools.designspaceLib import AxisLabelDescriptor, DesignSpaceDocument | |
def main(): | |
parser = argparse.ArgumentParser( | |
description="Converts statmake axis labels to DesignSpace 5.0 axis labels" | |
) | |
parser.add_argument("input", help="The source .designspace file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/jenskutilek/status/1548996988892479488 | |
def drawNuts(nuts, matches, nutPositions): | |
for (bi1, bs1), (bi2, bs2) in matches: | |
with savedState(): | |
strokeWidth(0.3 * distX) | |
if nuts[bi1][bs1] == nuts[bi2][bs2]: | |
stroke(0, 1, 0) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/mttymtt/status/1531022994323251202 | |
# DrawBot visualization | |
# FontTools for helper code | |
from fontTools.misc.bezierTools import calcCubicParameters, solveCubic | |
scaleFactor = 500 | |
pt0 = (0, 0) | |
pt1 = (0.37, 0.05) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See this Twitter thread: | |
# https://twitter.com/MauriceMeilleur/status/1488347208709718021 | |
def lerp(v1, v2, t): | |
return v1 + t * (v2 - v1) | |
def lerpPoint(p1, p2, t): | |
return lerp(p1[0], p2[0], t), lerp(p1[1], p2[1], t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://twitter.com/rosettatype/status/1468660017993854980 | |
def plotter_circle_spiral(bez, center, radius, penWidth): | |
H = 0.5522847498 # Bezier circle magic constant | |
radius -= penWidth / 2 | |
numRevolutions = ceil(radius / penWidth + 1) | |
xRadius = yRadius = radius | |
radiusDelta = radius / (numRevolutions - 1) | |
cx, cy = center | |
bez.moveTo((cx + radius, cy)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by: | |
# https://www.instagram.com/p/_hZD9hn9Xn/ | |
def square(x, y, size, phase): | |
turns = phase // 2 | |
q = (phase % 2) / 2 | |
with savedState(): | |
translate(x, y) | |
scale(size) | |
rotate(-90 * turns, center=(0.5, 0.5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on a work by Herbert W. Kapitzki | |
# https://twitter.com/Lett_Arc/status/1369712193063780352 | |
# from fontTools.misc.vector import Vector | |
from fontTools.misc.arrayTools import Vector | |
def pairs(iterable): | |
it = iter(iterable) | |
first = next(it) |
NewerOlder