Created
May 4, 2016 15:39
-
-
Save HinTak/33cdcb8e1558538389cb5e0475674acc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# mono ipy.exe ttc-splitter.py infile outfile | |
# [writes outfile.0,outfile.1, etc for member fonts] | |
# Copyright (c) Hin-Tak Leung | |
# Tips: | |
# "mono ipy.exe -h" to get options. | |
# -X:ColorfulConsole - useful on terminal with a light background | |
# (somehow forground color is hard-coded to white) | |
import clr | |
import sys | |
# IronPython does not have the os module, but it can use CPython's! | |
# NOTE: edit for your CPython's location | |
sys.path.append("/usr/lib64/python2.7/") | |
import os | |
# NOTE: edit "os.getcwd()" to FontVal's top location | |
# relative path does not seem to work. | |
sys.path.append(os.getcwd() + "/bin") | |
clr.AddReference("OTFontFile.dll") | |
from OTFontFile import * | |
from System import Array | |
if __name__ == '__main__': | |
if not sys.argv[1:]: | |
print("Usage: %s infile outfile" % sys.argv[0]) | |
infile = sys.argv[1] | |
outfile = sys.argv[2] | |
f = OTFile() | |
f.open(infile) | |
for i in range(0, f.GetNumFonts()): | |
fn = f.GetFont(i) | |
newout = "%s.%d" % (outfile, i) | |
memfont = Array[OTFont]([fn]) | |
OTFile.WriteFile(newout, memfont) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment