From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- gfx/harfbuzz/src/gen-emoji-table.py | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 gfx/harfbuzz/src/gen-emoji-table.py (limited to 'gfx/harfbuzz/src/gen-emoji-table.py') diff --git a/gfx/harfbuzz/src/gen-emoji-table.py b/gfx/harfbuzz/src/gen-emoji-table.py new file mode 100755 index 0000000000..551bc9c7ce --- /dev/null +++ b/gfx/harfbuzz/src/gen-emoji-table.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 + +"""usage: ./gen-emoji-table.py emoji-data.txt + +Input file: +* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt +""" + +import sys +from collections import OrderedDict +import packTab + +if len (sys.argv) != 2: + sys.exit (__doc__) + +f = open(sys.argv[1]) +header = [f.readline () for _ in range(10)] + +ranges = 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 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)) + + + +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 HB_UNICODE_EMOJI_TABLE_HH") +print ("#define HB_UNICODE_EMOJI_TABLE_HH") +print () +print ('#include "hb-unicode.hh"') +print () + +for typ, s in ranges.items(): + if typ != "Extended_Pictographic": continue + + arr = dict() + for start,end in s: + for i in range(start,end): + arr[i] = 1 + + sol = packTab.pack_table(arr, 0, compression=3) + code = packTab.Code('_hb_emoji') + sol.genCode(code, 'is_'+typ) + code.print_c(linkage='static inline') + print() + +print () +print ("#endif /* HB_UNICODE_EMOJI_TABLE_HH */") +print () +print ("/* == End of generated table == */") -- cgit v1.2.3