Imported Upstream version 2.6.4
[platform/upstream/harfbuzz.git] / src / gen-indic-table.py
index eedf420..912b1d7 100755 (executable)
@@ -98,6 +98,10 @@ for h in headers:
                print (" * %s" % (l.strip()))
 print (" */")
 print ()
+print ('#include "hb.hh"')
+print ()
+print ('#ifndef HB_NO_OT_SHAPE')
+print ()
 print ('#include "hb-ot-shape-complex-indic.hh"')
 print ()
 
@@ -129,8 +133,8 @@ what = ["INDIC_SYLLABIC_CATEGORY", "INDIC_MATRA_CATEGORY"]
 what_short = ["ISC", "IMC"]
 print ('#pragma GCC diagnostic push')
 print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
+cat_defs = []
 for i in range (2):
-       print ()
        vv = sorted (values[i].keys ())
        for v in vv:
                v_no_and = v.replace ('_And_', '_')
@@ -142,10 +146,17 @@ for i in range (2):
                                raise Exception ("Duplicate short value alias", v, all_shorts[i][s])
                        all_shorts[i][s] = v
                        short[i][v] = s
-               print ("#define %s_%s   %s_%s   %s/* %3d chars; %s */" %
-                       (what_short[i], s, what[i], v.upper (),
-                       '       '* ((48-1 - len (what[i]) - 1 - len (v)) // 8),
-                       values[i][v], v))
+               cat_defs.append ((what_short[i] + '_' + s, what[i] + '_' + v.upper (), str (values[i][v]), v))
+
+maxlen_s = max ([len (c[0]) for c in cat_defs])
+maxlen_l = max ([len (c[1]) for c in cat_defs])
+maxlen_n = max ([len (c[2]) for c in cat_defs])
+for s in what_short:
+       print ()
+       for c in [c for c in cat_defs if s in c[0]]:
+               print ("#define %s %s /* %s chars; %s */" %
+                       (c[0].ljust (maxlen_s), c[1].ljust (maxlen_l), c[2].rjust (maxlen_n), c[3]))
+print ()
 print ('#pragma GCC diagnostic pop')
 print ()
 print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)")
@@ -245,12 +256,14 @@ print ("}")
 print ()
 print ("#undef _")
 for i in range (2):
-       print
+       print ()
        vv = sorted (values[i].keys ())
        for v in vv:
                print ("#undef %s_%s" %
                        (what_short[i], short[i][v]))
 print ()
+print ('#endif')
+print ()
 print ("/* == End of generated table == */")
 
 # Maintain at least 30% occupancy in the table */