[HarfBuzz] harfbuzz-ng: Branch 'master' - 13 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Jun 28 14:34:29 PDT 2011


 src/gen-indic-table.py                   |   30 
 src/hb-ot-shape-complex-indic-machine.rl |    1 
 src/hb-ot-shape-complex-indic-table.hh   |   62 -
 src/hb-ot-shape-complex-indic.cc         |  211 ++++-
 src/hb-private.hh                        |    1 
 test/Makefile.am                         |   13 
 test/hb-test.h                           |   21 
 test/test-shape-complex.c                | 1154 +++++++++++++++++++++++++++++++
 8 files changed, 1407 insertions(+), 86 deletions(-)

New commits:
commit 253a57fb5ab211f67140e6139d183e49483a9074
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 17:26:03 2011 -0400

    [test-shape-complex] Remove the greek tests
    
    They are outdated with respect to the DejaVu Sans I'm using.
    We need to add font version checking to the tests.

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index 75741fb..2429d07 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -71,21 +71,6 @@ typedef struct
 } test_t;
 
 
-static const test_set_t tests_greek = {
-  {"DejaVuSans.ttf", 0},
-  {
-    { "",
-      { 0x3b1, 0x300, 0x313, 0 },
-      { 0xb8, 0x3d3, 0x3c7, 0 }
-    },
-    { "",
-      { 0x3b1, 0x313, 0x300, 0 },
-      { 0xd4, 0 }
-    },
-    {{0}}
-  }
-};
-
 static const test_set_t tests_devanagari1 = {
   {"raghu.ttf", 0},
   {
@@ -1145,8 +1130,6 @@ main (int argc, char **argv)
 
 #define TEST_SET(name) add_test_set (&tests_##name, #name)
 
-  TEST_SET (greek);
-
   TEST_SET (devanagari1);
   TEST_SET (devanagari2);
   TEST_SET (bengali1);
commit afa74bf90405fb121d3132982b87762c1686d80c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 17:25:17 2011 -0400

    [test-shape-complex] Print out expected and actual glyphstrings upon failure
    
    One has to run the test with --verbose to see that right now.

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index 57fa078..75741fb 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -1044,6 +1044,7 @@ test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
   hb_buffer_t *buffer;
   unsigned int i, len, expected_len;
   hb_glyph_info_t *glyphs;
+  hb_bool_t fail;
 
   g_assert (f->font);
 
@@ -1060,9 +1061,27 @@ test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
   expected_len = len;
 
   glyphs = hb_buffer_get_glyph_infos (buffer, &len);
-  g_assert_cmpint (len, ==, expected_len);
-  for (i = 0; i < len; i++)
-    g_assert_cmpint (glyphs[i].codepoint, ==, data->glyphs[i]);
+  fail = len != expected_len;
+  if (!fail)
+    for (i = 0; i < len; i++)
+      if (glyphs[i].codepoint != data->glyphs[i]) {
+        fail = TRUE;
+	break;
+      }
+
+  if (fail) {
+    GString *str = g_string_new ("");
+    for (i = 0; i < expected_len; i++)
+      g_string_append_printf (str, " %4d", data->glyphs[i]);
+    g_test_message ("Expected glyphs: %s", str->str);
+    g_string_truncate (str, 0);
+    for (i = 0; i < len; i++)
+      g_string_append_printf (str, " %4d", glyphs[i].codepoint);
+    g_test_message ("Received glyphs: %s", str->str);
+    g_string_free (str, TRUE);
+
+    g_test_fail ();
+  }
 
   hb_buffer_destroy (buffer);
 }
commit 42d453b0236f67239342df2003b7abce6e2c51ea
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 16:59:16 2011 -0400

    [test] Name tests after their input string

diff --git a/test/Makefile.am b/test/Makefile.am
index b6642f5..bad1118 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -82,7 +82,7 @@ check-tool-raw:
 # check-gtester: Run tests under gtester
 GTESTER = gtester
 check-gtester:
-	$(AM_V_at)$(MAKE) $(AM_MAKEFLGS) check-tool-raw TOOL="$(GTESTER) --verbose"
+	$(AM_V_at)$(MAKE) $(AM_MAKEFLGS) check-tool-raw TOOL="$(GTESTER) --verbose --keep-going"
 
 
 # Check tests under valgrind.  Saves log to log-valgrind.txt
diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index b944dd9..57fa078 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -44,6 +44,13 @@ typedef struct
   /* TODO add min/max face version */
 } font_data_t;
 
+static char *
+get_font_file (const font_data_t *font_data)
+{
+  return g_strdup_printf ("%s/fonts/%s", srcdir (), font_data->font_file);
+}
+
+
 typedef struct
 {
   char           comments[64];
@@ -54,13 +61,13 @@ typedef struct
 typedef struct
 {
   const font_data_t font_data;
-  const test_data_t tests[];
+  const test_data_t test_datas[];
 } test_set_t;
 
 typedef struct
 {
-  const font_data_t font_data;
-  const test_data_t tests[];
+  const font_data_t *font_data;
+  const test_data_t *test_data;
 } test_t;
 
 
@@ -79,7 +86,7 @@ static const test_set_t tests_greek = {
   }
 };
 
