Skip to content

Instantly share code, notes, and snippets.

@lilydjwg
Last active July 12, 2023 14:27
Show Gist options
  • Save lilydjwg/8877450 to your computer and use it in GitHub Desktop.
Save lilydjwg/8877450 to your computer and use it in GitHub Desktop.
Convert .ttc to several .ttf files into the current directory
#!/usr/bin/env python3
import sys
import fontforge
def main(file):
for font in fontforge.fontsInFile(file):
f = fontforge.open(u'%s(%s)' % (file, font))
f.generate('%s.ttf' % font)
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit('one ttc file one time.')
main(sys.argv[1])
@c02y
Copy link

c02y commented Jan 26, 2021

@lilydjwg Yes, it is "OpenType font collection", actually I already tried Fontforge to convert the ttc to ttf months ago, it was the same result, since the script is using fontforge, so I guess they are the same things.

I already found a better solution: https://github.com/DavidBarts/getfonts and successfully extract the ttc to multiple ttfs, they are working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment