Skip to content

Instantly share code, notes, and snippets.

@BjoernSchilberg
Created May 18, 2026 07:29
Show Gist options
  • Select an option

  • Save BjoernSchilberg/731b7dbc6300136e1df75dc71ae8cddc to your computer and use it in GitHub Desktop.

Select an option

Save BjoernSchilberg/731b7dbc6300136e1df75dc71ae8cddc to your computer and use it in GitHub Desktop.
Extract individual TTF files from TTC collection
import os
from fontTools.ttLib import TTCollection
ttc_path = '/home/bjoern/.local/share/fonts/Monocraft-nerd-fonts-patched.ttc'
out_dir = '/home/bjoern/.local/share/fonts/'
ttc = TTCollection(ttc_path)
for i, font in enumerate(ttc.fonts):
name_table = font['name']
ps_name = name_table.getName(6, 3, 1, 0x0409)
if ps_name:
ps_name = ps_name.toUnicode()
else:
ps_name = f'Monocraft-{i}'
out_path = os.path.join(out_dir, f'{ps_name}.ttf')
font.save(out_path)
print(f'Saved: {out_path}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment