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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/harfbuzz/contrib/tables/mirroring-parse.py
diff --git a/third_party/harfbuzz/contrib/tables/mirroring-parse.py b/third_party/harfbuzz/contrib/tables/mirroring-parse.py
new file mode 100644
index 0000000000000000000000000000000000000000..04a9431a7187e00163a8466bb2c1ccdd6e0d460b
--- /dev/null
+++ b/third_party/harfbuzz/contrib/tables/mirroring-parse.py
@@ -0,0 +1,44 @@
+import sys
+
+# 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
+
+def main(infile, outfile):
+ pairs = []
+ for line in infile:
+ line = line[:-1]
+ if len(line) == 0 or line[0] == '#':
+ continue
+ if '#' in line:
+ (data, _) = line.split('#', 1)
+ else:
+ data = line
+ if ';' not in data:
+ continue
+ (a, b) = data.split(';', 1)
+ a = int(a, 16)
+ b = int(b, 16)
+
+ pairs.append((a, b))
+
+ pairs.sort()
+
+ print >>outfile, '// Generated from Unicode Bidi Mirroring tables\n'
+ print >>outfile, '#ifndef MIRRORING_PROPERTY_H_'
+ print >>outfile, '#define MIRRORING_PROPERTY_H_\n'
+ print >>outfile, '#include <stdint.h>'
+ print >>outfile, 'struct mirroring_property {'
+ print >>outfile, ' uint32_t a;'
+ print >>outfile, ' uint32_t b;'
+ print >>outfile, '};\n'
+ print >>outfile, 'static const struct mirroring_property mirroring_properties[] = {'
+ for pair in pairs:
+ print >>outfile, ' {0x%x, 0x%x},' % pair
+ print >>outfile, '};\n'
+ print >>outfile, 'static const unsigned mirroring_properties_count = %d;\n' % len(pairs)
+ print >>outfile, '#endif // MIRRORING_PROPERTY_H_'
+
+if __name__ == '__main__':
+ if len(sys.argv) != 3:
+ print 'Usage: %s <input .txt> <output .h>' % sys.argv[0]
+ else:
+ main(file(sys.argv[1], 'r'), file(sys.argv[2], 'w+'))

Powered by Google App Engine
This is Rietveld 408576698