diff --git a/README.md b/README.md index 59bdf7b..eba5566 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,4 @@ This working directory is forked from the common code base, [ITF Base Devanagari ## Dependencies - [Adobe Font Development Kit for OpenType](http://www.adobe.com/devnet/opentype/afdko.html) (AFDKO), version 2.5 build 63209 (Sep 18 2014) or newer. -- Extra Python [scripts](https://github.com/adobe-type-tools/python-scripts) and [modules](https://github.com/adobe-type-tools/python-modules) for AFDKO, to be placed in the directory `FDK/Tools/osx`. +- A script [`UFOInstanceGenerator.py`](https://github.com/adobe-type-tools/python-scripts/blob/master/FDK%20Extras/UFOInstanceGenerator.py) (to be placed in AFDKO’s directory `FDK/Tools/osx`) and two [modules](https://github.com/adobe-type-tools/python-modules) (to be placed in Python’s `site-packages` directory) from Adobe. diff --git a/build.py b/build.py index 40995ce..660ed0c 100644 --- a/build.py +++ b/build.py @@ -1,6 +1,7 @@ #!/usr/bin/python import argparse, sys, subprocess, os.path +import WriteFeaturesMarkFDK import itf from config import ( @@ -25,8 +26,8 @@ help='reset style/instance directories' ) procedures.add_argument( - '-i', '--interpolate', action='store_true', - help='interpolate instances' + '-i', '--instance', action='store_true', + help='generate instances' ) procedures.add_argument( '-m', '--match', action='store_true', @@ -36,6 +37,10 @@ '-c', '--compile', action='store_true', help='compile OTFs' ) +procedures.add_argument( + '--nointerpolate', action='store_true', + help='do not interpolate the masters' +) if len(sys.argv) == 1: parser.print_help() @@ -75,13 +80,53 @@ print '#ITF: Done.\n' -if args.interpolate: +if args.instance: + + masters = [ + i for i in [ + itf.get_font('masters', suffix) for suffix in ['_0', '_1'] + ] if i + ] + + if args.nointerpolate: + + for font, style_name in zip(masters, STYLE_NAMES): + + print "\n#ITF: %s" % style_name + + style_dir = 'styles/' + style_name + + subprocess.call([ + 'cp', '-fr', font.path, + style_dir + '/font.ufo' + ]) + + if '-mark' in UFOIG_ARGS: + WriteFeaturesMarkFDK.MarkDataClass( + font = itf.get_font(style_dir), + folderPath = style_dir, + trimCasingTags = False, + genMkmkFeature = True if '-mkmk' in UFOIG_ARGS else False, + writeClassesFile = True if '-clas' in UFOIG_ARGS else False, + indianScriptsFormat = True if '-indi' in UFOIG_ARGS else False + ) + + if '-flat' in UFOIG_ARGS: + print "#ITF: Flattening the glyphs..." + subprocess.Popen( + ['checkoutlines', '-e', style_dir + '/font.ufo'], + stderr=subprocess.STDOUT, + stdout=subprocess.PIPE + ).communicate() + print "#ITF: Done." + + else: - itf.fix_Glyphs_UFO_masters() + itf.fix_Glyphs_UFO_masters(masters) - subprocess.call( - ['UFOInstanceGenerator.py', 'masters', '-o', 'styles'] + UFOIG_ARGS - ) + subprocess.call( + ['UFOInstanceGenerator.py', 'masters', '-o', 'styles'] + UFOIG_ARGS + ) if args.match: diff --git a/itf.py b/itf.py index 13340e2..c2dbe31 100644 --- a/itf.py +++ b/itf.py @@ -40,14 +40,18 @@ def get_font(directory, suffix = ''): + font_file_name = '' + for file_name in os.listdir(directory): if file_name.endswith(suffix + ".ufo"): font_file_name = file_name break - - font = robofab.world.OpenFont(directory + '/' + font_file_name) - - return font + if font_file_name: + font = robofab.world.OpenFont(directory + '/' + font_file_name) + return font + else: + print "#ITF: Can't find the font file with suffix `%s`." % suffix + return None def sort_glyphs(glyphs): @@ -136,9 +140,9 @@ def generate_classes(directory, suffix): print "#ITF: Done." -def fix_Glyphs_UFO_masters(): +def fix_Glyphs_UFO_masters(masters): - for font in [get_font('masters', suffix) for suffix in ['_0', '_1']]: + for font in masters: if not font.info.postscriptFamilyBlues: font.info.postscriptFamilyBlues = []