Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lianghai committed Nov 21, 2014
2 parents 579d662 + 4cf9db7 commit f798fb6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
59 changes: 52 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/python

import argparse, sys, subprocess, os.path
import WriteFeaturesMarkFDK

import itf
from config import (
Expand All @@ -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',
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 10 additions & 6 deletions itf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = []
Expand Down

0 comments on commit f798fb6

Please sign in to comment.