Skip to content

Instantly share code, notes, and snippets.

@simonsj
Created July 12, 2022 01:20
Show Gist options
  • Save simonsj/75975d9838b6ce76fbaa115f62f27db0 to your computer and use it in GitHub Desktop.
Save simonsj/75975d9838b6ce76fbaa115f62f27db0 to your computer and use it in GitHub Desktop.
extract-ttf-from-ttc.py
#!/usr/bin/env python3
#
# extract-ttf-from-ttc.py <input.ttc>
#
# Extract individual .ttf files from a .ttc.
#
from fontTools.ttLib import TTCollection
import sys
file = sys.argv[1]
collection = TTCollection(file)
for i, font in enumerate(collection.fonts):
print(f"collection.fonts[{i}]: {font}")
print(f"font[\"name\"]: {font['name']}")
font.save(f"./{i}.ttf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment