summaryrefslogtreecommitdiff
path: root/tools/gen-vertical-orientation-U-table.py
diff options
context:
space:
mode:
authorONO Yoshio <ohtsuka.yoshio@gmail.com>2018-10-17 17:37:19 +0900
committerONO Yoshio <ohtsuka.yoshio@gmail.com>2018-10-22 23:17:20 +0900
commitd2975902a87d3f4a6ff5806c35686c40af48ae70 (patch)
tree757d4c631a7f315d3e33026b2ecd426378bb56cd /tools/gen-vertical-orientation-U-table.py
parent9f405de60fbcf3cf52e61add5c8691778d6920cd (diff)
downloadpango-d2975902a87d3f4a6ff5806c35686c40af48ae70.tar.gz
Issue #322 - Vertical text doesn't fall back to rotated versions ...
...of horizontal glyphs when necessary Implemented UAX#50 to determine whether characters rotate or not in vertical layout.
Diffstat (limited to 'tools/gen-vertical-orientation-U-table.py')
-rwxr-xr-xtools/gen-vertical-orientation-U-table.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/gen-vertical-orientation-U-table.py b/tools/gen-vertical-orientation-U-table.py
new file mode 100755
index 00000000..4697b319
--- /dev/null
+++ b/tools/gen-vertical-orientation-U-table.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+#coding:utf-8
+import os
+import sys
+
+if len(sys.argv) != 2:
+ print('usage;./' + os.path.basename(__file__) + ' VerticalOrientation.txt')
+ sys.exit(1)
+
+#pick up all data from text
+data = []
+f = open(sys.argv[1], 'r')
+for line in f:
+ line = line.split("#")[0].strip()
+ if len(line) == 0:
+ continue
+
+ coderange, vo = line.split(";")
+ vo = vo.strip()
+
+ codes = coderange.split("..")
+ if len(codes) == 1:
+ st = int(codes[0], 16)
+ ed = st
+ else:
+ st = int(codes[0], 16)
+ ed = int(codes[1], 16)
+
+ data.append([st, ed, vo])
+f.close()
+
+
+#compress all data, replace Tu to U and Tr to R.
+compressed = []
+t = []
+for d in data:
+ if d[2] == 'Tu': d[2] = 'U'
+ if d[2] == 'Tr': d[2] = 'R'
+
+ if t == []:
+ t = d
+ else:
+ if t[2] == d[2] and t[1] + 1 == d[0]:
+ t[1] = d[1]
+ else:
+ compressed.append(t)
+ t = d
+compressed.append(t)
+
+
+#dump vo=U
+for d in compressed:
+ if d[2] == 'U':
+ print('{0x%04X, 0x%04X},' % tuple(d[0:2]))