summaryrefslogtreecommitdiff
path: root/tools/gen-emoji-table.py
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2018-11-20 22:12:47 -0500
committerBehdad Esfahbod <behdad@behdad.org>2018-11-20 22:12:47 -0500
commit32166a14a41c9183e2880459aceb79a6f56273e7 (patch)
treead4b986f6a6782ba0114364c6eb2d7d95739974e /tools/gen-emoji-table.py
parent1305d8905102d327eecb38f3a4d4c55dd4ed9909 (diff)
downloadpango-32166a14a41c9183e2880459aceb79a6f56273e7.tar.gz
[emoji] Shrink the emoji table by merging adjacent ranges
Patch by David Corbett in HarfBuzz.
Diffstat (limited to 'tools/gen-emoji-table.py')
-rwxr-xr-xtools/gen-emoji-table.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/gen-emoji-table.py b/tools/gen-emoji-table.py
index b8018eee..48832913 100755
--- a/tools/gen-emoji-table.py
+++ b/tools/gen-emoji-table.py
@@ -12,7 +12,7 @@ if len (sys.argv) != 2:
f = open(sys.argv[1])
header = [f.readline () for _ in range(10)]
-sets = OrderedDict()
+ranges = OrderedDict()
for line in f.readlines():
line = line.strip()
if not line or line[0] == '#':
@@ -25,9 +25,12 @@ for line in f.readlines():
else:
start = end = rang[0]
- if typ not in sets:
- sets[typ] = set()
- sets[typ].add((start, end))
+ if typ not in ranges:
+ ranges[typ] = []
+ if ranges[typ] and ranges[typ][-1][1] == start - 1:
+ ranges[typ][-1] = (ranges[typ][-1][0], end)
+ else:
+ ranges[typ].append((start, end))
@@ -50,7 +53,7 @@ print("#include <glib.h>")
print()
print("struct Interval {\n gunichar start, end;\n};")
-for typ,s in sets.items():
+for typ,s in ranges.items():
if typ not in ['Emoji',
'Emoji_Presentation',
'Emoji_Modifier',