Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Side by Side Diff: third_party/harfbuzz/contrib/tables/mirroring-parse.py

Issue 164123: Linux: support mirrored charactors (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 import sys
2
3 # http://www.unicode.org/Public/UNIDATA/auxiliary/BidiMirroring.txt
tony 2009/08/07 19:57:06 Nit: Can you add a comment explaining what this do
4
5 def main(infile, outfile):
6 pairs = []
7 for line in infile:
8 line = line[:-1]
9 if len(line) == 0 or line[0] == '#':
10 continue
11 if '#' in line:
12 (data, _) = line.split('#', 1)
13 else:
14 data = line
15 if ';' not in data:
16 continue
17 (a, b) = data.split(';', 1)
18 a = int(a, 16)
19 b = int(b, 16)
20
21 pairs.append((a, b))
22
23 pairs.sort()
24
25 print >>outfile, '// Generated from Unicode Bidi Mirroring tables\n'
26 print >>outfile, '#ifndef MIRRORING_PROPERTY_H_'
27 print >>outfile, '#define MIRRORING_PROPERTY_H_\n'
28 print >>outfile, '#include <stdint.h>'
29 print >>outfile, 'struct mirroring_property {'
30 print >>outfile, ' uint32_t a;'
31 print >>outfile, ' uint32_t b;'
32 print >>outfile, '};\n'
33 print >>outfile, 'static const struct mirroring_property mirroring_properties[ ] = {'
34 for pair in pairs:
35 print >>outfile, ' {0x%x, 0x%x},' % pair
36 print >>outfile, '};\n'
37 print >>outfile, 'static const unsigned mirroring_properties_count = %d;\n' % len(pairs)
38 print >>outfile, '#endif // MIRRORING_PROPERTY_H_'
39
40 if __name__ == '__main__':
41 if len(sys.argv) != 3:
42 print 'Usage: %s <input .txt> <output .h>' % sys.argv[0]
43 else:
44 main(file(sys.argv[1], 'r'), file(sys.argv[2], 'w+'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698