3 """Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh
4 Input is a tab separated list of unicode ranges from the otspec
5 (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur).
12 print ("""static OS2Range _hb_os2_unicode_ranges[] =
18 with
open (input_file
, mode
="r", encoding
="utf-8") as f
:
23 line
= f
.readline().strip()
26 fields
= re
.split(r
'\t+', line
)
28 current_bit
= fields
[0]
31 raise Exception("bad input :(.")
34 ranges
= re
.split("-", fields
[1])
36 raise Exception("bad input :(.")
38 v
= tuple((int(ranges
[0], 16), int(ranges
[1], 16), int(current_bit
), name
))
41 all_ranges
= sorted(all_ranges
, key
=lambda t
: t
[0])
43 for ranges
in all_ranges
:
44 start
= ("0x%X" % ranges
[0]).rjust(8)
45 end
= ("0x%X" % ranges
[1]).rjust(8)
46 bit
= ("%s" % ranges
[2]).rjust(3)
48 print (" {%s, %s, %s}, // %s" % (start
, end
, bit
, ranges
[3]))