files = [open (x, encoding='utf-8') for x in sys.argv[1:]]
headers = [[f.readline () for i in range (2)] for f in files]
unicode_data = [{} for _ in files] for i, f in enumerate (files): 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):
unicode_data[i][u] = t
# Merge data into one dict:
defaults = ('Other', 'Not_Applicable', 'No_Block')
combined = {} for i,d in enumerate (unicode_data): for u,v in d.items (): if i == 2andnot u in combined: continue ifnot u in combined:
combined[u] = list (defaults)
combined[u][i] = v
combined = {k:v for k,v in combined.items() if k in ALLOWED_SINGLES or v[2] in ALLOWED_BLOCKS}
# These should resolve to the position of the last part of the split sequence. 'Bottom_And_Right' : 'POST_C', 'Left_And_Right' : 'POST_C', 'Top_And_Bottom' : 'BELOW_C', 'Top_And_Bottom_And_Left' : 'BELOW_C', 'Top_And_Bottom_And_Right' : 'POST_C', 'Top_And_Left' : 'ABOVE_C', 'Top_And_Left_And_Right' : 'POST_C', 'Top_And_Right' : 'POST_C',
# These are the variation-selectors. They only appear in the Myanmar grammar # but are not Myanmar-specific 0xFE00: 'VS', 0xFE01: 'VS', 0xFE02: 'VS', 0xFE03: 'VS', 0xFE04: 'VS', 0xFE05: 'VS', 0xFE06: 'VS', 0xFE07: 'VS', 0xFE08: 'VS', 0xFE09: 'VS', 0xFE0A: 'VS', 0xFE0B: 'VS', 0xFE0C: 'VS', 0xFE0D: 'VS', 0xFE0E: 'VS', 0xFE0F: 'VS',
# These appear in the OT Myanmar spec, but are not Myanmar-specific 0x2015: 'PLACEHOLDER', 0x2022: 'PLACEHOLDER', 0x25FB: 'PLACEHOLDER', 0x25FC: 'PLACEHOLDER', 0x25FD: 'PLACEHOLDER', 0x25FE: 'PLACEHOLDER',
# Indic
0x0930: 'Ra', # Devanagari 0x09B0: 'Ra', # Bengali 0x09F0: 'Ra', # Bengali 0x0A30: 'Ra', # Gurmukhi No Reph 0x0AB0: 'Ra', # Gujarati 0x0B30: 'Ra', # Oriya 0x0BB0: 'Ra', # Tamil No Reph 0x0C30: 'Ra', # Telugu Reph formed only with ZWJ 0x0CB0: 'Ra', # Kannada 0x0D30: 'Ra', # Malayalam No Reph, Logical Repha
# The following act more like the Bindus. 0x0953: 'SM', 0x0954: 'SM',
# U+0A40 GURMUKHI VOWEL SIGN II may be preceded by U+0A02 GURMUKHI SIGN BINDI. 0x0A40: 'MPst',
# The following act like consonants. 0x0A72: 'C', 0x0A73: 'C',
# TODO: The following should only be allowed after a Visarga. # For now, just treat them like regular tone marks. 0x1CE2: 'A', 0x1CE3: 'A', 0x1CE4: 'A', 0x1CE5: 'A', 0x1CE6: 'A', 0x1CE7: 'A', 0x1CE8: 'A',
# TODO: The following should only be allowed after some of # the nasalization marks, maybe only for U+1CE9..U+1CF1. # For now, just treat them like tone marks. 0x1CED: 'A',
# The following take marks in standalone clusters, similar to Avagraha. 0xA8F2: 'Symbol', 0xA8F3: 'Symbol', 0xA8F4: 'Symbol', 0xA8F5: 'Symbol', 0xA8F6: 'Symbol', 0xA8F7: 'Symbol', 0x1CE9: 'Symbol', 0x1CEA: 'Symbol', 0x1CEB: 'Symbol', 0x1CEC: 'Symbol', 0x1CEE: 'Symbol', 0x1CEF: 'Symbol', 0x1CF0: 'Symbol', 0x1CF1: 'Symbol',
# According to ScriptExtensions.txt, these Grantha marks may also be used in Tamil, # so the Indic shaper needs to know their categories. 0x11301: 'SM', 0x11302: 'SM', 0x11303: 'SM', 0x1133B: 'N', 0x1133C: 'N',
for k,new_cat in category_overrides.items():
(cat, pos, _) = indic_data.get(k, defaults)
indic_data[k] = (new_cat, pos, unicode_data[2][k])
# We only expect position for certain types
positioned_categories = ('CM', 'SM', 'RS', 'H', 'M', 'MPst') for k, (cat, pos, block) in indic_data.items(): if cat notin positioned_categories:
pos = 'END'
indic_data[k] = (cat, pos, block)
# Position overrides are more complicated
# Keep in sync with CONSONANT_FLAGS in the shaper
consonant_categories = ('C', 'CS', 'Ra','CM', 'V', 'PLACEHOLDER', 'DOTTEDCIRCLE')
matra_categories = ('M', 'MPst')
smvd_categories = ('SM', 'SMPst', 'VD', 'A', 'Symbol') for k, (cat, pos, block) in indic_data.items(): if cat in consonant_categories:
pos = 'BASE_C' elif cat in matra_categories: if block.startswith('Khmer') or block.startswith('Myanmar'):
cat = position_to_category(pos) else:
pos = indic_matra_position(k, pos, block) elif cat in smvd_categories:
pos = 'SMVD';
indic_data[k] = (cat, pos, block)
for k,new_pos in position_overrides.items():
(cat, pos, _) = indic_data.get(k, defaults)
indic_data[k] = (cat, new_pos, unicode_data[2][k])
values = [{_: 1} for _ in defaults] for vv in indic_data.values(): for i,v in enumerate(vv):
values[i][v] = values[i].get (v, 0) + 1
# Move the outliers NO-BREAK SPACE and DOTTED CIRCLE out
singles = {} for u in ALLOWED_SINGLES:
singles[u] = indic_data[u] del indic_data[u]
print ("/* == Start of generated table == */")
print ("/*")
print (" * The following table is generated by running:")
print (" *")
print (" * ./gen-indic-table.py %sIndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt" %
("--rust "if language.name == "rust"else""))
print (" *")
print (" * on files with these headers:")
print (" *") for h in headers: for l in h:
print (" * %s" % (l.strip()))
print (" */")
print () if language.name == "c":
print ('#include "hb.hh"')
print ()
print ('#ifndef HB_NO_OT_SHAPE')
print ()
print ('#include "hb-ot-shaper-indic.hh"')
print ()
print ('#pragma GCC diagnostic push')
print ('#pragma GCC diagnostic ignored "-Wunused-macros"')
print ()
# Add some of the values, to make them more readable, and to avoid duplicates
for i in range (2): for v,s in short[i].items ():
all_shorts[i][s] = v
what = ["OT", "POS"]
what_short = ["_OT", "_POS"]
cat_defs = [] for i in range (2):
vv = sorted (values[i].keys ()) for v in vv:
v_no_and = v.replace ('_And_', '_') if v in short[i]:
s = short[i][v] else:
s = ''.join ([c for c in v_no_and if ord ('A') <= ord (c) <= ord ('Z')]) if s in all_shorts[i]: raise Exception ("Duplicate short value alias", v, all_shorts[i][s])
all_shorts[i][s] = v
short[i][v] = s
cat_defs.append ((what_short[i] + '_' + s, what[i] + '_' + (v.upper () if i else v), 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]]: if language.name == "c":
print ("#define %s %s /* %s chars; %s */" %
(c[0].ljust (maxlen_s), c[1].ljust (maxlen_l), c[2].rjust (maxlen_n), c[3])) else:
print ("use %s as %s /* %s chars; %s */" %
(c[1].ljust (maxlen_s), (c[0] + ";").ljust (maxlen_l), c[2].rjust (maxlen_n), c[3]))
print () if language.name == "c":
print ('#pragma GCC diagnostic pop')
print ()
print ("#define INDIC_COMBINE_CATEGORIES(S,M) ((S) | ((M) << 8))")
print ()
print ("#define _(S,M) INDIC_COMBINE_CATEGORIES (%s_##S, %s_##M)" % tuple(what_short))
print ()
print () else:
print ("const fn indic_combine_categories (s: u8, m: u8) -> u16")
print ("{")
print (" (s as u16) | ((m as u16) << 8)")
print ("}")
print ()
print ()
if language.name == "c":
default_value = "_(%s,%s)" % (short[0][defaults[0]], short[1][defaults[1]])
pack_data = {
u: "_(%s,%s)" % (short[0][d[0]], short[1][d[1]]) for u, d in indic_data.items ()
}
pack_data.update ({
u: "_(%s,%s)" % (short[0][d[0]], short[1][d[1]]) for u, d in singles.items ()
}) else:
default_value = "indic_combine_categories(_OT_%s, _POS_%s)" % (short[0][defaults[0]], short[1][defaults[1]])
pack_data = {
u: "indic_combine_categories(_OT_%s, _POS_%s)" % (short[0][d[0]], short[1][d[1]]) for u, d in indic_data.items ()
}
pack_data.update ({
u: "indic_combine_categories(_OT_%s, _POS_%s)" % (short[0][d[0]], short[1][d[1]]) for u, d in singles.items ()
})
unique_values = sorted (set (pack_data.values ()) | {default_value})
mapping = {v: i for i, v in enumerate (unique_values)}
code = packTab.Code ('_hb_indic')
value_type = 'uint16_t'if language.name == "c"else language.type_name ("u16")
indic_values, _ = code.addArray (value_type, 'values', unique_values)
sol = packTab.pack_table (pack_data, default=default_value, mapping=mapping, compression=9)
sol.genCode (code, 'get_categories_index', language=language, private=language.name == "c")
code.print_code (language=language, private=language.name == "c")
print () if language.name == "c":
print ("uint16_t")
print ("hb_indic_get_categories (hb_codepoint_t u)")
print ("{")
print (" return %s[_hb_indic_get_categories_index (u)];" % indic_values)
print ("}")
print ()
print ("#undef _")
print ("#undef INDIC_COMBINE_CATEGORIES") for i in range (2):
print ()
vv = sorted (values[i].keys ()) for v in vv:
print ("#undef %s_%s" %
(what_short[i], short[i][v]))
print ()
print ('#endif') else:
print ("#[inline]")
print ("pub(crate) fn get_categories (u: u32) -> (u8, u8)")
print ("{")
print (" let v = %s[_hb_indic_get_categories_index (u as usize) as usize];" % indic_values)
print (" ((v & 0xFF) as u8, (v >> 8) as u8)")
print ("}")
print ()
print ("/* == End of generated table == */")
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.22 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.