[Indic] Generate a single data table instead of multiple ones

This commit is contained in:
Behdad Esfahbod 2011-06-28 14:03:29 -04:00
parent a346e923a9
commit c4a59de6d8
2 changed files with 48 additions and 44 deletions

View File

@ -148,8 +148,10 @@ uu.sort ()
last = -1
num = 0
total = 0
tables = []
offset = 0
starts = []
ends = []
print "static const INDIC_TABLE_ELEMENT_TYPE indic_table[] = {"
for u in uu:
if u <= last:
continue
@ -162,26 +164,30 @@ for u in uu:
last = start-1
else:
if last >= 0:
print
print "};"
print
print "static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x%04x[] =" % start
print "{",
tables.append (start)
ends.append (last + 1)
offset += ends[-1] - starts[-1]
print
print
print "#define indic_offset_0x%04x %d" % (start, offset)
starts.append (start)
print_block (block, start, end, data)
last = end
ends.append (last + 1)
offset += ends[-1] - starts[-1]
print
print
print "#define indic_offset_total %d" % offset
print
print "};"
print
print
print "static INDIC_TABLE_ELEMENT_TYPE"
print "get_indic_categories (hb_codepoint_t u)"
print "{"
for u in tables:
t = "indic_table_0x%04x" % u
print " if (0x%04X <= u && u <= 0x%04X + ARRAY_LENGTH (%s)) return %s[u - 0x%04X];" % (u, u, t, t, u)
for (start,end) in zip (starts, ends):
offset = "indic_offset_0x%04x" % start
print " if (0x%04X <= u && u <= 0x%04X) return indic_table[u - 0x%04X + %s];" % (start, end, start, offset)
for u,d in singles.items ():
print " if (unlikely (u == 0x%04X)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]])
print " return _(x,x);"

View File

@ -89,8 +89,11 @@ HB_BEGIN_DECLS
#define _(S,M) INDIC_COMBINE_CATEGORIES (ISC_##S, IMC_##M)
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x0900[] =
{
static const INDIC_TABLE_ELEMENT_TYPE indic_table[4080] = {
#define indic_offset_0x0900 0
/* Devanagari (0900..097F) */
@ -377,10 +380,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x0900[] =
/* 1088 */ _(TM,x), _(TM,x), _(TM,x), _(TM,x), _(TM,x), _(TM,x), _(C,x), _(TM,x),
/* 1090 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 1098 */ _(x,x), _(x,x), _(TM,x), _(TM,x), _(M,R), _(M,T), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1700[] =
{
#define indic_offset_0x1700 1952
/* Tagalog (1700..171F) */
@ -428,10 +430,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1700[] =
/* 17E8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 17F0 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 17F8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1900[] =
{
#define indic_offset_0x1900 2208
/* Limbu (1900..194F) */
@ -504,10 +505,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1900[] =
/* 1A98 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 1AA0 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 1AA8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1b00[] =
{
#define indic_offset_0x1b00 2640
/* Balinese (1B00..1B7F) */
@ -562,10 +562,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x1b00[] =
/* 1C38 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 1C40 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 1C48 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(C,x), _(C,x), _(C,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0xa800[] =
{
#define indic_offset_0xa800 2976
/* Syloti Nagri (A800..A82F) */
@ -697,10 +696,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0xa800[] =
/* AAC8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* AAD0 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* AAD8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0xabc0[] =
{
#define indic_offset_0xabc0 3712
/* Meetei Mayek (ABC0..ABFF) */
@ -712,10 +710,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0xabc0[] =
/* ABE8 */ _(M,B), _(M,R), _(M,R), _(x,x), _(TM,x), _(V,B), _(x,x), _(x,x),
/* ABF0 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* ABF8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x10a00[] =
{
#define indic_offset_0x10a00 3776
/* Kharoshthi (10A00..10A5F) */
@ -731,10 +728,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x10a00[] =
/* 10A48 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 10A50 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 10A58 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x11000[] =
{
#define indic_offset_0x11000 3872
/* Brahmi (11000..1107F) */
@ -767,20 +763,22 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table_0x11000[] =
/* 110B8 */ _(M,R), _(V,B), _(N,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 110C0 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
/* 110C8 */ _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x), _(x,x),
};
#define indic_offset_total 4080
};
static INDIC_TABLE_ELEMENT_TYPE
get_indic_categories (hb_codepoint_t u)
{
if (0x0900 <= u && u <= 0x0900 + ARRAY_LENGTH (indic_table_0x0900)) return indic_table_0x0900[u - 0x0900];
if (0x1700 <= u && u <= 0x1700 + ARRAY_LENGTH (indic_table_0x1700)) return indic_table_0x1700[u - 0x1700];
if (0x1900 <= u && u <= 0x1900 + ARRAY_LENGTH (indic_table_0x1900)) return indic_table_0x1900[u - 0x1900];
if (0x1B00 <= u && u <= 0x1B00 + ARRAY_LENGTH (indic_table_0x1b00)) return indic_table_0x1b00[u - 0x1B00];
if (0xA800 <= u && u <= 0xA800 + ARRAY_LENGTH (indic_table_0xa800)) return indic_table_0xa800[u - 0xA800];
if (0xABC0 <= u && u <= 0xABC0 + ARRAY_LENGTH (indic_table_0xabc0)) return indic_table_0xabc0[u - 0xABC0];
if (0x10A00 <= u && u <= 0x10A00 + ARRAY_LENGTH (indic_table_0x10a00)) return indic_table_0x10a00[u - 0x10A00];
if (0x11000 <= u && u <= 0x11000 + ARRAY_LENGTH (indic_table_0x11000)) return indic_table_0x11000[u - 0x11000];
if (0x0900 <= u && u <= 0x10A0) return indic_table[u - 0x0900 + indic_offset_0x0900];
if (0x1700 <= u && u <= 0x1800) return indic_table[u - 0x1700 + indic_offset_0x1700];
if (0x1900 <= u && u <= 0x1AB0) return indic_table[u - 0x1900 + indic_offset_0x1900];
if (0x1B00 <= u && u <= 0x1C50) return indic_table[u - 0x1B00 + indic_offset_0x1b00];
if (0xA800 <= u && u <= 0xAAE0) return indic_table[u - 0xA800 + indic_offset_0xa800];
if (0xABC0 <= u && u <= 0xAC00) return indic_table[u - 0xABC0 + indic_offset_0xabc0];
if (0x10A00 <= u && u <= 0x10A60) return indic_table[u - 0x10A00 + indic_offset_0x10a00];
if (0x11000 <= u && u <= 0x110D0) return indic_table[u - 0x11000 + indic_offset_0x11000];
if (unlikely (u == 0x00A0)) return _(CP,x);
if (unlikely (u == 0x25CC)) return _(CP,x);
return _(x,x);