3 from __future__ import print_function, division, absolute_import
6 from collections import OrderedDict
9 if len (sys.argv) != 2:
10 print("usage: ./gen-emoji-table.py emoji-data.txt", file=sys.stderr)
14 header = [f.readline () for _ in range(10)]
16 ranges = OrderedDict()
17 for line in f.readlines():
19 if not line or line[0] == '#':
21 rang, typ = [s.strip() for s in line.split('#')[0].split(';')[:2]]
23 rang = [int(s, 16) for s in rang.split('..')]
31 if ranges[typ] and ranges[typ][-1][1] == start - 1:
32 ranges[typ][-1] = (ranges[typ][-1][0], end)
34 ranges[typ].append((start, end))
38 print ("/* == Start of generated table == */")
40 print (" * The following tables are generated by running:")
42 print (" * ./gen-emoji-table.py emoji-data.txt")
44 print (" * on file with this header:")
47 print (" * %s" % (l.strip()))
50 print ("#ifndef HB_UNICODE_EMOJI_TABLE_HH")
51 print ("#define HB_UNICODE_EMOJI_TABLE_HH")
53 print ('#include "hb-unicode.hh"')
56 for typ, s in ranges.items():
57 if typ != "Extended_Pictographic": continue
61 for i in range(start,end):
64 sol = packTab.pack_table(arr, 0, compression=3)
65 code = packTab.Code('_hb_emoji')
66 sol.genCode(code, 'is_'+typ)
67 code.print_c(linkage='static inline')
71 print ("#endif /* HB_UNICODE_EMOJI_TABLE_HH */")
73 print ("/* == End of generated table == */")