summaryrefslogtreecommitdiff
path: root/misc/glyphcheck.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-09-01 08:21:09 +0300
committerRasmus Andersson <rasmus@notion.se>2018-09-01 08:21:09 +0300
commitca1cb8c942f01b8b70bf344c00d770c4867dfc32 (patch)
treedd4742fe880b1198c431c1a82c0f7c4274a7d04f /misc/glyphcheck.py
parent6688a81405b8c234f6b197f5779533e801911404 (diff)
downloadinter-ca1cb8c942f01b8b70bf344c00d770c4867dfc32.tar.xz
tooling
Diffstat (limited to 'misc/glyphcheck.py')
-rwxr-xr-xmisc/glyphcheck.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/misc/glyphcheck.py b/misc/glyphcheck.py
new file mode 100755
index 000000000..755de686f
--- /dev/null
+++ b/misc/glyphcheck.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# encoding: utf8
+import sys, argparse
+from fontTools import ttLib
+
+
+def main():
+ argparser = argparse.ArgumentParser(description='Check glyph names')
+
+ argparser.add_argument('fontfiles', metavar='<path>', type=str, nargs='+',
+ help='TrueType or OpenType font files')
+
+ args = argparser.parse_args()
+
+ nmissing = 0
+
+ matchnames = set()
+ for line in sys.stdin:
+ line = line.strip()
+ if len(line) > 0 and line[0] != '#':
+ for line2 in line.split():
+ line2 = line2.strip()
+ if len(line2) > 0:
+ matchnames.add(line2)
+
+ for fontfile in args.fontfiles:
+ font = ttLib.TTFont(fontfile)
+ glyphnames = set(font.getGlyphOrder())
+
+ # for name in glyphnames:
+ # if not name in matchnames:
+ # print('%s missing in input' % name)
+
+ for name in matchnames:
+ if not name in glyphnames:
+ print('%s missing in font' % name)
+ nmissing = nmissing + 1
+
+
+ if nmissing == 0:
+ print('all glyphs found')
+
+
+if __name__ == '__main__':
+ main()