-static const test_set_t tests_devanagari_1 = {
+static const test_set_t tests_devanagari1 = {
   {"raghu.ttf", 0},
   {
     { "Ka",
@@ -134,7 +141,7 @@ static const test_set_t tests_devanagari_1 = {
   }
 };
 
-static const test_set_t tests_devanagari_2 = {
+static const test_set_t tests_devanagari2 = {
   {"mangal.ttf", 0},
   {
     { "Ka",
@@ -189,7 +196,7 @@ static const test_set_t tests_devanagari_2 = {
   }
 };
 
-static const test_set_t tests_bengali_1 = {
+static const test_set_t tests_bengali1 = {
   {"AkaashNormal.ttf", 0},
   {
     { "Ka",
@@ -337,7 +344,7 @@ static const test_set_t tests_bengali_1 = {
   }
 };
 
-static const test_set_t tests_bengali_2 = {
+static const test_set_t tests_bengali2 = {
   {"MuktiNarrow.ttf", 0},
   {
     { "Ka",
@@ -460,7 +467,7 @@ static const test_set_t tests_bengali_2 = {
   }
 };
 
-static const test_set_t tests_bengali_3 = {
+static const test_set_t tests_bengali3 = {
   {"LikhanNormal.ttf", 0},
   {
     { "",
@@ -691,7 +698,7 @@ static const test_set_t tests_telugu = {
   }
 };
 
-static const test_set_t tests_kannada_1 = {
+static const test_set_t tests_kannada1 = {
   {"Sampige.ttf", 0},
   {
     { "",
@@ -738,7 +745,7 @@ static const test_set_t tests_kannada_1 = {
   }
 };
 
-static const test_set_t tests_kannada_2 = {
+static const test_set_t tests_kannada2 = {
   {"tunga.ttf", 0},
   {
     { "",
@@ -773,7 +780,7 @@ static const test_set_t tests_kannada_2 = {
   }
 };
 
-static const test_set_t tests_malayalam_1 = {
+static const test_set_t tests_malayalam1 = {
   {"AkrutiMal2Normal.ttf", 0},
   {
     { "",
@@ -853,7 +860,7 @@ static const test_set_t tests_malayalam_1 = {
   }
 };
 
-static const test_set_t tests_malayalam_2 = {
+static const test_set_t tests_malayalam2 = {
   {"Rachana.ttf", 0},
   {
     { "",
@@ -995,6 +1002,8 @@ static const test_set_t tests_linearb = {
 
 
 
+
+
 typedef struct {
   FT_Library ft_library;
   FT_Face ft_face;
@@ -1004,15 +1013,16 @@ typedef struct {
 static void
 ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
 {
-  const test_set_t *test = user_data;
-  char *font_file = g_strdup_printf ("%s/fonts/%s", srcdir (), test->font_data.font_file);
+  const test_t *test = user_data;
+  char *font_file = get_font_file (test->font_data);
+  FT_Error err;
 
   FT_Init_FreeType (&f->ft_library);
 
-  if (FT_New_Face (f->ft_library, font_file, test->font_data.face_index, &f->ft_face))
-    g_test_message ("Font file %s not found.  Skipping test.", font_file);
-  else
-    f->font = hb_ft_font_create (f->ft_face, NULL);
+  err = FT_New_Face (f->ft_library, font_file, test->font_data->face_index, &f->ft_face);
+  g_assert_cmpint (err, ==, 0);
+
+  f->font = hb_ft_font_create (f->ft_face, NULL);
 
   g_free (font_file);
 }
@@ -1029,45 +1039,83 @@ ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data)
 static void
 test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
 {
-  const test_set_t *test_set = user_data;
-  const test_data_t *data;
-
-  if (!f->font)
-    return; /* Skip test */
+  const test_t *test = user_data;
+  const test_data_t *data = test->test_data;
+  hb_buffer_t *buffer;
+  unsigned int i, len, expected_len;
+  hb_glyph_info_t *glyphs;
 
-  for (data = test_set->tests; data->characters[0]; data++) {
-    hb_buffer_t *buffer;
-    unsigned int i, len, expected_len;
-    hb_glyph_info_t *glyphs;
+  g_assert (f->font);
 
-    if (data->comments[0])
-      g_test_message ("Test comments: %s", data->comments);
+  if (data->comments[0])
+    g_test_message ("Test comments: %s", data->comments);
 
-    buffer =  hb_buffer_create (0);
-    for (len = 0; data->characters[len]; len++) ;
-    hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
+  buffer =  hb_buffer_create (0);
+  for (len = 0; data->characters[len]; len++) ;
+  hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
 
-    hb_shape (f->font, buffer, NULL, 0);
+  hb_shape (f->font, buffer, NULL, 0);
 
-    for (len = 0; data->glyphs[len]; len++) ;
-    expected_len = len;
+  for (len = 0; data->glyphs[len]; len++) ;
+  expected_len = len;
 
-    glyphs = hb_buffer_get_glyph_infos (buffer, &len);
-    g_assert_cmpint (len, ==, expected_len);
-    for (i = 0; i < len; i++)
-      g_assert_cmphex (glyphs[i].codepoint, ==, data->glyphs[i]);
+  glyphs = hb_buffer_get_glyph_infos (buffer, &len);
+  g_assert_cmpint (len, ==, expected_len);
+  for (i = 0; i < len; i++)
+    g_assert_cmpint (glyphs[i].codepoint, ==, data->glyphs[i]);
 
-    hb_buffer_destroy (buffer);
-  }
+  hb_buffer_destroy (buffer);
 }
 
+static void
+test_shape_complex_skipped (gconstpointer user_data)
+{
+  const test_t *test = user_data;
+  const test_data_t *data = test->test_data;
+
+  if (data->comments[0])
+    g_test_message ("Test comments: %s", data->comments);
+
+  g_test_message ("Skipping test");
+}
 
 
 static void
 add_test_set (const test_set_t *test_set, const char *set_name)
 {
+  const test_data_t *data;
+  char *font_file;
+  hb_bool_t skip;
+
+  font_file = get_font_file (&test_set->font_data);
+  skip = !g_file_test (font_file, G_FILE_TEST_EXISTS);
+  g_free (font_file);
+
+  for (data = test_set->test_datas; data->characters[0]; data++) {
+    char *flavor;
+    GString *str;
+    const hb_codepoint_t *p;
 
-  hb_test_add_fixture_flavor (ft_fixture, (const void *) test_set, set_name, test_shape_complex);
+    test_t *test = g_slice_new0 (test_t);
+    test->font_data = &test_set->font_data;
+    test->test_data = data;
+
+    str = g_string_new ("<");
+    for (p = data->characters; *p; p++)
+      g_string_append_printf (str, "%04X,", *p);
+    str->str[str->len - 1] = '>';
+
+    flavor = g_strdup_printf ("%s/%s/%s", set_name, test_set->font_data.font_file, str->str);
+
+    g_string_free (str, TRUE);
+
+    if (skip)
+      hb_test_add_data_flavor ((const void *) test, flavor, test_shape_complex_skipped);
+    else
+      hb_test_add_fixture_flavor (ft_fixture, (const void *) test, flavor, test_shape_complex);
+
+    g_free (flavor);
+  }
 }
 
 
@@ -1080,19 +1128,19 @@ main (int argc, char **argv)
 
   TEST_SET (greek);
 
-  TEST_SET (devanagari_1);
-  TEST_SET (devanagari_2);
-  TEST_SET (bengali_1);
-  TEST_SET (bengali_2);
-  TEST_SET (bengali_3);
+  TEST_SET (devanagari1);
+  TEST_SET (devanagari2);
+  TEST_SET (bengali1);
+  TEST_SET (bengali2);
+  TEST_SET (bengali3);
   TEST_SET (gurmukhi);
   TEST_SET (oriya);
   TEST_SET (tamil);
   TEST_SET (telugu);
-  TEST_SET (kannada_1);
-  TEST_SET (kannada_2);
-  TEST_SET (malayalam_1);
-  TEST_SET (malayalam_2);
+  TEST_SET (kannada1);
+  TEST_SET (kannada2);
+  TEST_SET (malayalam1);
+  TEST_SET (malayalam2);
   TEST_SET (sinhala);
 
   TEST_SET (khmer);
commit 27413169782fdf79e278dd6552c8e194b3bc4eaa
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 16:21:31 2011 -0400

    Minor
    
    Towards a better test runner.

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index 243134a..b944dd9 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -63,6 +63,7 @@ typedef struct
   const test_data_t tests[];
 } test_t;
 
+
 static const test_set_t tests_greek = {
   {"DejaVuSans.ttf", 0},
   {
@@ -1062,13 +1063,20 @@ test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
 
 
 
+static void
+add_test_set (const test_set_t *test_set, const char *set_name)
+{
+
+  hb_test_add_fixture_flavor (ft_fixture, (const void *) test_set, set_name, test_shape_complex);
+}
+
 
 int
 main (int argc, char **argv)
 {
   hb_test_init (&argc, &argv);
 
-#define TEST_SET(name) hb_test_add_fixture_flavor (ft_fixture, (const void *) &tests_##name, #name, test_shape_complex)
+#define TEST_SET(name) add_test_set (&tests_##name, #name)
 
   TEST_SET (greek);
 
commit cc674cbf7fb9972975dc0499974e5e7fb4ae3c81
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 16:17:16 2011 -0400

    Minor

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index f8dcb0e..243134a 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -35,9 +35,7 @@
  * description.
  */
 
-#ifdef HAVE_FREETYPE
 #include <hb-ft.h>
-#endif
 
 typedef struct
 {
commit 20d8a3982ae320035edd6a04b402cefc9a5e5779
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 16:16:21 2011 -0400

    [test] Remove disabled code
    
    We'd add normalization and decomposition tests later.

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index 92f4efc..f8dcb0e 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -65,98 +65,6 @@ typedef struct
   const test_data_t tests[];
 } test_t;
 
-#if 0
-static bool decomposedShaping(FT_Face face, HB_Script script, const QChar &ch)
-{
-    QString uc = QString().append(ch);
-    Shaper shaper(face, script, uc);
-
-    uc = uc.normalized(QString::NormalizationForm_D);
-    Shaper decomposed(face, script, uc);
-
-    if( shaper.shaper_item.num_glyphs != decomposed.shaper_item.num_glyphs )
-        goto error;
-
-    for (unsigned int i = 0; i < shaper.shaper_item.num_glyphs; ++i) {
-        if ((shaper.shaper_item.glyphs[i]&0xffffff) != (decomposed.shaper_item.glyphs[i]&0xffffff))
-            goto error;
-    }
-    return true;
- error:
-    QString str = "";
-    int i = 0;
-    while (i < uc.length()) {
-        str += QString("%1 ").arg(uc[i].unicode(), 4, 16);
-        ++i;
-    }
-    qDebug("%s: decomposedShaping of char %4x failed\n    decomposedString: %s\n   nglyphs=%d, decomposed nglyphs %d",
-           face->family_name,
-           ch.unicode(), str.toLatin1().data(),
-           shaper.shaper_item.num_glyphs,
-           decomposed.shaper_item.num_glyphs);
-
-    str = "";
-    i = 0;
-    while (i < shaper.shaper_item.num_glyphs) {
-        str += QString("%1 ").arg(shaper.shaper_item.glyphs[i], 4, 16);
-        ++i;
-    }
-    qDebug("    composed glyph result   = %s", str.toLatin1().constData());
-    str = "";
-    i = 0;
-    while (i < decomposed.shaper_item.num_glyphs) {
-        str += QString("%1 ").arg(decomposed.shaper_item.glyphs[i], 4, 16);
-        ++i;
-    }
-    qDebug("    decomposed glyph result = %s", str.toLatin1().constData());
-    return false;
-}
-
-struct shape_test_t {
-    unsigned short unicode[16];
-    unsigned short glyphs[16];
-};
-
-void tst_QScriptEngine::greek()
-{
-  "DejaVuSans.ttf",
-    if (face) {
-        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
-            QString str;
-            str.append(uc);
-            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
-                /* qDebug() << "skipping" << hex << uc; */
-                continue;
-            }
-            if (uc == 0x1fc1 || uc == 0x1fed)
-                continue;
-            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
-        }
-        FT_Done_Face(face);
-    } else {
-        QSKIP("couln't find DejaVu Sans", SkipAll);
-    }
-
-
-    face = loadFace("SBL_grk.ttf");
-    if (face) {
-        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
-            QString str;
-            str.append(uc);
-            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
-                /* qDebug() << "skipping" << hex << uc; */
-                continue;
-            }
-            if (uc == 0x1fc1 || uc == 0x1fed)
-                continue;
-            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
-
-        }
-
-    };
-}
-#endif
-
 static const test_set_t tests_greek = {
   {"DejaVuSans.ttf", 0},
   {
commit 9704f0ca6c2defed52640da77506c80bc67b4f56
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 16:15:46 2011 -0400

    [test] Restructure shape test data a bit

diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
index 371f1d6..92f4efc 100644
--- a/test/test-shape-complex.c
+++ b/test/test-shape-complex.c
@@ -41,18 +41,29 @@
 
 typedef struct
 {
+  const char *font_file;
+  unsigned int face_index;
+  /* TODO add min/max face version */
+} font_data_t;
+
+typedef struct
+{
   char           comments[64];
   hb_codepoint_t characters[16];
   hb_codepoint_t glyphs[16];
-} test_t;
+} test_data_t;
 
 typedef struct
 {
-  const char *font_file;
-  unsigned int face_index;
-  const test_t tests[];
+  const font_data_t font_data;
+  const test_data_t tests[];
 } test_set_t;
 
+typedef struct
+{
+  const font_data_t font_data;
+  const test_data_t tests[];
+} test_t;
 
 #if 0
 static bool decomposedShaping(FT_Face face, HB_Script script, const QChar &ch)
@@ -147,7 +158,7 @@ void tst_QScriptEngine::greek()
 #endif
 
 static const test_set_t tests_greek = {
-  "DejaVuSans.ttf", 0,
+  {"DejaVuSans.ttf", 0},
   {
     { "",
       { 0x3b1, 0x300, 0x313, 0 },
@@ -162,7 +173,7 @@ static const test_set_t tests_greek = {
 };
 
 static const test_set_t tests_devanagari_1 = {
-  "raghu.ttf", 0,
+  {"raghu.ttf", 0},
   {
     { "Ka",
       { 0x0915, 0 },
@@ -217,7 +228,7 @@ static const test_set_t tests_devanagari_1 = {
 };
 
 static const test_set_t tests_devanagari_2 = {
-  "mangal.ttf", 0,
+  {"mangal.ttf", 0},
   {
     { "Ka",
       { 0x0915, 0 },
@@ -272,7 +283,7 @@ static const test_set_t tests_devanagari_2 = {
 };
 
 static const test_set_t tests_bengali_1 = {
-  "AkaashNormal.ttf", 0,
+  {"AkaashNormal.ttf", 0},
   {
     { "Ka",
       { 0x0995, 0 },
@@ -420,7 +431,7 @@ static const test_set_t tests_bengali_1 = {
 };
 
 static const test_set_t tests_bengali_2 = {
-  "MuktiNarrow.ttf", 0,
+  {"MuktiNarrow.ttf", 0},
   {
     { "Ka",
       { 0x0995, 0 },
@@ -543,7 +554,7 @@ static const test_set_t tests_bengali_2 = {
 };
 
 static const test_set_t tests_bengali_3 = {
-  "LikhanNormal.ttf", 0,
+  {"LikhanNormal.ttf", 0},
   {
     { "",
       { 0x09a8, 0x09cd, 0x09af, 0 },
@@ -582,7 +593,7 @@ static const test_set_t tests_bengali_3 = {
 };
 
 static const test_set_t tests_gurmukhi = {
-  "lohit_pa.ttf", 0,
+  {"lohit_pa.ttf", 0},
   {
     { "",
       { 0xA15, 0xA4D, 0xa39, 0 },
@@ -593,7 +604,7 @@ static const test_set_t tests_gurmukhi = {
 };
 
 static const test_set_t tests_oriya = {
-  "utkalm.ttf", 0,
+  {"utkalm.ttf", 0},
   {
     { "",
       { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
@@ -628,7 +639,7 @@ static const test_set_t tests_oriya = {
 };
 
 static const test_set_t tests_tamil = {
-  "akruti1.ttf", 0,
+  {"akruti1.ttf", 0},
   {
     { "",
       { 0x0b95, 0x0bc2, 0 },
@@ -723,7 +734,7 @@ static const test_set_t tests_tamil = {
 };
 
 static const test_set_t tests_telugu = {
-  "Pothana2000.ttf", 0,
+  {"Pothana2000.ttf", 0},
   {
     { "",
       { 0xc15, 0xc4d, 0 },
@@ -774,7 +785,7 @@ static const test_set_t tests_telugu = {
 };
 
 static const test_set_t tests_kannada_1 = {
-  "Sampige.ttf", 0,
+  {"Sampige.ttf", 0},
   {
     { "",
       { 0x0ca8, 0x0ccd, 0x0ca8, 0 },
@@ -821,7 +832,7 @@ static const test_set_t tests_kannada_1 = {
 };
 
 static const test_set_t tests_kannada_2 = {
-  "tunga.ttf", 0,
+  {"tunga.ttf", 0},
   {
     { "",
       { 0x0cb7, 0x0cc6, 0 },
@@ -856,7 +867,7 @@ static const test_set_t tests_kannada_2 = {
 };
 
 static const test_set_t tests_malayalam_1 = {
-  "AkrutiMal2Normal.ttf", 0,
+  {"AkrutiMal2Normal.ttf", 0},
   {
     { "",
       { 0x0d15, 0x0d46, 0 },
@@ -936,7 +947,7 @@ static const test_set_t tests_malayalam_1 = {
 };
 
 static const test_set_t tests_malayalam_2 = {
-  "Rachana.ttf", 0,
+  {"Rachana.ttf", 0},
   {
     { "",
       { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 },
@@ -964,7 +975,7 @@ static const test_set_t tests_malayalam_2 = {
 };
 
 static const test_set_t tests_sinhala = {
-  "FM-MalithiUW46.ttf", 0,
+  {"FM-MalithiUW46.ttf", 0},
   {
     { "",
       { 0xd9a, 0xdd9, 0xdcf, 0 },
@@ -995,7 +1006,7 @@ static const test_set_t tests_sinhala = {
 };
 
 static const test_set_t tests_khmer = {
-  "KhmerOS.ttf", 0,
+  {"KhmerOS.ttf", 0},
   {
     { "",
       { 0x179a, 0x17cd, 0 },
@@ -1038,7 +1049,7 @@ static const test_set_t tests_khmer = {
 };
 
 static const test_set_t tests_nko = {
-  "DejaVuSans.ttf", 0,
+  {"DejaVuSans.ttf", 0},
   {
     { "",
       { 0x7ca, 0 },
@@ -1065,7 +1076,7 @@ static const test_set_t tests_nko = {
 };
 
 static const test_set_t tests_linearb = {
-  "penuture.ttf", 0,
+  {"penuture.ttf", 0},
   {
     { "",
       { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03,  0 },
@@ -1087,11 +1098,11 @@ static void
 ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
 {
   const test_set_t *test = user_data;
-  char *font_file = g_strdup_printf ("%s/fonts/%s", srcdir (), test->font_file);
+  char *font_file = g_strdup_printf ("%s/fonts/%s", srcdir (), test->font_data.font_file);
 
   FT_Init_FreeType (&f->ft_library);
 
-  if (FT_New_Face (f->ft_library, font_file, test->face_index, &f->ft_face))
+  if (FT_New_Face (f->ft_library, font_file, test->font_data.face_index, &f->ft_face))
     g_test_message ("Font file %s not found.  Skipping test.", font_file);
   else
     f->font = hb_ft_font_create (f->ft_face, NULL);
@@ -1112,32 +1123,32 @@ static void
 test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
 {
   const test_set_t *test_set = user_data;
-  const test_t *test;
+  const test_data_t *data;
 
   if (!f->font)
     return; /* Skip test */
 
-  for (test = test_set->tests; test->characters[0]; test++) {
+  for (data = test_set->tests; data->characters[0]; data++) {
     hb_buffer_t *buffer;
     unsigned int i, len, expected_len;
     hb_glyph_info_t *glyphs;
 
-    if (test->comments[0])
-      g_test_message ("Test comments: %s", test->comments);
+    if (data->comments[0])
+      g_test_message ("Test comments: %s", data->comments);
 
     buffer =  hb_buffer_create (0);
-    for (len = 0; test->characters[len]; len++) ;
-    hb_buffer_add_utf32 (buffer, test->characters, len, 0, len);
+    for (len = 0; data->characters[len]; len++) ;
+    hb_buffer_add_utf32 (buffer, data->characters, len, 0, len);
 
     hb_shape (f->font, buffer, NULL, 0);
 
-    for (len = 0; test->glyphs[len]; len++) ;
+    for (len = 0; data->glyphs[len]; len++) ;
     expected_len = len;
 
     glyphs = hb_buffer_get_glyph_infos (buffer, &len);
     g_assert_cmpint (len, ==, expected_len);
     for (i = 0; i < len; i++)
-      g_assert_cmphex (glyphs[i].codepoint, ==, test->glyphs[i]);
+      g_assert_cmphex (glyphs[i].codepoint, ==, data->glyphs[i]);
 
     hb_buffer_destroy (buffer);
   }
commit 4ec30aec3014be6effc09cbbc88dcd075f3826df
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 14:13:38 2011 -0400

    [Indic] Optimize Indic table storage

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index cfd7bb4..e5601ff 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -121,10 +121,12 @@ enum indic_matra_category_t {
   INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT	= INDIC_MATRA_CATEGORY_NOT_APPLICABLE
 };
 
+/* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
+ * because gcc fails to optimize the latter and fills the table in at runtime. */
 #define INDIC_COMBINE_CATEGORIES(S,M) \
-  (ASSERT_STATIC_EXPR (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)), \
-   ASSERT_STATIC_EXPR (S < 16 && M < 16), \
-   (M << 4) | S)
+  (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \
+   ASSERT_STATIC_EXPR_ZERO (S < 16 && M < 16) + \
+   ((M << 4) | S))
 
 #include "hb-ot-shape-complex-indic-table.hh"
 
diff --git a/src/hb-private.hh b/src/hb-private.hh
index f385146..d749267 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -85,6 +85,7 @@ HB_BEGIN_DECLS
 #define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond))
 
 #define ASSERT_STATIC_EXPR(_cond) ((void) sizeof (char[(_cond) ? 1 : -1]))
+#define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * sizeof (char[(_cond) ? 1 : -1]))
 
 
 /* Lets assert int types.  Saves trouble down the road. */
commit c4a59de6d8c1e581b5c155319232be9e805e5cba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 14:03:29 2011 -0400

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

diff --git a/src/gen-indic-table.py b/src/gen-indic-table.py
index dc6a19a..f4fdb83 100755
--- a/src/gen-indic-table.py
+++ b/src/gen-indic-table.py
@@ -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
+print "#define indic_offset_total %d" % offset
+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);"
diff --git a/src/hb-ot-shape-complex-indic-table.hh b/src/hb-ot-shape-complex-indic-table.hh
index 4b04914..2ee27b8 100644
--- a/src/hb-ot-shape-complex-indic-table.hh
+++ b/src/hb-ot-shape-complex-indic-table.hh
@@ -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);
commit a346e923a99f920bbebc25b335db51fdfb1429ea
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Jun 28 12:49:18 2011 -0400

    [test] Add Indic tests from harfbuzz.old
    
    Needs fonts to be put in test/fonts.  Tests are skipped otherwise.
    Run with --verbose for details.  Working on improving the test runner
    to make it easier to make sense of what's going on.

diff --git a/test/Makefile.am b/test/Makefile.am
index 968f548..b6642f5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,7 +7,7 @@ DISTCLEANFILES =
 MAINTAINERCLEANFILES =
 
 if HAVE_GLIB
-AM_CPPFLAGS = -I$(top_srcdir)/src/ $(GLIB_CFLAGS) $(GTHREAD_CFLAGS)
+AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ $(GLIB_CFLAGS) $(GTHREAD_CFLAGS)
 LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS) $(GTHREAD_LIBS)
 
 EXTRA_DIST += hb-test.h
@@ -47,7 +47,13 @@ test_c_CPPFLAGS += $(FREETYPE_CFLAGS)
 test_cplusplus_CPPFLAGS += $(FREETYPE_CFLAGS)
 # TODO replace freetype with other stuff in the following test
 test_object_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
-test_object_LIBS = $(LDADD) $(FREETYPE_LIBS)
+test_object_LDADD = $(LDADD) $(FREETYPE_LIBS)
+
+TEST_PROGS += \
+	test-shape-complex \
+	$(NULL)
+test_shape_complex_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
+test_shape_complex_LDADD = $(LDADD) $(FREETYPE_LIBS)
 endif
 
 
@@ -58,6 +64,7 @@ TESTS_ENVIRONMENT = \
 	MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) \
 	G_DEBUG=gc-friendly \
 	G_SLICE=always-malloc \
+	srcdir=$(srcdir) \
 	$(ENV)
 
 
diff --git a/test/hb-test.h b/test/hb-test.h
index 938b700..09008aa 100644
--- a/test/hb-test.h
+++ b/test/hb-test.h
@@ -49,6 +49,27 @@ HB_BEGIN_DECLS
 				  ((const char *) s)[3]))
 
 
+static inline const char *
+srcdir (void)
+{
+  static const char *s;
+
+  if (!s) {
+    s = getenv ("srcdir");
+
+#ifdef SRCDIR
+    if (!s || !s[0])
+      s = SRCDIR;
+#endif
+
+    if (!s || !s[0])
+      s = ".";
+  }
+
+  return s;
+}
+
+
 /* Helpers */
 
 static inline void
diff --git a/test/test-shape-complex.c b/test/test-shape-complex.c
new file mode 100644
index 0000000..371f1d6
--- /dev/null
+++ b/test/test-shape-complex.c
@@ -0,0 +1,1179 @@
+/*
+ * Copyright © 2011  Google, Inc.
+ * Copyright © 2008  Nokia Corporation and/or its subsidiary(-ies)
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#include "hb-test.h"
+
+/* Unit tests for complex text shaping */
+
+/*
+ * This test provides a framework to test aspects of hb_shape() that are
+ * font-dependent.  Please add tests for any feature that fits that
+ * description.
+ */
+
+#ifdef HAVE_FREETYPE
+#include <hb-ft.h>
+#endif
+
+typedef struct
+{
+  char           comments[64];
+  hb_codepoint_t characters[16];
+  hb_codepoint_t glyphs[16];
+} test_t;
+
+typedef struct
+{
+  const char *font_file;
+  unsigned int face_index;
+  const test_t tests[];
+} test_set_t;
+
+
+#if 0
+static bool decomposedShaping(FT_Face face, HB_Script script, const QChar &ch)
+{
+    QString uc = QString().append(ch);
+    Shaper shaper(face, script, uc);
+
+    uc = uc.normalized(QString::NormalizationForm_D);
+    Shaper decomposed(face, script, uc);
+
+    if( shaper.shaper_item.num_glyphs != decomposed.shaper_item.num_glyphs )
+        goto error;
+
+    for (unsigned int i = 0; i < shaper.shaper_item.num_glyphs; ++i) {
+        if ((shaper.shaper_item.glyphs[i]&0xffffff) != (decomposed.shaper_item.glyphs[i]&0xffffff))
+            goto error;
+    }
+    return true;
+ error:
+    QString str = "";
+    int i = 0;
+    while (i < uc.length()) {
+        str += QString("%1 ").arg(uc[i].unicode(), 4, 16);
+        ++i;
+    }
+    qDebug("%s: decomposedShaping of char %4x failed\n    decomposedString: %s\n   nglyphs=%d, decomposed nglyphs %d",
+           face->family_name,
+           ch.unicode(), str.toLatin1().data(),
+           shaper.shaper_item.num_glyphs,
+           decomposed.shaper_item.num_glyphs);
+
+    str = "";
+    i = 0;
+    while (i < shaper.shaper_item.num_glyphs) {
+        str += QString("%1 ").arg(shaper.shaper_item.glyphs[i], 4, 16);
+        ++i;
+    }
+    qDebug("    composed glyph result   = %s", str.toLatin1().constData());
+    str = "";
+    i = 0;
+    while (i < decomposed.shaper_item.num_glyphs) {
+        str += QString("%1 ").arg(decomposed.shaper_item.glyphs[i], 4, 16);
+        ++i;
+    }
+    qDebug("    decomposed glyph result = %s", str.toLatin1().constData());
+    return false;
+}
+
+struct shape_test_t {
+    unsigned short unicode[16];
+    unsigned short glyphs[16];
+};
+
+void tst_QScriptEngine::greek()
+{
+  "DejaVuSans.ttf",
+    if (face) {
+        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
+            QString str;
+            str.append(uc);
+            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
+                /* qDebug() << "skipping" << hex << uc; */
+                continue;
+            }
+            if (uc == 0x1fc1 || uc == 0x1fed)
+                continue;
+            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
+        }
+        FT_Done_Face(face);
+    } else {
+        QSKIP("couln't find DejaVu Sans", SkipAll);
+    }
+
+
+    face = loadFace("SBL_grk.ttf");
+    if (face) {
+        for (int uc = 0x1f00; uc <= 0x1fff; ++uc) {
+            QString str;
+            str.append(uc);
+            if (str.normalized(QString::NormalizationForm_D).normalized(QString::NormalizationForm_C) != str) {
+                /* qDebug() << "skipping" << hex << uc; */
+                continue;
+            }
+            if (uc == 0x1fc1 || uc == 0x1fed)
+                continue;
+            QVERIFY( decomposedShaping(face, HB_Script_Greek, QChar(uc)) );
+
+        }
+
+    };
+}
+#endif
+
+static const test_set_t tests_greek = {
+  "DejaVuSans.ttf", 0,
+  {
+    { "",
+      { 0x3b1, 0x300, 0x313, 0 },
+      { 0xb8, 0x3d3, 0x3c7, 0 }
+    },
+    { "",
+      { 0x3b1, 0x313, 0x300, 0 },
+      { 0xd4, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_devanagari_1 = {
+  "raghu.ttf", 0,
+  {
+    { "Ka",
+      { 0x0915, 0 },
+      { 0x0080, 0 }
+    },
+    { "Ka Halant",
+      { 0x0915, 0x094d, 0 },
+      { 0x0080, 0x0051, 0 }
+    },
+    { "Ka Halant Ka",
+      { 0x0915, 0x094d, 0x0915, 0 },
+      { 0x00c8, 0x0080, 0 }
+    },
+    { "Ka MatraI",
+      { 0x0915, 0x093f, 0 },
+      { 0x01d1, 0x0080, 0 }
+    },
+    { "Ra Halant Ka",
+      { 0x0930, 0x094d, 0x0915, 0 },
+      { 0x0080, 0x005b, 0 }
+    },
+    { "Ra Halant Ka MatraI",
+      { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
+      { 0x01d1, 0x0080, 0x005b, 0 }
+    },
+    { "MatraI",
+      { 0x093f, 0 },
+      { 0x01d4, 0x029c, 0 }
+    },
+    { "Ka Nukta",
+      { 0x0915, 0x093c, 0 },
+      { 0x00a4, 0 }
+    },
+    { "Ka Halant Ra",
+      { 0x0915, 0x094d, 0x0930, 0 },
+      { 0x0110, 0 }
+    },
+    { "Ka Halant Ra Halant Ka",
+      { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
+      { 0x0158, 0x0080, 0 }
+    },
+    { "",
+      { 0x0930, 0x094d, 0x200d, 0 },
+      { 0x00e2, 0 }
+    },
+    { "",
+      { 0x0915, 0x094d, 0x0930, 0x094d, 0x200d, 0 },
+      { 0x0158, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_devanagari_2 = {
+  "mangal.ttf", 0,
+  {
+    { "Ka",
+      { 0x0915, 0 },
+      { 0x0080, 0 }
+    },
+    { "Ka Halant",
+      { 0x0915, 0x094d, 0 },
+      { 0x0080, 0x0051, 0 }
+    },
+    { "Ka Halant Ka",
+      { 0x0915, 0x094d, 0x0915, 0 },
+      { 0x00c8, 0x0080, 0 }
+    },
+    { "Ka MatraI",
+      { 0x0915, 0x093f, 0 },
+      { 0x01d1, 0x0080, 0 }
+    },
+    { "Ra Halant Ka",
+      { 0x0930, 0x094d, 0x0915, 0 },
+      { 0x0080, 0x005b, 0 }
+    },
+    { "Ra Halant Ka MatraI",
+      { 0x0930, 0x094d, 0x0915, 0x093f, 0 },
+      { 0x01d1, 0x0080, 0x005b, 0 }
+    },
+    { "MatraI",
+      { 0x093f, 0 },
+      { 0x01d4, 0x029c, 0 }
+    },
+    { "Ka Nukta",
+      { 0x0915, 0x093c, 0 },
+      { 0x00a4, 0 }
+    },
+    { "Ka Halant Ra",
+      { 0x0915, 0x094d, 0x0930, 0 },
+      { 0x0110, 0 }
+    },
+    { "Ka Halant Ra Halant Ka",
+      { 0x0915, 0x094d, 0x0930, 0x094d, 0x0915, 0 },
+      { 0x0158, 0x0080, 0 }
+    },
+    { "",
+      { 0x92b, 0x94d, 0x930, 0 },
+      { 0x125, 0 }
+    },
+    { "",
+      { 0x92b, 0x93c, 0x94d, 0x930, 0 },
+      { 0x149, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_bengali_1 = {
+  "AkaashNormal.ttf", 0,
+  {
+    { "Ka",
+      { 0x0995, 0 },
+      { 0x0151, 0 }
+    },
+    { "Ka Halant",
+      { 0x0995, 0x09cd, 0 },
+      { 0x0151, 0x017d, 0 }
+    },
+    { "Ka Halant Ka",
+      { 0x0995, 0x09cd, 0x0995, 0 },
+      { 0x019b, 0 }
+    },
+    { "Ka MatraI",
+      { 0x0995, 0x09bf, 0 },
+      { 0x0173, 0x0151, 0 }
+    },
+    { "Ra Halant Ka",
+      { 0x09b0, 0x09cd, 0x0995, 0 },
+      { 0x0151, 0x0276, 0 }
+    },
+    { "Ra Halant Ka MatraI",
+      { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
+      { 0x0173, 0x0151, 0x0276, 0 }
+    },
+    { "Ka Nukta",
+      { 0x0995, 0x09bc, 0 },
+      { 0x0151, 0x0171, 0 }
+    },
+    { "Ka Halant Ra",
+      { 0x0995, 0x09cd, 0x09b0, 0 },
+      { 0x01f4, 0 }
+    },
+    { "Ka Halant Ra Halant Ka",
+      { 0x0995, 0x09cd, 0x09b0, 0x09cd, 0x0995, 0 },
+      { 0x025c, 0x0276, 0x0151, 0 }
+    },
+    { "Ya + Halant",
+      { 0x09af, 0x09cd, 0 },
+      { 0x016a, 0x017d, 0 }
+    },
+    { "Da Halant Ya -> Da Ya-Phala",
+      { 0x09a6, 0x09cd, 0x09af, 0 },
+      { 0x01e5, 0 }
+    },
+    { "A Halant Ya -> A Ya-phala",
+      { 0x0985, 0x09cd, 0x09af, 0 },
+      { 0x0145, 0x01cf, 0 }
+    },
+    { "Na Halant Ka",
+      { 0x09a8, 0x09cd, 0x0995, 0 },
+      { 0x026f, 0x0151, 0 }
+    },
+    { "Na Halant ZWNJ Ka",
+      { 0x09a8, 0x09cd, 0x200c, 0x0995, 0 },
+      { 0x0164, 0x017d, 0x0151, 0 }
+    },
+    { "Na Halant ZWJ Ka",
+      { 0x09a8, 0x09cd, 0x200d, 0x0995, 0 },
+      { 0x026f, 0x0151, 0 }
+    },
+    { "Ka Halant ZWNJ Ka",
+      { 0x0995, 0x09cd, 0x200c, 0x0995, 0 },
+      { 0x0151, 0x017d, 0x0151, 0 }
+    },
+    { "Ka Halant ZWJ Ka",
+      { 0x0995, 0x09cd, 0x200d, 0x0995, 0 },
+      { 0x025c, 0x0151, 0 }
+    },
+    { "Na Halant Ra",
+      { 0x09a8, 0x09cd, 0x09b0, 0 },
+      { 0x0207, 0 }
+    },
+    { "Na Halant ZWNJ Ra",
+      { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
+      { 0x0164, 0x017d, 0x016b, 0 }
+    },
+    { "Na Halant ZWJ Ra",
+      { 0x09a8, 0x09cd, 0x200d, 0x09b0, 0 },
+      { 0x026f, 0x016b, 0 }
+    },
+    { "Na Halant Ba",
+      { 0x09a8, 0x09cd, 0x09ac, 0 },
+      { 0x022f, 0 }
+    },
+    { "Na Halant ZWNJ Ba",
+      { 0x09a8, 0x09cd, 0x200c, 0x09ac, 0 },
+      { 0x0164, 0x017d, 0x0167, 0 }
+    },
+    { "Na Halant ZWJ Ba",
+      { 0x09a8, 0x09cd, 0x200d, 0x09ac, 0 },
+      { 0x026f, 0x0167, 0 }
+    },
+    { "Na Halant Dha",
+      { 0x09a8, 0x09cd, 0x09a7, 0 },
+      { 0x01d3, 0 }
+    },
+    { "Na Halant ZWNJ Dha",
+      { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
+      { 0x0164, 0x017d, 0x0163, 0 }
+    },
+    { "Na Halant ZWJ Dha",
+      { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
+      { 0x026f, 0x0163, 0 }
+    },
+    { "Ra Halant Ka MatraAU",
+      { 0x09b0, 0x09cd, 0x0995, 0x09cc, 0 },
+      { 0x0179, 0x0151, 0x0276, 0x017e, 0 }
+    },
+    { "Ra Halant Ba Halant Ba",
+      { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
+      { 0x0232, 0x0276, 0 }
+    },
+    { "",
+      { 0x9b0, 0x9cd, 0x995, 0x9be, 0x982, 0 },
+      { 0x151, 0x276, 0x172, 0x143, 0 }
+    },
+    { "",
+      { 0x9b0, 0x9cd, 0x995, 0x9be, 0x983, 0 },
+      { 0x151, 0x276, 0x172, 0x144, 0 }
+    },
+    /*  Test decomposed two part matras */
+    { "",
+      { 0x995, 0x9c7, 0x9be, 0 },
+      { 0x179, 0x151, 0x172, 0 }
+    },
+    { "",
+      { 0x995, 0x9c7, 0x9d7, 0 },
+      { 0x179, 0x151, 0x17e, 0 }
+    },
+    { "",
+      { 0x9b0, 0x9cd, 0x9ad, 0 },
+      { 0x168, 0x276, 0 }
+    },
+    { "",
+      { 0x9f0, 0x9cd, 0x9ad, 0 },
+      { 0x168, 0x276, 0 }
+    },
+    { "",
+      { 0x9f1, 0x9cd, 0x9ad, 0 },
+      { 0x191, 0x17d, 0x168, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_bengali_2 = {
+  "MuktiNarrow.ttf", 0,
+  {
+    { "Ka",
+      { 0x0995, 0 },
+      { 0x0073, 0 }
+    },
+    { "Ka Halant",
+      { 0x0995, 0x09cd, 0 },
+      { 0x00b9, 0 }
+    },
+    { "Ka Halant Ka",
+      { 0x0995, 0x09cd, 0x0995, 0 },
+      { 0x0109, 0 }
+    },
+    { "Ka MatraI",
+      { 0x0995, 0x09bf, 0 },
+      { 0x0095, 0x0073, 0 }
+    },
+    { "Ra Halant Ka",
+      { 0x09b0, 0x09cd, 0x0995, 0 },
+      { 0x0073, 0x00e1, 0 }
+    },
+    { "Ra Halant Ka MatraI",
+      { 0x09b0, 0x09cd, 0x0995, 0x09bf, 0 },
+      { 0x0095, 0x0073, 0x00e1, 0 }
+    },
+    { "MatraI",
+      { 0x09bf, 0 },
+      { 0x0095, 0x01c8, 0 }
+    },
+    { "Ka Nukta",
+      { 0x0995, 0x09bc, 0 },
+      { 0x0073, 0x0093, 0 }
+    },
+    { "Ka Halant Ra",
+      { 0x0995, 0x09cd, 0x09b0, 0 },
+      { 0x00e5, 0 }
+    },
+    { "Ka Halant Ra Halant Ka",
+      { 0x995, 0x9cd, 0x9b0, 0x9cd, 0x995, 0 },
+      { 0x234, 0x24e, 0x73, 0 }
+    },
+    { "Ya + Halant",
+      { 0x09af, 0x09cd, 0 },
+      { 0x00d2, 0 }
+    },
+    { "Da Halant Ya -> Da Ya-Phala",
+      { 0x09a6, 0x09cd, 0x09af, 0 },
+      { 0x0084, 0x00e2, 0 }
+    },
+    { "A Halant Ya -> A Ya-phala",
+      { 0x0985, 0x09cd, 0x09af, 0 },
+      { 0x0067, 0x00e2, 0 }
+    },
+    { "Na Halant Ka",
+      { 0x09a8, 0x09cd, 0x0995, 0 },
+      { 0x0188, 0 }
+    },
+    { "Na Halant ZWNJ Ka",
+      { 0x9a8, 0x9cd, 0x200c, 0x995, 0 },
+      { 0xcc, 0x73, 0 }
+    },
+    { "Na Halant ZWJ Ka",
+      { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
+      { 0x247, 0x73, 0 }
+    },
+    { "Ka Halant ZWNJ Ka",
+      { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
+      { 0x247, 0x73, 0 }
+    },
+    { "Ka Halant ZWJ Ka",
+      { 0x9a8, 0x9cd, 0x200d, 0x995, 0 },
+      { 0x247, 0x73, 0 }
+    },
+    { "Na Halant Ra",
+      { 0x09a8, 0x09cd, 0x09b0, 0 },
+      { 0x00f8, 0 }
+    },
+    { "Na Halant ZWNJ Ra",
+      { 0x09a8, 0x09cd, 0x200c, 0x09b0, 0 },
+      { 0xcc, 0x8d, 0 }
+    },
+    { "Na Halant ZWJ Ra",
+      { 0x9a8, 0x9cd, 0x200d, 0x9b0, 0 },
+      { 0x247, 0x8d, 0 }
+    },
+    { "Na Halant Ba",
+      { 0x09a8, 0x09cd, 0x09ac, 0 },
+      { 0x0139, 0 }
+    },
+    { "Na Halant ZWNJ Ba",
+      { 0x9a8, 0x9cd, 0x200c, 0x9ac, 0 },
+      { 0xcc, 0x89, 0 }
+    },
+    { "Na Halant ZWJ Ba",
+      { 0x9a8, 0x9cd, 0x200d, 0x9ac, 0 },
+      { 0x247, 0x89, 0 }
+    },
+    { "Na Halant Dha",
+      { 0x09a8, 0x09cd, 0x09a7, 0 },
+      { 0x0145, 0 }
+    },
+    { "Na Halant ZWNJ Dha",
+      { 0x09a8, 0x09cd, 0x200c, 0x09a7, 0 },
+      { 0xcc, 0x85, 0 }
+    },
+    { "Na Halant ZWJ Dha",
+      { 0x09a8, 0x09cd, 0x200d, 0x09a7, 0 },
+      { 0x247, 0x85, 0 }
+    },
+    { "Ra Halant Ka MatraAU",
+      { 0x9b0, 0x9cd, 0x995, 0x9cc, 0 },
+      { 0x232, 0x73, 0xe1, 0xa0, 0 }
+    },
+    { "Ra Halant Ba Halant Ba",
+      { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0 },
+      { 0x013b, 0x00e1, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_bengali_3 = {
+  "LikhanNormal.ttf", 0,
+  {
+    { "",
+      { 0x09a8, 0x09cd, 0x09af, 0 },
+      { 0x01ca, 0 }
+    },
+    { "",
+      { 0x09b8, 0x09cd, 0x09af, 0 },
+      { 0x020e, 0 }
+    },
+    { "",
+      { 0x09b6, 0x09cd, 0x09af, 0 },
+      { 0x01f4, 0 }
+    },
+    { "",
+      { 0x09b7, 0x09cd, 0x09af, 0 },
+      { 0x01fe, 0 }
+    },
+    { "",
+      { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0 },
+      { 0x10b, 0x167, 0 }
+    },
+    { "",
+      { 0x9b0, 0x9cd, 0x9ad, 0 },
+      { 0xa1, 0x167, 0 }
+    },
+    { "",
+      { 0x9f0, 0x9cd, 0x9ad, 0 },
+      { 0xa1, 0x167, 0 }
+    },
+    { "",
+      { 0x9f1, 0x9cd, 0x9ad, 0 },
+      { 0x11c, 0xa1, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_gurmukhi = {
+  "lohit_pa.ttf", 0,
+  {
+    { "",
+      { 0xA15, 0xA4D, 0xa39, 0 },
+      { 0x3b, 0x8b, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_oriya = {
+  "utkalm.ttf", 0,
+  {
+    { "",
+      { 0xb15, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
+      { 0x150, 0x125, 0 }
+    },
+    { "",
+      { 0xb24, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
+      { 0x151, 0x120, 0 }
+    },
+    { "",
+      { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
+      { 0x152, 0x120, 0 }
+    },
+    { "",
+      { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb2c, 0 },
+      { 0x152, 0x120, 0 }
+    },
+    { "",
+      { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
+      { 0x176, 0 }
+    },
+    { "",
+      { 0xb38, 0xb4d, 0xb24, 0xb4d, 0xb30, 0 },
+      { 0x177, 0 }
+    },
+    { "",
+      { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0 },
+      { 0x176, 0x124, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_tamil = {
+  "akruti1.ttf", 0,
+  {
+    { "",
+      { 0x0b95, 0x0bc2, 0 },
+      { 0x004e, 0 }
+    },
+    { "",
+      { 0x0bae, 0x0bc2, 0 },
+      { 0x009e, 0 }
+    },
+    { "",
+      { 0x0b9a, 0x0bc2, 0 },
+      { 0x0058, 0 }
+    },
+    { "",
+      { 0x0b99, 0x0bc2, 0 },
+      { 0x0053, 0 }
+    },
+    { "",
+      { 0x0bb0, 0x0bc2, 0 },
+      { 0x00a8, 0 }
+    },
+    { "",
+      { 0x0ba4, 0x0bc2, 0 },
+      { 0x008e, 0 }
+    },
+    { "",
+      { 0x0b9f, 0x0bc2, 0 },
+      { 0x0062, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bc6, 0 },
+      { 0x000a, 0x0031, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bca, 0 },
+      { 0x000a, 0x0031, 0x0007, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bc6, 0x0bbe, 0 },
+      { 0x000a, 0x0031, 0x007, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bcd, 0x0bb7, 0 },
+      { 0x0049, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bcd, 0x0bb7, 0x0bca, 0 },
+      { 0x000a, 0x0049, 0x007, 0 }
+    },
+    { "",
+      { 0x0b95, 0x0bcd, 0x0bb7, 0x0bc6, 0x0bbe, 0 },
+      { 0x000a, 0x0049, 0x007, 0 }
+    },
+    { "",
+      { 0x0b9f, 0x0bbf, 0 },
+      { 0x005f, 0 }
+    },
+    { "",
+      { 0x0b9f, 0x0bc0, 0 },
+      { 0x0060, 0 }
+    },
+    { "",
+      { 0x0bb2, 0x0bc0, 0 },
+      { 0x00ab, 0 }
+    },
+    { "",
+      { 0x0bb2, 0x0bbf, 0 },
+      { 0x00aa, 0 }
+    },
+    { "",
+      { 0x0bb0, 0x0bcd, 0 },
+      { 0x00a4, 0 }
+    },
+    { "",
+      { 0x0bb0, 0x0bbf, 0 },
+      { 0x00a5, 0 }
+    },
+    { "",
+      { 0x0bb0, 0x0bc0, 0 },
+      { 0x00a6, 0 }
+    },
+    { "",
+      { 0x0b83, 0 },
+      { 0x0025, 0 }
+    },
+    { "",
+      { 0x0b83, 0x0b95, 0 },
+      { 0x0025, 0x0031, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_telugu = {
+  "Pothana2000.ttf", 0,
+  {
+    { "",
+      { 0xc15, 0xc4d, 0 },
+      { 0xbb, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc37, 0 },
+      { 0x4b, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc37, 0xc4d, 0 },
+      { 0xe0, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc37, 0xc4d, 0xc23, 0 },
+      { 0x4b, 0x91, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc30, 0 },
+      { 0x5a, 0xb2, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc30, 0xc4d, 0 },
+      { 0xbb, 0xb2, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc30, 0xc4d, 0xc15, 0 },
+      { 0x5a, 0xb2, 0x83, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc30, 0xc3f, 0 },
+      { 0xe2, 0xb2, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc15, 0xc48, 0 },
+      { 0xe6, 0xb3, 0x83, 0 }
+    },
+    { "",
+      { 0xc15, 0xc4d, 0xc30, 0xc48, 0 },
+      { 0xe6, 0xb3, 0x9f, 0 }
+    },
+    { "",
+      { 0xc15, 0xc46, 0xc56, 0 },
+      { 0xe6, 0xb3, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_kannada_1 = {
+  "Sampige.ttf", 0,
+  {
+    { "",
+      { 0x0ca8, 0x0ccd, 0x0ca8, 0 },
+      { 0x0049, 0x00ba, 0 }
+    },
+    { "",
+      { 0x0ca8, 0x0ccd, 0x0ca1, 0 },
+      { 0x0049, 0x00b3, 0 }
+    },
+    { "",
+      { 0x0caf, 0x0cc2, 0 },
+      { 0x004f, 0x005d, 0 }
+    },
+    { "",
+      { 0x0ce0, 0 },
+      { 0x006a, 0 }
+    },
+    { "",
+      { 0x0ce6, 0x0ce7, 0x0ce8, 0 },
+      { 0x006b, 0x006c, 0x006d, 0 }
+    },
+    { "",
+      { 0x0cb5, 0x0ccb, 0 },
+      { 0x015f, 0x0067, 0 }
+    },
+    { "",
+      { 0x0cb0, 0x0ccd, 0x0cae, 0 },
+      { 0x004e, 0x0082, 0 }
+    },
+    { "",
+      { 0x0cb0, 0x0ccd, 0x0c95, 0 },
+      { 0x0036, 0x0082, 0 }
+    },
+    { "",
+      { 0x0c95, 0x0ccd, 0x0cb0, 0 },
+      { 0x0036, 0x00c1, 0 }
+    },
+    { "",
+      { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0 },
+      { 0x0050, 0x00a7, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_kannada_2 = {
+  "tunga.ttf", 0,
+  {
+    { "",
+      { 0x0cb7, 0x0cc6, 0 },
+      { 0x00b0, 0x006c, 0 }
+    },
+    { "",
+      { 0x0cb7, 0x0ccd, 0 },
+      { 0x0163, 0 }
+    },
+    { "",
+      { 0xc95, 0xcbf, 0xcd5, 0 },
+      { 0x114, 0x73, 0 }
+    },
+    { "",
+      { 0xc95, 0xcc6, 0xcd5, 0 },
+      { 0x90, 0x6c, 0x73, 0 }
+    },
+    { "",
+      { 0xc95, 0xcc6, 0xcd6, 0 },
+      { 0x90, 0x6c, 0x74, 0 }
+    },
+    { "",
+      { 0xc95, 0xcc6, 0xcc2, 0 },
+      { 0x90, 0x6c, 0x69, 0 }
+    },
+    { "",
+      { 0xc95, 0xcca, 0xcd5, 0 },
+      { 0x90, 0x6c, 0x69, 0x73, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_malayalam_1 = {
+  "AkrutiMal2Normal.ttf", 0,
+  {
+    { "",
+      { 0x0d15, 0x0d46, 0 },
+      { 0x005e, 0x0034, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d47, 0 },
+      { 0x005f, 0x0034, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d4b, 0 },
+      { 0x005f, 0x0034, 0x0058, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d48, 0 },
+      { 0x0060, 0x0034, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d4a, 0 },
+      { 0x005e, 0x0034, 0x0058, 0 }
+    },
+    { "",
+      { 0x0d30, 0x0d4d, 0x0d15, 0 },
+      { 0x009e, 0x0034, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d4d, 0x0d35, 0 },
+      { 0x0034, 0x007a, 0 }
+    },
+    { "",
+      { 0x0d15, 0x0d4d, 0x0d2f, 0 },
+      { 0x0034, 0x00a2, 0 }
+    },
+    { "",
+      { 0x0d1f, 0x0d4d, 0x0d1f, 0 },
+      { 0x0069, 0 }
+    },
+    { "",
+      { 0x0d26, 0x0d4d, 0x0d26, 0 },
+      { 0x0074, 0 }
+    },
+    { "",
+      { 0x0d30, 0x0d4d, 0 },
+      { 0x009e, 0 }
+    },
+    { "",
+      { 0x0d30, 0x0d4d, 0x200c, 0 },
+      { 0x009e, 0 }
+    },
+    { "",
+      { 0x0d30, 0x0d4d, 0x200d, 0 },
+      { 0x009e, 0 }
+    },
+    { "",
+      { 0xd15, 0xd46, 0xd3e, 0 },
+      { 0x5e, 0x34, 0x58, 0 }
+    },
+    { "",
+      { 0xd15, 0xd47, 0xd3e, 0 },
+      { 0x5f, 0x34, 0x58, 0 }
+    },
+    { "",
+      { 0xd15, 0xd46, 0xd57, 0 },
+      { 0x5e, 0x34, 0x65, 0 }
+    },
+    { "",
+      { 0xd15, 0xd57, 0 },
+      { 0x34, 0x65, 0 }
+    },
+    { "",
+      { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0 },
+      { 0x69, 0x5b, 0x64, 0 }
+    },
+
+    {{0}}
+  }
+};
+
+static const test_set_t tests_malayalam_2 = {
+  "Rachana.ttf", 0,
+  {
+    { "",
+      { 0xd37, 0xd4d, 0xd1f, 0xd4d, 0xd30, 0xd40, 0 },
+      { 0x385, 0xa3, 0 }
+    },
+    { "",
+      { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
+      { 0x2ff, 0 }
+    },
+    { "",
+      { 0xd33, 0xd4d, 0xd33, 0 },
+      { 0x3f8, 0 }
+    },
+    { "",
+      { 0xd2f, 0xd4d, 0xd15, 0xd4d, 0xd15, 0xd41, 0 },
+      { 0x2ff, 0 }
+    },
+    { "",
+      { 0xd30, 0xd4d, 0x200d, 0xd35, 0xd4d, 0xd35, 0 },
+      { 0xf3, 0x350, 0 }
+    },
+
+    {{0}}
+  }
+};
+
+static const test_set_t tests_sinhala = {
+  "FM-MalithiUW46.ttf", 0,
+  {
+    { "",
+      { 0xd9a, 0xdd9, 0xdcf, 0 },
+      { 0x4a, 0x61, 0x42, 0 }
+    },
+    { "",
+      { 0xd9a, 0xdd9, 0xddf, 0 },
+      { 0x4a, 0x61, 0x50, 0 }
+    },
+    { "",
+      { 0xd9a, 0xdd9, 0xdca, 0 },
+      { 0x4a, 0x62, 0 }
+    },
+    { "",
+      { 0xd9a, 0xddc, 0xdca, 0 },
+      { 0x4a, 0x61, 0x42, 0x41, 0 }
+    },
+    { "",
+      { 0xd9a, 0xdda, 0 },
+      { 0x4a, 0x62, 0 }
+    },
+    { "",
+      { 0xd9a, 0xddd, 0 },
+      { 0x4a, 0x61, 0x42, 0x41, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_khmer = {
+  "KhmerOS.ttf", 0,
+  {
+    { "",
+      { 0x179a, 0x17cd, 0 },
+      { 0x24c, 0x27f, 0 }
+    },
+    { "",
+      { 0x179f, 0x17c5, 0 },
+      { 0x273, 0x203, 0 }
+    },
+    { "",
+      { 0x1790, 0x17d2, 0x1784, 0x17c3, 0 },
+      { 0x275, 0x242, 0x182, 0 }
+    },
+    { "",
+      { 0x179a, 0 },
+      { 0x24c, 0 }
+    },
+    { "",
+      { 0x1781, 0x17d2, 0x1798, 0x17c2, 0 },
+      { 0x274, 0x233, 0x197, 0 }
+    },
+    { "",
+      { 0x1798, 0x17b6, 0 },
+      { 0x1cb, 0 }
+    },
+    { "",
+      { 0x179a, 0x17b8, 0 },
+      { 0x24c, 0x26a, 0 }
+    },
+    { "",
+      { 0x1787, 0x17b6, 0 },
+      { 0x1ba, 0 }
+    },
+    { "",
+      { 0x1798, 0x17d2, 0x1796, 0x17bb, 0 },
+      { 0x24a, 0x195, 0x26d, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_nko = {
+  "DejaVuSans.ttf", 0,
+  {
+    { "",
+      { 0x7ca, 0 },
+      { 0x5c1, 0 }
+    },
+    { "",
+      { 0x7ca, 0x7ca, 0 },
+      { 0x14db, 0x14d9, 0 }
+    },
+    { "",
+      { 0x7ca, 0x7fa, 0x7ca, 0 },
+      { 0x14db, 0x5ec, 0x14d9, 0 }
+    },
+    { "",
+      { 0x7ca, 0x7f3, 0x7ca, 0 },
+      { 0x14db, 0x5e7, 0x14d9, 0 }
+    },
+    { "",
+      { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0 },
+      { 0x14db, 0x5e7, 0x5ec, 0x14d9, 0 }
+    },
+    {{0}}
+  }
+};
+
+static const test_set_t tests_linearb = {
+  "penuture.ttf", 0,
+  {
+    { "",
+      { 0xd800, 0xdc01, 0xd800, 0xdc02, 0xd800, 0xdc03,  0 },
+      { 0x5, 0x6, 0x7, 0 },
+    },
+    {{0}}
+  }
+};
+
+
+
+typedef struct {
+  FT_Library ft_library;
+  FT_Face ft_face;
+  hb_font_t *font;
+} ft_fixture_t;
+
+static void
+ft_fixture_init (ft_fixture_t *f, gconstpointer user_data)
+{
+  const test_set_t *test = user_data;
+  char *font_file = g_strdup_printf ("%s/fonts/%s", srcdir (), test->font_file);
+
+  FT_Init_FreeType (&f->ft_library);
+
+  if (FT_New_Face (f->ft_library, font_file, test->face_index, &f->ft_face))
+    g_test_message ("Font file %s not found.  Skipping test.", font_file);
+  else
+    f->font = hb_ft_font_create (f->ft_face, NULL);
+
+  g_free (font_file);
+}
+
+static void
+ft_fixture_finish (ft_fixture_t *f, gconstpointer user_data)
+{
+  hb_font_destroy (f->font);
+
+  FT_Done_Face (f->ft_face);
+  FT_Done_FreeType (f->ft_library);
+}
+
+static void
+test_shape_complex (ft_fixture_t *f, gconstpointer user_data)
+{
+  const test_set_t *test_set = user_data;
+  const test_t *test;
+
+  if (!f->font)
+    return; /* Skip test */
+
+  for (test = test_set->tests; test->characters[0]; test++) {
+    hb_buffer_t *buffer;
+    unsigned int i, len, expected_len;
+    hb_glyph_info_t *glyphs;
+
+    if (test->comments[0])
+      g_test_message ("Test comments: %s", test->comments);
+
+    buffer =  hb_buffer_create (0);
+    for (len = 0; test->characters[len]; len++) ;
+    hb_buffer_add_utf32 (buffer, test->characters, len, 0, len);
+
+    hb_shape (f->font, buffer, NULL, 0);
+
+    for (len = 0; test->glyphs[len]; len++) ;
+    expected_len = len;
+
+    glyphs = hb_buffer_get_glyph_infos (buffer, &len);
+    g_assert_cmpint (len, ==, expected_len);
+    for (i = 0; i < len; i++)
+      g_assert_cmphex (glyphs[i].codepoint, ==, test->glyphs[i]);
+
+    hb_buffer_destroy (buffer);
+  }
+}
+
+
+
+
+int
+main (int argc, char **argv)
+{
+  hb_test_init (&argc, &argv);
+
+#define TEST_SET(name) hb_test_add_fixture_flavor (ft_fixture, (const void *) &tests_##name, #name, test_shape_complex)
+
+  TEST_SET (greek);
+
+  TEST_SET (devanagari_1);
+  TEST_SET (devanagari_2);
+  TEST_SET (bengali_1);
+  TEST_SET (bengali_2);
+  TEST_SET (bengali_3);
+  TEST_SET (gurmukhi);
+  TEST_SET (oriya);
+  TEST_SET (tamil);
+  TEST_SET (telugu);
+  TEST_SET (kannada_1);
+  TEST_SET (kannada_2);
+  TEST_SET (malayalam_1);
+  TEST_SET (malayalam_2);
+  TEST_SET (sinhala);
+
+  TEST_SET (khmer);
+
+  TEST_SET (nko);
+  TEST_SET (linearb);
+
+  return hb_test_run();
+}
commit 8fdba506f0f1c66b50f8f4b114d624cb956d03b7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 24 20:45:55 2011 -0400

    [Indic] Define indic_position_t

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index a6edf85..cfd7bb4 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -56,6 +56,17 @@ enum indic_category_t {
   OT_NBSP
 };
 
+/* Visual positions in a syllable from left to right. */
+enum indic_position_t {
+  POS_PRE,
+  POS_BASE,
+  POS_ABOVE,
+  POS_BELOW,
+  POS_POST,
+
+  POS_INHERIT /* For Halant, Nukta, ZWJ, ZWNJ */
+};
+
 /* Categories used in IndicSyllabicCategory.txt from UCD */
 /* The assignments are guesswork */
 enum indic_syllabic_category_t {
@@ -85,31 +96,25 @@ enum indic_syllabic_category_t {
 
 /* Categories used in IndicSMatraCategory.txt from UCD */
 enum indic_matra_category_t {
-  INDIC_MATRA_CATEGORY_NOT_APPLICABLE		= 0,
+  INDIC_MATRA_CATEGORY_NOT_APPLICABLE		= POS_BASE,
 
-  INDIC_MATRA_CATEGORY_LEFT			= 0x01,
-  INDIC_MATRA_CATEGORY_TOP			= 0x02,
-  INDIC_MATRA_CATEGORY_BOTTOM			= 0x04,
-  INDIC_MATRA_CATEGORY_RIGHT			= 0x08,
+  INDIC_MATRA_CATEGORY_LEFT			= POS_PRE,
+  INDIC_MATRA_CATEGORY_TOP			= POS_ABOVE,
+  INDIC_MATRA_CATEGORY_BOTTOM			= POS_BELOW,
+  INDIC_MATRA_CATEGORY_RIGHT			= POS_POST,
 
   /* We don't really care much about these since we decompose them
-   * in the generic pre-shaping layer. */
-  INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT		= INDIC_MATRA_CATEGORY_BOTTOM +
-						  INDIC_MATRA_CATEGORY_RIGHT,
-  INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT		= INDIC_MATRA_CATEGORY_LEFT +
-						  INDIC_MATRA_CATEGORY_RIGHT,
-  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM		= INDIC_MATRA_CATEGORY_TOP +
-						  INDIC_MATRA_CATEGORY_BOTTOM,
-  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT	= INDIC_MATRA_CATEGORY_TOP +
-						  INDIC_MATRA_CATEGORY_BOTTOM +
-						  INDIC_MATRA_CATEGORY_RIGHT,
-  INDIC_MATRA_CATEGORY_TOP_AND_LEFT		= INDIC_MATRA_CATEGORY_TOP +
-						  INDIC_MATRA_CATEGORY_LEFT,
-  INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT	= INDIC_MATRA_CATEGORY_TOP +
-						  INDIC_MATRA_CATEGORY_LEFT +
-						  INDIC_MATRA_CATEGORY_RIGHT,
-  INDIC_MATRA_CATEGORY_TOP_AND_RIGHT		= INDIC_MATRA_CATEGORY_TOP +
-						  INDIC_MATRA_CATEGORY_RIGHT,
+   * in the generic pre-shaping layer.  They will only be used if
+   * the font does not cover the decomposition.  In which case, we
+   * define these as aliases to the place we want the split-matra
+   * glyph to show up.  Quite arbitrary. */
+  INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT		= INDIC_MATRA_CATEGORY_BOTTOM,
+  INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT		= INDIC_MATRA_CATEGORY_LEFT,
+  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM		= INDIC_MATRA_CATEGORY_BOTTOM,
+  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT	= INDIC_MATRA_CATEGORY_BOTTOM,
+  INDIC_MATRA_CATEGORY_TOP_AND_LEFT		= INDIC_MATRA_CATEGORY_LEFT,
+  INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT	= INDIC_MATRA_CATEGORY_LEFT,
+  INDIC_MATRA_CATEGORY_TOP_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
 
   INDIC_MATRA_CATEGORY_INVISIBLE		= INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
   INDIC_MATRA_CATEGORY_OVERSTRUCK		= INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
@@ -131,102 +136,102 @@ enum indic_matra_category_t {
  */
 static const struct {
   hb_codepoint_t u;
-  indic_matra_category_t position;
+  indic_position_t position;
 } consonant_positions[] = {
-  {0x0930, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x09AC, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x09AF, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x09B0, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x09F0, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0A2F, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x0A30, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0A35, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0A39, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0AB0, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B24, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B28, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B2C, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B2D, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B2E, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B2F, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x0B30, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B32, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B33, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0B5F, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x0B71, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C15, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C16, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C17, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C18, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C19, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1A, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1B, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1C, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1D, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1E, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C1F, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C20, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C21, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C22, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C23, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C24, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C25, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C26, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C27, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C28, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2A, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2B, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2C, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2D, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2E, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C2F, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C30, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C32, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C33, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C35, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C36, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C37, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C38, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C39, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C95, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C96, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C97, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C98, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C99, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9A, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9B, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9C, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9D, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9E, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0C9F, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA0, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA1, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA2, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA3, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA4, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA5, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA6, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA7, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CA8, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAA, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAB, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAC, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAD, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAE, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CAF, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB0, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB2, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB3, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB5, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB6, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB7, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB8, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CB9, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0CDE, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0D2F, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x0D30, INDIC_MATRA_CATEGORY_RIGHT},
-  {0x0D32, INDIC_MATRA_CATEGORY_BOTTOM},
-  {0x0D35, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0930, POS_BELOW},
+  {0x09AC, POS_BELOW},
+  {0x09AF, POS_POST},
+  {0x09B0, POS_BELOW},
+  {0x09F0, POS_BELOW},
+  {0x0A2F, POS_POST},
+  {0x0A30, POS_BELOW},
+  {0x0A35, POS_BELOW},
+  {0x0A39, POS_BELOW},
+  {0x0AB0, POS_BELOW},
+  {0x0B24, POS_BELOW},
+  {0x0B28, POS_BELOW},
+  {0x0B2C, POS_BELOW},
+  {0x0B2D, POS_BELOW},
+  {0x0B2E, POS_BELOW},
+  {0x0B2F, POS_POST},
+  {0x0B30, POS_BELOW},
+  {0x0B32, POS_BELOW},
+  {0x0B33, POS_BELOW},
+  {0x0B5F, POS_POST},
+  {0x0B71, POS_BELOW},
+  {0x0C15, POS_BELOW},
+  {0x0C16, POS_BELOW},
+  {0x0C17, POS_BELOW},
+  {0x0C18, POS_BELOW},
+  {0x0C19, POS_BELOW},
+  {0x0C1A, POS_BELOW},
+  {0x0C1B, POS_BELOW},
+  {0x0C1C, POS_BELOW},
+  {0x0C1D, POS_BELOW},
+  {0x0C1E, POS_BELOW},
+  {0x0C1F, POS_BELOW},
+  {0x0C20, POS_BELOW},
+  {0x0C21, POS_BELOW},
+  {0x0C22, POS_BELOW},
+  {0x0C23, POS_BELOW},
+  {0x0C24, POS_BELOW},
+  {0x0C25, POS_BELOW},
+  {0x0C26, POS_BELOW},
+  {0x0C27, POS_BELOW},
+  {0x0C28, POS_BELOW},
+  {0x0C2A, POS_BELOW},
+  {0x0C2B, POS_BELOW},
+  {0x0C2C, POS_BELOW},
+  {0x0C2D, POS_BELOW},
+  {0x0C2E, POS_BELOW},
+  {0x0C2F, POS_BELOW},
+  {0x0C30, POS_BELOW},
+  {0x0C32, POS_BELOW},
+  {0x0C33, POS_BELOW},
+  {0x0C35, POS_BELOW},
+  {0x0C36, POS_BELOW},
+  {0x0C37, POS_BELOW},
+  {0x0C38, POS_BELOW},
+  {0x0C39, POS_BELOW},
+  {0x0C95, POS_BELOW},
+  {0x0C96, POS_BELOW},
+  {0x0C97, POS_BELOW},
+  {0x0C98, POS_BELOW},
+  {0x0C99, POS_BELOW},
+  {0x0C9A, POS_BELOW},
+  {0x0C9B, POS_BELOW},
+  {0x0C9C, POS_BELOW},
+  {0x0C9D, POS_BELOW},
+  {0x0C9E, POS_BELOW},
+  {0x0C9F, POS_BELOW},
+  {0x0CA0, POS_BELOW},
+  {0x0CA1, POS_BELOW},
+  {0x0CA2, POS_BELOW},
+  {0x0CA3, POS_BELOW},
+  {0x0CA4, POS_BELOW},
+  {0x0CA5, POS_BELOW},
+  {0x0CA6, POS_BELOW},
+  {0x0CA7, POS_BELOW},
+  {0x0CA8, POS_BELOW},
+  {0x0CAA, POS_BELOW},
+  {0x0CAB, POS_BELOW},
+  {0x0CAC, POS_BELOW},
+  {0x0CAD, POS_BELOW},
+  {0x0CAE, POS_BELOW},
+  {0x0CAF, POS_BELOW},
+  {0x0CB0, POS_BELOW},
+  {0x0CB2, POS_BELOW},
+  {0x0CB3, POS_BELOW},
+  {0x0CB5, POS_BELOW},
+  {0x0CB6, POS_BELOW},
+  {0x0CB7, POS_BELOW},
+  {0x0CB8, POS_BELOW},
+  {0x0CB9, POS_BELOW},
+  {0x0CDE, POS_BELOW},
+  {0x0D2F, POS_POST},
+  {0x0D30, POS_POST},
+  {0x0D32, POS_BELOW},
+  {0x0D35, POS_POST},
 };
 
 
commit 65988a145b4a52c37fd53c1473034f9e701f61d9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 24 19:05:52 2011 -0400

    [Indic] Add a table of consonant positions
    
    Copied form HarfBuzz.old Indic data.  These are below and post
    consonants.  This is temporary.  Read the comment in the patch.

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 3541260..a6edf85 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -123,6 +123,112 @@ enum indic_matra_category_t {
 
 #include "hb-ot-shape-complex-indic-table.hh"
 
+/* XXX
+ * This is a hack for now.  We should:
+ * 1. Move this data into the main Indic table,
+ * and/or
+ * 2. Probe font lookups to determine consonant positions.
+ */
+static const struct {
+  hb_codepoint_t u;
+  indic_matra_category_t position;
+} consonant_positions[] = {
+  {0x0930, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x09AC, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x09AF, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x09B0, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x09F0, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0A2F, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0A30, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0A35, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0A39, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0AB0, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B24, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B28, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B2C, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B2D, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B2E, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B2F, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0B30, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B32, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B33, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0B5F, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0B71, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C15, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C16, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C17, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C18, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C19, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1A, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1B, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1C, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1D, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1E, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C1F, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C20, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C21, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C22, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C23, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C24, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C25, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C26, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C27, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C28, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2A, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2B, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2C, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2D, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2E, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C2F, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C30, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C32, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C33, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C35, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C36, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C37, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C38, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C39, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C95, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C96, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C97, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C98, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C99, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9A, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9B, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9C, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9D, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9E, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0C9F, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA0, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA1, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA2, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA3, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA4, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA5, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA6, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA7, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CA8, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAA, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAB, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAC, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAD, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAE, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CAF, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB0, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB2, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB3, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB5, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB6, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB7, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB8, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CB9, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0CDE, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0D2F, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0D30, INDIC_MATRA_CATEGORY_RIGHT},
+  {0x0D32, INDIC_MATRA_CATEGORY_BOTTOM},
+  {0x0D35, INDIC_MATRA_CATEGORY_RIGHT},
+};
+
 
 static const struct {
   hb_tag_t tag;
commit c7fe56a1d5d3e969b6ec51cd9ecd471706a19568
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 24 19:05:34 2011 -0400

    [Indic] Some of the basic features are global;  Mark them so

diff --git a/src/hb-ot-shape-complex-indic-machine.rl b/src/hb-ot-shape-complex-indic-machine.rl
index ba0b007..f65995b 100644
--- a/src/hb-ot-shape-complex-indic-machine.rl
+++ b/src/hb-ot-shape-complex-indic-machine.rl
@@ -39,6 +39,7 @@ HB_BEGIN_DECLS
 
 %%{
 
+# Same order as enum indic_category_t.  Not sure how to avoid duplication.
 X    = 0;
 C    = 1;
 Ra   = 2;
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index c52c5f7..3541260 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -38,10 +38,12 @@ HB_BEGIN_DECLS
 /* Cateories used in the OpenType spec:
  * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
  */
+/* Note: This enum is duplicated in the -machine.rl source file.
+ * Not sure how to avoid duplication. */
 enum indic_category_t {
   OT_X = 0,
   OT_C,
-  OT_Ra,
+  OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */
   OT_V,
   OT_N,
   OT_H,
@@ -121,18 +123,36 @@ enum indic_matra_category_t {
 
 #include "hb-ot-shape-complex-indic-table.hh"
 
-static const hb_tag_t indic_basic_features[] =
+
+static const struct {
+  hb_tag_t tag;
+  hb_bool_t is_global;
+} indic_basic_features[] =
 {
-  HB_TAG('n','u','k','t'),
-  HB_TAG('a','k','h','n'),
-  HB_TAG('r','p','h','f'),
-  HB_TAG('r','k','r','f'),
-  HB_TAG('p','r','e','f'),
-  HB_TAG('b','l','w','f'),
-  HB_TAG('h','a','l','f'),
-  HB_TAG('v','a','t','u'),
-  HB_TAG('p','s','t','f'),
-  HB_TAG('c','j','c','t'),
+  {HB_TAG('n','u','k','t'), true},
+  {HB_TAG('a','k','h','n'), false},
+  {HB_TAG('r','p','h','f'), false},
+  {HB_TAG('r','k','r','f'), false},
+  {HB_TAG('p','r','e','f'), false},
+  {HB_TAG('b','l','w','f'), false},
+  {HB_TAG('h','a','l','f'), false},
+  {HB_TAG('v','a','t','u'), true},
+  {HB_TAG('p','s','t','f'), false},
+  {HB_TAG('c','j','c','t'), true},
+};
+
+/* Same order as the indic_basic_features array */
+enum {
+  _NUKT,
+  AKHN,
+  RPHF,
+  RKRF,
+  PREF,
+  BLWF,
+  HALF,
+  _VATU,
+  PSTF,
+  _CJCT,
 };
 
 static const hb_tag_t indic_other_features[] =
@@ -153,7 +173,7 @@ void
 _hb_ot_shape_complex_collect_features_indic (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props HB_UNUSED)
 {
   for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++)
-    planner->map.add_bool_feature (indic_basic_features[i], false);
+    planner->map.add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global);
 
   for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++)
     planner->map.add_bool_feature (indic_other_features[i], true);
@@ -182,7 +202,7 @@ _hb_ot_shape_complex_setup_masks_indic	(hb_ot_shape_context_t *c)
   hb_mask_t mask_array[ARRAY_LENGTH (indic_basic_features)] = {0};
   unsigned int num_masks = ARRAY_LENGTH (indic_basic_features);
   for (unsigned int i = 0; i < num_masks; i++)
-    mask_array[i] = c->plan->map.get_1_mask (indic_basic_features[i]);
+    mask_array[i] = c->plan->map.get_1_mask (indic_basic_features[i].tag);
 }
 
 



More information about the HarfBuzz mailing list