-
-
Save lilydjwg/8877450 to your computer and use it in GitHub Desktop.
#!/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]) |
Thanks, it works here on Manjaro, I only need to install fontforge first.
Sad thing is, it removed a lot of info in the ttc font, such as the font name is empty, font version becomes 1.0, no Copyright, no Designer, no Layout Features.
And most importantly, the name of the font is blank in my Kobo eReader, and it doesn't work at all after I select the font.
@c02y Is your .ttc
file a TrueType font collection or an OpenType font collection? Generating ttf from an OpenType font will result in information loss (and you may try to generate a .otf
instead). The file
command can tell you which type your file is.
@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.
For macOS user, you may need the
brew install fontforge
and use system python2 (/usr/local/bin/python2.7).