Skip to content

Instantly share code, notes, and snippets.

@extesy
Created October 29, 2019 22:48
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 extesy/806b95cdef25b97003ff46de7fa9c416 to your computer and use it in GitHub Desktop.
Save extesy/806b95cdef25b97003ff46de7fa9c416 to your computer and use it in GitHub Desktop.
Schmelvetica - Absurd fonts for an absurd world
from fontTools.ttLib import TTFont
import random
import string
ORIGINAL_FONT_PATH = "path/to/Helvetica.ttc"
GLORIOUS_FONT_PATH = "path/to/Schmelvetica.ttc"
NEW_FONTNAME = b"Schmelvetica"
# Load the font
font = TTFont(ORIGINAL_FONT_PATH, fontNumber=0, lazy=False)
# Rename it
for i, n in enumerate(font["name"].names):
if b"Helvetica" in n.string:
n.string = NEW_FONTNAME
# this should be unique
font["name"].names[3].string = NEW_FONTNAME + b"; 0.001; 2019-10-23"
# Have fun with kerning
for kt in font["kern"].kernTables:
for k in itertools.product(string.ascii_letters, string.ascii_letters):
kt.kernTable[k] = random.randint(-100, 100)
print(k, kt.kernTable[k])
# get wobbly with it
for s in string.ascii_letters:
# Move all points relative to the new base
new_base = (random.randint(-100, 100), random.randint(-100, 100))
print(s, new_base)
for i, c in enumerate(font["glyf"][s].coordinates):
font["glyf"][s].coordinates[i] = (c[0] + new_base[0], c[1] + new_base[1])
# Enjoy your new glorious font!
font.save(GLORIOUS_FONT_PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment