3 """usage: ./gen-emoji-table.py emoji-data.txt emoji-test.txt
6 * https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
7 * https://www.unicode.org/Public/emoji/latest/emoji-test.txt
11 from collections
import OrderedDict
14 if len (sys
.argv
) != 3:
18 header
= [f
.readline () for _
in range(10)]
20 ranges
= OrderedDict()
21 for line
in f
.readlines():
23 if not line
or line
[0] == '#':
25 rang
, typ
= [s
.strip() for s
in line
.split('#')[0].split(';')[:2]]
27 rang
= [int(s
, 16) for s
in rang
.split('..')]
35 if ranges
[typ
] and ranges
[typ
][-1][1] == start
- 1:
36 ranges
[typ
][-1] = (ranges
[typ
][-1][0], end
)
38 ranges
[typ
].append((start
, end
))
42 print ("/* == Start of generated table == */")
44 print (" * The following tables are generated by running:")
46 print (" * ./gen-emoji-table.py emoji-data.txt")
48 print (" * on file with this header:")
51 print (" * %s" % (l
.strip()))
54 print ("#ifndef HB_UNICODE_EMOJI_TABLE_HH")
55 print ("#define HB_UNICODE_EMOJI_TABLE_HH")
57 print ('#include "hb-unicode.hh"')
60 for typ
, s
in ranges
.items():
61 if typ
!= "Extended_Pictographic": continue
65 for i
in range(start
, end
+ 1):
68 sol
= packTab
.pack_table(arr
, 0, compression
=9)
69 code
= packTab
.Code('_hb_emoji')
70 sol
.genCode(code
, 'is_'+typ
)
71 code
.print_c(linkage
='static inline')
75 print ("#endif /* HB_UNICODE_EMOJI_TABLE_HH */")
77 print ("/* == End of generated table == */")
82 with
open(sys
.argv
[2]) as f
:
83 for line
in f
.readlines():
85 line
= line
[:line
.index("#")]
87 line
= line
[:line
.index(";")]
89 line
= line
.split(" ")
92 sequences
.append(line
)
94 with
open("../test/shape/data/in-house/tests/emoji-clusters.tests", "w") as f
:
95 for sequence
in sequences
:
96 f
.write("../fonts/AdobeBlank2.ttf;--no-glyph-names --no-positions --font-funcs=ot")
97 f
.write(";" + ",".join(sequence
))
98 f
.write(";[" + "|".join("1=0" for c
in sequence
) + "]\n")