summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2017-07-31 21:45:16 +0100
committerBehdad Esfahbod <behdad@behdad.org>2017-07-31 23:04:15 +0100
commitf39ad9bab1f327062958b2750bf1f5609a9ee991 (patch)
tree2f4170c32d9101881c86b6d685533a215ab13b6a /tools
parent284d357e3d6e29c1437ca18bab347c1af8330908 (diff)
downloadpango-f39ad9bab1f327062958b2750bf1f5609a9ee991.tar.gz
Add data files and routines for emoji itemization
Ported from Chromium. Not hooked yet.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am1
-rwxr-xr-xtools/gen-emoji-table.py64
2 files changed, 65 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index eb34f31f..83d243f2 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -12,6 +12,7 @@ EXTRA_PROGRAMS = \
EXTRA_DIST= \
gen-color-table.pl \
+ gen-emoji-table.py \
rgb.txt
gen_script_for_lang_SOURCES = gen-script-for-lang.c
diff --git a/tools/gen-emoji-table.py b/tools/gen-emoji-table.py
new file mode 100755
index 00000000..600fe80f
--- /dev/null
+++ b/tools/gen-emoji-table.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+from __future__ import print_function, division, absolute_import
+import sys
+import os.path
+from collections import OrderedDict
+
+if len (sys.argv) != 2:
+ print("usage: ./gen-emoji-table.py emoji-data.txt", file=sys.stderr)
+ sys.exit (1)
+
+f = open(sys.argv[1])
+header = [f.readline () for _ in range(10)]
+
+sets = OrderedDict()
+for line in f.readlines():
+ line = line.strip()
+ if not line or line[0] == '#':
+ continue
+ rang, typ = [s.strip() for s in line.split('#')[0].split(';')[:2]]
+
+ rang = [int(s, 16) for s in rang.split('..')]
+ if len(rang) > 1:
+ start, end = rang
+ else:
+ start = end = rang[0]
+
+ if typ not in sets:
+ sets[typ] = set()
+ sets[typ].add((start, end))
+
+
+
+print("/* == Start of generated table == */")
+print("/*")
+print(" * The following tables are generated by running:")
+print(" *")
+print(" * ./gen-emoji-table.py emoji-data.txt")
+print(" *")
+print(" * on file with this header:")
+print(" *")
+for l in header:
+ print(" * %s" % (l.strip()))
+print(" */")
+print()
+print("#ifndef PANGO_EMOJI_TABLE_H")
+print("#define PANGO_EMOJI_TABLE_H")
+print()
+print("#include <glib.h>")
+print()
+print("struct Interval {\n gunichar start, end;\n};")
+
+for typ,s in sets.items():
+ print()
+ print("static const struct Interval _pango_%s_table[] =" % typ)
+ print("{")
+ for pair in sorted(s):
+ print(" {0x%04X, 0x%04X}," % pair)
+ print("};")
+
+print()
+print("#endif /* PANGO_EMOJI_TABLE_H */")
+print()
+print("/* == End of generated table == */")