Skip to content

Instantly share code, notes, and snippets.

@arrowtype
Created April 17, 2024 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arrowtype/21e194d39621bf0f33d68632559a691b to your computer and use it in GitHub Desktop.
Save arrowtype/21e194d39621bf0f33d68632559a691b to your computer and use it in GitHub Desktop.
A drawbot script used to proof kerns against the letter T
"""
This script requires some edits to be useful. Originally written for proofing Name Sans.
Demoed at https://www.youtube.com/watch?v=3a9KIPi_rTU
MIT License. Go ahead and use it!
Goals:
- Test `T` and `T.ultra` against basic lowercase: `TaTbTcT` etc, across full designspace, and especially around where it swaps to `T.ultra`
- Test `T` and `T.ultra` against relatively common diacritics
Usage:
- Pip Install Drawbot as a Python package
- Run this from the command line
"""
from drawBot import *
import os
import datetime
now = datetime.datetime.now().strftime("%Y_%m_%d-%H_%M")
date = datetime.datetime.now().strftime("%Y-%m-%d")
fontPath = "fonts/ArrowType-NameSans-v011/desktop/AT-NameSansVariable.ttf"
outputDir = "proofs/2023_07_17-drawbot-T-kerns"
filename = "name_sans-T-kerns-proof"
autoOpen = True
pageSize = "Letter"
border = 20
# first, make permutation strings
charsToTestBasic = "abcdefghijklmnopqrstuvwxyz"
charsToTestDiacritics = "onüäáừöéổíóújạcâôëỷưzlāōřêấỉựửèxýõốbàēậěėıšøứăæếìūầòîùỵīkớåĩnǎûmgfịảtłųỳộắőęềpụąờãd"
# charsToTestDiacritics = "horeaiuwysüäáừöéổívŷəóújạcâôëỷưzlāōřêấỉựửèxýõốbàēậěėıšøứăæếìūầòîȟùỵīkớåĩnǎûmgfịŵảtłųỳǝɛɔǜộắőęềpụąờãd"
# charsToTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# charsToTest = "0123456789"
def outputCharsToTest(charsToTest, separator="T"):
return separator + separator.join([c for c in charsToTest]) + separator
print(outputCharsToTest(charsToTestDiacritics))
fontSizes = [24,12]
italSteps = [0, 1]
# opszSteps = [8, 72]
opszSteps = [72]
wghtSteps = [100, 400, 700, 750, 800, 850, 875, 900, 925, 950, 1000]
# wghtSteps = [number for number in range(1,1001) if number % 50 == 0]
# go through permutations of stops
for italVal in italSteps:
for opszVal in opszSteps:
for wghtVal in wghtSteps:
newPage(pageSize)
font("AT Name Mono 230717k", 8)
# header with style info
textBox(f"Name Sans, v0.11 → opsz: {opszVal}, wght {wghtVal}, ital: {italVal} | {date}", (border, height()-border-18, width() - border*2, 24))
# create text
txt = FormattedString(
font=fontPath,
)
# txt.openTypeFeatures(rvrn=False) # DrawBot doesn’t appear to turn off rvrn
# set variable location
txt.fontVariations(ital=italVal, opsz=opszVal, wght=wghtVal)
for fontSizeVal in fontSizes:
txt.fontSize(fontSizeVal)
txt.lineHeight(fontSizeVal*1.5)
# set test string
txt.append(outputCharsToTest(charsToTestBasic))
# turn on simplified y, g, a
txt.openTypeFeatures(ss12=True, ss07=True, ss09=True)
txt.append(outputCharsToTest("yga"))
# test g.text
txt.openTypeFeatures(ss08=True)
txt.append(outputCharsToTest("g"))
txt.append("\n")
txt.openTypeFeatures(ss12=False, ss07=True, ss08=False, ss09=False)
txt.append(outputCharsToTest(charsToTestDiacritics))
txt.append("\n")
txt.append(outputCharsToTest(charsToTestBasic.upper()))
txt.append("\n\n")
# draw text
txt = textBox(txt, (border, border, width() - border*2, height() - border*2 - border))
# while txt:
# newPage(pageSize)
# txt = textBox(txt, (border, border, width() - border*2, height() - border*2))
if not os.path.exists(outputDir):
os.makedirs(outputDir)
saveTo=f"{outputDir}/{filename}-{now}.pdf"
saveImage(saveTo)
if autoOpen:
os.system(f"open -a Preview {saveTo}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment