From c1d972acbe314fe0d10091c3c1bdb4ba92a14900 Mon Sep 17 00:00:00 2001 From: handa Date: Thu, 26 Feb 2009 05:40:02 +0000 Subject: [PATCH] (glyph_class_table): New variable. (get_class_def_auto): New function. (OTF_drive_gdef): If a font doesn't have a GDEF table, use get_class_def_auto. --- src/otfdrive.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/otfdrive.c b/src/otfdrive.c index 763d847..7a41174 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -1429,6 +1429,71 @@ check_cmap_uvs (OTF_cmap *cmap, OTF_GlyphString *gstring, int idx) +/* GDEF */ +/* Table of GlyphClass and MarkAttackClass. + + For the Nth element CHAR, CHAR and the succeeding characters + (before CHAR of the next element) has GlyphClass C (= (N % 2) ? 3 : 1). + + This table is generated from the General Category (GC) property of + characters defined in the Unicode Character Database. */ + +static int glyph_class_table[] = + { 0x00000, 0x00300, 0x00370, 0x00483, 0x00487, 0x00488, 0x0048A, 0x00591, + 0x005BE, 0x005BF, 0x005C0, 0x005C1, 0x005C3, 0x005C4, 0x005C6, 0x005C7, + 0x005C8, 0x00610, 0x00616, 0x0064B, 0x0065F, 0x00670, 0x00671, 0x006D6, + 0x006DD, 0x006DE, 0x006E5, 0x006E7, 0x006E9, 0x006EA, 0x006EE, 0x00711, + 0x00712, 0x00730, 0x0074B, 0x007A6, 0x007B1, 0x007EB, 0x007F4, 0x00901, + 0x00904, 0x0093C, 0x0093D, 0x0093E, 0x0094E, 0x00951, 0x00955, 0x00962, + 0x00964, 0x00981, 0x00984, 0x009BC, 0x009BD, 0x009BE, 0x009C5, 0x009C7, + 0x009CE, 0x009D7, 0x009D8, 0x009E2, 0x009E4, 0x00A01, 0x00A04, 0x00A3C, + 0x00A3D, 0x00A3E, 0x00A4E, 0x00A70, 0x00A72, 0x00A81, 0x00A84, 0x00ABC, + 0x00ABD, 0x00ABE, 0x00ACE, 0x00AE2, 0x00AE4, 0x00B01, 0x00B04, 0x00B3C, + 0x00B3D, 0x00B3E, 0x00B44, 0x00B47, 0x00B58, 0x00B82, 0x00B83, 0x00BBE, + 0x00BCE, 0x00BD7, 0x00BD8, 0x00C01, 0x00C04, 0x00C3E, 0x00C45, 0x00C46, + 0x00C57, 0x00C82, 0x00C84, 0x00CBC, 0x00CBD, 0x00CBE, 0x00CC5, 0x00CC6, + 0x00CCE, 0x00CD5, 0x00CD7, 0x00CE2, 0x00CE4, 0x00D02, 0x00D04, 0x00D3E, + 0x00D44, 0x00D46, 0x00D4E, 0x00D57, 0x00D58, 0x00D82, 0x00D84, 0x00DCA, + 0x00DCB, 0x00DCF, 0x00DD7, 0x00DD8, 0x00DF4, 0x00E31, 0x00E32, 0x00E34, + 0x00E3B, 0x00E47, 0x00E4F, 0x00EB1, 0x00EB2, 0x00EB4, 0x00EBD, 0x00EC8, + 0x00ECE, 0x00F18, 0x00F1A, 0x00F35, 0x00F36, 0x00F37, 0x00F38, 0x00F39, + 0x00F3A, 0x00F3E, 0x00F40, 0x00F71, 0x00F85, 0x00F86, 0x00F88, 0x00F90, + 0x00FBD, 0x00FC6, 0x00FC7, 0x0102C, 0x0103A, 0x01056, 0x0105A, 0x0135F, + 0x01360, 0x01712, 0x01715, 0x01732, 0x01735, 0x01752, 0x01754, 0x01772, + 0x01774, 0x017B6, 0x017D4, 0x017DD, 0x017DE, 0x0180B, 0x0180E, 0x018A9, + 0x018AA, 0x01920, 0x0193C, 0x019B0, 0x019C1, 0x019C8, 0x019CA, 0x01A17, + 0x01A1C, 0x01B00, 0x01B05, 0x01B34, 0x01B45, 0x01B6B, 0x01B74, 0x01DC0, + 0x01E00, 0x020D0, 0x020F0, 0x0302A, 0x03030, 0x03099, 0x0309B, 0x0A802, + 0x0A803, 0x0A806, 0x0A807, 0x0A80B, 0x0A80C, 0x0A823, 0x0A828, 0x0FB1E, + 0x0FB1F, 0x0FE00, 0x0FE10, 0x0FE20, 0x0FE24, 0x10A01, 0x10A10, 0x10A38, + 0x10A40, 0x1D165, 0x1D16A, 0x1D16D, 0x1D173, 0x1D17B, 0x1D183, 0x1D185, + 0x1D18C, 0x1D1AA, 0x1D1AE, 0x1D242, 0x1D245, 0xE0100, 0xE01F0 }; + +int get_class_def_auto (int c) +{ + static int table_size + = sizeof glyph_class_table / sizeof glyph_class_table[0]; + int low, high, mid; + + if (c >= glyph_class_table[table_size - 1]) + return 0; + low = 0; + high = table_size - 1; + while (1) + { + mid = (low + high) / 2; + if (c < glyph_class_table[mid]) + high = mid - 1; + else if (c >= glyph_class_table[mid + 1]) + low = mid + 1; + else + break; + } + return ((mid % 2) ? 3 : 1); +} + + + /* API */ #define UVS_P(C) \ @@ -1554,6 +1619,10 @@ OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring) gstring->glyphs[i].GlyphClass = get_class_def (&gdef->glyph_class_def, gstring->glyphs[i].glyph_id); + else + for (i = 0; i < gstring->used; i++) + gstring->glyphs[i].GlyphClass + = get_class_def_auto (gstring->glyphs[i].c); if (gdef->mark_attach_class_def.offset) for (i = 0; i < gstring->used; i++) -- 1.7.10.4