Add a 'fonttools' command-line tool that simply runs modules
ttx is now equivalent to: $ fonttools ttx pyftsubset can be called as: $ fonttools subset varLib can be called as: $ fonttools.varLib Also adds a executable at toplevel called fonttools, such that with "./fonttools ..." one can run stuff without installing. Python seems to automatically include ./Lib into its search path.
This commit is contained in:
parent
a71faf9322
commit
f5bf9b04de
31
Lib/fontTools/__main__.py
Normal file
31
Lib/fontTools/__main__.py
Normal file
@ -0,0 +1,31 @@
|
||||
from __future__ import print_function, division, absolute_import
|
||||
|
||||
def main(args=None):
|
||||
import sys
|
||||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
|
||||
# TODO Add help output, --help, etc.
|
||||
|
||||
# TODO Handle library-wide options. Eg.:
|
||||
# --unicodedata
|
||||
# --verbose / other logging stuff
|
||||
|
||||
# TODO Allow a way to run arbitrary modules? Useful for setting
|
||||
# library-wide options and calling another library. Eg.:
|
||||
#
|
||||
# $ fonttools --unicodedata=... fontmake ...
|
||||
#
|
||||
# This allows for a git-like command where thirdparty commands
|
||||
# can be added. Should we just try importing the fonttools
|
||||
# module first and try without if it fails?
|
||||
|
||||
mod = 'fontTools.'+sys.argv[1]
|
||||
sys.argv[1] = sys.argv[0] + ' ' + sys.argv[1]
|
||||
del sys.argv[0]
|
||||
|
||||
import runpy
|
||||
runpy.run_module(mod, run_name='__main__')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
6
fonttools
Executable file
6
fonttools
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function, division, absolute_import
|
||||
from fontTools.__main__ import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user