Skip to content

Instantly share code, notes, and snippets.

@argon
Forked from fatum12/ttc2ttf.pe
Created July 16, 2020 17:40
Show Gist options
  • Save argon/538972766145c3edf5b22160d08aecb6 to your computer and use it in GitHub Desktop.
Save argon/538972766145c3edf5b22160d08aecb6 to your computer and use it in GitHub Desktop.
Unpack .ttc and .dfont to .ttf using FontForge
#!/usr/local/bin/fontforge
# Usage: fontforge -script ttc2ttf.pe /path/to/font.ttc
fonts = FontsInFile($1)
n = SizeOf(fonts)
i = 0
while (i < n)
Open($1 + "(" + fonts[i] + ")", 1)
index = ToString(i + 1)
if (i < 9)
index = "0" + index
endif
ext = ".ttf"
if ($order == 3)
ext = ".otf"
endif
filename = $fontname + "-" + index + ext
Generate(filename)
Print(filename)
Close()
++i
endloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment