summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2017-09-25 05:19:39 +0300
committerRasmus Andersson <rasmus@notion.se>2017-09-25 05:19:39 +0300
commitd96bba86f19f2cb212aaad5458e80132c598cecf (patch)
tree74e499aaa893583974495929e336289767f2b0fd /misc
parent958c0a58fd5d9604e71e8ff810129d3052483947 (diff)
downloadinter-d96bba86f19f2cb212aaad5458e80132c598cecf.tar.xz
Improvements to misc/rmglyph.py
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/rmglyph.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/misc/rmglyph.py b/misc/rmglyph.py
index f7b0489c4..3b5c41238 100755
--- a/misc/rmglyph.py
+++ b/misc/rmglyph.py
@@ -13,6 +13,7 @@ import cleanup_kerning
dryRun = False
+BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
def readLines(filename):
@@ -291,6 +292,32 @@ def updateFeaturesFile(filename, rmnames):
return didChange
+def grep(filename, names):
+ hasPrintedFilename = False
+ relFilename = os.path.relpath(os.path.abspath(filename), BASEDIR)
+ findCount = 0
+ with open(filename, 'r') as f:
+ lineno = 1
+ for line in f:
+ foundNames = []
+ for name in names:
+ col = line.find(name)
+ if col != -1:
+ foundNames.append((name, lineno, col, line))
+ findCount += 1
+ if len(foundNames):
+ if not hasPrintedFilename:
+ print('%s:' % relFilename)
+ hasPrintedFilename = True
+ for name, lineno, col, line in foundNames:
+ line = line.strip()
+ if len(line) > 50:
+ line = line[:47] + '...'
+ print(' %s\t%d:%d\t%s' % (name, lineno, col, line))
+ lineno += 1
+ return findCount
+
+
def main(argv=None):
argparser = ArgumentParser(
@@ -320,7 +347,6 @@ def main(argv=None):
args = argparser.parse_args(argv)
global dryRun
dryRun = args.dryRun
- BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
srcDir = os.path.join(BASEDIR, 'src')
# check if src font has modifications
@@ -476,12 +502,35 @@ def main(argv=None):
featuresChanged = updateFeaturesFile(featuresFile, rmnamesUnion)
+ # TMP for testing fuzzy
+ # rmnamesUnion = set()
+ # featuresChanged = False
+ # with open('_local/rmlog') as f:
+ # for line in f:
+ # line = line.strip()
+ # if len(line):
+ # rmnamesUnion.add(line)
+
+
print('\n————————————————————————————————————————————————————\n'+
'Removed %d glyphs:\n %s' % (
len(rmnamesUnion), '\n '.join(sorted(rmnamesUnion))))
print('\n————————————————————————————————————————————————————\n')
+ # find possibly-missed instances
+ print('Fuzzy matches:')
+ fuzzyMatchCount = 0
+ fuzzyMatchCount += grep(diacriticsFile, rmnamesUnion)
+ fuzzyMatchCount += grep(configFilename, rmnamesUnion)
+ fuzzyMatchCount += grep(featuresFile, rmnamesUnion)
+ for fontPath in fontPaths:
+ fuzzyMatchCount += grep(os.path.join(fontPath, 'lib.plist'), rmnamesUnion)
+ if fuzzyMatchCount == 0:
+ print(' (none)\n')
+ else:
+ print('You may want to look into those ^\n')
+
if featuresChanged:
print('You need to manually edit features.\n'+
'- git diff src/features.fea\n'+