1
0
mirror of https://github.com/google/fonts.git synced 2024-12-25 17:53:27 +03:00

Prints unicode names for a given nam file

This commit is contained in:
Nyshadh Reddy Rachamallu 2016-02-12 12:36:20 -08:00
parent 375f620797
commit 196332b202

28
tools/unicode_names.py Normal file
View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
import unicodedata
from google.apputils import app
import gflags as flags
FLAGS = flags.FLAGS
flags.DEFINE_string('nam_file', '', 'Location of file containing the codepoints')
def main(_):
with open(FLAGS.nam_file, 'r') as f:
for line in f:
print _ReformatLine(line)
def _ReformatLine(line):
if line.startswith('0x'):
codepoint = int(line[2:6], 16)
out = unichr(codepoint) + ' ' + unicodedata.name(unichr(codepoint), '')
return '0x%04X %s' % (codepoint, out)
else:
return line
if __name__ == '__main__':
app.run()