From a6eaa0eb29c6871919da16b5ed538f2a657b84da Mon Sep 17 00:00:00 2001 From: Denis Jacquerye Date: Fri, 20 Mar 2015 08:25:08 +0000 Subject: [PATCH] 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'