From a6eaa0eb29c6871919da16b5ed538f2a657b84da Mon Sep 17 00:00:00 2001 From: Denis Jacquerye Date: Fri, 20 Mar 2015 08:25:08 +0000 Subject: [PATCH 1/2] Use fonttools to set the ROUND_XY_TO_GRID bit --- sources/setflag.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/sources/setflag.py b/sources/setflag.py index 01de57f..7059102 100644 --- a/sources/setflag.py +++ b/sources/setflag.py @@ -1,27 +1,25 @@ -# This python script finds and replaces the flags="0x0" with flags="0x4" to set the ROUND_XY_TO_GRID bit in a TTX. -# I'm sure this could be done in a much more efficient way, i.e. actually calling fontTools directly instead of dumping and recompiling the GLYF table with TTX -# ... but I don't know how to do that +# This python script finds and replaces the flags="0x0" with flags="0x4" to set the ROUND_XY_TO_GRID bit in a TTF. +import os +import sys +from fontTools.ttLib import TTFont +from fontTools.ttx import makeOutputFileName -# import the modules that we need. (re is for regex) -import os, re, sys - -eachTTX = sys.argv[1] +inputTTF = sys.argv[1] # set the working directory for a shortcut # os.chdir('/Users/weihuang/Google Drive/Type Design/Google/Outputs/Test/Hinting') # open the source file and read it -fh = file(eachTTX, 'r') -subject = fh.read() -fh.close() - -# create the pattern object. Note the "r". In case you're unfamiliar with Python -# this is to set the string as raw so we don't have to escape our escape characters -pattern = re.compile(r' Date: Fri, 20 Mar 2015 08:26:02 +0000 Subject: [PATCH 2/2] No more TTX and use loop --- sources/generatefamily.sh | 40 +++++++++------------------------------ 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/sources/generatefamily.sh b/sources/generatefamily.sh index 72d2e6e..a95f37a 100644 --- a/sources/generatefamily.sh +++ b/sources/generatefamily.sh @@ -1,38 +1,16 @@ for i in *.ttf; do - ttx -t glyf "$i" -done -for i in *.ttx; do python setflag.py "$i" -done -for i in *.ttx; do - name=$(basename "$i" .ttx) - path=$(dirname "$i") - ttx -m "$path/$name.ttf" "$i" - rm "$i" - rm "$path/$name.ttf" - # mv "$path/$name#1.ttf" "$path/$name.ttf" + echo "Set flag for $i" done -ttfautohint -n -w G -x 0 -f latn WorkSans-Hairline#1.ttf WorkSans-Hairline.ttf -echo "WorkSans-Hairline.ttf hinted" -ttfautohint -n -w G -x 0 -f latn WorkSans-Thin#1.ttf WorkSans-Thin.ttf -echo "WorkSans-Thin.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-ExtraLight.ctrl WorkSans-ExtraLight#1.ttf WorkSans-ExtraLight.ttf -echo "WorkSans-ExtraLight.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-Light.ctrl WorkSans-Light#1.ttf WorkSans-Light.ttf -echo "WorkSans-Light.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-Regular.ctrl WorkSans-Regular#1.ttf WorkSans-Regular.ttf -echo "WorkSans-Regular.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-Medium.ctrl WorkSans-Medium#1.ttf WorkSans-Medium.ttf -echo "WorkSans-Medium.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-SemiBold.ctrl WorkSans-SemiBold#1.ttf WorkSans-SemiBold.ttf -echo "WorkSans-SemiBold.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-Bold.ctrl WorkSans-Bold#1.ttf WorkSans-Bold.ttf -echo "WorkSans-Bold.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-ExtraBold.ctrl WorkSans-ExtraBold#1.ttf WorkSans-ExtraBold.ttf -echo "WorkSans-ExtraBold.ttf hinted" -ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-Black.ctrl WorkSans-Black#1.ttf WorkSans-Black.ttf -echo "WorkSans-Black.ttf hinted" +for i in Hairline Thin; do + ttfautohint -n -w G -x 0 -f latn WorkSans-$i#1.ttf WorkSans-$i.ttf + echo "WorkSans-$i.ttf hinted" +done +for i in ExtraLight Light Regular Medium SemiBold Bold ExtraBold Black ; do + ttfautohint -n -w G -x 0 -f latn --control-file=hinting/WorkSans-$i.ctrl WorkSans-$i#1.ttf WorkSans-$i.ttf + echo "WorkSans-$i.ttf hinted" +done for i in *#1.ttf; do rm "$i"