[arabic-table] Read Blocks.txt and shuffle code around
No functional change.
This commit is contained in:
parent
171f970e4f
commit
3f5327a41e
|
@ -281,7 +281,7 @@ indic-table: gen-indic-table.py IndicSyllabicCategory.txt IndicMatraCategory.txt
|
||||||
mv hb-ot-shape-complex-indic-table.cc.tmp $(srcdir)/hb-ot-shape-complex-indic-table.cc || \
|
mv hb-ot-shape-complex-indic-table.cc.tmp $(srcdir)/hb-ot-shape-complex-indic-table.cc || \
|
||||||
($(RM) hb-ot-shape-complex-indic-table.cc.tmp; false)
|
($(RM) hb-ot-shape-complex-indic-table.cc.tmp; false)
|
||||||
|
|
||||||
arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt
|
arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
|
||||||
$(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-arabic-table.hh.tmp && \
|
$(AM_V_GEN) $(builddir)/$^ > hb-ot-shape-complex-arabic-table.hh.tmp && \
|
||||||
mv hb-ot-shape-complex-arabic-table.hh.tmp $(srcdir)/hb-ot-shape-complex-arabic-table.hh || \
|
mv hb-ot-shape-complex-arabic-table.hh.tmp $(srcdir)/hb-ot-shape-complex-arabic-table.hh || \
|
||||||
($(RM) hb-ot-shape-complex-arabic-table.hh.tmp; false)
|
($(RM) hb-ot-shape-complex-arabic-table.hh.tmp; false)
|
||||||
|
|
|
@ -3,34 +3,48 @@
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
if len (sys.argv) != 3:
|
if len (sys.argv) != 4:
|
||||||
print >>sys.stderr, "usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt"
|
print >>sys.stderr, "usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt"
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
|
|
||||||
files = [file (x) for x in sys.argv[1:]]
|
files = [file (x) for x in sys.argv[1:]]
|
||||||
|
|
||||||
headers = [[files[0].readline (), files[0].readline ()]]
|
headers = [[files[0].readline (), files[0].readline ()], [files[2].readline (), files[2].readline ()]]
|
||||||
headers.append (["UnicodeData.txt does not have a header."])
|
headers.append (["UnicodeData.txt does not have a header."])
|
||||||
while files[0].readline ().find ('##################') < 0:
|
while files[0].readline ().find ('##################') < 0:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
blocks = {}
|
||||||
|
def read_blocks(f):
|
||||||
|
global blocks
|
||||||
|
for line in f:
|
||||||
|
|
||||||
|
j = line.find ('#')
|
||||||
|
if j >= 0:
|
||||||
|
line = line[:j]
|
||||||
|
|
||||||
|
fields = [x.strip () for x in line.split (';')]
|
||||||
|
if len (fields) == 1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
uu = fields[0].split ('..')
|
||||||
|
start = int (uu[0], 16)
|
||||||
|
if len (uu) == 1:
|
||||||
|
end = start
|
||||||
|
else:
|
||||||
|
end = int (uu[1], 16)
|
||||||
|
|
||||||
|
t = fields[1]
|
||||||
|
|
||||||
|
for u in range (start, end + 1):
|
||||||
|
blocks[u] = t
|
||||||
|
|
||||||
def print_joining_table(f):
|
def print_joining_table(f):
|
||||||
|
|
||||||
print
|
values = {}
|
||||||
print "static const uint8_t joining_table[] ="
|
|
||||||
print "{"
|
|
||||||
|
|
||||||
min_u = 0x110000
|
|
||||||
max_u = 0
|
|
||||||
num = 0
|
|
||||||
last = -1
|
|
||||||
block = ''
|
|
||||||
for line in f:
|
for line in f:
|
||||||
|
|
||||||
if line[0] == '#':
|
if line[0] == '#':
|
||||||
if line.find (" characters"):
|
|
||||||
block = line[2:].strip ()
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fields = [x.strip () for x in line.split (';')]
|
fields = [x.strip () for x in line.split (';')]
|
||||||
|
@ -40,30 +54,29 @@ def print_joining_table(f):
|
||||||
u = int (fields[0], 16)
|
u = int (fields[0], 16)
|
||||||
if u == 0x200C or u == 0x200D:
|
if u == 0x200C or u == 0x200D:
|
||||||
continue
|
continue
|
||||||
if u < last:
|
|
||||||
raise Exception ("Input data character not sorted", u)
|
|
||||||
min_u = min (min_u, u)
|
|
||||||
max_u = max (max_u, u)
|
|
||||||
num += 1
|
|
||||||
|
|
||||||
if block:
|
|
||||||
print "\n /* %s */\n" % block
|
|
||||||
block = ''
|
|
||||||
|
|
||||||
if last != -1:
|
|
||||||
last += 1
|
|
||||||
while last < u:
|
|
||||||
print " JOINING_TYPE_X, /* %04X */" % last
|
|
||||||
last += 1
|
|
||||||
else:
|
|
||||||
last = u
|
|
||||||
|
|
||||||
if fields[3] in ["ALAPH", "DALATH RISH"]:
|
if fields[3] in ["ALAPH", "DALATH RISH"]:
|
||||||
value = "JOINING_GROUP_" + fields[3].replace(' ', '_')
|
value = "JOINING_GROUP_" + fields[3].replace(' ', '_')
|
||||||
else:
|
else:
|
||||||
value = "JOINING_TYPE_" + fields[2]
|
value = "JOINING_TYPE_" + fields[2]
|
||||||
print " %s, /* %s */" % (value, '; '.join(fields))
|
values[u] = (value, fields)
|
||||||
|
|
||||||
|
keys = values.keys()
|
||||||
|
min_u = min(keys)
|
||||||
|
max_u = max(keys)
|
||||||
|
num = len(values)
|
||||||
|
print
|
||||||
|
print "static const uint8_t joining_table[] ="
|
||||||
|
print "{"
|
||||||
|
last_block = None
|
||||||
|
for u in range(min_u, max_u+1):
|
||||||
|
value,fields = values.get(u, ("JOINING_TYPE_X", ["%04X"%u]))
|
||||||
|
block = blocks.get(u, last_block)
|
||||||
|
if block != last_block:
|
||||||
|
print "\n /* %s */\n" % block
|
||||||
|
last_block = block
|
||||||
|
|
||||||
|
print " %s, /* %s */" % (value, '; '.join(fields))
|
||||||
print
|
print
|
||||||
print "};"
|
print "};"
|
||||||
print
|
print
|
||||||
|
@ -174,7 +187,7 @@ print "/* == Start of generated table == */"
|
||||||
print "/*"
|
print "/*"
|
||||||
print " * The following table is generated by running:"
|
print " * The following table is generated by running:"
|
||||||
print " *"
|
print " *"
|
||||||
print " * ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt"
|
print " * ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt"
|
||||||
print " *"
|
print " *"
|
||||||
print " * on files with these headers:"
|
print " * on files with these headers:"
|
||||||
print " *"
|
print " *"
|
||||||
|
@ -187,6 +200,7 @@ print "#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH"
|
||||||
print "#define HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH"
|
print "#define HB_OT_SHAPE_COMPLEX_ARABIC_TABLE_HH"
|
||||||
print
|
print
|
||||||
|
|
||||||
|
read_blocks (files[2])
|
||||||
print_joining_table (files[0])
|
print_joining_table (files[0])
|
||||||
print_shaping_table (files[1])
|
print_shaping_table (files[1])
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
/*
|
/*
|
||||||
* The following table is generated by running:
|
* The following table is generated by running:
|
||||||
*
|
*
|
||||||
* ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt
|
* ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
|
||||||
*
|
*
|
||||||
* on files with these headers:
|
* on files with these headers:
|
||||||
*
|
*
|
||||||
* # ArabicShaping-6.2.0.txt
|
* # ArabicShaping-6.2.0.txt
|
||||||
* # Date: 2012-05-15, 21:05:00 GMT [KW]
|
* # Date: 2012-05-15, 21:05:00 GMT [KW]
|
||||||
|
* # Blocks-6.2.0.txt
|
||||||
|
* # Date: 2012-05-14, 22:42:00 GMT [KW, LI]
|
||||||
* UnicodeData.txt does not have a header.
|
* UnicodeData.txt does not have a header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,7 +20,7 @@
|
||||||
static const uint8_t joining_table[] =
|
static const uint8_t joining_table[] =
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Arabic Characters */
|
/* Arabic */
|
||||||
|
|
||||||
JOINING_TYPE_U, /* 0600; ARABIC NUMBER SIGN; U; No_Joining_Group */
|
JOINING_TYPE_U, /* 0600; ARABIC NUMBER SIGN; U; No_Joining_Group */
|
||||||
JOINING_TYPE_U, /* 0601; ARABIC SIGN SANAH; U; No_Joining_Group */
|
JOINING_TYPE_U, /* 0601; ARABIC SIGN SANAH; U; No_Joining_Group */
|
||||||
|
@ -277,7 +279,7 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_X, /* 06FE */
|
JOINING_TYPE_X, /* 06FE */
|
||||||
JOINING_TYPE_D, /* 06FF; KNOTTED HEH WITH INVERTED V ABOVE; D; KNOTTED HEH */
|
JOINING_TYPE_D, /* 06FF; KNOTTED HEH WITH INVERTED V ABOVE; D; KNOTTED HEH */
|
||||||
|
|
||||||
/* Syriac Characters */
|
/* Syriac */
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 0700 */
|
JOINING_TYPE_X, /* 0700 */
|
||||||
JOINING_TYPE_X, /* 0701 */
|
JOINING_TYPE_X, /* 0701 */
|
||||||
|
@ -360,7 +362,7 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_D, /* 074E; SOGDIAN KHAPH; D; KHAPH */
|
JOINING_TYPE_D, /* 074E; SOGDIAN KHAPH; D; KHAPH */
|
||||||
JOINING_TYPE_D, /* 074F; SOGDIAN FE; D; FE */
|
JOINING_TYPE_D, /* 074F; SOGDIAN FE; D; FE */
|
||||||
|
|
||||||
/* Arabic Supplement Characters */
|
/* Arabic Supplement */
|
||||||
|
|
||||||
JOINING_TYPE_D, /* 0750; DOTLESS BEH WITH HORIZONTAL 3 DOTS BELOW; D; BEH */
|
JOINING_TYPE_D, /* 0750; DOTLESS BEH WITH HORIZONTAL 3 DOTS BELOW; D; BEH */
|
||||||
JOINING_TYPE_D, /* 0751; BEH WITH 3 DOTS ABOVE; D; BEH */
|
JOINING_TYPE_D, /* 0751; BEH WITH 3 DOTS ABOVE; D; BEH */
|
||||||
|
@ -411,7 +413,7 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_D, /* 077E; SEEN WITH INVERTED V ABOVE; D; SEEN */
|
JOINING_TYPE_D, /* 077E; SEEN WITH INVERTED V ABOVE; D; SEEN */
|
||||||
JOINING_TYPE_D, /* 077F; KAF WITH 2 DOTS ABOVE; D; KAF */
|
JOINING_TYPE_D, /* 077F; KAF WITH 2 DOTS ABOVE; D; KAF */
|
||||||
|
|
||||||
/* N'Ko Characters */
|
/* Thaana */
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 0780 */
|
JOINING_TYPE_X, /* 0780 */
|
||||||
JOINING_TYPE_X, /* 0781 */
|
JOINING_TYPE_X, /* 0781 */
|
||||||
|
@ -477,6 +479,9 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_X, /* 07BD */
|
JOINING_TYPE_X, /* 07BD */
|
||||||
JOINING_TYPE_X, /* 07BE */
|
JOINING_TYPE_X, /* 07BE */
|
||||||
JOINING_TYPE_X, /* 07BF */
|
JOINING_TYPE_X, /* 07BF */
|
||||||
|
|
||||||
|
/* NKo */
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 07C0 */
|
JOINING_TYPE_X, /* 07C0 */
|
||||||
JOINING_TYPE_X, /* 07C1 */
|
JOINING_TYPE_X, /* 07C1 */
|
||||||
JOINING_TYPE_X, /* 07C2 */
|
JOINING_TYPE_X, /* 07C2 */
|
||||||
|
@ -536,14 +541,14 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_X, /* 07F8 */
|
JOINING_TYPE_X, /* 07F8 */
|
||||||
JOINING_TYPE_X, /* 07F9 */
|
JOINING_TYPE_X, /* 07F9 */
|
||||||
JOINING_TYPE_C, /* 07FA; NKO LAJANYALAN; C; No_Joining_Group */
|
JOINING_TYPE_C, /* 07FA; NKO LAJANYALAN; C; No_Joining_Group */
|
||||||
|
|
||||||
/* Mandaic Characters */
|
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 07FB */
|
JOINING_TYPE_X, /* 07FB */
|
||||||
JOINING_TYPE_X, /* 07FC */
|
JOINING_TYPE_X, /* 07FC */
|
||||||
JOINING_TYPE_X, /* 07FD */
|
JOINING_TYPE_X, /* 07FD */
|
||||||
JOINING_TYPE_X, /* 07FE */
|
JOINING_TYPE_X, /* 07FE */
|
||||||
JOINING_TYPE_X, /* 07FF */
|
JOINING_TYPE_X, /* 07FF */
|
||||||
|
|
||||||
|
/* Samaritan */
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 0800 */
|
JOINING_TYPE_X, /* 0800 */
|
||||||
JOINING_TYPE_X, /* 0801 */
|
JOINING_TYPE_X, /* 0801 */
|
||||||
JOINING_TYPE_X, /* 0802 */
|
JOINING_TYPE_X, /* 0802 */
|
||||||
|
@ -608,6 +613,9 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_X, /* 083D */
|
JOINING_TYPE_X, /* 083D */
|
||||||
JOINING_TYPE_X, /* 083E */
|
JOINING_TYPE_X, /* 083E */
|
||||||
JOINING_TYPE_X, /* 083F */
|
JOINING_TYPE_X, /* 083F */
|
||||||
|
|
||||||
|
/* Mandaic */
|
||||||
|
|
||||||
JOINING_TYPE_R, /* 0840; MANDAIC HALQA; R; No_Joining_Group */
|
JOINING_TYPE_R, /* 0840; MANDAIC HALQA; R; No_Joining_Group */
|
||||||
JOINING_TYPE_D, /* 0841; MANDAIC AB; D; No_Joining_Group */
|
JOINING_TYPE_D, /* 0841; MANDAIC AB; D; No_Joining_Group */
|
||||||
JOINING_TYPE_D, /* 0842; MANDAIC AG; D; No_Joining_Group */
|
JOINING_TYPE_D, /* 0842; MANDAIC AG; D; No_Joining_Group */
|
||||||
|
@ -633,9 +641,6 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_U, /* 0856; MANDAIC DUSHENNA; U; No_Joining_Group */
|
JOINING_TYPE_U, /* 0856; MANDAIC DUSHENNA; U; No_Joining_Group */
|
||||||
JOINING_TYPE_U, /* 0857; MANDAIC KAD; U; No_Joining_Group */
|
JOINING_TYPE_U, /* 0857; MANDAIC KAD; U; No_Joining_Group */
|
||||||
JOINING_TYPE_U, /* 0858; MANDAIC AIN; U; No_Joining_Group */
|
JOINING_TYPE_U, /* 0858; MANDAIC AIN; U; No_Joining_Group */
|
||||||
|
|
||||||
/* Arabic Extended-A Characters */
|
|
||||||
|
|
||||||
JOINING_TYPE_X, /* 0859 */
|
JOINING_TYPE_X, /* 0859 */
|
||||||
JOINING_TYPE_X, /* 085A */
|
JOINING_TYPE_X, /* 085A */
|
||||||
JOINING_TYPE_X, /* 085B */
|
JOINING_TYPE_X, /* 085B */
|
||||||
|
@ -707,6 +712,9 @@ static const uint8_t joining_table[] =
|
||||||
JOINING_TYPE_X, /* 089D */
|
JOINING_TYPE_X, /* 089D */
|
||||||
JOINING_TYPE_X, /* 089E */
|
JOINING_TYPE_X, /* 089E */
|
||||||
JOINING_TYPE_X, /* 089F */
|
JOINING_TYPE_X, /* 089F */
|
||||||
|
|
||||||
|
/* Arabic Extended-A */
|
||||||
|
|
||||||
JOINING_TYPE_D, /* 08A0; DOTLESS BEH WITH V BELOW; D; BEH */
|
JOINING_TYPE_D, /* 08A0; DOTLESS BEH WITH V BELOW; D; BEH */
|
||||||
JOINING_TYPE_X, /* 08A1 */
|
JOINING_TYPE_X, /* 08A1 */
|
||||||
JOINING_TYPE_D, /* 08A2; HAH WITH DOT BELOW AND 2 DOTS ABOVE; D; HAH */
|
JOINING_TYPE_D, /* 08A2; HAH WITH DOT BELOW AND 2 DOTS ABOVE; D; HAH */
|
||||||
|
|
Loading…
Reference in New Issue