Removed DOS style line endings
authorsamsung <samsung@ubuntu-desktop.(none)>
Thu, 8 Apr 2010 05:38:37 +0000 (11:08 +0530)
committersamsung <samsung@ubuntu-desktop.(none)>
Thu, 8 Apr 2010 05:38:37 +0000 (11:08 +0530)
99 files changed:
harfbuzz-0.1/debian/changelog
harfbuzz-0.1/debian/files
harfbuzz-0.1/debian/libharfbuzz-dbg/DEBIAN/control
harfbuzz-0.1/debian/libharfbuzz-dbg/DEBIAN/md5sums
harfbuzz-0.1/debian/libharfbuzz-dbg/usr/share/doc/libharfbuzz-dbg/changelog.Debian.gz
harfbuzz-0.1/debian/libharfbuzz-dev/DEBIAN/control
harfbuzz-0.1/debian/libharfbuzz-dev/DEBIAN/md5sums
harfbuzz-0.1/debian/libharfbuzz-dev/usr/share/doc/libharfbuzz-dev/changelog.Debian.gz
harfbuzz-0.1/debian/libharfbuzz/DEBIAN/control
harfbuzz-0.1/debian/libharfbuzz/DEBIAN/md5sums
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-buffer-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-buffer.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-dump.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-external.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gdef-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gdef.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-global.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gpos-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gpos.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gsub-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-gsub.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-impl.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-open-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-open.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-shape.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-shaper-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-shaper.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-stream-private.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz-stream.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/harfbuzz.h
harfbuzz-0.1/debian/libharfbuzz/usr/include/harfbuzz/hb_unicode_tables.h
harfbuzz-0.1/debian/libharfbuzz/usr/share/doc/libharfbuzz/changelog.Debian.gz
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-buffer-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-buffer.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-dump.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-external.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gdef-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gdef.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-global.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gpos-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gpos.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gsub-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-gsub.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-impl.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-open-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-open.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-shape.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-shaper-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-shaper.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-stream-private.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz-stream.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/harfbuzz.h
harfbuzz-0.1/debian/tmp/usr/include/harfbuzz/hb_unicode_tables.h
harfbuzz-0.1/debian/tmp/usr/lib/libharfbuzz.so
harfbuzz-0.1/harfbuzz-dump.o
harfbuzz-0.1/harfbuzz-external.o
harfbuzz-0.1/harfbuzz-shaper-all.o
harfbuzz-0.1/harfbuzz.o
harfbuzz-0.1/include/harfbuzz-buffer-private.h
harfbuzz-0.1/include/harfbuzz-buffer.h
harfbuzz-0.1/include/harfbuzz-dump.h
harfbuzz-0.1/include/harfbuzz-external.h
harfbuzz-0.1/include/harfbuzz-gdef-private.h
harfbuzz-0.1/include/harfbuzz-gdef.h
harfbuzz-0.1/include/harfbuzz-global.h
harfbuzz-0.1/include/harfbuzz-gpos-private.h
harfbuzz-0.1/include/harfbuzz-gpos.h
harfbuzz-0.1/include/harfbuzz-gsub-private.h
harfbuzz-0.1/include/harfbuzz-gsub.h
harfbuzz-0.1/include/harfbuzz-impl.h
harfbuzz-0.1/include/harfbuzz-open-private.h
harfbuzz-0.1/include/harfbuzz-open.h
harfbuzz-0.1/include/harfbuzz-shape.h
harfbuzz-0.1/include/harfbuzz-shaper-private.h
harfbuzz-0.1/include/harfbuzz-shaper.h
harfbuzz-0.1/include/harfbuzz-stream-private.h
harfbuzz-0.1/include/harfbuzz-stream.h
harfbuzz-0.1/include/harfbuzz.h
harfbuzz-0.1/include/hb_unicode_tables.h
harfbuzz-0.1/src/harfbuzz-arabic.c
harfbuzz-0.1/src/harfbuzz-buffer.c
harfbuzz-0.1/src/harfbuzz-dump.c
harfbuzz-0.1/src/harfbuzz-external.c
harfbuzz-0.1/src/harfbuzz-gdef.c
harfbuzz-0.1/src/harfbuzz-gpos.c
harfbuzz-0.1/src/harfbuzz-gsub.c
harfbuzz-0.1/src/harfbuzz-hangul.c
harfbuzz-0.1/src/harfbuzz-hebrew.c
harfbuzz-0.1/src/harfbuzz-impl.c
harfbuzz-0.1/src/harfbuzz-indic.c
harfbuzz-0.1/src/harfbuzz-khmer.c
harfbuzz-0.1/src/harfbuzz-myanmar.c
harfbuzz-0.1/src/harfbuzz-open.c
harfbuzz-0.1/src/harfbuzz-shaper-all.c
harfbuzz-0.1/src/harfbuzz-shaper.c
harfbuzz-0.1/src/harfbuzz-stream.c
harfbuzz-0.1/src/harfbuzz-thai.c
harfbuzz-0.1/src/harfbuzz-tibetan.c
harfbuzz-0.1/src/harfbuzz.c

index 9c6f930..bb223e6 100755 (executable)
@@ -1,3 +1,15 @@
+harfbuzz (0.4.0-1slp2+5) unstable; urgency=low
+
+  * Removed DOS style line endings 
+
+ -- Janani <janani.k@samsung.com>  Thu, 08 Apr 2010 10:53:45 +0530
+
+harfbuzz (0.4.0-1slp2+4) unstable; urgency=low
+
+  * Minor changes 
+
+ -- Janani <janani.k@samsung.com>  Tue, 06 Apr 2010 13:14:09 +0530
+
 harfbuzz (0.4.0-1slp2+3) unstable; urgency=low
 
   * Modified makefile and install file
index 25f4372..c0beb5c 100755 (executable)
@@ -1,3 +1,3 @@
-libharfbuzz_0.4.0-1slp2+3_armel.deb libs optional
-libharfbuzz-dev_0.4.0-1slp2+3_armel.deb libdevel optional
-libharfbuzz-dbg_0.4.0-1slp2+3_armel.deb debug optional
+libharfbuzz_0.4.0-1slp2+4_armel.deb libs optional
+libharfbuzz-dev_0.4.0-1slp2+4_armel.deb libdevel optional
+libharfbuzz-dbg_0.4.0-1slp2+4_armel.deb debug optional
index 1f3e7a9..793f57f 100755 (executable)
@@ -1,10 +1,10 @@
 Package: libharfbuzz-dbg
 Source: harfbuzz
-Version: 0.4.0-1slp2+3
+Version: 0.4.0-1slp2+4
 Architecture: armel
 Maintainer: janani <janani.k@samsung.com>
 Installed-Size: 52
-Depends: libharfbuzz (= 0.4.0-1slp2+3)
+Depends: libharfbuzz (= 0.4.0-1slp2+4)
 Section: debug
 Priority: optional
 Description: Hindi reshaping library (unstripped)
index 92bc495..1501549 100755 (executable)
@@ -1,3 +1,3 @@
 93e65ad0ab6ed5807bad917b9f2331ec  usr/lib/debug/usr/lib/libharfbuzz.so
-0bb889780a7cf71cd4ed473423126967  usr/share/doc/libharfbuzz-dbg/changelog.Debian.gz
+03a837c13bdeffc82c8a8b2634bf360d  usr/share/doc/libharfbuzz-dbg/changelog.Debian.gz
 df1d54271f4722f7e2b3bcfdf7b69ddd  usr/share/doc/libharfbuzz-dbg/copyright
index abee691..4f2ce80 100755 (executable)
Binary files a/harfbuzz-0.1/debian/libharfbuzz-dbg/usr/share/doc/libharfbuzz-dbg/changelog.Debian.gz and b/harfbuzz-0.1/debian/libharfbuzz-dbg/usr/share/doc/libharfbuzz-dbg/changelog.Debian.gz differ
index b92bdaa..ee859c7 100755 (executable)
@@ -1,10 +1,10 @@
 Package: libharfbuzz-dev
 Source: harfbuzz
-Version: 0.4.0-1slp2+3
+Version: 0.4.0-1slp2+4
 Architecture: armel
 Maintainer: janani <janani.k@samsung.com>
 Installed-Size: 32
-Depends: libharfbuzz (= 0.4.0-1slp2+3)
+Depends: libharfbuzz (= 0.4.0-1slp2+4)
 Section: libdevel
 Priority: optional
 Description: Hindi reshaping library (unstripped)
index d46dfb4..ff6905a 100755 (executable)
@@ -1,2 +1,2 @@
-0bb889780a7cf71cd4ed473423126967  usr/share/doc/libharfbuzz-dev/changelog.Debian.gz
+03a837c13bdeffc82c8a8b2634bf360d  usr/share/doc/libharfbuzz-dev/changelog.Debian.gz
 df1d54271f4722f7e2b3bcfdf7b69ddd  usr/share/doc/libharfbuzz-dev/copyright
index abee691..4f2ce80 100755 (executable)
Binary files a/harfbuzz-0.1/debian/libharfbuzz-dev/usr/share/doc/libharfbuzz-dev/changelog.Debian.gz and b/harfbuzz-0.1/debian/libharfbuzz-dev/usr/share/doc/libharfbuzz-dev/changelog.Debian.gz differ
index fd738dc..e4b363d 100755 (executable)
@@ -1,9 +1,9 @@
 Package: libharfbuzz
 Source: harfbuzz
-Version: 0.4.0-1slp2+3
+Version: 0.4.0-1slp2+4
 Architecture: armel
 Maintainer: janani <janani.k@samsung.com>
-Installed-Size: 544
+Installed-Size: 536
 Section: libs
 Priority: optional
 Description: Hindi Reshaping Library
index 74051c6..f2b2811 100755 (executable)
@@ -1,25 +1,25 @@
 9b0bfea1e5ca29ab694bb66e0c7806d5  usr/lib/pkgconfig/harfbuzz.pc
 a2cee363d5fe3f089785f3dab5cdece0  usr/lib/libharfbuzz.so
-0bb889780a7cf71cd4ed473423126967  usr/share/doc/libharfbuzz/changelog.Debian.gz
+03a837c13bdeffc82c8a8b2634bf360d  usr/share/doc/libharfbuzz/changelog.Debian.gz
 df1d54271f4722f7e2b3bcfdf7b69ddd  usr/share/doc/libharfbuzz/copyright
-f07cf3f8659df2a666184c3c043c57fa  usr/include/harfbuzz/harfbuzz-buffer.h
-47748f702eb5274fddb2135b2477317f  usr/include/harfbuzz/harfbuzz-gsub.h
-83721b07d4299f8ab0fe55fa0d976fc3  usr/include/harfbuzz/harfbuzz.h
-134cf9413e3fbbc6d0eea62bd4b16682  usr/include/harfbuzz/harfbuzz-gdef-private.h
-6e42a9e70afbfa731771b4565152f8cc  usr/include/harfbuzz/harfbuzz-shaper-private.h
-9df5ea3e3b974f2940595a3adacb5303  usr/include/harfbuzz/harfbuzz-gpos-private.h
-32096ebe2fd5d49e37875b0a72f0f4bc  usr/include/harfbuzz/harfbuzz-gpos.h
-416859ec08a3566b35d457a9a15420ac  usr/include/harfbuzz/harfbuzz-stream-private.h
-f3febd1da5508f366c7ea622e22525b9  usr/include/harfbuzz/harfbuzz-external.h
-6e3ed9f28485fecfe3fd391b65b889e6  usr/include/harfbuzz/harfbuzz-open-private.h
-088511a85a252f02d62ae630379bf9e9  usr/include/harfbuzz/harfbuzz-shaper.h
-cfc2582df6ae2fa569e7d2aeebc98574  usr/include/harfbuzz/harfbuzz-shape.h
-5832347c18af6fd511e4f023ab549098  usr/include/harfbuzz/harfbuzz-open.h
-6b2506726da5a95f96a2ea679e2ba609  usr/include/harfbuzz/harfbuzz-stream.h
-ad9e0bd699461a9bde278e39327dd07a  usr/include/harfbuzz/harfbuzz-global.h
-f7e5472b9dd9fa8348e09383f3c44aaf  usr/include/harfbuzz/harfbuzz-impl.h
-4ca1f40b516f0f5a0fd6a9bf5b0f49a4  usr/include/harfbuzz/harfbuzz-gsub-private.h
-c394005fdbe3daa995350f04b4692e35  usr/include/harfbuzz/harfbuzz-gdef.h
-4b1e1188405946bfa9627e3ea83779bd  usr/include/harfbuzz/hb_unicode_tables.h
-52d48ff2e2fc1e33feb94d1749c4f724  usr/include/harfbuzz/harfbuzz-dump.h
-88824c157a2d24a43b50e5d4138f54c8  usr/include/harfbuzz/harfbuzz-buffer-private.h
+4c95527607ebe81b3b87094d25f27d6f  usr/include/harfbuzz/harfbuzz-buffer.h
+4a7663d206e00bb042dba9fabd243ae9  usr/include/harfbuzz/harfbuzz-gsub.h
+65dfc4afe912b56f394c8985cfcf982e  usr/include/harfbuzz/harfbuzz.h
+fb2e84d414e994fd6d47da65f29df300  usr/include/harfbuzz/harfbuzz-gdef-private.h
+8806581e394a1a3a0099fce9f7ae5bb7  usr/include/harfbuzz/harfbuzz-shaper-private.h
+111f7fed581aa11bbe2ee382dd96546e  usr/include/harfbuzz/harfbuzz-gpos-private.h
+654ef5dddd2ddde763009bb010f93f9e  usr/include/harfbuzz/harfbuzz-gpos.h
+7f73615794097fc97880721f7c3844fa  usr/include/harfbuzz/harfbuzz-stream-private.h
+3301fa97e5569747a02bd14cf18c87e3  usr/include/harfbuzz/harfbuzz-external.h
+54dd91224a24321989a911c28f5189d0  usr/include/harfbuzz/harfbuzz-open-private.h
+e20e7a6e21d4a30ce787e19822e6a137  usr/include/harfbuzz/harfbuzz-shaper.h
+a60482b499aab325c2f4fb04d7d8d218  usr/include/harfbuzz/harfbuzz-shape.h
+cad7ee9763ed7cf8ab8c19a9cd032037  usr/include/harfbuzz/harfbuzz-open.h
+c67245642f9cfbe111845d1295e1a1df  usr/include/harfbuzz/harfbuzz-stream.h
+506fe3027f7d09525d8656a6e75fb28f  usr/include/harfbuzz/harfbuzz-global.h
+19ceb1cfa7341882723952dbfef77886  usr/include/harfbuzz/harfbuzz-impl.h
+0e5f19fed6de3112c16c3c2a00add25b  usr/include/harfbuzz/harfbuzz-gsub-private.h
+ee979fb624827ff36c3f43e6d95ce2ac  usr/include/harfbuzz/harfbuzz-gdef.h
+29c5d48f316d72850f83d50fd602e18a  usr/include/harfbuzz/hb_unicode_tables.h
+5a35d8724db16ab426ef6e730514f3cc  usr/include/harfbuzz/harfbuzz-dump.h
+f700543a6ea295f677155f9e8aa38846  usr/include/harfbuzz/harfbuzz-buffer-private.h
index 1b039ba..5065f2e 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_PRIVATE_H\r
-#define HARFBUZZ_BUFFER_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_swap( HB_Buffer buffer );\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_clear_output( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_clear_positions( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyphs( HB_Buffer  buffer,\r
-                             HB_UShort  num_in,\r
-                             HB_UShort  num_out,\r
-                             HB_UShort *glyph_data,\r
-                             HB_UShort  component,\r
-                             HB_UShort  ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyph ( HB_Buffer buffer,\r
-                             HB_UInt   glyph_index,\r
-                             HB_UShort component,\r
-                             HB_UShort ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_replace_output_glyph ( HB_Buffer buffer,\r
-                                 HB_UInt   glyph_index,\r
-                                 HB_Bool   inplace );\r
-\r
-HB_INTERNAL HB_UShort\r
-_hb_buffer_allocate_ligid( HB_Buffer buffer );\r
-\r
-\r
-/* convenience macros */\r
-\r
-#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)\r
-#define IN_ITEM( pos )         (&buffer->in_string[(pos)])\r
-#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)\r
-#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])\r
-#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)\r
-#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)\r
-#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)\r
-#define POSITION( pos )        (&buffer->positions[(pos)])\r
-#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)\r
-#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])\r
-\r
-#define CHECK_Property( gdef, index, flags, property )                                 \\r
-          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \\r
-                                      (property) ) ) != HB_Err_Ok )\r
-\r
-#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \\r
-          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \\r
-                                                   (num_in), (num_out),                \\r
-                                                    (glyph_data), (component), (ligID)  \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \\r
-          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \\r
-                                                    (glyph_index), (component), (ligID) \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \\r
-          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \\r
-                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )\r
-#define COPY_Glyph( buffer )                                                           \\r
-         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_PRIVATE_H
+#define HARFBUZZ_BUFFER_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
+
+HB_INTERNAL void
+_hb_buffer_swap( HB_Buffer buffer );
+
+HB_INTERNAL void
+_hb_buffer_clear_output( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_clear_positions( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyphs( HB_Buffer  buffer,
+                             HB_UShort  num_in,
+                             HB_UShort  num_out,
+                             HB_UShort *glyph_data,
+                             HB_UShort  component,
+                             HB_UShort  ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyph ( HB_Buffer buffer,
+                             HB_UInt   glyph_index,
+                             HB_UShort component,
+                             HB_UShort ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_copy_output_glyph ( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_replace_output_glyph ( HB_Buffer buffer,
+                                 HB_UInt   glyph_index,
+                                 HB_Bool   inplace );
+
+HB_INTERNAL HB_UShort
+_hb_buffer_allocate_ligid( HB_Buffer buffer );
+
+
+/* convenience macros */
+
+#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)
+#define IN_ITEM( pos )         (&buffer->in_string[(pos)])
+#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)
+#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])
+#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)
+#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)
+#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)
+#define POSITION( pos )        (&buffer->positions[(pos)])
+#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)
+#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])
+
+#define CHECK_Property( gdef, index, flags, property )                                 \
+          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \
+                                      (property) ) ) != HB_Err_Ok )
+
+#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \
+          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \
+                                                   (num_in), (num_out),                \
+                                                    (glyph_data), (component), (ligID)  \
+                                                  ) ) != HB_Err_Ok )
+#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \
+          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \
+                                                    (glyph_index), (component), (ligID) \
+                                                  ) ) != HB_Err_Ok )
+#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \
+          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \
+                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )
+#define COPY_Glyph( buffer )                                                           \
+         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_PRIVATE_H */
index e215e9f..b134407 100755 (executable)
@@ -1,94 +1,94 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_H\r
-#define HARFBUZZ_BUFFER_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_GlyphItemRec_ {\r
-  HB_UInt     gindex;\r
-  HB_UInt     properties;\r
-  HB_UInt     cluster;\r
-  HB_UShort   component;\r
-  HB_UShort   ligID;\r
-  HB_UShort   gproperties;\r
-} HB_GlyphItemRec, *HB_GlyphItem;\r
-\r
-typedef struct HB_PositionRec_ {\r
-  HB_Fixed   x_pos;\r
-  HB_Fixed   y_pos;\r
-  HB_Fixed   x_advance;\r
-  HB_Fixed   y_advance;\r
-  HB_UShort  back;            /* number of glyphs to go back\r
-                                for drawing current glyph   */\r
-  HB_Bool    new_advance;     /* if set, the advance width values are\r
-                                absolute, i.e., they won't be\r
-                                added to the original glyph's value\r
-                                but rather replace them.            */\r
-  HB_Short  cursive_chain;   /* character to which this connects,\r
-                                may be positive or negative; used\r
-                                only internally                     */\r
-} HB_PositionRec, *HB_Position;\r
-\r
-\r
-typedef struct HB_BufferRec_{ \r
-  HB_UInt    allocated;\r
-\r
-  HB_UInt    in_length;\r
-  HB_UInt    out_length;\r
-  HB_UInt    in_pos;\r
-  HB_UInt    out_pos;\r
-  \r
-  HB_Bool       separate_out;\r
-  HB_GlyphItem  in_string;\r
-  HB_GlyphItem  out_string;\r
-  HB_GlyphItem  alt_string;\r
-  HB_Position   positions;\r
-  HB_UShort      max_ligID;\r
-} HB_BufferRec, *HB_Buffer;\r
-\r
-HB_Error\r
-hb_buffer_new( HB_Buffer *buffer );\r
-\r
-void\r
-hb_buffer_free( HB_Buffer buffer );\r
-\r
-void\r
-hb_buffer_clear( HB_Buffer buffer );\r
-\r
-HB_Error\r
-hb_buffer_add_glyph( HB_Buffer buffer,\r
-                     HB_UInt    glyph_index,\r
-                     HB_UInt    properties,\r
-                     HB_UInt    cluster );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_H
+#define HARFBUZZ_BUFFER_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_GlyphItemRec_ {
+  HB_UInt     gindex;
+  HB_UInt     properties;
+  HB_UInt     cluster;
+  HB_UShort   component;
+  HB_UShort   ligID;
+  HB_UShort   gproperties;
+} HB_GlyphItemRec, *HB_GlyphItem;
+
+typedef struct HB_PositionRec_ {
+  HB_Fixed   x_pos;
+  HB_Fixed   y_pos;
+  HB_Fixed   x_advance;
+  HB_Fixed   y_advance;
+  HB_UShort  back;            /* number of glyphs to go back
+                                for drawing current glyph   */
+  HB_Bool    new_advance;     /* if set, the advance width values are
+                                absolute, i.e., they won't be
+                                added to the original glyph's value
+                                but rather replace them.            */
+  HB_Short  cursive_chain;   /* character to which this connects,
+                                may be positive or negative; used
+                                only internally                     */
+} HB_PositionRec, *HB_Position;
+
+
+typedef struct HB_BufferRec_{ 
+  HB_UInt    allocated;
+
+  HB_UInt    in_length;
+  HB_UInt    out_length;
+  HB_UInt    in_pos;
+  HB_UInt    out_pos;
+  
+  HB_Bool       separate_out;
+  HB_GlyphItem  in_string;
+  HB_GlyphItem  out_string;
+  HB_GlyphItem  alt_string;
+  HB_Position   positions;
+  HB_UShort      max_ligID;
+} HB_BufferRec, *HB_Buffer;
+
+HB_Error
+hb_buffer_new( HB_Buffer *buffer );
+
+void
+hb_buffer_free( HB_Buffer buffer );
+
+void
+hb_buffer_clear( HB_Buffer buffer );
+
+HB_Error
+hb_buffer_add_glyph( HB_Buffer buffer,
+                     HB_UInt    glyph_index,
+                     HB_UInt    properties,
+                     HB_UInt    cluster );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_H */
index 5d552e7..ea4a62b 100755 (executable)
@@ -1,41 +1,41 @@
-/*\r
- * Copyright (C) 2000, 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_DUMP_H\r
-#define HARFBUZZ_DUMP_H\r
-\r
-#include <stdio.h>\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);\r
-void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_DUMP_H */\r
+/*
+ * Copyright (C) 2000, 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_DUMP_H
+#define HARFBUZZ_DUMP_H
+
+#include <stdio.h>
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);
+void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_DUMP_H */
index d2e36d6..d064f87 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_EXTERNAL_H\r
-#define HARFBUZZ_EXTERNAL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* This header contains some methods that are not part of\r
-   Harfbuzz itself, but referenced by it.\r
-   They need to be provided by the application/library\r
-*/\r
-\r
-\r
-/*\r
- see http://www.unicode.org/reports/tr14/tr14-19.html\r
- we don't use the XX, AI and CB properties and map them to AL instead.\r
- as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.\r
-*/\r
-typedef enum {\r
-    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,\r
-    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,\r
-    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,\r
-    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,\r
-    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,\r
-    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,\r
-    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK\r
-} HB_LineBreakClass;\r
-\r
-typedef enum \r
-{\r
-    HB_NoCategory,\r
-\r
-    HB_Mark_NonSpacing,          /*   Mn */\r
-    HB_Mark_SpacingCombining,    /*   Mc */\r
-    HB_Mark_Enclosing,           /*   Me */\r
-\r
-    HB_Number_DecimalDigit,      /*   Nd */\r
-    HB_Number_Letter,            /*   Nl */\r
-    HB_Number_Other,             /*   No */\r
-\r
-    HB_Separator_Space,          /*   Zs */\r
-    HB_Separator_Line,           /*   Zl */\r
-    HB_Separator_Paragraph,      /*   Zp */\r
-\r
-    HB_Other_Control,            /*   Cc */\r
-    HB_Other_Format,             /*   Cf */\r
-    HB_Other_Surrogate,          /*   Cs */\r
-    HB_Other_PrivateUse,         /*   Co */\r
-    HB_Other_NotAssigned,        /*   Cn */\r
-\r
-    HB_Letter_Uppercase,         /*   Lu */\r
-    HB_Letter_Lowercase,         /*   Ll */\r
-    HB_Letter_Titlecase,         /*   Lt */\r
-    HB_Letter_Modifier,          /*   Lm */\r
-    HB_Letter_Other,             /*   Lo */\r
-\r
-    HB_Punctuation_Connector,    /*   Pc */\r
-    HB_Punctuation_Dash,         /*   Pd */\r
-    HB_Punctuation_Open,         /*   Ps */\r
-    HB_Punctuation_Close,        /*   Pe */\r
-    HB_Punctuation_InitialQuote, /*   Pi */\r
-    HB_Punctuation_FinalQuote,   /*   Pf */\r
-    HB_Punctuation_Other,        /*   Po */\r
-\r
-    HB_Symbol_Math,              /*   Sm */\r
-    HB_Symbol_Currency,          /*   Sc */\r
-    HB_Symbol_Modifier,          /*   Sk */\r
-    HB_Symbol_Other              /*   So */\r
-} HB_CharCategory;\r
-\r
-typedef enum\r
-{\r
-    HB_Grapheme_Other, \r
-    HB_Grapheme_CR,\r
-    HB_Grapheme_LF,\r
-    HB_Grapheme_Control,\r
-    HB_Grapheme_Extend,\r
-    HB_Grapheme_L, \r
-    HB_Grapheme_V, \r
-    HB_Grapheme_T, \r
-    HB_Grapheme_LV, \r
-    HB_Grapheme_LVT\r
-} HB_GraphemeClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Word_Other,\r
-    HB_Word_Format,\r
-    HB_Word_Katakana,\r
-    HB_Word_ALetter,\r
-    HB_Word_MidLetter,\r
-    HB_Word_MidNum,\r
-    HB_Word_Numeric,\r
-    HB_Word_ExtendNumLet\r
-} HB_WordClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Sentence_Other,\r
-    HB_Sentence_Sep,\r
-    HB_Sentence_Format,\r
-    HB_Sentence_Sp,\r
-    HB_Sentence_Lower,\r
-    HB_Sentence_Upper,\r
-    HB_Sentence_OLetter,\r
-    HB_Sentence_Numeric,\r
-    HB_Sentence_ATerm,\r
-    HB_Sentence_STerm,\r
-    HB_Sentence_Close\r
-} HB_SentenceClass;\r
-\r
-HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);\r
-HB_WordClass HB_GetWordClass(HB_UChar32 ch);\r
-HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);\r
-HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);\r
-\r
-void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);\r
-void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);\r
-HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);\r
-int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);\r
-HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);\r
-\r
-void *HB_Library_Resolve(const char *library, const char *symbol);\r
-\r
-void *HB_TextCodecForMib(int mib);\r
-char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);\r
-void HB_TextCodec_FreeResult(char *);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_EXTERNAL_H
+#define HARFBUZZ_EXTERNAL_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* This header contains some methods that are not part of
+   Harfbuzz itself, but referenced by it.
+   They need to be provided by the application/library
+*/
+
+
+/*
+ see http://www.unicode.org/reports/tr14/tr14-19.html
+ we don't use the XX, AI and CB properties and map them to AL instead.
+ as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.
+*/
+typedef enum {
+    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,
+    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,
+    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,
+    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,
+    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,
+    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,
+    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK
+} HB_LineBreakClass;
+
+typedef enum 
+{
+    HB_NoCategory,
+
+    HB_Mark_NonSpacing,          /*   Mn */
+    HB_Mark_SpacingCombining,    /*   Mc */
+    HB_Mark_Enclosing,           /*   Me */
+
+    HB_Number_DecimalDigit,      /*   Nd */
+    HB_Number_Letter,            /*   Nl */
+    HB_Number_Other,             /*   No */
+
+    HB_Separator_Space,          /*   Zs */
+    HB_Separator_Line,           /*   Zl */
+    HB_Separator_Paragraph,      /*   Zp */
+
+    HB_Other_Control,            /*   Cc */
+    HB_Other_Format,             /*   Cf */
+    HB_Other_Surrogate,          /*   Cs */
+    HB_Other_PrivateUse,         /*   Co */
+    HB_Other_NotAssigned,        /*   Cn */
+
+    HB_Letter_Uppercase,         /*   Lu */
+    HB_Letter_Lowercase,         /*   Ll */
+    HB_Letter_Titlecase,         /*   Lt */
+    HB_Letter_Modifier,          /*   Lm */
+    HB_Letter_Other,             /*   Lo */
+
+    HB_Punctuation_Connector,    /*   Pc */
+    HB_Punctuation_Dash,         /*   Pd */
+    HB_Punctuation_Open,         /*   Ps */
+    HB_Punctuation_Close,        /*   Pe */
+    HB_Punctuation_InitialQuote, /*   Pi */
+    HB_Punctuation_FinalQuote,   /*   Pf */
+    HB_Punctuation_Other,        /*   Po */
+
+    HB_Symbol_Math,              /*   Sm */
+    HB_Symbol_Currency,          /*   Sc */
+    HB_Symbol_Modifier,          /*   Sk */
+    HB_Symbol_Other              /*   So */
+} HB_CharCategory;
+
+typedef enum
+{
+    HB_Grapheme_Other, 
+    HB_Grapheme_CR,
+    HB_Grapheme_LF,
+    HB_Grapheme_Control,
+    HB_Grapheme_Extend,
+    HB_Grapheme_L, 
+    HB_Grapheme_V, 
+    HB_Grapheme_T, 
+    HB_Grapheme_LV, 
+    HB_Grapheme_LVT
+} HB_GraphemeClass;
+
+
+typedef enum
+{
+    HB_Word_Other,
+    HB_Word_Format,
+    HB_Word_Katakana,
+    HB_Word_ALetter,
+    HB_Word_MidLetter,
+    HB_Word_MidNum,
+    HB_Word_Numeric,
+    HB_Word_ExtendNumLet
+} HB_WordClass;
+
+
+typedef enum
+{
+    HB_Sentence_Other,
+    HB_Sentence_Sep,
+    HB_Sentence_Format,
+    HB_Sentence_Sp,
+    HB_Sentence_Lower,
+    HB_Sentence_Upper,
+    HB_Sentence_OLetter,
+    HB_Sentence_Numeric,
+    HB_Sentence_ATerm,
+    HB_Sentence_STerm,
+    HB_Sentence_Close
+} HB_SentenceClass;
+
+HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);
+HB_WordClass HB_GetWordClass(HB_UChar32 ch);
+HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);
+HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);
+
+void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);
+void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);
+HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);
+int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);
+HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);
+
+void *HB_Library_Resolve(const char *library, const char *symbol);
+
+void *HB_TextCodecForMib(int mib);
+char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);
+void HB_TextCodec_FreeResult(char *);
+
+HB_END_HEADER
+
+#endif
index 78543cd..da06b6f 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_PRIVATE_H\r
-#define HARFBUZZ_GDEF_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-buffer-private.h"\r
-#include "harfbuzz-gdef.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Attachment related structures */\r
-\r
-struct  HB_AttachPoint_\r
-{\r
-  HB_UShort   PointCount;             /* size of the PointIndex array */\r
-  HB_UShort*  PointIndex;             /* array of contour points      */\r
-};\r
-\r
-/* Ligature Caret related structures */\r
-\r
-struct  HB_CaretValueFormat1_\r
-{\r
-  HB_Short  Coordinate;               /* x or y value (in design units) */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;\r
-\r
-\r
-struct  HB_CaretValueFormat2_\r
-{\r
-  HB_UShort  CaretValuePoint;         /* contour point index on glyph */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;\r
-\r
-\r
-struct  HB_CaretValueFormat3_\r
-{\r
-  HB_Short    Coordinate;             /* x or y value (in design units) */\r
-  HB_Device  Device;                 /* Device table for x or y value  */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;\r
-\r
-\r
-struct  HB_CaretValueFormat4_\r
-{\r
-  HB_UShort  IdCaretValue;            /* metric ID */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;\r
-\r
-\r
-struct  HB_CaretValue_\r
-{\r
-  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */\r
-\r
-  union\r
-  {\r
-    HB_CaretValueFormat1  cvf1;\r
-    HB_CaretValueFormat2  cvf2;\r
-    HB_CaretValueFormat3  cvf3;\r
-    HB_CaretValueFormat4  cvf4;\r
-  } cvf;\r
-};\r
-\r
-typedef struct HB_CaretValue_  HB_CaretValue;\r
-\r
-\r
-struct  HB_LigGlyph_\r
-{\r
-  HB_Bool          loaded;\r
-\r
-  HB_UShort        CaretCount;        /* number of caret values */\r
-  HB_CaretValue*  CaretValue;        /* array of caret values  */\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,\r
-                                      HB_UShort        glyphID,\r
-                                      HB_UShort        property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,\r
-                                  HB_GlyphItem    item,\r
-                                  HB_UShort        flags,\r
-                                  HB_UShort*       property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,\r
-                                                 HB_Stream      input,\r
-                                                 HB_Lookup*     lo,\r
-                                                 HB_UShort      num_lookups );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_PRIVATE_H
+#define HARFBUZZ_GDEF_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-buffer-private.h"
+#include "harfbuzz-gdef.h"
+
+HB_BEGIN_HEADER
+
+
+/* Attachment related structures */
+
+struct  HB_AttachPoint_
+{
+  HB_UShort   PointCount;             /* size of the PointIndex array */
+  HB_UShort*  PointIndex;             /* array of contour points      */
+};
+
+/* Ligature Caret related structures */
+
+struct  HB_CaretValueFormat1_
+{
+  HB_Short  Coordinate;               /* x or y value (in design units) */
+};
+
+typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;
+
+
+struct  HB_CaretValueFormat2_
+{
+  HB_UShort  CaretValuePoint;         /* contour point index on glyph */
+};
+
+typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;
+
+
+struct  HB_CaretValueFormat3_
+{
+  HB_Short    Coordinate;             /* x or y value (in design units) */
+  HB_Device  Device;                 /* Device table for x or y value  */
+};
+
+typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;
+
+
+struct  HB_CaretValueFormat4_
+{
+  HB_UShort  IdCaretValue;            /* metric ID */
+};
+
+typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;
+
+
+struct  HB_CaretValue_
+{
+  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */
+
+  union
+  {
+    HB_CaretValueFormat1  cvf1;
+    HB_CaretValueFormat2  cvf2;
+    HB_CaretValueFormat3  cvf3;
+    HB_CaretValueFormat4  cvf4;
+  } cvf;
+};
+
+typedef struct HB_CaretValue_  HB_CaretValue;
+
+
+struct  HB_LigGlyph_
+{
+  HB_Bool          loaded;
+
+  HB_UShort        CaretCount;        /* number of caret values */
+  HB_CaretValue*  CaretValue;        /* array of caret values  */
+};
+
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+                                      HB_UShort        glyphID,
+                                      HB_UShort        property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+                                  HB_GlyphItem    item,
+                                  HB_UShort        flags,
+                                  HB_UShort*       property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,
+                                                 HB_Stream      input,
+                                                 HB_Lookup*     lo,
+                                                 HB_UShort      num_lookups );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_PRIVATE_H */
index bf7a70e..b6dcadc 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_H\r
-#define HARFBUZZ_GDEF_H\r
-\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding\r
- * flag in the LookupFlag field.     */\r
-#define HB_GDEF_BASE_GLYPH  0x0002\r
-#define HB_GDEF_LIGATURE    0x0004\r
-#define HB_GDEF_MARK        0x0008\r
-#define HB_GDEF_COMPONENT   0x0010\r
-\r
-\r
-typedef struct HB_AttachPoint_  HB_AttachPoint;\r
-\r
-\r
-struct  HB_AttachList_\r
-{\r
-  HB_Bool           loaded;\r
-\r
-  HB_Coverage       Coverage;         /* Coverage table              */\r
-  HB_UShort         GlyphCount;       /* number of glyphs with\r
-                                        attachments                 */\r
-  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */\r
-};\r
-\r
-typedef struct HB_AttachList_  HB_AttachList;\r
-\r
-typedef struct HB_LigGlyph_  HB_LigGlyph;\r
-\r
-struct  HB_LigCaretList_\r
-{\r
-  HB_Bool        loaded;\r
-\r
-  HB_Coverage    Coverage;            /* Coverage table            */\r
-  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */\r
-  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */\r
-};\r
-\r
-typedef struct HB_LigCaretList_  HB_LigCaretList;\r
-\r
-\r
-\r
-/* The `NewGlyphClasses' field is not defined in the TTO specification.\r
-   We use it for fonts with a constructed `GlyphClassDef' structure\r
-   (i.e., which don't have a GDEF table) to collect glyph classes\r
-   assigned during the lookup process.  The number of arrays in this\r
-   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth\r
-   array then contains the glyph class values of the glyphs not covered\r
-   by the ClassRangeRecords structures with index n-1 and n.  We store\r
-   glyph class values for four glyphs in a single array element.\r
-\r
-   `LastGlyph' is identical to the number of glyphs minus one in the\r
-   font; we need it only if `NewGlyphClasses' is not NULL (to have an\r
-   upper bound for the last array).\r
-\r
-   Note that we first store the file offset to the `MarkAttachClassDef'\r
-   field (which has been introduced in OpenType 1.2) -- since the\r
-   `Version' field value hasn't been increased to indicate that we have\r
-   one more field for some obscure reason, we must parse the GSUB table\r
-   to find out whether class values refer to this table.  Only then we\r
-   can finally load the MarkAttachClassDef structure if necessary.      */\r
-\r
-struct  HB_GDEFHeader_\r
-{\r
-  HB_UInt             offset;\r
-\r
-  HB_16Dot16             Version;\r
-\r
-  HB_ClassDefinition   GlyphClassDef;\r
-  HB_AttachList        AttachList;\r
-  HB_LigCaretList      LigCaretList;\r
-  HB_UInt             MarkAttachClassDef_offset;\r
-  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */\r
-\r
-  HB_UShort            LastGlyph;\r
-  HB_UShort**          NewGlyphClasses;\r
-};\r
-\r
-typedef struct HB_GDEFHeader_   HB_GDEFHeader;\r
-typedef struct HB_GDEFHeader_*  HB_GDEF;\r
-\r
-\r
-HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );\r
-      \r
-\r
-HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,\r
-                             HB_GDEFHeader** gdef );\r
-\r
-\r
-HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );\r
-\r
-\r
-HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,\r
-                                     HB_UShort        glyphID,\r
-                                     HB_UShort*       property );\r
-\r
-HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,\r
-                                        HB_UShort        num_glyphs,\r
-                                        HB_UShort        glyph_count,\r
-                                        HB_UShort*       glyph_array,\r
-                                        HB_UShort*       class_array );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_H
+#define HARFBUZZ_GDEF_H
+
+#include "harfbuzz-open.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding
+ * flag in the LookupFlag field.     */
+#define HB_GDEF_BASE_GLYPH  0x0002
+#define HB_GDEF_LIGATURE    0x0004
+#define HB_GDEF_MARK        0x0008
+#define HB_GDEF_COMPONENT   0x0010
+
+
+typedef struct HB_AttachPoint_  HB_AttachPoint;
+
+
+struct  HB_AttachList_
+{
+  HB_Bool           loaded;
+
+  HB_Coverage       Coverage;         /* Coverage table              */
+  HB_UShort         GlyphCount;       /* number of glyphs with
+                                        attachments                 */
+  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */
+};
+
+typedef struct HB_AttachList_  HB_AttachList;
+
+typedef struct HB_LigGlyph_  HB_LigGlyph;
+
+struct  HB_LigCaretList_
+{
+  HB_Bool        loaded;
+
+  HB_Coverage    Coverage;            /* Coverage table            */
+  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */
+  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */
+};
+
+typedef struct HB_LigCaretList_  HB_LigCaretList;
+
+
+
+/* The `NewGlyphClasses' field is not defined in the TTO specification.
+   We use it for fonts with a constructed `GlyphClassDef' structure
+   (i.e., which don't have a GDEF table) to collect glyph classes
+   assigned during the lookup process.  The number of arrays in this
+   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
+   array then contains the glyph class values of the glyphs not covered
+   by the ClassRangeRecords structures with index n-1 and n.  We store
+   glyph class values for four glyphs in a single array element.
+
+   `LastGlyph' is identical to the number of glyphs minus one in the
+   font; we need it only if `NewGlyphClasses' is not NULL (to have an
+   upper bound for the last array).
+
+   Note that we first store the file offset to the `MarkAttachClassDef'
+   field (which has been introduced in OpenType 1.2) -- since the
+   `Version' field value hasn't been increased to indicate that we have
+   one more field for some obscure reason, we must parse the GSUB table
+   to find out whether class values refer to this table.  Only then we
+   can finally load the MarkAttachClassDef structure if necessary.      */
+
+struct  HB_GDEFHeader_
+{
+  HB_UInt             offset;
+
+  HB_16Dot16             Version;
+
+  HB_ClassDefinition   GlyphClassDef;
+  HB_AttachList        AttachList;
+  HB_LigCaretList      LigCaretList;
+  HB_UInt             MarkAttachClassDef_offset;
+  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */
+
+  HB_UShort            LastGlyph;
+  HB_UShort**          NewGlyphClasses;
+};
+
+typedef struct HB_GDEFHeader_   HB_GDEFHeader;
+typedef struct HB_GDEFHeader_*  HB_GDEF;
+
+
+HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );
+      
+
+HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,
+                             HB_GDEFHeader** gdef );
+
+
+HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
+
+
+HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
+                                     HB_UShort        glyphID,
+                                     HB_UShort*       property );
+
+HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
+                                        HB_UShort        num_glyphs,
+                                        HB_UShort        glyph_count,
+                                        HB_UShort*       glyph_array,
+                                        HB_UShort*       class_array );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_H */
index 9b8bfbf..0bb5669 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- */\r
-\r
-#ifndef HARFBUZZ_GLOBAL_H\r
-#define HARFBUZZ_GLOBAL_H\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#ifdef __cplusplus\r
-#define HB_BEGIN_HEADER  extern "C" {\r
-#define HB_END_HEADER  }\r
-#else\r
-#define HB_BEGIN_HEADER  /* nothing */\r
-#define HB_END_HEADER  /* nothing */\r
-#endif\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef FALSE\r
-#define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-#define TRUE (!FALSE)\r
-#endif\r
-\r
-#ifndef false\r
-#define false 0\r
-#endif\r
-\r
-#ifndef true\r
-#define true (!FALSE)\r
-#endif\r
-\r
-#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \\r
-          ( ( (HB_UInt)_x1 << 24 ) |     \\r
-            ( (HB_UInt)_x2 << 16 ) |     \\r
-            ( (HB_UInt)_x3 <<  8 ) |     \\r
-              (HB_UInt)_x4         )\r
-\r
-typedef char hb_int8;\r
-typedef unsigned char hb_uint8;\r
-typedef short hb_int16;\r
-typedef unsigned short hb_uint16;\r
-typedef int hb_int32;\r
-typedef unsigned int hb_uint32;\r
-\r
-typedef hb_uint8 HB_Bool;\r
-typedef hb_uint8 bool;\r
-\r
-typedef hb_uint8 HB_Byte;\r
-typedef hb_uint16 HB_UShort;\r
-typedef hb_uint32 HB_UInt;\r
-typedef hb_int8 HB_Char;\r
-typedef hb_int16 HB_Short;\r
-typedef hb_int32 HB_Int;\r
-\r
-typedef hb_uint16 HB_UChar16;\r
-typedef hb_uint32 HB_UChar32;\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_int32 HB_Fixed; /* 26.6 */\r
-\r
-#define HB_FIXED_CONSTANT(v) ((v) * 64)\r
-#define HB_FIXED_ROUND(v) (((v)+32) & -64)\r
-\r
-typedef hb_int32 HB_16Dot16; /* 16.16 */\r
-\r
-typedef void * HB_Pointer;\r
-typedef hb_uint32 HB_Tag;\r
-\r
-typedef enum {\r
-  /* no error */\r
-  HB_Err_Ok                           = 0x0000,\r
-  HB_Err_Not_Covered                  = 0xFFFF,\r
-\r
-  /* _hb_err() is called whenever returning the following errors,\r
-   * and in a couple places for HB_Err_Not_Covered too. */\r
-\r
-  /* programmer error */\r
-  HB_Err_Invalid_Argument             = 0x1A66,\r
-\r
-  /* font error */\r
-  HB_Err_Invalid_SubTable_Format      = 0x157F,\r
-  HB_Err_Invalid_SubTable             = 0x1570,\r
-  HB_Err_Read_Error                   = 0x6EAD,\r
-\r
-  /* system error */\r
-  HB_Err_Out_Of_Memory                = 0xDEAD\r
-} HB_Error;\r
-\r
-typedef struct {\r
-    HB_Fixed x;\r
-    HB_Fixed y;\r
-} HB_FixedPoint;\r
-\r
-typedef struct HB_Font_ *HB_Font;\r
-typedef struct HB_StreamRec_ *HB_Stream;\r
-typedef struct HB_FaceRec_ *HB_Face;\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ */
+
+#ifndef HARFBUZZ_GLOBAL_H
+#define HARFBUZZ_GLOBAL_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+#define HB_BEGIN_HEADER  extern "C" {
+#define HB_END_HEADER  }
+#else
+#define HB_BEGIN_HEADER  /* nothing */
+#define HB_END_HEADER  /* nothing */
+#endif
+
+HB_BEGIN_HEADER
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+#ifndef false
+#define false 0
+#endif
+
+#ifndef true
+#define true (!FALSE)
+#endif
+
+#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
+          ( ( (HB_UInt)_x1 << 24 ) |     \
+            ( (HB_UInt)_x2 << 16 ) |     \
+            ( (HB_UInt)_x3 <<  8 ) |     \
+              (HB_UInt)_x4         )
+
+typedef char hb_int8;
+typedef unsigned char hb_uint8;
+typedef short hb_int16;
+typedef unsigned short hb_uint16;
+typedef int hb_int32;
+typedef unsigned int hb_uint32;
+
+typedef hb_uint8 HB_Bool;
+typedef hb_uint8 bool;
+
+typedef hb_uint8 HB_Byte;
+typedef hb_uint16 HB_UShort;
+typedef hb_uint32 HB_UInt;
+typedef hb_int8 HB_Char;
+typedef hb_int16 HB_Short;
+typedef hb_int32 HB_Int;
+
+typedef hb_uint16 HB_UChar16;
+typedef hb_uint32 HB_UChar32;
+typedef hb_uint32 HB_Glyph;
+typedef hb_int32 HB_Fixed; /* 26.6 */
+
+#define HB_FIXED_CONSTANT(v) ((v) * 64)
+#define HB_FIXED_ROUND(v) (((v)+32) & -64)
+
+typedef hb_int32 HB_16Dot16; /* 16.16 */
+
+typedef void * HB_Pointer;
+typedef hb_uint32 HB_Tag;
+
+typedef enum {
+  /* no error */
+  HB_Err_Ok                           = 0x0000,
+  HB_Err_Not_Covered                  = 0xFFFF,
+
+  /* _hb_err() is called whenever returning the following errors,
+   * and in a couple places for HB_Err_Not_Covered too. */
+
+  /* programmer error */
+  HB_Err_Invalid_Argument             = 0x1A66,
+
+  /* font error */
+  HB_Err_Invalid_SubTable_Format      = 0x157F,
+  HB_Err_Invalid_SubTable             = 0x1570,
+  HB_Err_Read_Error                   = 0x6EAD,
+
+  /* system error */
+  HB_Err_Out_Of_Memory                = 0xDEAD
+} HB_Error;
+
+typedef struct {
+    HB_Fixed x;
+    HB_Fixed y;
+} HB_FixedPoint;
+
+typedef struct HB_Font_ *HB_Font;
+typedef struct HB_StreamRec_ *HB_Stream;
+typedef struct HB_FaceRec_ *HB_Face;
+
+HB_END_HEADER
+
+#endif
index c2865ba..4110700 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_PRIVATE_H\r
-#define HARFBUZZ_GPOS_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* shared tables */\r
-\r
-struct  HB_ValueRecord_\r
-{\r
-  HB_Short    XPlacement;             /* horizontal adjustment for\r
-                                        placement                      */\r
-  HB_Short    YPlacement;             /* vertical adjustment for\r
-                                        placement                      */\r
-  HB_Short    XAdvance;               /* horizontal adjustment for\r
-                                        advance                        */\r
-  HB_Short    YAdvance;               /* vertical adjustment for\r
-                                        advance                        */\r
-  HB_Device  XPlacementDevice;       /* device table for horizontal\r
-                                        placement                      */\r
-  HB_Device  YPlacementDevice;       /* device table for vertical\r
-                                        placement                      */\r
-  HB_Device  XAdvanceDevice;         /* device table for horizontal\r
-                                        advance                        */\r
-  HB_Device  YAdvanceDevice;         /* device table for vertical\r
-                                        advance                        */\r
-  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */\r
-  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */\r
-  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */\r
-  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */\r
-};\r
-\r
-typedef struct HB_ValueRecord_  HB_ValueRecord;\r
-\r
-\r
-/* Mask values to scan the value format of the ValueRecord structure.\r
- We always expand compressed ValueRecords of the font.              */\r
-\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800\r
-\r
-\r
-struct  HB_AnchorFormat1_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value */\r
-  HB_Short   YCoordinate;             /* vertical value   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;\r
-\r
-\r
-struct  HB_AnchorFormat2_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value             */\r
-  HB_Short   YCoordinate;             /* vertical value               */\r
-  HB_UShort  AnchorPoint;             /* index to glyph contour point */\r
-};\r
-\r
-typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;\r
-\r
-\r
-struct  HB_AnchorFormat3_\r
-{\r
-  HB_Short    XCoordinate;            /* horizontal value              */\r
-  HB_Short    YCoordinate;            /* vertical value                */\r
-  HB_Device  XDeviceTable;           /* device table for X coordinate */\r
-  HB_Device  YDeviceTable;           /* device table for Y coordinate */\r
-};\r
-\r
-typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;\r
-\r
-\r
-struct  HB_AnchorFormat4_\r
-{\r
-  HB_UShort  XIdAnchor;               /* horizontal metric ID */\r
-  HB_UShort  YIdAnchor;               /* vertical metric ID   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;\r
-\r
-\r
-struct  HB_Anchor_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates\r
-                                        that there is no Anchor table */\r
-\r
-  union\r
-  {\r
-    HB_AnchorFormat1  af1;\r
-    HB_AnchorFormat2  af2;\r
-    HB_AnchorFormat3  af3;\r
-    HB_AnchorFormat4  af4;\r
-  } af;\r
-};\r
-\r
-typedef struct HB_Anchor_  HB_Anchor;\r
-\r
-\r
-struct  HB_MarkRecord_\r
-{\r
-  HB_UShort   Class;                  /* mark class   */\r
-  HB_Anchor  MarkAnchor;             /* anchor table */\r
-};\r
-\r
-typedef struct HB_MarkRecord_  HB_MarkRecord;\r
-\r
-\r
-struct  HB_MarkArray_\r
-{\r
-  HB_UShort        MarkCount;         /* number of MarkRecord tables */\r
-  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */\r
-};\r
-\r
-typedef struct HB_MarkArray_  HB_MarkArray;\r
-\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SinglePosFormat1_\r
-{\r
-  HB_ValueRecord  Value;             /* ValueRecord for all covered\r
-                                        glyphs                      */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;\r
-\r
-\r
-struct  HB_SinglePosFormat2_\r
-{\r
-  HB_UShort         ValueCount;       /* number of ValueRecord tables */\r
-  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;\r
-\r
-\r
-struct  HB_SinglePos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  HB_UShort     ValueFormat;          /* format of ValueRecord table */\r
-\r
-  union\r
-  {\r
-    HB_SinglePosFormat1  spf1;\r
-    HB_SinglePosFormat2  spf2;\r
-  } spf;\r
-};\r
-\r
-typedef struct HB_SinglePos_  HB_SinglePos;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_PairValueRecord_\r
-{\r
-  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_PairValueRecord_  HB_PairValueRecord;\r
-\r
-\r
-struct  HB_PairSet_\r
-{\r
-  HB_UShort             PairValueCount;\r
-                                     /* number of PairValueRecord tables */\r
-  HB_PairValueRecord*  PairValueRecord;\r
-                                     /* array of PairValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_PairSet_  HB_PairSet;\r
-\r
-\r
-struct  HB_PairPosFormat1_\r
-{\r
-  HB_UShort     PairSetCount;         /* number of PairSet tables    */\r
-  HB_PairSet*  PairSet;              /* array of PairSet tables     */\r
-};\r
-\r
-typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;\r
-\r
-\r
-struct  HB_Class2Record_\r
-{\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_Class2Record_  HB_Class2Record;\r
-\r
-\r
-struct  HB_Class1Record_\r
-{\r
-  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */\r
-};\r
-\r
-typedef struct HB_Class1Record_  HB_Class1Record;\r
-\r
-\r
-struct  HB_PairPosFormat2_\r
-{\r
-  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */\r
-  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */\r
-  HB_UShort            Class1Count;   /* number of classes in ClassDef1\r
-                                        table                          */\r
-  HB_UShort            Class2Count;   /* number of classes in ClassDef2\r
-                                        table                          */\r
-  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */\r
-};\r
-\r
-typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;\r
-\r
-\r
-struct  HB_PairPos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-  HB_UShort     ValueFormat1;         /* format of ValueRecord table\r
-                                        for first glyph             */\r
-  HB_UShort     ValueFormat2;         /* format of ValueRecord table\r
-                                        for second glyph            */\r
-\r
-  union\r
-  {\r
-    HB_PairPosFormat1  ppf1;\r
-    HB_PairPosFormat2  ppf2;\r
-  } ppf;\r
-};\r
-\r
-typedef struct HB_PairPos_  HB_PairPos;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_EntryExitRecord_\r
-{\r
-  HB_Anchor  EntryAnchor;            /* entry Anchor table */\r
-  HB_Anchor  ExitAnchor;             /* exit Anchor table  */\r
-};\r
-\r
-\r
-typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;\r
-\r
-struct  HB_CursivePos_\r
-{\r
-  HB_UShort             PosFormat;    /* always 1                         */\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             EntryExitCount;\r
-                                     /* number of EntryExitRecord tables */\r
-  HB_EntryExitRecord*  EntryExitRecord;\r
-                                     /* array of EntryExitRecord tables  */\r
-};\r
-\r
-typedef struct HB_CursivePos_  HB_CursivePos;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_BaseRecord_\r
-{\r
-  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_BaseRecord_  HB_BaseRecord;\r
-\r
-\r
-struct  HB_BaseArray_\r
-{\r
-  HB_UShort        BaseCount;         /* number of BaseRecord tables */\r
-  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */\r
-};\r
-\r
-typedef struct HB_BaseArray_  HB_BaseArray;\r
-\r
-\r
-struct  HB_MarkBasePos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1                  */\r
-  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */\r
-  HB_Coverage   BaseCoverage;        /* base glyph coverage table */\r
-  HB_UShort      ClassCount;          /* number of mark classes    */\r
-  HB_MarkArray  MarkArray;           /* mark array table          */\r
-  HB_BaseArray  BaseArray;           /* base array table          */\r
-};\r
-\r
-typedef struct HB_MarkBasePos_  HB_MarkBasePos;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_ComponentRecord_\r
-{\r
-  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor\r
-                                        tables                         */\r
-};\r
-\r
-typedef struct HB_ComponentRecord_  HB_ComponentRecord;\r
-\r
-\r
-struct  HB_LigatureAttach_\r
-{\r
-  HB_UShort             ComponentCount;\r
-                                     /* number of ComponentRecord tables */\r
-  HB_ComponentRecord*  ComponentRecord;\r
-                                     /* array of ComponentRecord tables  */\r
-};\r
-\r
-typedef struct HB_LigatureAttach_  HB_LigatureAttach;\r
-\r
-\r
-struct  HB_LigatureArray_\r
-{\r
-  HB_UShort            LigatureCount; /* number of LigatureAttach tables */\r
-  HB_LigatureAttach*  LigatureAttach;\r
-                                     /* array of LigatureAttach tables  */\r
-};\r
-\r
-typedef struct HB_LigatureArray_  HB_LigatureArray;\r
-\r
-\r
-struct  HB_MarkLigPos_\r
-{\r
-  HB_UShort          PosFormat;       /* always 1                      */\r
-  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */\r
-  HB_Coverage       LigatureCoverage;\r
-                                     /* ligature glyph coverage table */\r
-  HB_UShort          ClassCount;      /* number of mark classes        */\r
-  HB_MarkArray      MarkArray;       /* mark array table              */\r
-  HB_LigatureArray  LigatureArray;   /* ligature array table          */\r
-};\r
-\r
-typedef struct HB_MarkLigPos_  HB_MarkLigPos;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_Mark2Record_\r
-{\r
-  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_Mark2Record_  HB_Mark2Record;\r
-\r
-\r
-struct  HB_Mark2Array_\r
-{\r
-  HB_UShort         Mark2Count;       /* number of Mark2Record tables */\r
-  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */\r
-};\r
-\r
-typedef struct HB_Mark2Array_  HB_Mark2Array;\r
-\r
-\r
-struct  HB_MarkMarkPos_\r
-{\r
-  HB_UShort       PosFormat;          /* always 1                         */\r
-  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */\r
-  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */\r
-  HB_UShort       ClassCount;         /* number of combining mark classes */\r
-  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */\r
-  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */\r
-};\r
-\r
-typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;\r
-\r
-\r
-/* needed by both lookup type 7 and 8 */\r
-\r
-struct  HB_PosLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;\r
-\r
-\r
-/* LookupType 7 */\r
-\r
-struct  HB_PosRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of input glyphs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosRule_  HB_PosRule;\r
-\r
-\r
-struct  HB_PosRuleSet_\r
-{\r
-  HB_UShort     PosRuleCount;         /* number of PosRule tables */\r
-  HB_PosRule*  PosRule;              /* array of PosRule tables  */\r
-};\r
-\r
-typedef struct HB_PosRuleSet_  HB_PosRuleSet;\r
-\r
-\r
-struct  HB_ContextPosFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */\r
-  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;\r
-\r
-\r
-struct  HB_PosClassRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of context classes  */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Class;        /* array of classes                 */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosClassRule_  HB_PosClassRule;\r
-\r
-\r
-struct  HB_PosClassSet_\r
-{\r
-  HB_UShort          PosClassRuleCount;\r
-                                     /* number of PosClassRule tables */\r
-  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */\r
-};\r
-\r
-typedef struct HB_PosClassSet_  HB_PosClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextPosFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            PosClassSetCount;\r
-                                     /* number of PosClassSet tables */\r
-  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;\r
-\r
-\r
-struct  HB_ContextPosFormat3_\r
-{\r
-  HB_UShort             GlyphCount;   /* number of input glyphs           */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_Coverage*         Coverage;     /* array of Coverage tables         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;\r
-\r
-\r
-struct  HB_ContextPos_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, or 3     */\r
-\r
-  union\r
-  {\r
-    HB_ContextPosFormat1  cpf1;\r
-    HB_ContextPosFormat2  cpf2;\r
-    HB_ContextPosFormat3  cpf3;\r
-  } cpf;\r
-};\r
-\r
-typedef struct HB_ContextPos_  HB_ContextPos;\r
-\r
-\r
-/* LookupType 8 */\r
-\r
-struct  HB_ChainPosRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords       */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecords       */\r
-};\r
-\r
-typedef struct HB_ChainPosRule_  HB_ChainPosRule;\r
-\r
-\r
-struct  HB_ChainPosRuleSet_\r
-{\r
-  HB_UShort          ChainPosRuleCount;\r
-                                     /* number of ChainPosRule tables */\r
-  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;\r
-\r
-\r
-struct  HB_ChainContextPosFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainPosRuleSetCount;\r
-                                     /* number of ChainPosRuleSet tables */\r
-  HB_ChainPosRuleSet*  ChainPosRuleSet;\r
-                                     /* array of ChainPosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;\r
-\r
-\r
-struct  HB_ChainPosClassRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*            Backtrack;    /* array of backtrack classes      */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*            Input;        /* array of context classes        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*            Lookahead;    /* array of lookahead classes      */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords      */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;\r
-\r
-\r
-struct  HB_ChainPosClassSet_\r
-{\r
-  HB_UShort               ChainPosClassRuleCount;\r
-                                     /* number of ChainPosClassRule\r
-                                        tables                      */\r
-  HB_ChainPosClassRule*  ChainPosClassRule;\r
-                                     /* array of ChainPosClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextPosFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainPosClassSetCount;\r
-                                     /* number of ChainPosClassSet\r
-                                        tables                     */\r
-  HB_ChainPosClassSet*  ChainPosClassSet;\r
-                                     /* array of ChainPosClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;\r
-\r
-\r
-struct  HB_ChainContextPosFormat3_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*         BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*         InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*         LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords    */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;\r
-\r
-\r
-struct  HB_ChainContextPos_\r
-{\r
-  HB_UShort  PosFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextPosFormat1  ccpf1;\r
-    HB_ChainContextPosFormat2  ccpf2;\r
-    HB_ChainContextPosFormat3  ccpf3;\r
-  } ccpf;\r
-};\r
-\r
-typedef struct HB_ChainContextPos_  HB_ChainContextPos;\r
-\r
-\r
-#if 0\r
-/* LookupType 10 */\r
-struct HB_ExtensionPos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GPOS_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionPos_  HB_ExtensionPos;\r
-#endif\r
-\r
-\r
-union  HB_GPOS_SubTable_\r
-{\r
-  HB_SinglePos        single;\r
-  HB_PairPos          pair;\r
-  HB_CursivePos       cursive;\r
-  HB_MarkBasePos      markbase;\r
-  HB_MarkLigPos       marklig;\r
-  HB_MarkMarkPos      markmark;\r
-  HB_ContextPos       context;\r
-  HB_ChainContextPos  chain;\r
-};\r
-\r
-typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_PRIVATE_H
+#define HARFBUZZ_GPOS_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+
+/* shared tables */
+
+struct  HB_ValueRecord_
+{
+  HB_Short    XPlacement;             /* horizontal adjustment for
+                                        placement                      */
+  HB_Short    YPlacement;             /* vertical adjustment for
+                                        placement                      */
+  HB_Short    XAdvance;               /* horizontal adjustment for
+                                        advance                        */
+  HB_Short    YAdvance;               /* vertical adjustment for
+                                        advance                        */
+  HB_Device  XPlacementDevice;       /* device table for horizontal
+                                        placement                      */
+  HB_Device  YPlacementDevice;       /* device table for vertical
+                                        placement                      */
+  HB_Device  XAdvanceDevice;         /* device table for horizontal
+                                        advance                        */
+  HB_Device  YAdvanceDevice;         /* device table for vertical
+                                        advance                        */
+  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */
+  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */
+  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */
+  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */
+};
+
+typedef struct HB_ValueRecord_  HB_ValueRecord;
+
+
+/* Mask values to scan the value format of the ValueRecord structure.
+ We always expand compressed ValueRecords of the font.              */
+
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080
+#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100
+#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200
+#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400
+#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800
+
+
+struct  HB_AnchorFormat1_
+{
+  HB_Short   XCoordinate;             /* horizontal value */
+  HB_Short   YCoordinate;             /* vertical value   */
+};
+
+typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;
+
+
+struct  HB_AnchorFormat2_
+{
+  HB_Short   XCoordinate;             /* horizontal value             */
+  HB_Short   YCoordinate;             /* vertical value               */
+  HB_UShort  AnchorPoint;             /* index to glyph contour point */
+};
+
+typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;
+
+
+struct  HB_AnchorFormat3_
+{
+  HB_Short    XCoordinate;            /* horizontal value              */
+  HB_Short    YCoordinate;            /* vertical value                */
+  HB_Device  XDeviceTable;           /* device table for X coordinate */
+  HB_Device  YDeviceTable;           /* device table for Y coordinate */
+};
+
+typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;
+
+
+struct  HB_AnchorFormat4_
+{
+  HB_UShort  XIdAnchor;               /* horizontal metric ID */
+  HB_UShort  YIdAnchor;               /* vertical metric ID   */
+};
+
+typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;
+
+
+struct  HB_Anchor_
+{
+  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates
+                                        that there is no Anchor table */
+
+  union
+  {
+    HB_AnchorFormat1  af1;
+    HB_AnchorFormat2  af2;
+    HB_AnchorFormat3  af3;
+    HB_AnchorFormat4  af4;
+  } af;
+};
+
+typedef struct HB_Anchor_  HB_Anchor;
+
+
+struct  HB_MarkRecord_
+{
+  HB_UShort   Class;                  /* mark class   */
+  HB_Anchor  MarkAnchor;             /* anchor table */
+};
+
+typedef struct HB_MarkRecord_  HB_MarkRecord;
+
+
+struct  HB_MarkArray_
+{
+  HB_UShort        MarkCount;         /* number of MarkRecord tables */
+  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */
+};
+
+typedef struct HB_MarkArray_  HB_MarkArray;
+
+
+/* LookupType 1 */
+
+struct  HB_SinglePosFormat1_
+{
+  HB_ValueRecord  Value;             /* ValueRecord for all covered
+                                        glyphs                      */
+};
+
+typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;
+
+
+struct  HB_SinglePosFormat2_
+{
+  HB_UShort         ValueCount;       /* number of ValueRecord tables */
+  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */
+};
+
+typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;
+
+
+struct  HB_SinglePos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  HB_UShort     ValueFormat;          /* format of ValueRecord table */
+
+  union
+  {
+    HB_SinglePosFormat1  spf1;
+    HB_SinglePosFormat2  spf2;
+  } spf;
+};
+
+typedef struct HB_SinglePos_  HB_SinglePos;
+
+
+/* LookupType 2 */
+
+struct  HB_PairValueRecord_
+{
+  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_PairValueRecord_  HB_PairValueRecord;
+
+
+struct  HB_PairSet_
+{
+  HB_UShort             PairValueCount;
+                                     /* number of PairValueRecord tables */
+  HB_PairValueRecord*  PairValueRecord;
+                                     /* array of PairValueRecord tables  */
+};
+
+typedef struct HB_PairSet_  HB_PairSet;
+
+
+struct  HB_PairPosFormat1_
+{
+  HB_UShort     PairSetCount;         /* number of PairSet tables    */
+  HB_PairSet*  PairSet;              /* array of PairSet tables     */
+};
+
+typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;
+
+
+struct  HB_Class2Record_
+{
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_Class2Record_  HB_Class2Record;
+
+
+struct  HB_Class1Record_
+{
+  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */
+};
+
+typedef struct HB_Class1Record_  HB_Class1Record;
+
+
+struct  HB_PairPosFormat2_
+{
+  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */
+  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */
+  HB_UShort            Class1Count;   /* number of classes in ClassDef1
+                                        table                          */
+  HB_UShort            Class2Count;   /* number of classes in ClassDef2
+                                        table                          */
+  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */
+};
+
+typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;
+
+
+struct  HB_PairPos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+  HB_UShort     ValueFormat1;         /* format of ValueRecord table
+                                        for first glyph             */
+  HB_UShort     ValueFormat2;         /* format of ValueRecord table
+                                        for second glyph            */
+
+  union
+  {
+    HB_PairPosFormat1  ppf1;
+    HB_PairPosFormat2  ppf2;
+  } ppf;
+};
+
+typedef struct HB_PairPos_  HB_PairPos;
+
+
+/* LookupType 3 */
+
+struct  HB_EntryExitRecord_
+{
+  HB_Anchor  EntryAnchor;            /* entry Anchor table */
+  HB_Anchor  ExitAnchor;             /* exit Anchor table  */
+};
+
+
+typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;
+
+struct  HB_CursivePos_
+{
+  HB_UShort             PosFormat;    /* always 1                         */
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             EntryExitCount;
+                                     /* number of EntryExitRecord tables */
+  HB_EntryExitRecord*  EntryExitRecord;
+                                     /* array of EntryExitRecord tables  */
+};
+
+typedef struct HB_CursivePos_  HB_CursivePos;
+
+
+/* LookupType 4 */
+
+struct  HB_BaseRecord_
+{
+  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_BaseRecord_  HB_BaseRecord;
+
+
+struct  HB_BaseArray_
+{
+  HB_UShort        BaseCount;         /* number of BaseRecord tables */
+  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */
+};
+
+typedef struct HB_BaseArray_  HB_BaseArray;
+
+
+struct  HB_MarkBasePos_
+{
+  HB_UShort      PosFormat;           /* always 1                  */
+  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */
+  HB_Coverage   BaseCoverage;        /* base glyph coverage table */
+  HB_UShort      ClassCount;          /* number of mark classes    */
+  HB_MarkArray  MarkArray;           /* mark array table          */
+  HB_BaseArray  BaseArray;           /* base array table          */
+};
+
+typedef struct HB_MarkBasePos_  HB_MarkBasePos;
+
+
+/* LookupType 5 */
+
+struct  HB_ComponentRecord_
+{
+  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor
+                                        tables                         */
+};
+
+typedef struct HB_ComponentRecord_  HB_ComponentRecord;
+
+
+struct  HB_LigatureAttach_
+{
+  HB_UShort             ComponentCount;
+                                     /* number of ComponentRecord tables */
+  HB_ComponentRecord*  ComponentRecord;
+                                     /* array of ComponentRecord tables  */
+};
+
+typedef struct HB_LigatureAttach_  HB_LigatureAttach;
+
+
+struct  HB_LigatureArray_
+{
+  HB_UShort            LigatureCount; /* number of LigatureAttach tables */
+  HB_LigatureAttach*  LigatureAttach;
+                                     /* array of LigatureAttach tables  */
+};
+
+typedef struct HB_LigatureArray_  HB_LigatureArray;
+
+
+struct  HB_MarkLigPos_
+{
+  HB_UShort          PosFormat;       /* always 1                      */
+  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */
+  HB_Coverage       LigatureCoverage;
+                                     /* ligature glyph coverage table */
+  HB_UShort          ClassCount;      /* number of mark classes        */
+  HB_MarkArray      MarkArray;       /* mark array table              */
+  HB_LigatureArray  LigatureArray;   /* ligature array table          */
+};
+
+typedef struct HB_MarkLigPos_  HB_MarkLigPos;
+
+
+/* LookupType 6 */
+
+struct  HB_Mark2Record_
+{
+  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_Mark2Record_  HB_Mark2Record;
+
+
+struct  HB_Mark2Array_
+{
+  HB_UShort         Mark2Count;       /* number of Mark2Record tables */
+  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */
+};
+
+typedef struct HB_Mark2Array_  HB_Mark2Array;
+
+
+struct  HB_MarkMarkPos_
+{
+  HB_UShort       PosFormat;          /* always 1                         */
+  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */
+  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */
+  HB_UShort       ClassCount;         /* number of combining mark classes */
+  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */
+  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */
+};
+
+typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;
+
+
+/* needed by both lookup type 7 and 8 */
+
+struct  HB_PosLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;
+
+
+/* LookupType 7 */
+
+struct  HB_PosRule_
+{
+  HB_UShort             GlyphCount;   /* total number of input glyphs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosRule_  HB_PosRule;
+
+
+struct  HB_PosRuleSet_
+{
+  HB_UShort     PosRuleCount;         /* number of PosRule tables */
+  HB_PosRule*  PosRule;              /* array of PosRule tables  */
+};
+
+typedef struct HB_PosRuleSet_  HB_PosRuleSet;
+
+
+struct  HB_ContextPosFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */
+  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */
+};
+
+typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;
+
+
+struct  HB_PosClassRule_
+{
+  HB_UShort             GlyphCount;   /* total number of context classes  */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Class;        /* array of classes                 */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosClassRule_  HB_PosClassRule;
+
+
+struct  HB_PosClassSet_
+{
+  HB_UShort          PosClassRuleCount;
+                                     /* number of PosClassRule tables */
+  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */
+};
+
+typedef struct HB_PosClassSet_  HB_PosClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextPosFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            PosClassSetCount;
+                                     /* number of PosClassSet tables */
+  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */
+};
+
+typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;
+
+
+struct  HB_ContextPosFormat3_
+{
+  HB_UShort             GlyphCount;   /* number of input glyphs           */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_Coverage*         Coverage;     /* array of Coverage tables         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;
+
+
+struct  HB_ContextPos_
+{
+  HB_UShort  PosFormat;               /* 1, 2, or 3     */
+
+  union
+  {
+    HB_ContextPosFormat1  cpf1;
+    HB_ContextPosFormat2  cpf2;
+    HB_ContextPosFormat3  cpf3;
+  } cpf;
+};
+
+typedef struct HB_ContextPos_  HB_ContextPos;
+
+
+/* LookupType 8 */
+
+struct  HB_ChainPosRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecords       */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecords       */
+};
+
+typedef struct HB_ChainPosRule_  HB_ChainPosRule;
+
+
+struct  HB_ChainPosRuleSet_
+{
+  HB_UShort          ChainPosRuleCount;
+                                     /* number of ChainPosRule tables */
+  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */
+};
+
+typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;
+
+
+struct  HB_ChainContextPosFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainPosRuleSetCount;
+                                     /* number of ChainPosRuleSet tables */
+  HB_ChainPosRuleSet*  ChainPosRuleSet;
+                                     /* array of ChainPosRuleSet tables  */
+};
+
+typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;
+
+
+struct  HB_ChainPosClassRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*            Backtrack;    /* array of backtrack classes      */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*            Input;        /* array of context classes        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*            Lookahead;    /* array of lookahead classes      */
+  HB_UShort             PosCount;     /* number of PosLookupRecords      */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;
+
+
+struct  HB_ChainPosClassSet_
+{
+  HB_UShort               ChainPosClassRuleCount;
+                                     /* number of ChainPosClassRule
+                                        tables                      */
+  HB_ChainPosClassRule*  ChainPosClassRule;
+                                     /* array of ChainPosClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextPosFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainPosClassSetCount;
+                                     /* number of ChainPosClassSet
+                                        tables                     */
+  HB_ChainPosClassSet*  ChainPosClassSet;
+                                     /* array of ChainPosClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;
+
+
+struct  HB_ChainContextPosFormat3_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*         BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort             InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*         InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*         LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort             PosCount;     /* number of PosLookupRecords    */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;
+
+
+struct  HB_ChainContextPos_
+{
+  HB_UShort  PosFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextPosFormat1  ccpf1;
+    HB_ChainContextPosFormat2  ccpf2;
+    HB_ChainContextPosFormat3  ccpf3;
+  } ccpf;
+};
+
+typedef struct HB_ChainContextPos_  HB_ChainContextPos;
+
+
+#if 0
+/* LookupType 10 */
+struct HB_ExtensionPos_
+{
+  HB_UShort      PosFormat;           /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GPOS_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionPos_  HB_ExtensionPos;
+#endif
+
+
+union  HB_GPOS_SubTable_
+{
+  HB_SinglePos        single;
+  HB_PairPos          pair;
+  HB_CursivePos       cursive;
+  HB_MarkBasePos      markbase;
+  HB_MarkLigPos       marklig;
+  HB_MarkMarkPos      markmark;
+  HB_ContextPos       context;
+  HB_ChainContextPos  chain;
+};
+
+typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;
+
+
+
+HB_INTERNAL HB_Error
+_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_PRIVATE_H */
index 20bb7d9..2840dae 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_H\r
-#define HARFBUZZ_GPOS_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph positioning */\r
-\r
-#define HB_GPOS_LOOKUP_SINGLE     1\r
-#define HB_GPOS_LOOKUP_PAIR       2\r
-#define HB_GPOS_LOOKUP_CURSIVE    3\r
-#define HB_GPOS_LOOKUP_MARKBASE   4\r
-#define HB_GPOS_LOOKUP_MARKLIG    5\r
-#define HB_GPOS_LOOKUP_MARKMARK   6\r
-#define HB_GPOS_LOOKUP_CONTEXT    7\r
-#define HB_GPOS_LOOKUP_CHAIN      8\r
-#define HB_GPOS_LOOKUP_EXTENSION  9\r
-\r
-/* A pointer to a function which accesses the PostScript interpreter.\r
-   Multiple Master fonts need this interface to convert a metric ID\r
-   (as stored in an OpenType font version 1.2 or higher) `metric_id'\r
-   into a metric value (returned in `metric_value').\r
-\r
-   `data' points to the user-defined structure specified during a\r
-   call to HB_GPOS_Register_MM_Function().\r
-\r
-   `metric_value' must be returned as a scaled value (but shouldn't\r
-   be rounded).                                                       */\r
-\r
-typedef HB_Error  (*HB_MMFunction)(HB_Font       font,\r
-                                   HB_UShort    metric_id,\r
-                                   HB_Fixed*      metric_value,\r
-                                   void*        data );\r
-\r
-\r
-struct  HB_GPOSHeader_\r
-{\r
-  HB_16Dot16           Version;\r
-\r
-  HB_ScriptList     ScriptList;\r
-  HB_FeatureList    FeatureList;\r
-  HB_LookupList     LookupList;\r
-\r
-  HB_GDEFHeader*    gdef;\r
-\r
-  /* this is OpenType 1.2 -- Multiple Master fonts need this\r
-     callback function to get various metric values from the\r
-     PostScript interpreter.                                 */\r
-\r
-  HB_MMFunction     mmfunc;\r
-  void*              data;\r
-};\r
-\r
-typedef struct HB_GPOSHeader_  HB_GPOSHeader;\r
-typedef HB_GPOSHeader* HB_GPOS;\r
-\r
-\r
-HB_Error  HB_Load_GPOS_Table( HB_Stream stream, \r
-                              HB_GPOSHeader** gpos,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,\r
-                                       HB_MMFunction   mmfunc,\r
-                                       void*            data );\r
-\r
-/* If `dvi' is TRUE, glyph contour points for anchor points and device\r
-   tables are ignored -- you will get device independent values.         */\r
-\r
-\r
-HB_Error  HB_GPOS_Apply_String( HB_Font           font,\r
-                               HB_GPOSHeader*   gpos,\r
-                               HB_UShort         load_flags,\r
-                               HB_Buffer        buffer,\r
-                               HB_Bool           dvi,\r
-                               HB_Bool           r2l );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_H
+#define HARFBUZZ_GPOS_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph positioning */
+
+#define HB_GPOS_LOOKUP_SINGLE     1
+#define HB_GPOS_LOOKUP_PAIR       2
+#define HB_GPOS_LOOKUP_CURSIVE    3
+#define HB_GPOS_LOOKUP_MARKBASE   4
+#define HB_GPOS_LOOKUP_MARKLIG    5
+#define HB_GPOS_LOOKUP_MARKMARK   6
+#define HB_GPOS_LOOKUP_CONTEXT    7
+#define HB_GPOS_LOOKUP_CHAIN      8
+#define HB_GPOS_LOOKUP_EXTENSION  9
+
+/* A pointer to a function which accesses the PostScript interpreter.
+   Multiple Master fonts need this interface to convert a metric ID
+   (as stored in an OpenType font version 1.2 or higher) `metric_id'
+   into a metric value (returned in `metric_value').
+
+   `data' points to the user-defined structure specified during a
+   call to HB_GPOS_Register_MM_Function().
+
+   `metric_value' must be returned as a scaled value (but shouldn't
+   be rounded).                                                       */
+
+typedef HB_Error  (*HB_MMFunction)(HB_Font       font,
+                                   HB_UShort    metric_id,
+                                   HB_Fixed*      metric_value,
+                                   void*        data );
+
+
+struct  HB_GPOSHeader_
+{
+  HB_16Dot16           Version;
+
+  HB_ScriptList     ScriptList;
+  HB_FeatureList    FeatureList;
+  HB_LookupList     LookupList;
+
+  HB_GDEFHeader*    gdef;
+
+  /* this is OpenType 1.2 -- Multiple Master fonts need this
+     callback function to get various metric values from the
+     PostScript interpreter.                                 */
+
+  HB_MMFunction     mmfunc;
+  void*              data;
+};
+
+typedef struct HB_GPOSHeader_  HB_GPOSHeader;
+typedef HB_GPOSHeader* HB_GPOS;
+
+
+HB_Error  HB_Load_GPOS_Table( HB_Stream stream, 
+                              HB_GPOSHeader** gpos,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
+
+
+HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );
+
+
+HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,
+                                       HB_MMFunction   mmfunc,
+                                       void*            data );
+
+/* If `dvi' is TRUE, glyph contour points for anchor points and device
+   tables are ignored -- you will get device independent values.         */
+
+
+HB_Error  HB_GPOS_Apply_String( HB_Font           font,
+                               HB_GPOSHeader*   gpos,
+                               HB_UShort         load_flags,
+                               HB_Buffer        buffer,
+                               HB_Bool           dvi,
+                               HB_Bool           r2l );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_H */
index f47b46c..dd5ffdf 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_PRIVATE_H\r
-#define HARFBUZZ_GSUB_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gsub.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SingleSubstFormat1_\r
-{\r
-  HB_Short  DeltaGlyphID;             /* constant added to get\r
-                                        substitution glyph index */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;\r
-\r
-\r
-struct  HB_SingleSubstFormat2_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in\r
-                                        Substitute array              */\r
-  HB_UShort*  Substitute;             /* array of substitute glyph IDs */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;\r
-\r
-\r
-struct  HB_SingleSubst_\r
-{\r
-  HB_UShort     SubstFormat;          /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  union\r
-  {\r
-    HB_SingleSubstFormat1  ssf1;\r
-    HB_SingleSubstFormat2  ssf2;\r
-  } ssf;\r
-};\r
-\r
-typedef struct HB_SingleSubst_  HB_SingleSubst;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_Sequence_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Substitute array           */\r
-  HB_UShort*  Substitute;             /* string of glyph IDs to\r
-                                        substitute                 */\r
-};\r
-\r
-typedef struct HB_Sequence_  HB_Sequence;\r
-\r
-\r
-struct  HB_MultipleSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1                  */\r
-  HB_Coverage   Coverage;            /* Coverage table            */\r
-  HB_UShort      SequenceCount;       /* number of Sequence tables */\r
-  HB_Sequence*  Sequence;            /* array of Sequence tables  */\r
-};\r
-\r
-typedef struct HB_MultipleSubst_  HB_MultipleSubst;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_AlternateSet_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Alternate array              */\r
-  HB_UShort*  Alternate;              /* array of alternate glyph IDs */\r
-};\r
-\r
-typedef struct HB_AlternateSet_  HB_AlternateSet;\r
-\r
-\r
-struct  HB_AlternateSubst_\r
-{\r
-  HB_UShort          SubstFormat;     /* always 1                      */\r
-  HB_Coverage       Coverage;        /* Coverage table                */\r
-  HB_UShort          AlternateSetCount;\r
-                                     /* number of AlternateSet tables */\r
-  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */\r
-};\r
-\r
-typedef struct HB_AlternateSubst_  HB_AlternateSubst;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_Ligature_\r
-{\r
-  HB_UShort   LigGlyph;               /* glyphID of ligature\r
-                                        to substitute                    */\r
-  HB_UShort   ComponentCount;         /* number of components in ligature */\r
-  HB_UShort*  Component;              /* array of component glyph IDs     */\r
-};\r
-\r
-typedef struct HB_Ligature_  HB_Ligature;\r
-\r
-\r
-struct  HB_LigatureSet_\r
-{\r
-  HB_UShort      LigatureCount;       /* number of Ligature tables */\r
-  HB_Ligature*  Ligature;            /* array of Ligature tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSet_  HB_LigatureSet;\r
-\r
-\r
-struct  HB_LigatureSubst_\r
-{\r
-  HB_UShort         SubstFormat;      /* always 1                     */\r
-  HB_Coverage      Coverage;         /* Coverage table               */\r
-  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */\r
-  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSubst_  HB_LigatureSubst;\r
-\r
-\r
-/* needed by both lookup type 5 and 6 */\r
-\r
-struct  HB_SubstLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_SubRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of input glyphs */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                       */\r
-  HB_UShort*              Input;      /* array of input glyph IDs     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                       */\r
-};\r
-\r
-typedef struct HB_SubRule_  HB_SubRule;\r
-\r
-\r
-struct  HB_SubRuleSet_\r
-{\r
-  HB_UShort     SubRuleCount;         /* number of SubRule tables */\r
-  HB_SubRule*  SubRule;              /* array of SubRule tables  */\r
-};\r
-\r
-typedef struct HB_SubRuleSet_  HB_SubRuleSet;\r
-\r
-\r
-struct  HB_ContextSubstFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */\r
-  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;\r
-\r
-\r
-struct  HB_SubClassRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of context classes */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                          */\r
-  HB_UShort*              Class;      /* array of classes                */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                          */\r
-};\r
-\r
-typedef struct HB_SubClassRule_  HB_SubClassRule;\r
-\r
-\r
-struct  HB_SubClassSet_\r
-{\r
-  HB_UShort          SubClassRuleCount;\r
-                                     /* number of SubClassRule tables */\r
-  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */\r
-};\r
-\r
-typedef struct HB_SubClassSet_  HB_SubClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextSubstFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            SubClassSetCount;\r
-                                     /* number of SubClassSet tables */\r
-  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;\r
-\r
-\r
-struct  HB_ContextSubstFormat3_\r
-{\r
-  HB_UShort               GlyphCount; /* number of input glyphs        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_Coverage*           Coverage;   /* array of Coverage tables      */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;\r
-\r
-\r
-struct  HB_ContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ContextSubstFormat1  csf1;\r
-    HB_ContextSubstFormat2  csf2;\r
-    HB_ContextSubstFormat3  csf3;\r
-  } csf;\r
-};\r
-\r
-typedef struct HB_ContextSubst_  HB_ContextSubst;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_ChainSubRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*              Input;      /* array of input glyph IDs         */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecords      */\r
-};\r
-\r
-typedef struct HB_ChainSubRule_  HB_ChainSubRule;\r
-\r
-\r
-struct  HB_ChainSubRuleSet_\r
-{\r
-  HB_UShort          ChainSubRuleCount;\r
-                                     /* number of ChainSubRule tables */\r
-  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainSubRuleSetCount;\r
-                                     /* number of ChainSubRuleSet tables */\r
-  HB_ChainSubRuleSet*  ChainSubRuleSet;\r
-                                     /* array of ChainSubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;\r
-\r
-\r
-struct  HB_ChainSubClassRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*              Backtrack;  /* array of backtrack classes      */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*              Input;      /* array of context classes        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*              Lookahead;  /* array of lookahead classes      */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords    */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;\r
-\r
-\r
-struct  HB_ChainSubClassSet_\r
-{\r
-  HB_UShort               ChainSubClassRuleCount;\r
-                                     /* number of ChainSubClassRule\r
-                                        tables                      */\r
-  HB_ChainSubClassRule*  ChainSubClassRule;\r
-                                     /* array of ChainSubClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextSubstFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainSubClassSetCount;\r
-                                     /* number of ChainSubClassSet\r
-                                        tables                     */\r
-  HB_ChainSubClassSet*  ChainSubClassSet;\r
-                                     /* array of ChainSubClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat3_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*           BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*           InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*           LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;\r
-\r
-\r
-struct  HB_ChainContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextSubstFormat1  ccsf1;\r
-    HB_ChainContextSubstFormat2  ccsf2;\r
-    HB_ChainContextSubstFormat3  ccsf3;\r
-  } ccsf;\r
-};\r
-\r
-typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;\r
-\r
-\r
-#if 0\r
-/* LookupType 7 */\r
-struct HB_ExtensionSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GSUB_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;\r
-#endif\r
-\r
-\r
-/* LookupType 8 */\r
-struct HB_ReverseChainContextSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_Coverage   Coverage;              /* coverage table for input glyphs */\r
-  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */\r
-  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage\r
-                                        tables                          */\r
-  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */\r
-  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage\r
-                                        tables                          */\r
-  HB_UShort      GlyphCount;          /* number of Glyph IDs             */\r
-  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */\r
-};\r
-\r
-typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;\r
-\r
-\r
-union  HB_GSUB_SubTable_\r
-{\r
-  HB_SingleSubst              single;\r
-  HB_MultipleSubst            multiple;\r
-  HB_AlternateSubst           alternate;\r
-  HB_LigatureSubst            ligature;\r
-  HB_ContextSubst             context;\r
-  HB_ChainContextSubst        chain;\r
-  HB_ReverseChainContextSubst reverse;\r
-};\r
-\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_PRIVATE_H
+#define HARFBUZZ_GSUB_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gsub.h"
+
+HB_BEGIN_HEADER
+
+
+typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;
+
+/* LookupType 1 */
+
+struct  HB_SingleSubstFormat1_
+{
+  HB_Short  DeltaGlyphID;             /* constant added to get
+                                        substitution glyph index */
+};
+
+typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;
+
+
+struct  HB_SingleSubstFormat2_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in
+                                        Substitute array              */
+  HB_UShort*  Substitute;             /* array of substitute glyph IDs */
+};
+
+typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;
+
+
+struct  HB_SingleSubst_
+{
+  HB_UShort     SubstFormat;          /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  union
+  {
+    HB_SingleSubstFormat1  ssf1;
+    HB_SingleSubstFormat2  ssf2;
+  } ssf;
+};
+
+typedef struct HB_SingleSubst_  HB_SingleSubst;
+
+
+/* LookupType 2 */
+
+struct  HB_Sequence_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Substitute array           */
+  HB_UShort*  Substitute;             /* string of glyph IDs to
+                                        substitute                 */
+};
+
+typedef struct HB_Sequence_  HB_Sequence;
+
+
+struct  HB_MultipleSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1                  */
+  HB_Coverage   Coverage;            /* Coverage table            */
+  HB_UShort      SequenceCount;       /* number of Sequence tables */
+  HB_Sequence*  Sequence;            /* array of Sequence tables  */
+};
+
+typedef struct HB_MultipleSubst_  HB_MultipleSubst;
+
+
+/* LookupType 3 */
+
+struct  HB_AlternateSet_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Alternate array              */
+  HB_UShort*  Alternate;              /* array of alternate glyph IDs */
+};
+
+typedef struct HB_AlternateSet_  HB_AlternateSet;
+
+
+struct  HB_AlternateSubst_
+{
+  HB_UShort          SubstFormat;     /* always 1                      */
+  HB_Coverage       Coverage;        /* Coverage table                */
+  HB_UShort          AlternateSetCount;
+                                     /* number of AlternateSet tables */
+  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */
+};
+
+typedef struct HB_AlternateSubst_  HB_AlternateSubst;
+
+
+/* LookupType 4 */
+
+struct  HB_Ligature_
+{
+  HB_UShort   LigGlyph;               /* glyphID of ligature
+                                        to substitute                    */
+  HB_UShort   ComponentCount;         /* number of components in ligature */
+  HB_UShort*  Component;              /* array of component glyph IDs     */
+};
+
+typedef struct HB_Ligature_  HB_Ligature;
+
+
+struct  HB_LigatureSet_
+{
+  HB_UShort      LigatureCount;       /* number of Ligature tables */
+  HB_Ligature*  Ligature;            /* array of Ligature tables  */
+};
+
+typedef struct HB_LigatureSet_  HB_LigatureSet;
+
+
+struct  HB_LigatureSubst_
+{
+  HB_UShort         SubstFormat;      /* always 1                     */
+  HB_Coverage      Coverage;         /* Coverage table               */
+  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */
+  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */
+};
+
+typedef struct HB_LigatureSubst_  HB_LigatureSubst;
+
+
+/* needed by both lookup type 5 and 6 */
+
+struct  HB_SubstLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;
+
+
+/* LookupType 5 */
+
+struct  HB_SubRule_
+{
+  HB_UShort               GlyphCount; /* total number of input glyphs */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                       */
+  HB_UShort*              Input;      /* array of input glyph IDs     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                       */
+};
+
+typedef struct HB_SubRule_  HB_SubRule;
+
+
+struct  HB_SubRuleSet_
+{
+  HB_UShort     SubRuleCount;         /* number of SubRule tables */
+  HB_SubRule*  SubRule;              /* array of SubRule tables  */
+};
+
+typedef struct HB_SubRuleSet_  HB_SubRuleSet;
+
+
+struct  HB_ContextSubstFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */
+  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;
+
+
+struct  HB_SubClassRule_
+{
+  HB_UShort               GlyphCount; /* total number of context classes */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                          */
+  HB_UShort*              Class;      /* array of classes                */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                          */
+};
+
+typedef struct HB_SubClassRule_  HB_SubClassRule;
+
+
+struct  HB_SubClassSet_
+{
+  HB_UShort          SubClassRuleCount;
+                                     /* number of SubClassRule tables */
+  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */
+};
+
+typedef struct HB_SubClassSet_  HB_SubClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextSubstFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            SubClassSetCount;
+                                     /* number of SubClassSet tables */
+  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;
+
+
+struct  HB_ContextSubstFormat3_
+{
+  HB_UShort               GlyphCount; /* number of input glyphs        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_Coverage*           Coverage;   /* array of Coverage tables      */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;
+
+
+struct  HB_ContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ContextSubstFormat1  csf1;
+    HB_ContextSubstFormat2  csf2;
+    HB_ContextSubstFormat3  csf3;
+  } csf;
+};
+
+typedef struct HB_ContextSubst_  HB_ContextSubst;
+
+
+/* LookupType 6 */
+
+struct  HB_ChainSubRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*              Input;      /* array of input glyph IDs         */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecords      */
+};
+
+typedef struct HB_ChainSubRule_  HB_ChainSubRule;
+
+
+struct  HB_ChainSubRuleSet_
+{
+  HB_UShort          ChainSubRuleCount;
+                                     /* number of ChainSubRule tables */
+  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */
+};
+
+typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;
+
+
+struct  HB_ChainContextSubstFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainSubRuleSetCount;
+                                     /* number of ChainSubRuleSet tables */
+  HB_ChainSubRuleSet*  ChainSubRuleSet;
+                                     /* array of ChainSubRuleSet tables  */
+};
+
+typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;
+
+
+struct  HB_ChainSubClassRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*              Backtrack;  /* array of backtrack classes      */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*              Input;      /* array of context classes        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*              Lookahead;  /* array of lookahead classes      */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords    */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;
+
+
+struct  HB_ChainSubClassSet_
+{
+  HB_UShort               ChainSubClassRuleCount;
+                                     /* number of ChainSubClassRule
+                                        tables                      */
+  HB_ChainSubClassRule*  ChainSubClassRule;
+                                     /* array of ChainSubClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextSubstFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainSubClassSetCount;
+                                     /* number of ChainSubClassSet
+                                        tables                     */
+  HB_ChainSubClassSet*  ChainSubClassSet;
+                                     /* array of ChainSubClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;
+
+
+struct  HB_ChainContextSubstFormat3_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*           BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort               InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*           InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*           LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;
+
+
+struct  HB_ChainContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextSubstFormat1  ccsf1;
+    HB_ChainContextSubstFormat2  ccsf2;
+    HB_ChainContextSubstFormat3  ccsf3;
+  } ccsf;
+};
+
+typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;
+
+
+#if 0
+/* LookupType 7 */
+struct HB_ExtensionSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GSUB_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;
+#endif
+
+
+/* LookupType 8 */
+struct HB_ReverseChainContextSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_Coverage   Coverage;              /* coverage table for input glyphs */
+  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */
+  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage
+                                        tables                          */
+  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */
+  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage
+                                        tables                          */
+  HB_UShort      GlyphCount;          /* number of Glyph IDs             */
+  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */
+};
+
+typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;
+
+
+union  HB_GSUB_SubTable_
+{
+  HB_SingleSubst              single;
+  HB_MultipleSubst            multiple;
+  HB_AlternateSubst           alternate;
+  HB_LigatureSubst            ligature;
+  HB_ContextSubst             context;
+  HB_ChainContextSubst        chain;
+  HB_ReverseChainContextSubst reverse;
+};
+
+
+
+
+HB_INTERNAL HB_Error
+_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_PRIVATE_H */
index 4471751..1ca3f0c 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_H\r
-#define HARFBUZZ_GSUB_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph substitution */\r
-\r
-#define HB_GSUB_LOOKUP_SINGLE        1\r
-#define HB_GSUB_LOOKUP_MULTIPLE      2\r
-#define HB_GSUB_LOOKUP_ALTERNATE     3\r
-#define HB_GSUB_LOOKUP_LIGATURE      4\r
-#define HB_GSUB_LOOKUP_CONTEXT       5\r
-#define HB_GSUB_LOOKUP_CHAIN         6\r
-#define HB_GSUB_LOOKUP_EXTENSION     7\r
-#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8\r
-\r
-\r
-/* A pointer to a function which selects the alternate glyph.  `pos' is\r
-   the position of the glyph with index `glyphID', `num_alternates'\r
-   gives the number of alternates in the `alternates' array.  `data'\r
-   points to the user-defined structure specified during a call to\r
-   HB_GSUB_Register_Alternate_Function().  The function must return an\r
-   index into the `alternates' array.                                   */\r
-\r
-typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,\r
-                                     HB_UShort   glyphID,\r
-                                     HB_UShort   num_alternates,\r
-                                     HB_UShort*  alternates,\r
-                                     void*       data );\r
-\r
-\r
-struct  HB_GSUBHeader_\r
-{\r
-  HB_UInt         offset;\r
-\r
-  HB_16Dot16         Version;\r
-\r
-  HB_ScriptList   ScriptList;\r
-  HB_FeatureList  FeatureList;\r
-  HB_LookupList   LookupList;\r
-\r
-  HB_GDEFHeader*  gdef;\r
-\r
-  /* the next two fields are used for an alternate substitution callback\r
-     function to select the proper alternate glyph.                      */\r
-\r
-  HB_AltFunction  altfunc;\r
-  void*            data;\r
-};\r
-\r
-typedef struct HB_GSUBHeader_   HB_GSUBHeader;\r
-typedef HB_GSUBHeader*  HB_GSUB;\r
-\r
-\r
-HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,\r
-                             HB_GSUBHeader** gsub,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,\r
-                                              HB_AltFunction  altfunc,\r
-                                              void*            data );\r
-\r
-\r
-HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,\r
-                               HB_Buffer        buffer );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_H
+#define HARFBUZZ_GSUB_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph substitution */
+
+#define HB_GSUB_LOOKUP_SINGLE        1
+#define HB_GSUB_LOOKUP_MULTIPLE      2
+#define HB_GSUB_LOOKUP_ALTERNATE     3
+#define HB_GSUB_LOOKUP_LIGATURE      4
+#define HB_GSUB_LOOKUP_CONTEXT       5
+#define HB_GSUB_LOOKUP_CHAIN         6
+#define HB_GSUB_LOOKUP_EXTENSION     7
+#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8
+
+
+/* A pointer to a function which selects the alternate glyph.  `pos' is
+   the position of the glyph with index `glyphID', `num_alternates'
+   gives the number of alternates in the `alternates' array.  `data'
+   points to the user-defined structure specified during a call to
+   HB_GSUB_Register_Alternate_Function().  The function must return an
+   index into the `alternates' array.                                   */
+
+typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,
+                                     HB_UShort   glyphID,
+                                     HB_UShort   num_alternates,
+                                     HB_UShort*  alternates,
+                                     void*       data );
+
+
+struct  HB_GSUBHeader_
+{
+  HB_UInt         offset;
+
+  HB_16Dot16         Version;
+
+  HB_ScriptList   ScriptList;
+  HB_FeatureList  FeatureList;
+  HB_LookupList   LookupList;
+
+  HB_GDEFHeader*  gdef;
+
+  /* the next two fields are used for an alternate substitution callback
+     function to select the proper alternate glyph.                      */
+
+  HB_AltFunction  altfunc;
+  void*            data;
+};
+
+typedef struct HB_GSUBHeader_   HB_GSUBHeader;
+typedef HB_GSUBHeader*  HB_GSUB;
+
+
+HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,
+                             HB_GSUBHeader** gsub,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,
+                                              HB_AltFunction  altfunc,
+                                              void*            data );
+
+
+HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,
+                               HB_Buffer        buffer );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_H */
index 358f587..2e86168 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_IMPL_H\r
-#define HARFBUZZ_IMPL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-#include <stdlib.h>\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef HB_INTERNAL\r
-# define HB_INTERNAL\r
-#endif\r
-\r
-#ifndef NULL\r
-# define NULL ((void *)0)\r
-#endif\r
-\r
-#ifndef FALSE\r
-# define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-# define TRUE 1\r
-#endif\r
-\r
-#ifndef TTAG_GDEF\r
-# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )\r
-#endif\r
-#ifndef TTAG_GPOS\r
-# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )\r
-#endif\r
-#ifndef TTAG_GSUB\r
-# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )\r
-#endif\r
-\r
-#ifndef HB_UNUSED\r
-# define HB_UNUSED(arg) ((arg) = (arg))\r
-#endif\r
-\r
-#define HB_LIKELY(cond) (cond)\r
-#define HB_UNLIKELY(cond) (cond)\r
-\r
-#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))\r
-\r
-\r
-\r
-#define HB_IsHighSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xd800)\r
-\r
-#define HB_IsLowSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xdc00)\r
-\r
-#define HB_SurrogateToUcs4(high, low) \\r
-    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;\r
-\r
-\r
-\r
-\r
-\r
-#define  ALLOC(_ptr,_size,_type)   \\r
-           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )\r
-\r
-#define  REALLOC(_ptr,_newsz,_type)  \\r
-           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )\r
-\r
-#define  FREE(_ptr)                    \\r
-  do {                                 \\r
-    if ( (_ptr) )                      \\r
-    {                                  \\r
-      _hb_free( _ptr );     \\r
-      _ptr = NULL;                     \\r
-    }                                  \\r
-  } while (0)\r
-\r
-#define  ALLOC_ARRAY(_ptr,_count,_type)   \\r
-           ALLOC(_ptr,(_count)*sizeof(_type),_type*)\r
-\r
-#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \\r
-           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)\r
-\r
-#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )\r
-\r
-#define ERR_HB(err)   _hb_err (err)\r
-\r
-\r
-//HB_INTERNAL\r
-HB_Pointer\r
-_hb_alloc( size_t    size,\r
-          HB_Error *perror_ );\r
-\r
-//HB_INTERNAL\r
-       HB_Pointer\r
-_hb_realloc( HB_Pointer block,\r
-            size_t     new_size,\r
-            HB_Error  *perror_ );\r
-\r
-//HB_INTERNAL \r
-       void\r
-_hb_free( HB_Pointer block );\r
-\r
-\r
-/* helper func to set a breakpoint on */\r
-//HB_INTERNAL \r
-HB_Error\r
-_hb_err(HB_Error code);\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_IMPL_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_IMPL_H
+#define HARFBUZZ_IMPL_H
+
+#include "harfbuzz-global.h"
+
+#include <stdlib.h>
+
+HB_BEGIN_HEADER
+
+#ifndef HB_INTERNAL
+# define HB_INTERNAL
+#endif
+
+#ifndef NULL
+# define NULL ((void *)0)
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef TTAG_GDEF
+# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
+#endif
+#ifndef TTAG_GPOS
+# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
+#endif
+#ifndef TTAG_GSUB
+# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
+#endif
+
+#ifndef HB_UNUSED
+# define HB_UNUSED(arg) ((arg) = (arg))
+#endif
+
+#define HB_LIKELY(cond) (cond)
+#define HB_UNLIKELY(cond) (cond)
+
+#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
+
+
+
+#define HB_IsHighSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xd800)
+
+#define HB_IsLowSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xdc00)
+
+#define HB_SurrogateToUcs4(high, low) \
+    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;
+
+
+
+
+
+#define  ALLOC(_ptr,_size,_type)   \
+           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )
+
+#define  REALLOC(_ptr,_newsz,_type)  \
+           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
+
+#define  FREE(_ptr)                    \
+  do {                                 \
+    if ( (_ptr) )                      \
+    {                                  \
+      _hb_free( _ptr );     \
+      _ptr = NULL;                     \
+    }                                  \
+  } while (0)
+
+#define  ALLOC_ARRAY(_ptr,_count,_type)   \
+           ALLOC(_ptr,(_count)*sizeof(_type),_type*)
+
+#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
+           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)
+
+#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
+
+#define ERR_HB(err)   _hb_err (err)
+
+
+//HB_INTERNAL
+HB_Pointer
+_hb_alloc( size_t    size,
+          HB_Error *perror_ );
+
+//HB_INTERNAL
+       HB_Pointer
+_hb_realloc( HB_Pointer block,
+            size_t     new_size,
+            HB_Error  *perror_ );
+
+//HB_INTERNAL 
+       void
+_hb_free( HB_Pointer block );
+
+
+/* helper func to set a breakpoint on */
+//HB_INTERNAL 
+HB_Error
+_hb_err(HB_Error code);
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_IMPL_H */
index 02aae80..73dd383 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_PRIVATE_H\r
-#define HARFBUZZ_OPEN_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-gpos-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-struct  HB_SubTable_\r
-{\r
-  union\r
-  {\r
-    HB_GSUB_SubTable  gsub;\r
-    HB_GPOS_SubTable  gpos;\r
-  } st;\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,\r
-                          HB_Stream     input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,\r
-                           HB_Stream         input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_LookupList( HB_LookupList*  ll,\r
-                          HB_Stream        input,\r
-                          HB_Type         type );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Coverage( HB_Coverage* c,\r
-                        HB_Stream      input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,\r
-                               HB_UShort             limit,\r
-                               HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,\r
-                                              HB_UShort             limit,\r
-                                              HB_UInt              class_offset,\r
-                                              HB_UInt              base_offset,\r
-                                              HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Device( HB_Device* d,\r
-                      HB_Stream    input );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );\r
-HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );\r
-HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,\r
-                      HB_Type         type );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );\r
-HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );\r
-HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Coverage_Index( HB_Coverage* c,\r
-                         HB_UShort      glyphID,\r
-                         HB_UShort*     index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Class( HB_ClassDefinition* cd,\r
-                    HB_UShort             glyphID,\r
-                   HB_UShort*          klass,\r
-                    HB_UShort*            index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Device( HB_Device* d,\r
-                     HB_UShort    size,\r
-                     HB_Short*    value );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_PRIVATE_H
+#define HARFBUZZ_OPEN_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-gpos-private.h"
+
+HB_BEGIN_HEADER
+
+
+struct  HB_SubTable_
+{
+  union
+  {
+    HB_GSUB_SubTable  gsub;
+    HB_GPOS_SubTable  gpos;
+  } st;
+};
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+                          HB_Stream     input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+                           HB_Stream         input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_LookupList( HB_LookupList*  ll,
+                          HB_Stream        input,
+                          HB_Type         type );
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Coverage( HB_Coverage* c,
+                        HB_Stream      input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+                               HB_UShort             limit,
+                               HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+                                              HB_UShort             limit,
+                                              HB_UInt              class_offset,
+                                              HB_UInt              base_offset,
+                                              HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Device( HB_Device* d,
+                      HB_Stream    input );
+
+HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );
+HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );
+HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,
+                      HB_Type         type );
+
+HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );
+HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );
+HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );
+
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Coverage_Index( HB_Coverage* c,
+                         HB_UShort      glyphID,
+                         HB_UShort*     index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+                    HB_UShort             glyphID,
+                   HB_UShort*          klass,
+                    HB_UShort*            index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Device( HB_Device* d,
+                     HB_UShort    size,
+                     HB_Short*    value );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_PRIVATE_H */
index 8bc33dc..bdc6358 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_H\r
-#define HARFBUZZ_OPEN_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* Use this if a feature applies to all glyphs */\r
-#define HB_ALL_GLYPHS                    0xFFFF\r
-\r
-#define HB_DEFAULT_LANGUAGE              0xFFFF\r
-\r
-#define HB_MAX_NESTING_LEVEL             100\r
-\r
-\r
-/* Script list related structures */\r
-\r
-struct  HB_LangSys_\r
-{\r
-  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */\r
-  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */\r
-  HB_UShort   FeatureCount;           /* number of Feature indices */\r
-  HB_UShort*  FeatureIndex;           /* array of Feature indices  */\r
-};\r
-\r
-typedef struct HB_LangSys_  HB_LangSys;\r
-\r
-\r
-struct  HB_LangSysRecord_\r
-{\r
-  HB_UInt     LangSysTag;            /* LangSysTag identifier */\r
-  HB_LangSys  LangSys;               /* LangSys table         */\r
-};\r
-\r
-typedef struct HB_LangSysRecord_  HB_LangSysRecord;\r
-\r
-\r
-struct  HB_ScriptTable_\r
-{\r
-  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */\r
-  HB_UShort           LangSysCount;   /* number of LangSysRecords */\r
-  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptTable_  HB_ScriptTable;\r
-\r
-\r
-struct  HB_ScriptRecord_\r
-{\r
-  HB_UInt        ScriptTag;              /* ScriptTag identifier */\r
-  HB_ScriptTable  Script;                 /* Script table         */\r
-};\r
-\r
-typedef struct HB_ScriptRecord_  HB_ScriptRecord;\r
-\r
-\r
-struct  HB_ScriptList_\r
-{\r
-  HB_UShort          ScriptCount;     /* number of ScriptRecords */\r
-  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptList_  HB_ScriptList;\r
-\r
-\r
-/* Feature list related structures */\r
-\r
-struct HB_Feature_\r
-{\r
-  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */\r
-  HB_UShort   LookupListCount;        /* number of LookupList indices */\r
-  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */\r
-};\r
-\r
-typedef struct HB_Feature_  HB_Feature;\r
-\r
-\r
-struct  HB_FeatureRecord_\r
-{\r
-  HB_UInt     FeatureTag;            /* FeatureTag identifier */\r
-  HB_Feature  Feature;               /* Feature table         */\r
-};\r
-\r
-typedef struct HB_FeatureRecord_  HB_FeatureRecord;\r
-\r
-\r
-struct  HB_FeatureList_\r
-{\r
-  HB_UShort           FeatureCount;   /* number of FeatureRecords */\r
-  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */\r
-  HB_UShort*           ApplyOrder;     /* order to apply features */\r
-  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */\r
-};\r
-\r
-typedef struct HB_FeatureList_  HB_FeatureList;\r
-\r
-\r
-/* Lookup list related structures */\r
-\r
-typedef struct HB_SubTable_  HB_SubTable;\r
-\r
-\r
-struct  HB_Lookup_\r
-{\r
-  HB_UShort      LookupType;          /* Lookup type         */\r
-  HB_UShort      LookupFlag;          /* Lookup qualifiers   */\r
-  HB_UShort      SubTableCount;       /* number of SubTables */\r
-  HB_SubTable*  SubTable;            /* array of SubTables  */\r
-};\r
-\r
-typedef struct HB_Lookup_  HB_Lookup;\r
-\r
-\r
-/* The `Properties' field is not defined in the OpenType specification but\r
-   is needed for processing lookups.  If properties[n] is > 0, the\r
-   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will\r
-   process Lookup[n] for glyphs which have the specific bit not set in\r
-   the `properties' field of the input string object.                  */\r
-\r
-struct  HB_LookupList_\r
-{\r
-  HB_UShort    LookupCount;           /* number of Lookups       */\r
-  HB_Lookup*  Lookup;                /* array of Lookup records */\r
-  HB_UInt*     Properties;            /* array of flags          */\r
-};\r
-\r
-typedef struct HB_LookupList_  HB_LookupList;\r
-\r
-\r
-/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the\r
-   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in\r
-   OpenType 1.3 -- if set, the last glyph in a cursive attachment\r
-   sequence has to be positioned on the baseline -- regardless of the\r
-   writing direction.                                                    */\r
-\r
-#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001\r
-#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002\r
-#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004\r
-#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008\r
-#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00\r
-\r
-\r
-struct  HB_CoverageFormat1_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */\r
-  HB_UShort*  GlyphArray;             /* array of glyph IDs             */\r
-};\r
-\r
-typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;\r
-\r
-\r
-struct HB_RangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range */\r
-  HB_UShort  End;                     /* last glyph ID in the range  */\r
-  HB_UShort  StartCoverageIndex;      /* coverage index of first\r
-                                        glyph ID in the range       */\r
-};\r
-\r
-typedef struct HB_RangeRecord_  HB_RangeRecord;\r
-\r
-\r
-struct  HB_CoverageFormat2_\r
-{\r
-  HB_UShort         RangeCount;       /* number of RangeRecords */\r
-  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */\r
-};\r
-\r
-typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;\r
-\r
-\r
-struct  HB_Coverage_\r
-{\r
-  HB_UShort  CoverageFormat;          /* 1 or 2 */\r
-\r
-  union\r
-  {\r
-    HB_CoverageFormat1  cf1;\r
-    HB_CoverageFormat2  cf2;\r
-  } cf;\r
-};\r
-\r
-typedef struct HB_Coverage_  HB_Coverage;\r
-\r
-\r
-struct  HB_ClassDefFormat1_\r
-{\r
-  HB_UShort   StartGlyph;             /* first glyph ID of the\r
-                                        ClassValueArray             */\r
-  HB_UShort   GlyphCount;             /* size of the ClassValueArray */\r
-  HB_UShort*  ClassValueArray;        /* array of class values       */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;\r
-\r
-\r
-struct  HB_ClassRangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range    */\r
-  HB_UShort  End;                     /* last glyph ID in the range     */\r
-  HB_UShort  Class;                   /* applied to all glyphs in range */\r
-};\r
-\r
-typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;\r
-\r
-\r
-struct  HB_ClassDefFormat2_\r
-{\r
-  HB_UShort              ClassRangeCount;\r
-                                     /* number of ClassRangeRecords */\r
-  HB_ClassRangeRecord*  ClassRangeRecord;\r
-                                     /* array of ClassRangeRecords  */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;\r
-\r
-\r
-struct  HB_ClassDefinition_\r
-{\r
-  HB_Bool    loaded;\r
-\r
-  HB_UShort  ClassFormat;             /* 1 or 2                      */\r
-\r
-  union\r
-  {\r
-    HB_ClassDefFormat1  cd1;\r
-    HB_ClassDefFormat2  cd2;\r
-  } cd;\r
-};\r
-\r
-typedef struct HB_ClassDefinition_  HB_ClassDefinition;\r
-\r
-\r
-struct HB_Device_\r
-{\r
-  HB_UShort   StartSize;              /* smallest size to correct      */\r
-  HB_UShort   EndSize;                /* largest size to correct       */\r
-  HB_UShort   DeltaFormat;            /* DeltaValue array data format:\r
-                                        1, 2, or 3                    */\r
-  HB_UShort*  DeltaValue;             /* array of compressed data      */\r
-};\r
-\r
-typedef struct HB_Device_  HB_Device;\r
-\r
-\r
-enum  HB_Type_\r
-{\r
-  HB_Type_GSUB,\r
-  HB_Type_GPOS\r
-};\r
-\r
-typedef enum HB_Type_  HB_Type;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_H
+#define HARFBUZZ_OPEN_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* Use this if a feature applies to all glyphs */
+#define HB_ALL_GLYPHS                    0xFFFF
+
+#define HB_DEFAULT_LANGUAGE              0xFFFF
+
+#define HB_MAX_NESTING_LEVEL             100
+
+
+/* Script list related structures */
+
+struct  HB_LangSys_
+{
+  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */
+  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */
+  HB_UShort   FeatureCount;           /* number of Feature indices */
+  HB_UShort*  FeatureIndex;           /* array of Feature indices  */
+};
+
+typedef struct HB_LangSys_  HB_LangSys;
+
+
+struct  HB_LangSysRecord_
+{
+  HB_UInt     LangSysTag;            /* LangSysTag identifier */
+  HB_LangSys  LangSys;               /* LangSys table         */
+};
+
+typedef struct HB_LangSysRecord_  HB_LangSysRecord;
+
+
+struct  HB_ScriptTable_
+{
+  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */
+  HB_UShort           LangSysCount;   /* number of LangSysRecords */
+  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */
+};
+
+typedef struct HB_ScriptTable_  HB_ScriptTable;
+
+
+struct  HB_ScriptRecord_
+{
+  HB_UInt        ScriptTag;              /* ScriptTag identifier */
+  HB_ScriptTable  Script;                 /* Script table         */
+};
+
+typedef struct HB_ScriptRecord_  HB_ScriptRecord;
+
+
+struct  HB_ScriptList_
+{
+  HB_UShort          ScriptCount;     /* number of ScriptRecords */
+  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */
+};
+
+typedef struct HB_ScriptList_  HB_ScriptList;
+
+
+/* Feature list related structures */
+
+struct HB_Feature_
+{
+  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */
+  HB_UShort   LookupListCount;        /* number of LookupList indices */
+  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */
+};
+
+typedef struct HB_Feature_  HB_Feature;
+
+
+struct  HB_FeatureRecord_
+{
+  HB_UInt     FeatureTag;            /* FeatureTag identifier */
+  HB_Feature  Feature;               /* Feature table         */
+};
+
+typedef struct HB_FeatureRecord_  HB_FeatureRecord;
+
+
+struct  HB_FeatureList_
+{
+  HB_UShort           FeatureCount;   /* number of FeatureRecords */
+  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */
+  HB_UShort*           ApplyOrder;     /* order to apply features */
+  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */
+};
+
+typedef struct HB_FeatureList_  HB_FeatureList;
+
+
+/* Lookup list related structures */
+
+typedef struct HB_SubTable_  HB_SubTable;
+
+
+struct  HB_Lookup_
+{
+  HB_UShort      LookupType;          /* Lookup type         */
+  HB_UShort      LookupFlag;          /* Lookup qualifiers   */
+  HB_UShort      SubTableCount;       /* number of SubTables */
+  HB_SubTable*  SubTable;            /* array of SubTables  */
+};
+
+typedef struct HB_Lookup_  HB_Lookup;
+
+
+/* The `Properties' field is not defined in the OpenType specification but
+   is needed for processing lookups.  If properties[n] is > 0, the
+   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will
+   process Lookup[n] for glyphs which have the specific bit not set in
+   the `properties' field of the input string object.                  */
+
+struct  HB_LookupList_
+{
+  HB_UShort    LookupCount;           /* number of Lookups       */
+  HB_Lookup*  Lookup;                /* array of Lookup records */
+  HB_UInt*     Properties;            /* array of flags          */
+};
+
+typedef struct HB_LookupList_  HB_LookupList;
+
+
+/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the
+   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in
+   OpenType 1.3 -- if set, the last glyph in a cursive attachment
+   sequence has to be positioned on the baseline -- regardless of the
+   writing direction.                                                    */
+
+#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001
+#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002
+#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004
+#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008
+#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00
+
+
+struct  HB_CoverageFormat1_
+{
+  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */
+  HB_UShort*  GlyphArray;             /* array of glyph IDs             */
+};
+
+typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;
+
+
+struct HB_RangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range */
+  HB_UShort  End;                     /* last glyph ID in the range  */
+  HB_UShort  StartCoverageIndex;      /* coverage index of first
+                                        glyph ID in the range       */
+};
+
+typedef struct HB_RangeRecord_  HB_RangeRecord;
+
+
+struct  HB_CoverageFormat2_
+{
+  HB_UShort         RangeCount;       /* number of RangeRecords */
+  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */
+};
+
+typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;
+
+
+struct  HB_Coverage_
+{
+  HB_UShort  CoverageFormat;          /* 1 or 2 */
+
+  union
+  {
+    HB_CoverageFormat1  cf1;
+    HB_CoverageFormat2  cf2;
+  } cf;
+};
+
+typedef struct HB_Coverage_  HB_Coverage;
+
+
+struct  HB_ClassDefFormat1_
+{
+  HB_UShort   StartGlyph;             /* first glyph ID of the
+                                        ClassValueArray             */
+  HB_UShort   GlyphCount;             /* size of the ClassValueArray */
+  HB_UShort*  ClassValueArray;        /* array of class values       */
+};
+
+typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;
+
+
+struct  HB_ClassRangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range    */
+  HB_UShort  End;                     /* last glyph ID in the range     */
+  HB_UShort  Class;                   /* applied to all glyphs in range */
+};
+
+typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;
+
+
+struct  HB_ClassDefFormat2_
+{
+  HB_UShort              ClassRangeCount;
+                                     /* number of ClassRangeRecords */
+  HB_ClassRangeRecord*  ClassRangeRecord;
+                                     /* array of ClassRangeRecords  */
+};
+
+typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;
+
+
+struct  HB_ClassDefinition_
+{
+  HB_Bool    loaded;
+
+  HB_UShort  ClassFormat;             /* 1 or 2                      */
+
+  union
+  {
+    HB_ClassDefFormat1  cd1;
+    HB_ClassDefFormat2  cd2;
+  } cd;
+};
+
+typedef struct HB_ClassDefinition_  HB_ClassDefinition;
+
+
+struct HB_Device_
+{
+  HB_UShort   StartSize;              /* smallest size to correct      */
+  HB_UShort   EndSize;                /* largest size to correct       */
+  HB_UShort   DeltaFormat;            /* DeltaValue array data format:
+                                        1, 2, or 3                    */
+  HB_UShort*  DeltaValue;             /* array of compressed data      */
+};
+
+typedef struct HB_Device_  HB_Device;
+
+
+enum  HB_Type_
+{
+  HB_Type_GSUB,
+  HB_Type_GPOS
+};
+
+typedef enum HB_Type_  HB_Type;
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_H */
index 82c510a..e4b5f9a 100755 (executable)
-/*\r
- * Copyright (C) 2006  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor\r
- */\r
-\r
-#include <stdint.h>\r
-\r
-/* Base Types */\r
-\r
-typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */\r
-typedef char HB_Boolean;\r
-typedef hb_uint32 HB_Fixed; /* 26.6 */\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_uint32 HB_Unichar;\r
-\r
-/* Metrics reported by the font backend for use of the shaper */\r
-typedef struct _HB_GlyphMetrics HB_GlyphMetrics;\r
-struct _HB_GlyphMetrics\r
-{\r
-    HB_Fixed advance;\r
-    \r
-    /* Do we need ink/logical extents for the glyph here? */\r
-};\r
-\r
-/*\r
- * HB_Font: Abstract font interface.\r
- *  First pass of this might just have FT_Face *getFace();\r
- */\r
-typedef struct _HB_Font HB_Font;\r
-typedef struct _HB_FontClass HB_FontClass;\r
-\r
-struct HB_FontClass {\r
-    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);\r
-    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);\r
-    HB_Boolean (*freeSFontTable)(void **cookie);\r
-};\r
-\r
-struct _HB_Font {\r
-    HB_FontClass *clazz;\r
-};\r
-\r
-/*\r
- * Language tags, of the form en-us; represented as interned, canonicalized\r
- * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")\r
- * both return the same (pointer-comparable) HB_Language).\r
- */\r
-typedef struct HB_Language_ *HB_Language;\r
-\r
-HB_Language hb_language_from_string(const char *str);\r
-const char *hb_language_to_string(HB_Language language);\r
-\r
-/* Special treatment for the edges of runs.\r
- */\r
-typedef enum {\r
-    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,\r
-    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,\r
-    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */\r
-} HB_RunEdge;\r
-\r
-/* Defines optional informaiton in HB_ShapeInput; this allows extension\r
- * of HB_ShapeInput while keeping binary compatibility\r
- */\r
-typedef enum {\r
-    HB_SHAPE_START_TYPE = 1 << 0,\r
-    HB_SHAPE_END_TYPE   = 1 << 1\r
-} HB_ShapeFlags;\r
-\r
-/* Attributes types are described by "interned strings"; this is a little\r
- * annoying if you want to write a switch statement, but keeps things\r
- * simple.\r
- */\r
-typedef struct _HB_AttributeType *HB_AttributeType;\r
-\r
-HB_AttributeType hb_attribute_type_from_string(const char *str);\r
-const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);\r
-\r
-struct HB_Attribute {\r
-    HB_AttributeType type;\r
-    int start; \r
-    int end;\r
-};\r
-\r
-\r
-/**\r
- * You could handle this like HB_Language, but an enum seems a little nicer;\r
- * another approach would be to use OpenType script tags.\r
- */\r
-typedef enum {\r
-    HB_SCRIPT_LATIN\r
-    /* ... */\r
-} HB_ShapeScript;\r
-\r
-/* This is just the subset of direction information needed by the shaper */\r
-typedef enum {\r
-    HB_DIRECTION_LTR,\r
-    HB_DIRECTION_RTL,\r
-    HB_DIRECTION_TTB\r
-} HB_Direction;\r
-\r
-typedef struct _HB_ShapeInput HB_ShapeInput;\r
-struct _HB_ShapeInput {\r
-    /* Defines what fields the caller has initialized - fields not in\r
-     * the enum are mandatory.\r
-     */\r
-    HB_ShapeFlags flags;\r
-    \r
-    HB_CodePoint *text;\r
-    int length;       /* total length of text to shape */\r
-    int shape_offset; /* start of section to shape */\r
-    int shape_length; /* number of code points to shape */\r
-\r
-    HB_Direction direction;\r
-    HB_ShapeScript script;\r
-    HB_Language language;\r
-\r
-    HB_AttributeType *attributes;\r
-    int n_attributes;\r
-\r
-    HB_RunEdge start_type;\r
-    HB_RunEdge end_type;\r
-};\r
-\r
-struct HB_GlyphItem {\r
-    HB_Glyph glyph;\r
-    \r
-    HB_Fixed x_offset;\r
-    HB_Fixed y_offset;\r
-    HB_Fixed advance;\r
-\r
-    /* Add kashida information, etc, here */\r
-};\r
-\r
-typedef enum {\r
-    HB_RESULT_SUCCESS,\r
-    HB_RESULT_NO_MEMORY,\r
-    HB_SHAPE_RESULT_FAILED\r
-} HB_Result;\r
-\r
-/*\r
- * Buffer for output \r
- */\r
-typedef struct _HB_GlyphBuffer HB_GlyphBuffer;\r
-struct _HB_GlyphBuffer {\r
-    int glyph_item_size;\r
-    int total_glyphs;\r
-    \r
-    int *log_clusters; /* Uniscribe style */\r
-    int cluster_space;\r
-  \r
-    int glyph_space;\r
-    void *glyph_buffer;\r
-};\r
-\r
-/* Making this self-allocating simplifies writing shapers and\r
- * also keeps things easier for caller. item_size passed in\r
- * must be at least sizeof(HB_GlyphItem) but can be bigger,\r
- * to accomodate application structures that extend HB_GlyphItem.\r
- * The allocated items will be zero-initialized.\r
- *\r
- * (Hack: Harfbuzz could choose to use even a *bigger* item size\r
- * and stick internal information before the public item structure.\r
- * This hack could possibly be used to unify this with HB_Buffer)\r
- */\r
-HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);\r
-void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);\r
-HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);\r
-HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);\r
-void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);\r
-\r
-\r
-/* Accessor for a particular glyph */\r
-#define HB_GLYPH_BUFFER_ITEM(buffer, index)\r
-\r
-/*\r
- * Main shaping function\r
- */\r
-HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);\r
+/*
+ * Copyright (C) 2006  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor
+ */
+
+#include <stdint.h>
+
+/* Base Types */
+
+typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */
+typedef char HB_Boolean;
+typedef hb_uint32 HB_Fixed; /* 26.6 */
+typedef hb_uint32 HB_Glyph;
+typedef hb_uint32 HB_Unichar;
+
+/* Metrics reported by the font backend for use of the shaper */
+typedef struct _HB_GlyphMetrics HB_GlyphMetrics;
+struct _HB_GlyphMetrics
+{
+    HB_Fixed advance;
+    
+    /* Do we need ink/logical extents for the glyph here? */
+};
+
+/*
+ * HB_Font: Abstract font interface.
+ *  First pass of this might just have FT_Face *getFace();
+ */
+typedef struct _HB_Font HB_Font;
+typedef struct _HB_FontClass HB_FontClass;
+
+struct HB_FontClass {
+    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);
+    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);
+    HB_Boolean (*freeSFontTable)(void **cookie);
+};
+
+struct _HB_Font {
+    HB_FontClass *clazz;
+};
+
+/*
+ * Language tags, of the form en-us; represented as interned, canonicalized
+ * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")
+ * both return the same (pointer-comparable) HB_Language).
+ */
+typedef struct HB_Language_ *HB_Language;
+
+HB_Language hb_language_from_string(const char *str);
+const char *hb_language_to_string(HB_Language language);
+
+/* Special treatment for the edges of runs.
+ */
+typedef enum {
+    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,
+    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,
+    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */
+} HB_RunEdge;
+
+/* Defines optional informaiton in HB_ShapeInput; this allows extension
+ * of HB_ShapeInput while keeping binary compatibility
+ */
+typedef enum {
+    HB_SHAPE_START_TYPE = 1 << 0,
+    HB_SHAPE_END_TYPE   = 1 << 1
+} HB_ShapeFlags;
+
+/* Attributes types are described by "interned strings"; this is a little
+ * annoying if you want to write a switch statement, but keeps things
+ * simple.
+ */
+typedef struct _HB_AttributeType *HB_AttributeType;
+
+HB_AttributeType hb_attribute_type_from_string(const char *str);
+const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);
+
+struct HB_Attribute {
+    HB_AttributeType type;
+    int start; 
+    int end;
+};
+
+
+/**
+ * You could handle this like HB_Language, but an enum seems a little nicer;
+ * another approach would be to use OpenType script tags.
+ */
+typedef enum {
+    HB_SCRIPT_LATIN
+    /* ... */
+} HB_ShapeScript;
+
+/* This is just the subset of direction information needed by the shaper */
+typedef enum {
+    HB_DIRECTION_LTR,
+    HB_DIRECTION_RTL,
+    HB_DIRECTION_TTB
+} HB_Direction;
+
+typedef struct _HB_ShapeInput HB_ShapeInput;
+struct _HB_ShapeInput {
+    /* Defines what fields the caller has initialized - fields not in
+     * the enum are mandatory.
+     */
+    HB_ShapeFlags flags;
+    
+    HB_CodePoint *text;
+    int length;       /* total length of text to shape */
+    int shape_offset; /* start of section to shape */
+    int shape_length; /* number of code points to shape */
+
+    HB_Direction direction;
+    HB_ShapeScript script;
+    HB_Language language;
+
+    HB_AttributeType *attributes;
+    int n_attributes;
+
+    HB_RunEdge start_type;
+    HB_RunEdge end_type;
+};
+
+struct HB_GlyphItem {
+    HB_Glyph glyph;
+    
+    HB_Fixed x_offset;
+    HB_Fixed y_offset;
+    HB_Fixed advance;
+
+    /* Add kashida information, etc, here */
+};
+
+typedef enum {
+    HB_RESULT_SUCCESS,
+    HB_RESULT_NO_MEMORY,
+    HB_SHAPE_RESULT_FAILED
+} HB_Result;
+
+/*
+ * Buffer for output 
+ */
+typedef struct _HB_GlyphBuffer HB_GlyphBuffer;
+struct _HB_GlyphBuffer {
+    int glyph_item_size;
+    int total_glyphs;
+    
+    int *log_clusters; /* Uniscribe style */
+    int cluster_space;
+  
+    int glyph_space;
+    void *glyph_buffer;
+};
+
+/* Making this self-allocating simplifies writing shapers and
+ * also keeps things easier for caller. item_size passed in
+ * must be at least sizeof(HB_GlyphItem) but can be bigger,
+ * to accomodate application structures that extend HB_GlyphItem.
+ * The allocated items will be zero-initialized.
+ *
+ * (Hack: Harfbuzz could choose to use even a *bigger* item size
+ * and stick internal information before the public item structure.
+ * This hack could possibly be used to unify this with HB_Buffer)
+ */
+HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);
+void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);
+HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);
+HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);
+void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);
+
+
+/* Accessor for a particular glyph */
+#define HB_GLYPH_BUFFER_ITEM(buffer, index)
+
+/*
+ * Main shaping function
+ */
+HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);
index bb0ae9f..e4e7ebc 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_PRIVATE_H\r
-#define HARFBUZZ_SHAPER_PRIVATE_H\r
-\r
-HB_BEGIN_HEADER\r
-enum {\r
-    C_DOTTED_CIRCLE = 0x25CC\r
-};\r
-\r
-typedef enum \r
-{\r
-    HB_Combining_BelowLeftAttached       = 200,\r
-    HB_Combining_BelowAttached           = 202,\r
-    HB_Combining_BelowRightAttached      = 204,\r
-    HB_Combining_LeftAttached            = 208,\r
-    HB_Combining_RightAttached           = 210,\r
-    HB_Combining_AboveLeftAttached       = 212,\r
-    HB_Combining_AboveAttached           = 214,\r
-    HB_Combining_AboveRightAttached      = 216,\r
-\r
-    HB_Combining_BelowLeft               = 218,\r
-    HB_Combining_Below                   = 220,\r
-    HB_Combining_BelowRight              = 222,\r
-    HB_Combining_Left                    = 224,\r
-    HB_Combining_Right                   = 226,\r
-    HB_Combining_AboveLeft               = 228,\r
-    HB_Combining_Above                   = 230,\r
-    HB_Combining_AboveRight              = 232,\r
-\r
-    HB_Combining_DoubleBelow             = 233,\r
-    HB_Combining_DoubleAbove             = 234,\r
-    HB_Combining_IotaSubscript           = 240\r
-} HB_CombiningClass;\r
-\r
-typedef enum {\r
-    CcmpProperty = 0x1,\r
-    InitProperty = 0x2,\r
-    IsolProperty = 0x4,\r
-    FinaProperty = 0x8,\r
-    MediProperty = 0x10,\r
-    RligProperty = 0x20,\r
-    CaltProperty = 0x40,\r
-    LigaProperty = 0x80,\r
-    DligProperty = 0x100,\r
-    CswhProperty = 0x200,\r
-    MsetProperty = 0x400,\r
-\r
-    /* used by indic and myanmar shaper */\r
-    NuktaProperty = 0x4,\r
-    AkhantProperty = 0x8,\r
-    RephProperty = 0x10,\r
-    PreFormProperty = 0x20,\r
-    BelowFormProperty = 0x40,\r
-    AboveFormProperty = 0x80,\r
-    HalfFormProperty = 0x100,\r
-    PostFormProperty = 0x200,\r
-    VattuProperty = 0x400,\r
-    PreSubstProperty = 0x800,\r
-    BelowSubstProperty = 0x1000,\r
-    AboveSubstProperty = 0x2000,\r
-    PostSubstProperty = 0x4000,\r
-    HalantProperty = 0x8000,\r
-    CligProperty = 0x10000\r
-\r
-} HB_OpenTypeProperty;\r
-\r
-/* return true if ok. */\r
-typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);\r
-typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    HB_ShapeFunction shape;\r
-    HB_AttributeFunction charAttributes;\r
-} HB_ScriptEngine;\r
-\r
-extern const HB_ScriptEngine HB_ScriptEngines[];\r
-\r
-extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);\r
-\r
-extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    hb_uint32 tag;\r
-    hb_uint32 property;\r
-} HB_OpenTypeFeature;\r
-\r
-#define PositioningProperties 0x80000000\r
-\r
-HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);\r
-\r
-HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);\r
-HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);\r
-\r
-void HB_HeuristicPosition(HB_ShaperItem *item);\r
-void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);\r
-\r
-#define HB_IsControlChar(uc) \\r
-    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \\r
-     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \\r
-     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))\r
-\r
-HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);\r
-\r
-#define HB_GetGlyphAdvances(shaper_item) \\r
-    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \\r
-                                               shaper_item->glyphs, shaper_item->num_glyphs, \\r
-                                               shaper_item->advances, \\r
-                                               shaper_item->face->current_flags);\r
-\r
-#define HB_DECLARE_STACKARRAY(Type, Name) \\r
-    Type stack##Name[64]; \ \r
-    Type *Name = stack##Name;\r
-\r
-#define HB_INIT_STACKARRAY(Type, Name, Length) \\r
-    if ((Length) >= 64) \\r
-        Name = (Type *)malloc((Length) * sizeof(Type));\r
-\r
-#define HB_STACKARRAY(Type, Name, Length) \\r
-    HB_DECLARE_STACKARRAY(Type, Name) \\r
-    HB_INIT_STACKARRAY(Type, Name, Length)\r
-\r
-#define HB_FREE_STACKARRAY(Name) \\r
-    if (stack##Name != Name) \\r
-        free(Name);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_PRIVATE_H
+#define HARFBUZZ_SHAPER_PRIVATE_H
+
+HB_BEGIN_HEADER
+enum {
+    C_DOTTED_CIRCLE = 0x25CC
+};
+
+typedef enum 
+{
+    HB_Combining_BelowLeftAttached       = 200,
+    HB_Combining_BelowAttached           = 202,
+    HB_Combining_BelowRightAttached      = 204,
+    HB_Combining_LeftAttached            = 208,
+    HB_Combining_RightAttached           = 210,
+    HB_Combining_AboveLeftAttached       = 212,
+    HB_Combining_AboveAttached           = 214,
+    HB_Combining_AboveRightAttached      = 216,
+
+    HB_Combining_BelowLeft               = 218,
+    HB_Combining_Below                   = 220,
+    HB_Combining_BelowRight              = 222,
+    HB_Combining_Left                    = 224,
+    HB_Combining_Right                   = 226,
+    HB_Combining_AboveLeft               = 228,
+    HB_Combining_Above                   = 230,
+    HB_Combining_AboveRight              = 232,
+
+    HB_Combining_DoubleBelow             = 233,
+    HB_Combining_DoubleAbove             = 234,
+    HB_Combining_IotaSubscript           = 240
+} HB_CombiningClass;
+
+typedef enum {
+    CcmpProperty = 0x1,
+    InitProperty = 0x2,
+    IsolProperty = 0x4,
+    FinaProperty = 0x8,
+    MediProperty = 0x10,
+    RligProperty = 0x20,
+    CaltProperty = 0x40,
+    LigaProperty = 0x80,
+    DligProperty = 0x100,
+    CswhProperty = 0x200,
+    MsetProperty = 0x400,
+
+    /* used by indic and myanmar shaper */
+    NuktaProperty = 0x4,
+    AkhantProperty = 0x8,
+    RephProperty = 0x10,
+    PreFormProperty = 0x20,
+    BelowFormProperty = 0x40,
+    AboveFormProperty = 0x80,
+    HalfFormProperty = 0x100,
+    PostFormProperty = 0x200,
+    VattuProperty = 0x400,
+    PreSubstProperty = 0x800,
+    BelowSubstProperty = 0x1000,
+    AboveSubstProperty = 0x2000,
+    PostSubstProperty = 0x4000,
+    HalantProperty = 0x8000,
+    CligProperty = 0x10000
+
+} HB_OpenTypeProperty;
+
+/* return true if ok. */
+typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);
+typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    HB_ShapeFunction shape;
+    HB_AttributeFunction charAttributes;
+} HB_ScriptEngine;
+
+extern const HB_ScriptEngine HB_ScriptEngines[];
+
+extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);
+
+extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    hb_uint32 tag;
+    hb_uint32 property;
+} HB_OpenTypeFeature;
+
+#define PositioningProperties 0x80000000
+
+HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);
+
+HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);
+HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);
+
+void HB_HeuristicPosition(HB_ShaperItem *item);
+void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);
+
+#define HB_IsControlChar(uc) \
+    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \
+     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \
+     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))
+
+HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);
+
+#define HB_GetGlyphAdvances(shaper_item) \
+    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \
+                                               shaper_item->glyphs, shaper_item->num_glyphs, \
+                                               shaper_item->advances, \
+                                               shaper_item->face->current_flags);
+
+#define HB_DECLARE_STACKARRAY(Type, Name) \
+    Type stack##Name[64]; \ 
+    Type *Name = stack##Name;
+
+#define HB_INIT_STACKARRAY(Type, Name, Length) \
+    if ((Length) >= 64) \
+        Name = (Type *)malloc((Length) * sizeof(Type));
+
+#define HB_STACKARRAY(Type, Name, Length) \
+    HB_DECLARE_STACKARRAY(Type, Name) \
+    HB_INIT_STACKARRAY(Type, Name, Length)
+
+#define HB_FREE_STACKARRAY(Name) \
+    if (stack##Name != Name) \
+        free(Name);
+
+HB_END_HEADER
+
+#endif
index c74c664..9bdc8c6 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_H\r
-#define HARFBUZZ_SHAPER_H\r
-\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-external.h" \r
-#include "harfbuzz-stream-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef enum {\r
-        HB_Script_Common,\r
-        HB_Script_Greek,\r
-        HB_Script_Cyrillic,\r
-        HB_Script_Armenian,\r
-        HB_Script_Hebrew,\r
-        HB_Script_Arabic,\r
-        HB_Script_Syriac,\r
-        HB_Script_Thaana,\r
-        HB_Script_Devanagari,\r
-        HB_Script_Bengali,\r
-        HB_Script_Gurmukhi,\r
-        HB_Script_Gujarati,\r
-        HB_Script_Oriya,\r
-        HB_Script_Tamil,\r
-        HB_Script_Telugu,\r
-        HB_Script_Kannada,\r
-        HB_Script_Malayalam,\r
-        HB_Script_Sinhala,\r
-        HB_Script_Thai,\r
-        HB_Script_Lao,\r
-        HB_Script_Tibetan,\r
-        HB_Script_Myanmar,\r
-        HB_Script_Georgian,\r
-        HB_Script_Hangul,\r
-        HB_Script_Ogham,\r
-        HB_Script_Runic,\r
-        HB_Script_Khmer,\r
-        HB_Script_Nko,\r
-        HB_Script_Inherited,\r
-        HB_ScriptCount = HB_Script_Inherited\r
-        /*\r
-        HB_Script_Latin = Common,\r
-        HB_Script_Ethiopic = Common,\r
-        HB_Script_Cherokee = Common,\r
-        HB_Script_CanadianAboriginal = Common,\r
-        HB_Script_Mongolian = Common,\r
-        HB_Script_Hiragana = Common,\r
-        HB_Script_Katakana = Common,\r
-        HB_Script_Bopomofo = Common,\r
-        HB_Script_Han = Common,\r
-        HB_Script_Yi = Common,\r
-        HB_Script_OldItalic = Common,\r
-        HB_Script_Gothic = Common,\r
-        HB_Script_Deseret = Common,\r
-        HB_Script_Tagalog = Common,\r
-        HB_Script_Hanunoo = Common,\r
-        HB_Script_Buhid = Common,\r
-        HB_Script_Tagbanwa = Common,\r
-        HB_Script_Limbu = Common,\r
-        HB_Script_TaiLe = Common,\r
-        HB_Script_LinearB = Common,\r
-        HB_Script_Ugaritic = Common,\r
-        HB_Script_Shavian = Common,\r
-        HB_Script_Osmanya = Common,\r
-        HB_Script_Cypriot = Common,\r
-        HB_Script_Braille = Common,\r
-        HB_Script_Buginese = Common,\r
-        HB_Script_Coptic = Common,\r
-        HB_Script_NewTaiLue = Common,\r
-        HB_Script_Glagolitic = Common,\r
-        HB_Script_Tifinagh = Common,\r
-        HB_Script_SylotiNagri = Common,\r
-        HB_Script_OldPersian = Common,\r
-        HB_Script_Kharoshthi = Common,\r
-        HB_Script_Balinese = Common,\r
-        HB_Script_Cuneiform = Common,\r
-        HB_Script_Phoenician = Common,\r
-        HB_Script_PhagsPa = Common,\r
-        */\r
-} HB_Script;\r
-\r
-typedef struct\r
-{\r
-    hb_uint32 pos;\r
-    hb_uint32 length;\r
-    HB_Script script;\r
-    hb_uint8 bidiLevel;\r
-} HB_ScriptItem;\r
-\r
-typedef enum {\r
-    HB_NoBreak,\r
-    HB_SoftHyphen,\r
-    HB_Break,\r
-    HB_ForcedBreak\r
-} HB_LineBreakType;\r
-\r
-\r
-typedef struct {\r
-    /*HB_LineBreakType*/ unsigned lineBreakType  :2;\r
-    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */\r
-    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */\r
-    /*HB_Bool*/ unsigned wordBoundary            :1;\r
-    /*HB_Bool*/ unsigned sentenceBoundary        :1;\r
-    unsigned unused                  :2;\r
-} HB_CharAttributes;\r
-\r
-void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                              const HB_ScriptItem *items, hb_uint32 numItems,\r
-                              HB_CharAttributes *attributes);\r
-\r
-\r
-typedef enum {\r
-    HB_LeftToRight = 0,\r
-    HB_RightToLeft = 1\r
-} HB_StringToGlyphsFlags;\r
-\r
-typedef enum {\r
-    HB_ShaperFlag_Default = 0,\r
-    HB_ShaperFlag_NoKerning = 1,\r
-    HB_ShaperFlag_UseDesignMetrics = 2\r
-} HB_ShaperFlag;\r
-\r
-/* \r
-   highest value means highest priority for justification. Justification is done by first inserting kashidas\r
-   starting with the highest priority positions, then stretching spaces, afterwards extending inter char\r
-   spacing, and last spacing between arabic words.\r
-   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.\r
-*/\r
-typedef enum {\r
-    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */\r
-    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */\r
-    HB_Character      = 2,   /* Inter-character justification point follows this glyph */\r
-    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */\r
-    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */\r
-    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */\r
-    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */\r
-    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */\r
-    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */\r
-    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */\r
-    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */\r
-} HB_JustificationClass;\r
-\r
-/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep\r
- * it like that. If this is a problem please tell Trolltech :)\r
- */\r
-typedef struct {\r
-    unsigned justification   :4;  /* Justification class */\r
-    unsigned clusterStart    :1;  /* First glyph of representation of cluster */\r
-    unsigned mark            :1;  /* needs to be positioned around base char */\r
-    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */\r
-    unsigned dontPrint       :1;\r
-    unsigned combiningClass  :8;\r
-} HB_GlyphAttributes;\r
-\r
-typedef struct HB_FaceRec_ {\r
-    HB_Bool isSymbolFont;\r
-\r
-    HB_GDEF gdef;\r
-    HB_GSUB gsub;\r
-    HB_GPOS gpos;\r
-    HB_Bool supported_scripts[HB_ScriptCount];\r
-    HB_Buffer buffer;\r
-    HB_Script current_script;\r
-    int current_flags; /* HB_ShaperFlags */\r
-    HB_Bool has_opentype_kerning;\r
-    HB_Bool glyphs_substituted;\r
-    HB_GlyphAttributes *tmpAttributes;\r
-    unsigned int *tmpLogClusters;\r
-    int length;\r
-    int orig_nglyphs;\r
-} HB_FaceRec;\r
-\r
-typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);\r
-\r
-HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);\r
-void HB_FreeFace(HB_Face face);\r
-\r
-typedef struct {\r
-    HB_Fixed x, y;\r
-    HB_Fixed width, height;\r
-    HB_Fixed xOffset, yOffset;\r
-} HB_GlyphMetrics;\r
-\r
-typedef enum {\r
-    HB_FontAscent\r
-} HB_FontMetric;\r
-\r
-typedef struct {\r
-    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);\r
-    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);\r
-    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);\r
-    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */\r
-    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);\r
-    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);\r
-} HB_FontClass;\r
-\r
-typedef struct HB_Font_ {\r
-    const HB_FontClass *klass;\r
-\r
-    /* Metrics */\r
-    HB_UShort x_ppem, y_ppem;\r
-    HB_16Dot16 x_scale, y_scale;\r
-\r
-    void *userData;\r
-} HB_FontRec;\r
-\r
-typedef struct HB_ShaperItem_ HB_ShaperItem;\r
-\r
-struct HB_ShaperItem_ {\r
-    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */\r
-    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */\r
-    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */\r
-    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */\r
-    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */\r
-    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */\r
-    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */\r
-    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */\r
-\r
-    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */\r
-                                            /* output: required capacity (may be larger than actual capacity) */\r
-\r
-    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */\r
-    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */\r
-    HB_Fixed *advances;                     /* output: <num_glyphs> advances */\r
-    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */\r
-    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */\r
-\r
-    /* internal */\r
-    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */\r
-};\r
-\r
-HB_Bool HB_ShapeItem(HB_ShaperItem *item);\r
-\r
-\r
-extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-//#ifdef __cplusplus\r
-//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;\r
-//#endif\r
-\r
-extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_H
+#define HARFBUZZ_SHAPER_H
+
+#include "harfbuzz-global.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-external.h" 
+#include "harfbuzz-stream-private.h"
+
+HB_BEGIN_HEADER
+
+typedef enum {
+        HB_Script_Common,
+        HB_Script_Greek,
+        HB_Script_Cyrillic,
+        HB_Script_Armenian,
+        HB_Script_Hebrew,
+        HB_Script_Arabic,
+        HB_Script_Syriac,
+        HB_Script_Thaana,
+        HB_Script_Devanagari,
+        HB_Script_Bengali,
+        HB_Script_Gurmukhi,
+        HB_Script_Gujarati,
+        HB_Script_Oriya,
+        HB_Script_Tamil,
+        HB_Script_Telugu,
+        HB_Script_Kannada,
+        HB_Script_Malayalam,
+        HB_Script_Sinhala,
+        HB_Script_Thai,
+        HB_Script_Lao,
+        HB_Script_Tibetan,
+        HB_Script_Myanmar,
+        HB_Script_Georgian,
+        HB_Script_Hangul,
+        HB_Script_Ogham,
+        HB_Script_Runic,
+        HB_Script_Khmer,
+        HB_Script_Nko,
+        HB_Script_Inherited,
+        HB_ScriptCount = HB_Script_Inherited
+        /*
+        HB_Script_Latin = Common,
+        HB_Script_Ethiopic = Common,
+        HB_Script_Cherokee = Common,
+        HB_Script_CanadianAboriginal = Common,
+        HB_Script_Mongolian = Common,
+        HB_Script_Hiragana = Common,
+        HB_Script_Katakana = Common,
+        HB_Script_Bopomofo = Common,
+        HB_Script_Han = Common,
+        HB_Script_Yi = Common,
+        HB_Script_OldItalic = Common,
+        HB_Script_Gothic = Common,
+        HB_Script_Deseret = Common,
+        HB_Script_Tagalog = Common,
+        HB_Script_Hanunoo = Common,
+        HB_Script_Buhid = Common,
+        HB_Script_Tagbanwa = Common,
+        HB_Script_Limbu = Common,
+        HB_Script_TaiLe = Common,
+        HB_Script_LinearB = Common,
+        HB_Script_Ugaritic = Common,
+        HB_Script_Shavian = Common,
+        HB_Script_Osmanya = Common,
+        HB_Script_Cypriot = Common,
+        HB_Script_Braille = Common,
+        HB_Script_Buginese = Common,
+        HB_Script_Coptic = Common,
+        HB_Script_NewTaiLue = Common,
+        HB_Script_Glagolitic = Common,
+        HB_Script_Tifinagh = Common,
+        HB_Script_SylotiNagri = Common,
+        HB_Script_OldPersian = Common,
+        HB_Script_Kharoshthi = Common,
+        HB_Script_Balinese = Common,
+        HB_Script_Cuneiform = Common,
+        HB_Script_Phoenician = Common,
+        HB_Script_PhagsPa = Common,
+        */
+} HB_Script;
+
+typedef struct
+{
+    hb_uint32 pos;
+    hb_uint32 length;
+    HB_Script script;
+    hb_uint8 bidiLevel;
+} HB_ScriptItem;
+
+typedef enum {
+    HB_NoBreak,
+    HB_SoftHyphen,
+    HB_Break,
+    HB_ForcedBreak
+} HB_LineBreakType;
+
+
+typedef struct {
+    /*HB_LineBreakType*/ unsigned lineBreakType  :2;
+    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */
+    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */
+    /*HB_Bool*/ unsigned wordBoundary            :1;
+    /*HB_Bool*/ unsigned sentenceBoundary        :1;
+    unsigned unused                  :2;
+} HB_CharAttributes;
+
+void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                              const HB_ScriptItem *items, hb_uint32 numItems,
+                              HB_CharAttributes *attributes);
+
+
+typedef enum {
+    HB_LeftToRight = 0,
+    HB_RightToLeft = 1
+} HB_StringToGlyphsFlags;
+
+typedef enum {
+    HB_ShaperFlag_Default = 0,
+    HB_ShaperFlag_NoKerning = 1,
+    HB_ShaperFlag_UseDesignMetrics = 2
+} HB_ShaperFlag;
+
+/* 
+   highest value means highest priority for justification. Justification is done by first inserting kashidas
+   starting with the highest priority positions, then stretching spaces, afterwards extending inter char
+   spacing, and last spacing between arabic words.
+   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.
+*/
+typedef enum {
+    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */
+    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */
+    HB_Character      = 2,   /* Inter-character justification point follows this glyph */
+    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */
+    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */
+    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */
+    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */
+    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
+    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */
+    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */
+    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */
+} HB_JustificationClass;
+
+/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep
+ * it like that. If this is a problem please tell Trolltech :)
+ */
+typedef struct {
+    unsigned justification   :4;  /* Justification class */
+    unsigned clusterStart    :1;  /* First glyph of representation of cluster */
+    unsigned mark            :1;  /* needs to be positioned around base char */
+    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */
+    unsigned dontPrint       :1;
+    unsigned combiningClass  :8;
+} HB_GlyphAttributes;
+
+typedef struct HB_FaceRec_ {
+    HB_Bool isSymbolFont;
+
+    HB_GDEF gdef;
+    HB_GSUB gsub;
+    HB_GPOS gpos;
+    HB_Bool supported_scripts[HB_ScriptCount];
+    HB_Buffer buffer;
+    HB_Script current_script;
+    int current_flags; /* HB_ShaperFlags */
+    HB_Bool has_opentype_kerning;
+    HB_Bool glyphs_substituted;
+    HB_GlyphAttributes *tmpAttributes;
+    unsigned int *tmpLogClusters;
+    int length;
+    int orig_nglyphs;
+} HB_FaceRec;
+
+typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
+
+HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);
+void HB_FreeFace(HB_Face face);
+
+typedef struct {
+    HB_Fixed x, y;
+    HB_Fixed width, height;
+    HB_Fixed xOffset, yOffset;
+} HB_GlyphMetrics;
+
+typedef enum {
+    HB_FontAscent
+} HB_FontMetric;
+
+typedef struct {
+    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
+    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);
+    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
+    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */
+    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
+    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);
+} HB_FontClass;
+
+typedef struct HB_Font_ {
+    const HB_FontClass *klass;
+
+    /* Metrics */
+    HB_UShort x_ppem, y_ppem;
+    HB_16Dot16 x_scale, y_scale;
+
+    void *userData;
+} HB_FontRec;
+
+typedef struct HB_ShaperItem_ HB_ShaperItem;
+
+struct HB_ShaperItem_ {
+    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */
+    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */
+    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */
+    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */
+    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */
+    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */
+    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */
+    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */
+
+    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */
+                                            /* output: required capacity (may be larger than actual capacity) */
+
+    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */
+    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */
+    HB_Fixed *advances;                     /* output: <num_glyphs> advances */
+    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */
+    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */
+
+    /* internal */
+    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */
+};
+
+HB_Bool HB_ShapeItem(HB_ShaperItem *item);
+
+
+extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+//#ifdef __cplusplus
+//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;
+//#endif
+
+extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+
+
+HB_END_HEADER
+
+#endif
index 322cf08..7dd41ad 100755 (executable)
@@ -1,81 +1,81 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_PRIVATE_H\r
-#define HARFBUZZ_STREAM_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-HB_INTERNAL void\r
-_hb_close_stream( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Int\r
-_hb_stream_pos( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_seek( HB_Stream stream,\r
-                 HB_UInt   pos );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_frame_enter( HB_Stream stream,\r
-                        HB_UInt   size );\r
-\r
-HB_INTERNAL    void\r
-_hb_stream_frame_exit( HB_Stream stream );\r
-\r
-/* convenience macros */\r
-\r
-#define  SET_ERR(c)   ( (error = (c)) != 0 )\r
-\r
-#define  GOTO_Table(tag) (0)\r
-#define  FILE_Pos()      _hb_stream_pos( stream )\r
-#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )\r
-#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )\r
-#define  FORGET_Frame()      _hb_stream_frame_exit( stream )\r
-\r
-#define  GET_Byte()      (*stream->cursor++)\r
-#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \\r
-                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \\r
-                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-\r
-\r
-#define  GET_Char()      ((HB_Char)GET_Byte())\r
-#define  GET_UShort()    ((HB_UShort)GET_Short())\r
-#define  GET_ULong()     ((HB_UInt)GET_Long())\r
-#define  GET_Tag4()      GET_ULong()\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_STREAM_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_PRIVATE_H
+#define HARFBUZZ_STREAM_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+HB_INTERNAL void
+_hb_close_stream( HB_Stream stream );
+
+HB_INTERNAL    HB_Int
+_hb_stream_pos( HB_Stream stream );
+
+HB_INTERNAL    HB_Error
+_hb_stream_seek( HB_Stream stream,
+                 HB_UInt   pos );
+
+HB_INTERNAL    HB_Error
+_hb_stream_frame_enter( HB_Stream stream,
+                        HB_UInt   size );
+
+HB_INTERNAL    void
+_hb_stream_frame_exit( HB_Stream stream );
+
+/* convenience macros */
+
+#define  SET_ERR(c)   ( (error = (c)) != 0 )
+
+#define  GOTO_Table(tag) (0)
+#define  FILE_Pos()      _hb_stream_pos( stream )
+#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )
+#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )
+#define  FORGET_Frame()      _hb_stream_frame_exit( stream )
+
+#define  GET_Byte()      (*stream->cursor++)
+#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \
+                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \
+                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+
+
+#define  GET_Char()      ((HB_Char)GET_Byte())
+#define  GET_UShort()    ((HB_UShort)GET_Short())
+#define  GET_ULong()     ((HB_UInt)GET_Long())
+#define  GET_Tag4()      GET_ULong()
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_STREAM_PRIVATE_H */
index e49c307..07578d5 100755 (executable)
@@ -1,42 +1,42 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_H\r
-#define HARFBUZZ_STREAM_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_StreamRec_\r
-{\r
-    HB_Byte*       base;\r
-    HB_UInt        size;\r
-    HB_UInt        pos;\r
-    \r
-    HB_Byte*       cursor;\r
-} HB_StreamRec;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_H
+#define HARFBUZZ_STREAM_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_StreamRec_
+{
+    HB_Byte*       base;
+    HB_UInt        size;
+    HB_UInt        pos;
+    
+    HB_Byte*       cursor;
+} HB_StreamRec;
+
+
+HB_END_HEADER
+
+#endif
index d127458..8d86779 100755 (executable)
@@ -1,49 +1,49 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_H\r
-#define HARFBUZZ_H\r
-\r
-#include "harfbuzz-external.h"\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-buffer.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-shaper.h"\r
-\r
-#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */\r
-#define HB_ZWJ           0x200D   /** Zero Width Joiner */\r
-#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */\r
-\r
-#define HB_INITIAL_NO_OF_GLYPH 64\r
-\r
-extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;\r
-extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;\r
-extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_H
+#define HARFBUZZ_H
+
+#include "harfbuzz-external.h"
+#include "harfbuzz-impl.h"
+#include "harfbuzz-global.h"
+#include "harfbuzz-buffer.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-shaper.h"
+
+#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */
+#define HB_ZWJ           0x200D   /** Zero Width Joiner */
+#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */
+
+#define HB_INITIAL_NO_OF_GLYPH 64
+
+extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;
+extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;
+extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;
+
+#endif /* HARFBUZZ_OPEN_H */
index 20e40e6..0ff1a4e 100755 (executable)
-\r
-/*\r
- * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef __hb_unicode_tables_h__\r
-#define __hb_unicode_tables_h__\r
-\r
-#include "math.h"\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-typedef struct\r
-{\r
-       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable\r
-       HB_Script *pSubTable;\r
-\r
-}unicodeScriptTableStruct;\r
-\r
-HB_Script subTableThanaSyriac[] = \r
-{\r
-       HB_Script_Syriac,//0x00\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x08\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x10\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x18\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x20\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x28\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x30\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x38\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x40\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x48\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,//0x4f\r
-\r
-       HB_Script_Common,//0x50\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x58\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x60\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x68\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x70\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x78\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Thaana,//0x80\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x88\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x90\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x98\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,//0xbf\r
-};\r
-\r
-HB_Script subTableDevaBengali[] = \r
-{\r
-       HB_Script_Devanagari,//0x00\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x08\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x10\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x18\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x20\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x28\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x30\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x38\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x40\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x48\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x4f\r
-\r
-       HB_Script_Devanagari,//0x50\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x58\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x60\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x68\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x70\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x78\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x7f\r
-\r
-\r
-       HB_Script_Bengali,//0x80\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x88\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x90\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0x98\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xb0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xb8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xc0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xc8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xe0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xe8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableGuruGuarati[]=\r
-{\r
-       HB_Script_Gurmukhi,//0x00\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x08\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x10\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x18\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x20\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x28\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x30\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x38\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x40\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x48\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x4f\r
-\r
-       HB_Script_Gurmukhi,//0x50\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x58\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x60\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x68\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x70\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x78\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x7f\r
-\r
-\r
-       HB_Script_Gujarati,//0x80\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x88\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x90\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0x98\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xb0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xb8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xc0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xc8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xe0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xe8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOriyaTamil[]=\r
-{\r
-       HB_Script_Oriya,//0x00\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x08\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x10\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x18\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x20\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x28\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x30\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x38\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x40\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x48\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x4f\r
-\r
-       HB_Script_Oriya,//0x50\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x58\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x60\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x68\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x70\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x78\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x7f\r
-\r
-\r
-       HB_Script_Tamil,//0x80\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x88\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x90\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0x98\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xb0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xb8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xc0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xc8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xe0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xe8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableTelukannada[]=\r
-{\r
-       HB_Script_Telugu,//0x00\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x08\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x10\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x18\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x20\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x28\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x30\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x38\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x40\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x48\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x4f\r
-\r
-       HB_Script_Telugu,//0x50\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x58\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x60\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x68\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x70\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x78\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x7f\r
-\r
-\r
-       HB_Script_Kannada,//0x80\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x88\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x90\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0x98\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xb0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xb8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xc0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xc8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xe0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xe8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMalSinhala[]=\r
-{\r
-       HB_Script_Malayalam,//0x00\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x08\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x10\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x18\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x20\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x28\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x30\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x38\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x40\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x48\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x4f\r
-\r
-       HB_Script_Malayalam,//0x50\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x58\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x60\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x68\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x70\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x78\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x7f\r
-\r
-\r
-       HB_Script_Sinhala,//0x80\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x88\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x90\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0x98\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xb0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xb8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xc0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xc8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xe0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xe8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableThaiLao[]=\r
-{\r
-       HB_Script_Thai,//0x00\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x08\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x10\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x18\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x20\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x28\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x30\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x38\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x40\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x48\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x4f\r
-\r
-       HB_Script_Thai,//0x50\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x58\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x60\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x68\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x70\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x78\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x7f\r
-\r
-\r
-       HB_Script_Lao,//0x80\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x88\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x90\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0x98\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xb0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xb8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xc0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xc8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xe0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xe8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMyanGeorgian[] =\r
-{\r
-       HB_Script_Myanmar,//0x00\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x08\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x10\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x18\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x20\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x28\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x30\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x38\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x40\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x48\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x4f\r
-\r
-       HB_Script_Myanmar,//0x50\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x58\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x60\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x68\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x70\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x78\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x7f\r
-\r
-\r
-       HB_Script_Myanmar,//0x80\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x88\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x90\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x98\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Georgian,//0xa0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xa8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xb0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xb8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xc0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xc8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xe0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xe8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOghamRunic[] = \r
-{\r
-       HB_Script_Ogham,//0x00\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x08\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x10\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x18\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x20\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x28\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x30\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x38\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x40\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x48\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x4f\r
-\r
-       HB_Script_Ogham,//0x50\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x58\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x60\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x68\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x70\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x78\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x7f\r
-\r
-\r
-       HB_Script_Ogham,//0x80\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x88\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x90\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x98\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Runic,//0xa0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xa8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xb0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xb8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xc0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xc8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xe0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xe8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,//0xff\r
-\r
-};\r
-\r
-#define VFE_UNICODE_MAX_SCRIPT 256\r
-\r
-static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=\r
-{\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Greek, 0},\r
-\r
-       {HB_Script_Cyrillic, 0},//0x04\r
-       {HB_Script_Armenian, 0},\r
-       {HB_Script_Arabic, 0},\r
-       {0xc0, subTableThanaSyriac},\r
-\r
-       {HB_Script_Common, 0},//0x08\r
-       {0x100, subTableDevaBengali},\r
-       {0x100, subTableGuruGuarati},\r
-       {0x100, subTableOriyaTamil},\r
-       \r
-       {0x100, subTableTelukannada},//0x0c\r
-       {0x100, subTableMalSinhala},\r
-       {0x100, subTableThaiLao},\r
-       {HB_Script_Tibetan, 0},\r
-\r
-       {0x100, subTableMyanGeorgian},//0x10\r
-       {HB_Script_Hangul, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x14\r
-       {HB_Script_Common, 0},\r
-       {0x100, subTableOghamRunic},\r
-       {HB_Script_Khmer, 0},\r
-\r
-       {HB_Script_Common, 0},//0x18\r
-       {HB_Script_Khmer, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x1c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x20\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x24\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x28\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x2c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x30\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x34\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x38\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x3c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x44\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x48\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x4c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x50\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x54\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x58\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x5c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x60\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x64\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x68\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x6c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x70\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x74\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x78\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x7c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x80\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x84\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x88\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x8c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x94\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x98\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x9c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xac\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xbc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xcc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xdc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xec\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xfc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},//ff\r
-};\r
-\r
-#endif /* __hb_unicode_tables_h__ */\r
-\r
+
+/*
+ * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef __hb_unicode_tables_h__
+#define __hb_unicode_tables_h__
+
+#include "math.h"
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+typedef struct
+{
+       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable
+       HB_Script *pSubTable;
+
+}unicodeScriptTableStruct;
+
+HB_Script subTableThanaSyriac[] = 
+{
+       HB_Script_Syriac,//0x00
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x08
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x10
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x18
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x20
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x28
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x30
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x38
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x40
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x48
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,//0x4f
+
+       HB_Script_Common,//0x50
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x58
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x60
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x68
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x70
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x78
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Thaana,//0x80
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x88
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x90
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x98
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,//0xbf
+};
+
+HB_Script subTableDevaBengali[] = 
+{
+       HB_Script_Devanagari,//0x00
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x08
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x10
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x18
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x20
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x28
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x30
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x38
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x40
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x48
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x4f
+
+       HB_Script_Devanagari,//0x50
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x58
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x60
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x68
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x70
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x78
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x7f
+
+
+       HB_Script_Bengali,//0x80
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x88
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x90
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0x98
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xb0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xb8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xc0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xc8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xe0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xe8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,//0xff
+
+};
+
+
+HB_Script subTableGuruGuarati[]=
+{
+       HB_Script_Gurmukhi,//0x00
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x08
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x10
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x18
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x20
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x28
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x30
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x38
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x40
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x48
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x4f
+
+       HB_Script_Gurmukhi,//0x50
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x58
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x60
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x68
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x70
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x78
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x7f
+
+
+       HB_Script_Gujarati,//0x80
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x88
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x90
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0x98
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xb0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xb8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xc0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xc8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xe0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xe8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,//0xff
+
+};
+
+HB_Script subTableOriyaTamil[]=
+{
+       HB_Script_Oriya,//0x00
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x08
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x10
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x18
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x20
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x28
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x30
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x38
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x40
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x48
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x4f
+
+       HB_Script_Oriya,//0x50
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x58
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x60
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x68
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x70
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x78
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x7f
+
+
+       HB_Script_Tamil,//0x80
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x88
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x90
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0x98
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xb0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xb8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xc0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xc8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xe0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xe8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,//0xff
+
+};
+
+
+HB_Script subTableTelukannada[]=
+{
+       HB_Script_Telugu,//0x00
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x08
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x10
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x18
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x20
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x28
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x30
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x38
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x40
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x48
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x4f
+
+       HB_Script_Telugu,//0x50
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x58
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x60
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x68
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x70
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x78
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x7f
+
+
+       HB_Script_Kannada,//0x80
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x88
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x90
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0x98
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xb0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xb8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xc0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xc8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xe0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xe8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,//0xff
+
+};
+
+HB_Script subTableMalSinhala[]=
+{
+       HB_Script_Malayalam,//0x00
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x08
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x10
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x18
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x20
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x28
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x30
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x38
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x40
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x48
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x4f
+
+       HB_Script_Malayalam,//0x50
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x58
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x60
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x68
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x70
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x78
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x7f
+
+
+       HB_Script_Sinhala,//0x80
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x88
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x90
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0x98
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xb0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xb8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xc0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xc8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xe0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xe8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,//0xff
+
+};
+
+HB_Script subTableThaiLao[]=
+{
+       HB_Script_Thai,//0x00
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x08
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x10
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x18
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x20
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x28
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x30
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x38
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x40
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x48
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x4f
+
+       HB_Script_Thai,//0x50
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x58
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x60
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x68
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x70
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x78
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x7f
+
+
+       HB_Script_Lao,//0x80
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x88
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x90
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0x98
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xb0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xb8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xc0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xc8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xe0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xe8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,//0xff
+
+};
+
+HB_Script subTableMyanGeorgian[] =
+{
+       HB_Script_Myanmar,//0x00
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x08
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x10
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x18
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x20
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x28
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x30
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x38
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x40
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x48
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x4f
+
+       HB_Script_Myanmar,//0x50
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x58
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x60
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x68
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x70
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x78
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x7f
+
+
+       HB_Script_Myanmar,//0x80
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x88
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x90
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x98
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Georgian,//0xa0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xa8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xb0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xb8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xc0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xc8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xe0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xe8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,//0xff
+
+};
+
+HB_Script subTableOghamRunic[] = 
+{
+       HB_Script_Ogham,//0x00
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x08
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x10
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x18
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x20
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x28
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x30
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x38
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x40
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x48
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x4f
+
+       HB_Script_Ogham,//0x50
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x58
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x60
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x68
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x70
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x78
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x7f
+
+
+       HB_Script_Ogham,//0x80
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x88
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x90
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x98
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Runic,//0xa0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xa8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xb0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xb8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xc0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xc8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xe0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xe8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,//0xff
+
+};
+
+#define VFE_UNICODE_MAX_SCRIPT 256
+
+static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=
+{
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Greek, 0},
+
+       {HB_Script_Cyrillic, 0},//0x04
+       {HB_Script_Armenian, 0},
+       {HB_Script_Arabic, 0},
+       {0xc0, subTableThanaSyriac},
+
+       {HB_Script_Common, 0},//0x08
+       {0x100, subTableDevaBengali},
+       {0x100, subTableGuruGuarati},
+       {0x100, subTableOriyaTamil},
+       
+       {0x100, subTableTelukannada},//0x0c
+       {0x100, subTableMalSinhala},
+       {0x100, subTableThaiLao},
+       {HB_Script_Tibetan, 0},
+
+       {0x100, subTableMyanGeorgian},//0x10
+       {HB_Script_Hangul, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x14
+       {HB_Script_Common, 0},
+       {0x100, subTableOghamRunic},
+       {HB_Script_Khmer, 0},
+
+       {HB_Script_Common, 0},//0x18
+       {HB_Script_Khmer, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x1c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x20
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x24
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x28
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x2c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x30
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x34
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x38
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x3c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x44
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x48
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x4c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x50
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x54
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x58
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x5c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x60
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x64
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x68
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x6c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x70
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x74
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x78
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x7c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x80
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x84
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x88
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x8c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x94
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x98
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x9c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xac
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xbc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xcc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xdc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xec
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xfc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},//ff
+};
+
+#endif /* __hb_unicode_tables_h__ */
+
index abee691..4f2ce80 100755 (executable)
Binary files a/harfbuzz-0.1/debian/libharfbuzz/usr/share/doc/libharfbuzz/changelog.Debian.gz and b/harfbuzz-0.1/debian/libharfbuzz/usr/share/doc/libharfbuzz/changelog.Debian.gz differ
index 1b039ba..5065f2e 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_PRIVATE_H\r
-#define HARFBUZZ_BUFFER_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_swap( HB_Buffer buffer );\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_clear_output( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_clear_positions( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyphs( HB_Buffer  buffer,\r
-                             HB_UShort  num_in,\r
-                             HB_UShort  num_out,\r
-                             HB_UShort *glyph_data,\r
-                             HB_UShort  component,\r
-                             HB_UShort  ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyph ( HB_Buffer buffer,\r
-                             HB_UInt   glyph_index,\r
-                             HB_UShort component,\r
-                             HB_UShort ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_replace_output_glyph ( HB_Buffer buffer,\r
-                                 HB_UInt   glyph_index,\r
-                                 HB_Bool   inplace );\r
-\r
-HB_INTERNAL HB_UShort\r
-_hb_buffer_allocate_ligid( HB_Buffer buffer );\r
-\r
-\r
-/* convenience macros */\r
-\r
-#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)\r
-#define IN_ITEM( pos )         (&buffer->in_string[(pos)])\r
-#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)\r
-#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])\r
-#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)\r
-#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)\r
-#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)\r
-#define POSITION( pos )        (&buffer->positions[(pos)])\r
-#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)\r
-#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])\r
-\r
-#define CHECK_Property( gdef, index, flags, property )                                 \\r
-          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \\r
-                                      (property) ) ) != HB_Err_Ok )\r
-\r
-#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \\r
-          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \\r
-                                                   (num_in), (num_out),                \\r
-                                                    (glyph_data), (component), (ligID)  \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \\r
-          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \\r
-                                                    (glyph_index), (component), (ligID) \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \\r
-          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \\r
-                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )\r
-#define COPY_Glyph( buffer )                                                           \\r
-         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_PRIVATE_H
+#define HARFBUZZ_BUFFER_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
+
+HB_INTERNAL void
+_hb_buffer_swap( HB_Buffer buffer );
+
+HB_INTERNAL void
+_hb_buffer_clear_output( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_clear_positions( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyphs( HB_Buffer  buffer,
+                             HB_UShort  num_in,
+                             HB_UShort  num_out,
+                             HB_UShort *glyph_data,
+                             HB_UShort  component,
+                             HB_UShort  ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyph ( HB_Buffer buffer,
+                             HB_UInt   glyph_index,
+                             HB_UShort component,
+                             HB_UShort ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_copy_output_glyph ( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_replace_output_glyph ( HB_Buffer buffer,
+                                 HB_UInt   glyph_index,
+                                 HB_Bool   inplace );
+
+HB_INTERNAL HB_UShort
+_hb_buffer_allocate_ligid( HB_Buffer buffer );
+
+
+/* convenience macros */
+
+#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)
+#define IN_ITEM( pos )         (&buffer->in_string[(pos)])
+#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)
+#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])
+#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)
+#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)
+#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)
+#define POSITION( pos )        (&buffer->positions[(pos)])
+#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)
+#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])
+
+#define CHECK_Property( gdef, index, flags, property )                                 \
+          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \
+                                      (property) ) ) != HB_Err_Ok )
+
+#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \
+          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \
+                                                   (num_in), (num_out),                \
+                                                    (glyph_data), (component), (ligID)  \
+                                                  ) ) != HB_Err_Ok )
+#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \
+          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \
+                                                    (glyph_index), (component), (ligID) \
+                                                  ) ) != HB_Err_Ok )
+#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \
+          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \
+                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )
+#define COPY_Glyph( buffer )                                                           \
+         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_PRIVATE_H */
index e215e9f..b134407 100755 (executable)
@@ -1,94 +1,94 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_H\r
-#define HARFBUZZ_BUFFER_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_GlyphItemRec_ {\r
-  HB_UInt     gindex;\r
-  HB_UInt     properties;\r
-  HB_UInt     cluster;\r
-  HB_UShort   component;\r
-  HB_UShort   ligID;\r
-  HB_UShort   gproperties;\r
-} HB_GlyphItemRec, *HB_GlyphItem;\r
-\r
-typedef struct HB_PositionRec_ {\r
-  HB_Fixed   x_pos;\r
-  HB_Fixed   y_pos;\r
-  HB_Fixed   x_advance;\r
-  HB_Fixed   y_advance;\r
-  HB_UShort  back;            /* number of glyphs to go back\r
-                                for drawing current glyph   */\r
-  HB_Bool    new_advance;     /* if set, the advance width values are\r
-                                absolute, i.e., they won't be\r
-                                added to the original glyph's value\r
-                                but rather replace them.            */\r
-  HB_Short  cursive_chain;   /* character to which this connects,\r
-                                may be positive or negative; used\r
-                                only internally                     */\r
-} HB_PositionRec, *HB_Position;\r
-\r
-\r
-typedef struct HB_BufferRec_{ \r
-  HB_UInt    allocated;\r
-\r
-  HB_UInt    in_length;\r
-  HB_UInt    out_length;\r
-  HB_UInt    in_pos;\r
-  HB_UInt    out_pos;\r
-  \r
-  HB_Bool       separate_out;\r
-  HB_GlyphItem  in_string;\r
-  HB_GlyphItem  out_string;\r
-  HB_GlyphItem  alt_string;\r
-  HB_Position   positions;\r
-  HB_UShort      max_ligID;\r
-} HB_BufferRec, *HB_Buffer;\r
-\r
-HB_Error\r
-hb_buffer_new( HB_Buffer *buffer );\r
-\r
-void\r
-hb_buffer_free( HB_Buffer buffer );\r
-\r
-void\r
-hb_buffer_clear( HB_Buffer buffer );\r
-\r
-HB_Error\r
-hb_buffer_add_glyph( HB_Buffer buffer,\r
-                     HB_UInt    glyph_index,\r
-                     HB_UInt    properties,\r
-                     HB_UInt    cluster );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_H
+#define HARFBUZZ_BUFFER_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_GlyphItemRec_ {
+  HB_UInt     gindex;
+  HB_UInt     properties;
+  HB_UInt     cluster;
+  HB_UShort   component;
+  HB_UShort   ligID;
+  HB_UShort   gproperties;
+} HB_GlyphItemRec, *HB_GlyphItem;
+
+typedef struct HB_PositionRec_ {
+  HB_Fixed   x_pos;
+  HB_Fixed   y_pos;
+  HB_Fixed   x_advance;
+  HB_Fixed   y_advance;
+  HB_UShort  back;            /* number of glyphs to go back
+                                for drawing current glyph   */
+  HB_Bool    new_advance;     /* if set, the advance width values are
+                                absolute, i.e., they won't be
+                                added to the original glyph's value
+                                but rather replace them.            */
+  HB_Short  cursive_chain;   /* character to which this connects,
+                                may be positive or negative; used
+                                only internally                     */
+} HB_PositionRec, *HB_Position;
+
+
+typedef struct HB_BufferRec_{ 
+  HB_UInt    allocated;
+
+  HB_UInt    in_length;
+  HB_UInt    out_length;
+  HB_UInt    in_pos;
+  HB_UInt    out_pos;
+  
+  HB_Bool       separate_out;
+  HB_GlyphItem  in_string;
+  HB_GlyphItem  out_string;
+  HB_GlyphItem  alt_string;
+  HB_Position   positions;
+  HB_UShort      max_ligID;
+} HB_BufferRec, *HB_Buffer;
+
+HB_Error
+hb_buffer_new( HB_Buffer *buffer );
+
+void
+hb_buffer_free( HB_Buffer buffer );
+
+void
+hb_buffer_clear( HB_Buffer buffer );
+
+HB_Error
+hb_buffer_add_glyph( HB_Buffer buffer,
+                     HB_UInt    glyph_index,
+                     HB_UInt    properties,
+                     HB_UInt    cluster );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_H */
index 5d552e7..ea4a62b 100755 (executable)
@@ -1,41 +1,41 @@
-/*\r
- * Copyright (C) 2000, 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_DUMP_H\r
-#define HARFBUZZ_DUMP_H\r
-\r
-#include <stdio.h>\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);\r
-void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_DUMP_H */\r
+/*
+ * Copyright (C) 2000, 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_DUMP_H
+#define HARFBUZZ_DUMP_H
+
+#include <stdio.h>
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);
+void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_DUMP_H */
index d2e36d6..d064f87 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_EXTERNAL_H\r
-#define HARFBUZZ_EXTERNAL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* This header contains some methods that are not part of\r
-   Harfbuzz itself, but referenced by it.\r
-   They need to be provided by the application/library\r
-*/\r
-\r
-\r
-/*\r
- see http://www.unicode.org/reports/tr14/tr14-19.html\r
- we don't use the XX, AI and CB properties and map them to AL instead.\r
- as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.\r
-*/\r
-typedef enum {\r
-    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,\r
-    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,\r
-    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,\r
-    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,\r
-    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,\r
-    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,\r
-    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK\r
-} HB_LineBreakClass;\r
-\r
-typedef enum \r
-{\r
-    HB_NoCategory,\r
-\r
-    HB_Mark_NonSpacing,          /*   Mn */\r
-    HB_Mark_SpacingCombining,    /*   Mc */\r
-    HB_Mark_Enclosing,           /*   Me */\r
-\r
-    HB_Number_DecimalDigit,      /*   Nd */\r
-    HB_Number_Letter,            /*   Nl */\r
-    HB_Number_Other,             /*   No */\r
-\r
-    HB_Separator_Space,          /*   Zs */\r
-    HB_Separator_Line,           /*   Zl */\r
-    HB_Separator_Paragraph,      /*   Zp */\r
-\r
-    HB_Other_Control,            /*   Cc */\r
-    HB_Other_Format,             /*   Cf */\r
-    HB_Other_Surrogate,          /*   Cs */\r
-    HB_Other_PrivateUse,         /*   Co */\r
-    HB_Other_NotAssigned,        /*   Cn */\r
-\r
-    HB_Letter_Uppercase,         /*   Lu */\r
-    HB_Letter_Lowercase,         /*   Ll */\r
-    HB_Letter_Titlecase,         /*   Lt */\r
-    HB_Letter_Modifier,          /*   Lm */\r
-    HB_Letter_Other,             /*   Lo */\r
-\r
-    HB_Punctuation_Connector,    /*   Pc */\r
-    HB_Punctuation_Dash,         /*   Pd */\r
-    HB_Punctuation_Open,         /*   Ps */\r
-    HB_Punctuation_Close,        /*   Pe */\r
-    HB_Punctuation_InitialQuote, /*   Pi */\r
-    HB_Punctuation_FinalQuote,   /*   Pf */\r
-    HB_Punctuation_Other,        /*   Po */\r
-\r
-    HB_Symbol_Math,              /*   Sm */\r
-    HB_Symbol_Currency,          /*   Sc */\r
-    HB_Symbol_Modifier,          /*   Sk */\r
-    HB_Symbol_Other              /*   So */\r
-} HB_CharCategory;\r
-\r
-typedef enum\r
-{\r
-    HB_Grapheme_Other, \r
-    HB_Grapheme_CR,\r
-    HB_Grapheme_LF,\r
-    HB_Grapheme_Control,\r
-    HB_Grapheme_Extend,\r
-    HB_Grapheme_L, \r
-    HB_Grapheme_V, \r
-    HB_Grapheme_T, \r
-    HB_Grapheme_LV, \r
-    HB_Grapheme_LVT\r
-} HB_GraphemeClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Word_Other,\r
-    HB_Word_Format,\r
-    HB_Word_Katakana,\r
-    HB_Word_ALetter,\r
-    HB_Word_MidLetter,\r
-    HB_Word_MidNum,\r
-    HB_Word_Numeric,\r
-    HB_Word_ExtendNumLet\r
-} HB_WordClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Sentence_Other,\r
-    HB_Sentence_Sep,\r
-    HB_Sentence_Format,\r
-    HB_Sentence_Sp,\r
-    HB_Sentence_Lower,\r
-    HB_Sentence_Upper,\r
-    HB_Sentence_OLetter,\r
-    HB_Sentence_Numeric,\r
-    HB_Sentence_ATerm,\r
-    HB_Sentence_STerm,\r
-    HB_Sentence_Close\r
-} HB_SentenceClass;\r
-\r
-HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);\r
-HB_WordClass HB_GetWordClass(HB_UChar32 ch);\r
-HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);\r
-HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);\r
-\r
-void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);\r
-void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);\r
-HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);\r
-int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);\r
-HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);\r
-\r
-void *HB_Library_Resolve(const char *library, const char *symbol);\r
-\r
-void *HB_TextCodecForMib(int mib);\r
-char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);\r
-void HB_TextCodec_FreeResult(char *);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_EXTERNAL_H
+#define HARFBUZZ_EXTERNAL_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* This header contains some methods that are not part of
+   Harfbuzz itself, but referenced by it.
+   They need to be provided by the application/library
+*/
+
+
+/*
+ see http://www.unicode.org/reports/tr14/tr14-19.html
+ we don't use the XX, AI and CB properties and map them to AL instead.
+ as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.
+*/
+typedef enum {
+    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,
+    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,
+    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,
+    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,
+    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,
+    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,
+    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK
+} HB_LineBreakClass;
+
+typedef enum 
+{
+    HB_NoCategory,
+
+    HB_Mark_NonSpacing,          /*   Mn */
+    HB_Mark_SpacingCombining,    /*   Mc */
+    HB_Mark_Enclosing,           /*   Me */
+
+    HB_Number_DecimalDigit,      /*   Nd */
+    HB_Number_Letter,            /*   Nl */
+    HB_Number_Other,             /*   No */
+
+    HB_Separator_Space,          /*   Zs */
+    HB_Separator_Line,           /*   Zl */
+    HB_Separator_Paragraph,      /*   Zp */
+
+    HB_Other_Control,            /*   Cc */
+    HB_Other_Format,             /*   Cf */
+    HB_Other_Surrogate,          /*   Cs */
+    HB_Other_PrivateUse,         /*   Co */
+    HB_Other_NotAssigned,        /*   Cn */
+
+    HB_Letter_Uppercase,         /*   Lu */
+    HB_Letter_Lowercase,         /*   Ll */
+    HB_Letter_Titlecase,         /*   Lt */
+    HB_Letter_Modifier,          /*   Lm */
+    HB_Letter_Other,             /*   Lo */
+
+    HB_Punctuation_Connector,    /*   Pc */
+    HB_Punctuation_Dash,         /*   Pd */
+    HB_Punctuation_Open,         /*   Ps */
+    HB_Punctuation_Close,        /*   Pe */
+    HB_Punctuation_InitialQuote, /*   Pi */
+    HB_Punctuation_FinalQuote,   /*   Pf */
+    HB_Punctuation_Other,        /*   Po */
+
+    HB_Symbol_Math,              /*   Sm */
+    HB_Symbol_Currency,          /*   Sc */
+    HB_Symbol_Modifier,          /*   Sk */
+    HB_Symbol_Other              /*   So */
+} HB_CharCategory;
+
+typedef enum
+{
+    HB_Grapheme_Other, 
+    HB_Grapheme_CR,
+    HB_Grapheme_LF,
+    HB_Grapheme_Control,
+    HB_Grapheme_Extend,
+    HB_Grapheme_L, 
+    HB_Grapheme_V, 
+    HB_Grapheme_T, 
+    HB_Grapheme_LV, 
+    HB_Grapheme_LVT
+} HB_GraphemeClass;
+
+
+typedef enum
+{
+    HB_Word_Other,
+    HB_Word_Format,
+    HB_Word_Katakana,
+    HB_Word_ALetter,
+    HB_Word_MidLetter,
+    HB_Word_MidNum,
+    HB_Word_Numeric,
+    HB_Word_ExtendNumLet
+} HB_WordClass;
+
+
+typedef enum
+{
+    HB_Sentence_Other,
+    HB_Sentence_Sep,
+    HB_Sentence_Format,
+    HB_Sentence_Sp,
+    HB_Sentence_Lower,
+    HB_Sentence_Upper,
+    HB_Sentence_OLetter,
+    HB_Sentence_Numeric,
+    HB_Sentence_ATerm,
+    HB_Sentence_STerm,
+    HB_Sentence_Close
+} HB_SentenceClass;
+
+HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);
+HB_WordClass HB_GetWordClass(HB_UChar32 ch);
+HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);
+HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);
+
+void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);
+void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);
+HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);
+int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);
+HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);
+
+void *HB_Library_Resolve(const char *library, const char *symbol);
+
+void *HB_TextCodecForMib(int mib);
+char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);
+void HB_TextCodec_FreeResult(char *);
+
+HB_END_HEADER
+
+#endif
index 78543cd..da06b6f 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_PRIVATE_H\r
-#define HARFBUZZ_GDEF_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-buffer-private.h"\r
-#include "harfbuzz-gdef.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Attachment related structures */\r
-\r
-struct  HB_AttachPoint_\r
-{\r
-  HB_UShort   PointCount;             /* size of the PointIndex array */\r
-  HB_UShort*  PointIndex;             /* array of contour points      */\r
-};\r
-\r
-/* Ligature Caret related structures */\r
-\r
-struct  HB_CaretValueFormat1_\r
-{\r
-  HB_Short  Coordinate;               /* x or y value (in design units) */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;\r
-\r
-\r
-struct  HB_CaretValueFormat2_\r
-{\r
-  HB_UShort  CaretValuePoint;         /* contour point index on glyph */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;\r
-\r
-\r
-struct  HB_CaretValueFormat3_\r
-{\r
-  HB_Short    Coordinate;             /* x or y value (in design units) */\r
-  HB_Device  Device;                 /* Device table for x or y value  */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;\r
-\r
-\r
-struct  HB_CaretValueFormat4_\r
-{\r
-  HB_UShort  IdCaretValue;            /* metric ID */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;\r
-\r
-\r
-struct  HB_CaretValue_\r
-{\r
-  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */\r
-\r
-  union\r
-  {\r
-    HB_CaretValueFormat1  cvf1;\r
-    HB_CaretValueFormat2  cvf2;\r
-    HB_CaretValueFormat3  cvf3;\r
-    HB_CaretValueFormat4  cvf4;\r
-  } cvf;\r
-};\r
-\r
-typedef struct HB_CaretValue_  HB_CaretValue;\r
-\r
-\r
-struct  HB_LigGlyph_\r
-{\r
-  HB_Bool          loaded;\r
-\r
-  HB_UShort        CaretCount;        /* number of caret values */\r
-  HB_CaretValue*  CaretValue;        /* array of caret values  */\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,\r
-                                      HB_UShort        glyphID,\r
-                                      HB_UShort        property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,\r
-                                  HB_GlyphItem    item,\r
-                                  HB_UShort        flags,\r
-                                  HB_UShort*       property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,\r
-                                                 HB_Stream      input,\r
-                                                 HB_Lookup*     lo,\r
-                                                 HB_UShort      num_lookups );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_PRIVATE_H
+#define HARFBUZZ_GDEF_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-buffer-private.h"
+#include "harfbuzz-gdef.h"
+
+HB_BEGIN_HEADER
+
+
+/* Attachment related structures */
+
+struct  HB_AttachPoint_
+{
+  HB_UShort   PointCount;             /* size of the PointIndex array */
+  HB_UShort*  PointIndex;             /* array of contour points      */
+};
+
+/* Ligature Caret related structures */
+
+struct  HB_CaretValueFormat1_
+{
+  HB_Short  Coordinate;               /* x or y value (in design units) */
+};
+
+typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;
+
+
+struct  HB_CaretValueFormat2_
+{
+  HB_UShort  CaretValuePoint;         /* contour point index on glyph */
+};
+
+typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;
+
+
+struct  HB_CaretValueFormat3_
+{
+  HB_Short    Coordinate;             /* x or y value (in design units) */
+  HB_Device  Device;                 /* Device table for x or y value  */
+};
+
+typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;
+
+
+struct  HB_CaretValueFormat4_
+{
+  HB_UShort  IdCaretValue;            /* metric ID */
+};
+
+typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;
+
+
+struct  HB_CaretValue_
+{
+  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */
+
+  union
+  {
+    HB_CaretValueFormat1  cvf1;
+    HB_CaretValueFormat2  cvf2;
+    HB_CaretValueFormat3  cvf3;
+    HB_CaretValueFormat4  cvf4;
+  } cvf;
+};
+
+typedef struct HB_CaretValue_  HB_CaretValue;
+
+
+struct  HB_LigGlyph_
+{
+  HB_Bool          loaded;
+
+  HB_UShort        CaretCount;        /* number of caret values */
+  HB_CaretValue*  CaretValue;        /* array of caret values  */
+};
+
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+                                      HB_UShort        glyphID,
+                                      HB_UShort        property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+                                  HB_GlyphItem    item,
+                                  HB_UShort        flags,
+                                  HB_UShort*       property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,
+                                                 HB_Stream      input,
+                                                 HB_Lookup*     lo,
+                                                 HB_UShort      num_lookups );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_PRIVATE_H */
index bf7a70e..b6dcadc 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_H\r
-#define HARFBUZZ_GDEF_H\r
-\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding\r
- * flag in the LookupFlag field.     */\r
-#define HB_GDEF_BASE_GLYPH  0x0002\r
-#define HB_GDEF_LIGATURE    0x0004\r
-#define HB_GDEF_MARK        0x0008\r
-#define HB_GDEF_COMPONENT   0x0010\r
-\r
-\r
-typedef struct HB_AttachPoint_  HB_AttachPoint;\r
-\r
-\r
-struct  HB_AttachList_\r
-{\r
-  HB_Bool           loaded;\r
-\r
-  HB_Coverage       Coverage;         /* Coverage table              */\r
-  HB_UShort         GlyphCount;       /* number of glyphs with\r
-                                        attachments                 */\r
-  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */\r
-};\r
-\r
-typedef struct HB_AttachList_  HB_AttachList;\r
-\r
-typedef struct HB_LigGlyph_  HB_LigGlyph;\r
-\r
-struct  HB_LigCaretList_\r
-{\r
-  HB_Bool        loaded;\r
-\r
-  HB_Coverage    Coverage;            /* Coverage table            */\r
-  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */\r
-  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */\r
-};\r
-\r
-typedef struct HB_LigCaretList_  HB_LigCaretList;\r
-\r
-\r
-\r
-/* The `NewGlyphClasses' field is not defined in the TTO specification.\r
-   We use it for fonts with a constructed `GlyphClassDef' structure\r
-   (i.e., which don't have a GDEF table) to collect glyph classes\r
-   assigned during the lookup process.  The number of arrays in this\r
-   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth\r
-   array then contains the glyph class values of the glyphs not covered\r
-   by the ClassRangeRecords structures with index n-1 and n.  We store\r
-   glyph class values for four glyphs in a single array element.\r
-\r
-   `LastGlyph' is identical to the number of glyphs minus one in the\r
-   font; we need it only if `NewGlyphClasses' is not NULL (to have an\r
-   upper bound for the last array).\r
-\r
-   Note that we first store the file offset to the `MarkAttachClassDef'\r
-   field (which has been introduced in OpenType 1.2) -- since the\r
-   `Version' field value hasn't been increased to indicate that we have\r
-   one more field for some obscure reason, we must parse the GSUB table\r
-   to find out whether class values refer to this table.  Only then we\r
-   can finally load the MarkAttachClassDef structure if necessary.      */\r
-\r
-struct  HB_GDEFHeader_\r
-{\r
-  HB_UInt             offset;\r
-\r
-  HB_16Dot16             Version;\r
-\r
-  HB_ClassDefinition   GlyphClassDef;\r
-  HB_AttachList        AttachList;\r
-  HB_LigCaretList      LigCaretList;\r
-  HB_UInt             MarkAttachClassDef_offset;\r
-  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */\r
-\r
-  HB_UShort            LastGlyph;\r
-  HB_UShort**          NewGlyphClasses;\r
-};\r
-\r
-typedef struct HB_GDEFHeader_   HB_GDEFHeader;\r
-typedef struct HB_GDEFHeader_*  HB_GDEF;\r
-\r
-\r
-HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );\r
-      \r
-\r
-HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,\r
-                             HB_GDEFHeader** gdef );\r
-\r
-\r
-HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );\r
-\r
-\r
-HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,\r
-                                     HB_UShort        glyphID,\r
-                                     HB_UShort*       property );\r
-\r
-HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,\r
-                                        HB_UShort        num_glyphs,\r
-                                        HB_UShort        glyph_count,\r
-                                        HB_UShort*       glyph_array,\r
-                                        HB_UShort*       class_array );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_H
+#define HARFBUZZ_GDEF_H
+
+#include "harfbuzz-open.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding
+ * flag in the LookupFlag field.     */
+#define HB_GDEF_BASE_GLYPH  0x0002
+#define HB_GDEF_LIGATURE    0x0004
+#define HB_GDEF_MARK        0x0008
+#define HB_GDEF_COMPONENT   0x0010
+
+
+typedef struct HB_AttachPoint_  HB_AttachPoint;
+
+
+struct  HB_AttachList_
+{
+  HB_Bool           loaded;
+
+  HB_Coverage       Coverage;         /* Coverage table              */
+  HB_UShort         GlyphCount;       /* number of glyphs with
+                                        attachments                 */
+  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */
+};
+
+typedef struct HB_AttachList_  HB_AttachList;
+
+typedef struct HB_LigGlyph_  HB_LigGlyph;
+
+struct  HB_LigCaretList_
+{
+  HB_Bool        loaded;
+
+  HB_Coverage    Coverage;            /* Coverage table            */
+  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */
+  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */
+};
+
+typedef struct HB_LigCaretList_  HB_LigCaretList;
+
+
+
+/* The `NewGlyphClasses' field is not defined in the TTO specification.
+   We use it for fonts with a constructed `GlyphClassDef' structure
+   (i.e., which don't have a GDEF table) to collect glyph classes
+   assigned during the lookup process.  The number of arrays in this
+   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
+   array then contains the glyph class values of the glyphs not covered
+   by the ClassRangeRecords structures with index n-1 and n.  We store
+   glyph class values for four glyphs in a single array element.
+
+   `LastGlyph' is identical to the number of glyphs minus one in the
+   font; we need it only if `NewGlyphClasses' is not NULL (to have an
+   upper bound for the last array).
+
+   Note that we first store the file offset to the `MarkAttachClassDef'
+   field (which has been introduced in OpenType 1.2) -- since the
+   `Version' field value hasn't been increased to indicate that we have
+   one more field for some obscure reason, we must parse the GSUB table
+   to find out whether class values refer to this table.  Only then we
+   can finally load the MarkAttachClassDef structure if necessary.      */
+
+struct  HB_GDEFHeader_
+{
+  HB_UInt             offset;
+
+  HB_16Dot16             Version;
+
+  HB_ClassDefinition   GlyphClassDef;
+  HB_AttachList        AttachList;
+  HB_LigCaretList      LigCaretList;
+  HB_UInt             MarkAttachClassDef_offset;
+  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */
+
+  HB_UShort            LastGlyph;
+  HB_UShort**          NewGlyphClasses;
+};
+
+typedef struct HB_GDEFHeader_   HB_GDEFHeader;
+typedef struct HB_GDEFHeader_*  HB_GDEF;
+
+
+HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );
+      
+
+HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,
+                             HB_GDEFHeader** gdef );
+
+
+HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
+
+
+HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
+                                     HB_UShort        glyphID,
+                                     HB_UShort*       property );
+
+HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
+                                        HB_UShort        num_glyphs,
+                                        HB_UShort        glyph_count,
+                                        HB_UShort*       glyph_array,
+                                        HB_UShort*       class_array );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_H */
index 9b8bfbf..0bb5669 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- */\r
-\r
-#ifndef HARFBUZZ_GLOBAL_H\r
-#define HARFBUZZ_GLOBAL_H\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#ifdef __cplusplus\r
-#define HB_BEGIN_HEADER  extern "C" {\r
-#define HB_END_HEADER  }\r
-#else\r
-#define HB_BEGIN_HEADER  /* nothing */\r
-#define HB_END_HEADER  /* nothing */\r
-#endif\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef FALSE\r
-#define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-#define TRUE (!FALSE)\r
-#endif\r
-\r
-#ifndef false\r
-#define false 0\r
-#endif\r
-\r
-#ifndef true\r
-#define true (!FALSE)\r
-#endif\r
-\r
-#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \\r
-          ( ( (HB_UInt)_x1 << 24 ) |     \\r
-            ( (HB_UInt)_x2 << 16 ) |     \\r
-            ( (HB_UInt)_x3 <<  8 ) |     \\r
-              (HB_UInt)_x4         )\r
-\r
-typedef char hb_int8;\r
-typedef unsigned char hb_uint8;\r
-typedef short hb_int16;\r
-typedef unsigned short hb_uint16;\r
-typedef int hb_int32;\r
-typedef unsigned int hb_uint32;\r
-\r
-typedef hb_uint8 HB_Bool;\r
-typedef hb_uint8 bool;\r
-\r
-typedef hb_uint8 HB_Byte;\r
-typedef hb_uint16 HB_UShort;\r
-typedef hb_uint32 HB_UInt;\r
-typedef hb_int8 HB_Char;\r
-typedef hb_int16 HB_Short;\r
-typedef hb_int32 HB_Int;\r
-\r
-typedef hb_uint16 HB_UChar16;\r
-typedef hb_uint32 HB_UChar32;\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_int32 HB_Fixed; /* 26.6 */\r
-\r
-#define HB_FIXED_CONSTANT(v) ((v) * 64)\r
-#define HB_FIXED_ROUND(v) (((v)+32) & -64)\r
-\r
-typedef hb_int32 HB_16Dot16; /* 16.16 */\r
-\r
-typedef void * HB_Pointer;\r
-typedef hb_uint32 HB_Tag;\r
-\r
-typedef enum {\r
-  /* no error */\r
-  HB_Err_Ok                           = 0x0000,\r
-  HB_Err_Not_Covered                  = 0xFFFF,\r
-\r
-  /* _hb_err() is called whenever returning the following errors,\r
-   * and in a couple places for HB_Err_Not_Covered too. */\r
-\r
-  /* programmer error */\r
-  HB_Err_Invalid_Argument             = 0x1A66,\r
-\r
-  /* font error */\r
-  HB_Err_Invalid_SubTable_Format      = 0x157F,\r
-  HB_Err_Invalid_SubTable             = 0x1570,\r
-  HB_Err_Read_Error                   = 0x6EAD,\r
-\r
-  /* system error */\r
-  HB_Err_Out_Of_Memory                = 0xDEAD\r
-} HB_Error;\r
-\r
-typedef struct {\r
-    HB_Fixed x;\r
-    HB_Fixed y;\r
-} HB_FixedPoint;\r
-\r
-typedef struct HB_Font_ *HB_Font;\r
-typedef struct HB_StreamRec_ *HB_Stream;\r
-typedef struct HB_FaceRec_ *HB_Face;\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ */
+
+#ifndef HARFBUZZ_GLOBAL_H
+#define HARFBUZZ_GLOBAL_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+#define HB_BEGIN_HEADER  extern "C" {
+#define HB_END_HEADER  }
+#else
+#define HB_BEGIN_HEADER  /* nothing */
+#define HB_END_HEADER  /* nothing */
+#endif
+
+HB_BEGIN_HEADER
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+#ifndef false
+#define false 0
+#endif
+
+#ifndef true
+#define true (!FALSE)
+#endif
+
+#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
+          ( ( (HB_UInt)_x1 << 24 ) |     \
+            ( (HB_UInt)_x2 << 16 ) |     \
+            ( (HB_UInt)_x3 <<  8 ) |     \
+              (HB_UInt)_x4         )
+
+typedef char hb_int8;
+typedef unsigned char hb_uint8;
+typedef short hb_int16;
+typedef unsigned short hb_uint16;
+typedef int hb_int32;
+typedef unsigned int hb_uint32;
+
+typedef hb_uint8 HB_Bool;
+typedef hb_uint8 bool;
+
+typedef hb_uint8 HB_Byte;
+typedef hb_uint16 HB_UShort;
+typedef hb_uint32 HB_UInt;
+typedef hb_int8 HB_Char;
+typedef hb_int16 HB_Short;
+typedef hb_int32 HB_Int;
+
+typedef hb_uint16 HB_UChar16;
+typedef hb_uint32 HB_UChar32;
+typedef hb_uint32 HB_Glyph;
+typedef hb_int32 HB_Fixed; /* 26.6 */
+
+#define HB_FIXED_CONSTANT(v) ((v) * 64)
+#define HB_FIXED_ROUND(v) (((v)+32) & -64)
+
+typedef hb_int32 HB_16Dot16; /* 16.16 */
+
+typedef void * HB_Pointer;
+typedef hb_uint32 HB_Tag;
+
+typedef enum {
+  /* no error */
+  HB_Err_Ok                           = 0x0000,
+  HB_Err_Not_Covered                  = 0xFFFF,
+
+  /* _hb_err() is called whenever returning the following errors,
+   * and in a couple places for HB_Err_Not_Covered too. */
+
+  /* programmer error */
+  HB_Err_Invalid_Argument             = 0x1A66,
+
+  /* font error */
+  HB_Err_Invalid_SubTable_Format      = 0x157F,
+  HB_Err_Invalid_SubTable             = 0x1570,
+  HB_Err_Read_Error                   = 0x6EAD,
+
+  /* system error */
+  HB_Err_Out_Of_Memory                = 0xDEAD
+} HB_Error;
+
+typedef struct {
+    HB_Fixed x;
+    HB_Fixed y;
+} HB_FixedPoint;
+
+typedef struct HB_Font_ *HB_Font;
+typedef struct HB_StreamRec_ *HB_Stream;
+typedef struct HB_FaceRec_ *HB_Face;
+
+HB_END_HEADER
+
+#endif
index c2865ba..4110700 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_PRIVATE_H\r
-#define HARFBUZZ_GPOS_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* shared tables */\r
-\r
-struct  HB_ValueRecord_\r
-{\r
-  HB_Short    XPlacement;             /* horizontal adjustment for\r
-                                        placement                      */\r
-  HB_Short    YPlacement;             /* vertical adjustment for\r
-                                        placement                      */\r
-  HB_Short    XAdvance;               /* horizontal adjustment for\r
-                                        advance                        */\r
-  HB_Short    YAdvance;               /* vertical adjustment for\r
-                                        advance                        */\r
-  HB_Device  XPlacementDevice;       /* device table for horizontal\r
-                                        placement                      */\r
-  HB_Device  YPlacementDevice;       /* device table for vertical\r
-                                        placement                      */\r
-  HB_Device  XAdvanceDevice;         /* device table for horizontal\r
-                                        advance                        */\r
-  HB_Device  YAdvanceDevice;         /* device table for vertical\r
-                                        advance                        */\r
-  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */\r
-  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */\r
-  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */\r
-  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */\r
-};\r
-\r
-typedef struct HB_ValueRecord_  HB_ValueRecord;\r
-\r
-\r
-/* Mask values to scan the value format of the ValueRecord structure.\r
- We always expand compressed ValueRecords of the font.              */\r
-\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800\r
-\r
-\r
-struct  HB_AnchorFormat1_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value */\r
-  HB_Short   YCoordinate;             /* vertical value   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;\r
-\r
-\r
-struct  HB_AnchorFormat2_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value             */\r
-  HB_Short   YCoordinate;             /* vertical value               */\r
-  HB_UShort  AnchorPoint;             /* index to glyph contour point */\r
-};\r
-\r
-typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;\r
-\r
-\r
-struct  HB_AnchorFormat3_\r
-{\r
-  HB_Short    XCoordinate;            /* horizontal value              */\r
-  HB_Short    YCoordinate;            /* vertical value                */\r
-  HB_Device  XDeviceTable;           /* device table for X coordinate */\r
-  HB_Device  YDeviceTable;           /* device table for Y coordinate */\r
-};\r
-\r
-typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;\r
-\r
-\r
-struct  HB_AnchorFormat4_\r
-{\r
-  HB_UShort  XIdAnchor;               /* horizontal metric ID */\r
-  HB_UShort  YIdAnchor;               /* vertical metric ID   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;\r
-\r
-\r
-struct  HB_Anchor_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates\r
-                                        that there is no Anchor table */\r
-\r
-  union\r
-  {\r
-    HB_AnchorFormat1  af1;\r
-    HB_AnchorFormat2  af2;\r
-    HB_AnchorFormat3  af3;\r
-    HB_AnchorFormat4  af4;\r
-  } af;\r
-};\r
-\r
-typedef struct HB_Anchor_  HB_Anchor;\r
-\r
-\r
-struct  HB_MarkRecord_\r
-{\r
-  HB_UShort   Class;                  /* mark class   */\r
-  HB_Anchor  MarkAnchor;             /* anchor table */\r
-};\r
-\r
-typedef struct HB_MarkRecord_  HB_MarkRecord;\r
-\r
-\r
-struct  HB_MarkArray_\r
-{\r
-  HB_UShort        MarkCount;         /* number of MarkRecord tables */\r
-  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */\r
-};\r
-\r
-typedef struct HB_MarkArray_  HB_MarkArray;\r
-\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SinglePosFormat1_\r
-{\r
-  HB_ValueRecord  Value;             /* ValueRecord for all covered\r
-                                        glyphs                      */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;\r
-\r
-\r
-struct  HB_SinglePosFormat2_\r
-{\r
-  HB_UShort         ValueCount;       /* number of ValueRecord tables */\r
-  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;\r
-\r
-\r
-struct  HB_SinglePos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  HB_UShort     ValueFormat;          /* format of ValueRecord table */\r
-\r
-  union\r
-  {\r
-    HB_SinglePosFormat1  spf1;\r
-    HB_SinglePosFormat2  spf2;\r
-  } spf;\r
-};\r
-\r
-typedef struct HB_SinglePos_  HB_SinglePos;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_PairValueRecord_\r
-{\r
-  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_PairValueRecord_  HB_PairValueRecord;\r
-\r
-\r
-struct  HB_PairSet_\r
-{\r
-  HB_UShort             PairValueCount;\r
-                                     /* number of PairValueRecord tables */\r
-  HB_PairValueRecord*  PairValueRecord;\r
-                                     /* array of PairValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_PairSet_  HB_PairSet;\r
-\r
-\r
-struct  HB_PairPosFormat1_\r
-{\r
-  HB_UShort     PairSetCount;         /* number of PairSet tables    */\r
-  HB_PairSet*  PairSet;              /* array of PairSet tables     */\r
-};\r
-\r
-typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;\r
-\r
-\r
-struct  HB_Class2Record_\r
-{\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_Class2Record_  HB_Class2Record;\r
-\r
-\r
-struct  HB_Class1Record_\r
-{\r
-  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */\r
-};\r
-\r
-typedef struct HB_Class1Record_  HB_Class1Record;\r
-\r
-\r
-struct  HB_PairPosFormat2_\r
-{\r
-  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */\r
-  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */\r
-  HB_UShort            Class1Count;   /* number of classes in ClassDef1\r
-                                        table                          */\r
-  HB_UShort            Class2Count;   /* number of classes in ClassDef2\r
-                                        table                          */\r
-  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */\r
-};\r
-\r
-typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;\r
-\r
-\r
-struct  HB_PairPos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-  HB_UShort     ValueFormat1;         /* format of ValueRecord table\r
-                                        for first glyph             */\r
-  HB_UShort     ValueFormat2;         /* format of ValueRecord table\r
-                                        for second glyph            */\r
-\r
-  union\r
-  {\r
-    HB_PairPosFormat1  ppf1;\r
-    HB_PairPosFormat2  ppf2;\r
-  } ppf;\r
-};\r
-\r
-typedef struct HB_PairPos_  HB_PairPos;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_EntryExitRecord_\r
-{\r
-  HB_Anchor  EntryAnchor;            /* entry Anchor table */\r
-  HB_Anchor  ExitAnchor;             /* exit Anchor table  */\r
-};\r
-\r
-\r
-typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;\r
-\r
-struct  HB_CursivePos_\r
-{\r
-  HB_UShort             PosFormat;    /* always 1                         */\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             EntryExitCount;\r
-                                     /* number of EntryExitRecord tables */\r
-  HB_EntryExitRecord*  EntryExitRecord;\r
-                                     /* array of EntryExitRecord tables  */\r
-};\r
-\r
-typedef struct HB_CursivePos_  HB_CursivePos;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_BaseRecord_\r
-{\r
-  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_BaseRecord_  HB_BaseRecord;\r
-\r
-\r
-struct  HB_BaseArray_\r
-{\r
-  HB_UShort        BaseCount;         /* number of BaseRecord tables */\r
-  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */\r
-};\r
-\r
-typedef struct HB_BaseArray_  HB_BaseArray;\r
-\r
-\r
-struct  HB_MarkBasePos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1                  */\r
-  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */\r
-  HB_Coverage   BaseCoverage;        /* base glyph coverage table */\r
-  HB_UShort      ClassCount;          /* number of mark classes    */\r
-  HB_MarkArray  MarkArray;           /* mark array table          */\r
-  HB_BaseArray  BaseArray;           /* base array table          */\r
-};\r
-\r
-typedef struct HB_MarkBasePos_  HB_MarkBasePos;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_ComponentRecord_\r
-{\r
-  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor\r
-                                        tables                         */\r
-};\r
-\r
-typedef struct HB_ComponentRecord_  HB_ComponentRecord;\r
-\r
-\r
-struct  HB_LigatureAttach_\r
-{\r
-  HB_UShort             ComponentCount;\r
-                                     /* number of ComponentRecord tables */\r
-  HB_ComponentRecord*  ComponentRecord;\r
-                                     /* array of ComponentRecord tables  */\r
-};\r
-\r
-typedef struct HB_LigatureAttach_  HB_LigatureAttach;\r
-\r
-\r
-struct  HB_LigatureArray_\r
-{\r
-  HB_UShort            LigatureCount; /* number of LigatureAttach tables */\r
-  HB_LigatureAttach*  LigatureAttach;\r
-                                     /* array of LigatureAttach tables  */\r
-};\r
-\r
-typedef struct HB_LigatureArray_  HB_LigatureArray;\r
-\r
-\r
-struct  HB_MarkLigPos_\r
-{\r
-  HB_UShort          PosFormat;       /* always 1                      */\r
-  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */\r
-  HB_Coverage       LigatureCoverage;\r
-                                     /* ligature glyph coverage table */\r
-  HB_UShort          ClassCount;      /* number of mark classes        */\r
-  HB_MarkArray      MarkArray;       /* mark array table              */\r
-  HB_LigatureArray  LigatureArray;   /* ligature array table          */\r
-};\r
-\r
-typedef struct HB_MarkLigPos_  HB_MarkLigPos;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_Mark2Record_\r
-{\r
-  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_Mark2Record_  HB_Mark2Record;\r
-\r
-\r
-struct  HB_Mark2Array_\r
-{\r
-  HB_UShort         Mark2Count;       /* number of Mark2Record tables */\r
-  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */\r
-};\r
-\r
-typedef struct HB_Mark2Array_  HB_Mark2Array;\r
-\r
-\r
-struct  HB_MarkMarkPos_\r
-{\r
-  HB_UShort       PosFormat;          /* always 1                         */\r
-  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */\r
-  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */\r
-  HB_UShort       ClassCount;         /* number of combining mark classes */\r
-  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */\r
-  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */\r
-};\r
-\r
-typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;\r
-\r
-\r
-/* needed by both lookup type 7 and 8 */\r
-\r
-struct  HB_PosLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;\r
-\r
-\r
-/* LookupType 7 */\r
-\r
-struct  HB_PosRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of input glyphs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosRule_  HB_PosRule;\r
-\r
-\r
-struct  HB_PosRuleSet_\r
-{\r
-  HB_UShort     PosRuleCount;         /* number of PosRule tables */\r
-  HB_PosRule*  PosRule;              /* array of PosRule tables  */\r
-};\r
-\r
-typedef struct HB_PosRuleSet_  HB_PosRuleSet;\r
-\r
-\r
-struct  HB_ContextPosFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */\r
-  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;\r
-\r
-\r
-struct  HB_PosClassRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of context classes  */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Class;        /* array of classes                 */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosClassRule_  HB_PosClassRule;\r
-\r
-\r
-struct  HB_PosClassSet_\r
-{\r
-  HB_UShort          PosClassRuleCount;\r
-                                     /* number of PosClassRule tables */\r
-  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */\r
-};\r
-\r
-typedef struct HB_PosClassSet_  HB_PosClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextPosFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            PosClassSetCount;\r
-                                     /* number of PosClassSet tables */\r
-  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;\r
-\r
-\r
-struct  HB_ContextPosFormat3_\r
-{\r
-  HB_UShort             GlyphCount;   /* number of input glyphs           */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_Coverage*         Coverage;     /* array of Coverage tables         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;\r
-\r
-\r
-struct  HB_ContextPos_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, or 3     */\r
-\r
-  union\r
-  {\r
-    HB_ContextPosFormat1  cpf1;\r
-    HB_ContextPosFormat2  cpf2;\r
-    HB_ContextPosFormat3  cpf3;\r
-  } cpf;\r
-};\r
-\r
-typedef struct HB_ContextPos_  HB_ContextPos;\r
-\r
-\r
-/* LookupType 8 */\r
-\r
-struct  HB_ChainPosRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords       */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecords       */\r
-};\r
-\r
-typedef struct HB_ChainPosRule_  HB_ChainPosRule;\r
-\r
-\r
-struct  HB_ChainPosRuleSet_\r
-{\r
-  HB_UShort          ChainPosRuleCount;\r
-                                     /* number of ChainPosRule tables */\r
-  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;\r
-\r
-\r
-struct  HB_ChainContextPosFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainPosRuleSetCount;\r
-                                     /* number of ChainPosRuleSet tables */\r
-  HB_ChainPosRuleSet*  ChainPosRuleSet;\r
-                                     /* array of ChainPosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;\r
-\r
-\r
-struct  HB_ChainPosClassRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*            Backtrack;    /* array of backtrack classes      */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*            Input;        /* array of context classes        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*            Lookahead;    /* array of lookahead classes      */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords      */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;\r
-\r
-\r
-struct  HB_ChainPosClassSet_\r
-{\r
-  HB_UShort               ChainPosClassRuleCount;\r
-                                     /* number of ChainPosClassRule\r
-                                        tables                      */\r
-  HB_ChainPosClassRule*  ChainPosClassRule;\r
-                                     /* array of ChainPosClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextPosFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainPosClassSetCount;\r
-                                     /* number of ChainPosClassSet\r
-                                        tables                     */\r
-  HB_ChainPosClassSet*  ChainPosClassSet;\r
-                                     /* array of ChainPosClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;\r
-\r
-\r
-struct  HB_ChainContextPosFormat3_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*         BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*         InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*         LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords    */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;\r
-\r
-\r
-struct  HB_ChainContextPos_\r
-{\r
-  HB_UShort  PosFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextPosFormat1  ccpf1;\r
-    HB_ChainContextPosFormat2  ccpf2;\r
-    HB_ChainContextPosFormat3  ccpf3;\r
-  } ccpf;\r
-};\r
-\r
-typedef struct HB_ChainContextPos_  HB_ChainContextPos;\r
-\r
-\r
-#if 0\r
-/* LookupType 10 */\r
-struct HB_ExtensionPos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GPOS_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionPos_  HB_ExtensionPos;\r
-#endif\r
-\r
-\r
-union  HB_GPOS_SubTable_\r
-{\r
-  HB_SinglePos        single;\r
-  HB_PairPos          pair;\r
-  HB_CursivePos       cursive;\r
-  HB_MarkBasePos      markbase;\r
-  HB_MarkLigPos       marklig;\r
-  HB_MarkMarkPos      markmark;\r
-  HB_ContextPos       context;\r
-  HB_ChainContextPos  chain;\r
-};\r
-\r
-typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_PRIVATE_H
+#define HARFBUZZ_GPOS_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+
+/* shared tables */
+
+struct  HB_ValueRecord_
+{
+  HB_Short    XPlacement;             /* horizontal adjustment for
+                                        placement                      */
+  HB_Short    YPlacement;             /* vertical adjustment for
+                                        placement                      */
+  HB_Short    XAdvance;               /* horizontal adjustment for
+                                        advance                        */
+  HB_Short    YAdvance;               /* vertical adjustment for
+                                        advance                        */
+  HB_Device  XPlacementDevice;       /* device table for horizontal
+                                        placement                      */
+  HB_Device  YPlacementDevice;       /* device table for vertical
+                                        placement                      */
+  HB_Device  XAdvanceDevice;         /* device table for horizontal
+                                        advance                        */
+  HB_Device  YAdvanceDevice;         /* device table for vertical
+                                        advance                        */
+  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */
+  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */
+  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */
+  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */
+};
+
+typedef struct HB_ValueRecord_  HB_ValueRecord;
+
+
+/* Mask values to scan the value format of the ValueRecord structure.
+ We always expand compressed ValueRecords of the font.              */
+
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080
+#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100
+#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200
+#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400
+#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800
+
+
+struct  HB_AnchorFormat1_
+{
+  HB_Short   XCoordinate;             /* horizontal value */
+  HB_Short   YCoordinate;             /* vertical value   */
+};
+
+typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;
+
+
+struct  HB_AnchorFormat2_
+{
+  HB_Short   XCoordinate;             /* horizontal value             */
+  HB_Short   YCoordinate;             /* vertical value               */
+  HB_UShort  AnchorPoint;             /* index to glyph contour point */
+};
+
+typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;
+
+
+struct  HB_AnchorFormat3_
+{
+  HB_Short    XCoordinate;            /* horizontal value              */
+  HB_Short    YCoordinate;            /* vertical value                */
+  HB_Device  XDeviceTable;           /* device table for X coordinate */
+  HB_Device  YDeviceTable;           /* device table for Y coordinate */
+};
+
+typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;
+
+
+struct  HB_AnchorFormat4_
+{
+  HB_UShort  XIdAnchor;               /* horizontal metric ID */
+  HB_UShort  YIdAnchor;               /* vertical metric ID   */
+};
+
+typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;
+
+
+struct  HB_Anchor_
+{
+  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates
+                                        that there is no Anchor table */
+
+  union
+  {
+    HB_AnchorFormat1  af1;
+    HB_AnchorFormat2  af2;
+    HB_AnchorFormat3  af3;
+    HB_AnchorFormat4  af4;
+  } af;
+};
+
+typedef struct HB_Anchor_  HB_Anchor;
+
+
+struct  HB_MarkRecord_
+{
+  HB_UShort   Class;                  /* mark class   */
+  HB_Anchor  MarkAnchor;             /* anchor table */
+};
+
+typedef struct HB_MarkRecord_  HB_MarkRecord;
+
+
+struct  HB_MarkArray_
+{
+  HB_UShort        MarkCount;         /* number of MarkRecord tables */
+  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */
+};
+
+typedef struct HB_MarkArray_  HB_MarkArray;
+
+
+/* LookupType 1 */
+
+struct  HB_SinglePosFormat1_
+{
+  HB_ValueRecord  Value;             /* ValueRecord for all covered
+                                        glyphs                      */
+};
+
+typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;
+
+
+struct  HB_SinglePosFormat2_
+{
+  HB_UShort         ValueCount;       /* number of ValueRecord tables */
+  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */
+};
+
+typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;
+
+
+struct  HB_SinglePos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  HB_UShort     ValueFormat;          /* format of ValueRecord table */
+
+  union
+  {
+    HB_SinglePosFormat1  spf1;
+    HB_SinglePosFormat2  spf2;
+  } spf;
+};
+
+typedef struct HB_SinglePos_  HB_SinglePos;
+
+
+/* LookupType 2 */
+
+struct  HB_PairValueRecord_
+{
+  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_PairValueRecord_  HB_PairValueRecord;
+
+
+struct  HB_PairSet_
+{
+  HB_UShort             PairValueCount;
+                                     /* number of PairValueRecord tables */
+  HB_PairValueRecord*  PairValueRecord;
+                                     /* array of PairValueRecord tables  */
+};
+
+typedef struct HB_PairSet_  HB_PairSet;
+
+
+struct  HB_PairPosFormat1_
+{
+  HB_UShort     PairSetCount;         /* number of PairSet tables    */
+  HB_PairSet*  PairSet;              /* array of PairSet tables     */
+};
+
+typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;
+
+
+struct  HB_Class2Record_
+{
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_Class2Record_  HB_Class2Record;
+
+
+struct  HB_Class1Record_
+{
+  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */
+};
+
+typedef struct HB_Class1Record_  HB_Class1Record;
+
+
+struct  HB_PairPosFormat2_
+{
+  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */
+  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */
+  HB_UShort            Class1Count;   /* number of classes in ClassDef1
+                                        table                          */
+  HB_UShort            Class2Count;   /* number of classes in ClassDef2
+                                        table                          */
+  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */
+};
+
+typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;
+
+
+struct  HB_PairPos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+  HB_UShort     ValueFormat1;         /* format of ValueRecord table
+                                        for first glyph             */
+  HB_UShort     ValueFormat2;         /* format of ValueRecord table
+                                        for second glyph            */
+
+  union
+  {
+    HB_PairPosFormat1  ppf1;
+    HB_PairPosFormat2  ppf2;
+  } ppf;
+};
+
+typedef struct HB_PairPos_  HB_PairPos;
+
+
+/* LookupType 3 */
+
+struct  HB_EntryExitRecord_
+{
+  HB_Anchor  EntryAnchor;            /* entry Anchor table */
+  HB_Anchor  ExitAnchor;             /* exit Anchor table  */
+};
+
+
+typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;
+
+struct  HB_CursivePos_
+{
+  HB_UShort             PosFormat;    /* always 1                         */
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             EntryExitCount;
+                                     /* number of EntryExitRecord tables */
+  HB_EntryExitRecord*  EntryExitRecord;
+                                     /* array of EntryExitRecord tables  */
+};
+
+typedef struct HB_CursivePos_  HB_CursivePos;
+
+
+/* LookupType 4 */
+
+struct  HB_BaseRecord_
+{
+  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_BaseRecord_  HB_BaseRecord;
+
+
+struct  HB_BaseArray_
+{
+  HB_UShort        BaseCount;         /* number of BaseRecord tables */
+  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */
+};
+
+typedef struct HB_BaseArray_  HB_BaseArray;
+
+
+struct  HB_MarkBasePos_
+{
+  HB_UShort      PosFormat;           /* always 1                  */
+  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */
+  HB_Coverage   BaseCoverage;        /* base glyph coverage table */
+  HB_UShort      ClassCount;          /* number of mark classes    */
+  HB_MarkArray  MarkArray;           /* mark array table          */
+  HB_BaseArray  BaseArray;           /* base array table          */
+};
+
+typedef struct HB_MarkBasePos_  HB_MarkBasePos;
+
+
+/* LookupType 5 */
+
+struct  HB_ComponentRecord_
+{
+  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor
+                                        tables                         */
+};
+
+typedef struct HB_ComponentRecord_  HB_ComponentRecord;
+
+
+struct  HB_LigatureAttach_
+{
+  HB_UShort             ComponentCount;
+                                     /* number of ComponentRecord tables */
+  HB_ComponentRecord*  ComponentRecord;
+                                     /* array of ComponentRecord tables  */
+};
+
+typedef struct HB_LigatureAttach_  HB_LigatureAttach;
+
+
+struct  HB_LigatureArray_
+{
+  HB_UShort            LigatureCount; /* number of LigatureAttach tables */
+  HB_LigatureAttach*  LigatureAttach;
+                                     /* array of LigatureAttach tables  */
+};
+
+typedef struct HB_LigatureArray_  HB_LigatureArray;
+
+
+struct  HB_MarkLigPos_
+{
+  HB_UShort          PosFormat;       /* always 1                      */
+  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */
+  HB_Coverage       LigatureCoverage;
+                                     /* ligature glyph coverage table */
+  HB_UShort          ClassCount;      /* number of mark classes        */
+  HB_MarkArray      MarkArray;       /* mark array table              */
+  HB_LigatureArray  LigatureArray;   /* ligature array table          */
+};
+
+typedef struct HB_MarkLigPos_  HB_MarkLigPos;
+
+
+/* LookupType 6 */
+
+struct  HB_Mark2Record_
+{
+  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_Mark2Record_  HB_Mark2Record;
+
+
+struct  HB_Mark2Array_
+{
+  HB_UShort         Mark2Count;       /* number of Mark2Record tables */
+  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */
+};
+
+typedef struct HB_Mark2Array_  HB_Mark2Array;
+
+
+struct  HB_MarkMarkPos_
+{
+  HB_UShort       PosFormat;          /* always 1                         */
+  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */
+  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */
+  HB_UShort       ClassCount;         /* number of combining mark classes */
+  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */
+  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */
+};
+
+typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;
+
+
+/* needed by both lookup type 7 and 8 */
+
+struct  HB_PosLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;
+
+
+/* LookupType 7 */
+
+struct  HB_PosRule_
+{
+  HB_UShort             GlyphCount;   /* total number of input glyphs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosRule_  HB_PosRule;
+
+
+struct  HB_PosRuleSet_
+{
+  HB_UShort     PosRuleCount;         /* number of PosRule tables */
+  HB_PosRule*  PosRule;              /* array of PosRule tables  */
+};
+
+typedef struct HB_PosRuleSet_  HB_PosRuleSet;
+
+
+struct  HB_ContextPosFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */
+  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */
+};
+
+typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;
+
+
+struct  HB_PosClassRule_
+{
+  HB_UShort             GlyphCount;   /* total number of context classes  */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Class;        /* array of classes                 */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosClassRule_  HB_PosClassRule;
+
+
+struct  HB_PosClassSet_
+{
+  HB_UShort          PosClassRuleCount;
+                                     /* number of PosClassRule tables */
+  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */
+};
+
+typedef struct HB_PosClassSet_  HB_PosClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextPosFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            PosClassSetCount;
+                                     /* number of PosClassSet tables */
+  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */
+};
+
+typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;
+
+
+struct  HB_ContextPosFormat3_
+{
+  HB_UShort             GlyphCount;   /* number of input glyphs           */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_Coverage*         Coverage;     /* array of Coverage tables         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;
+
+
+struct  HB_ContextPos_
+{
+  HB_UShort  PosFormat;               /* 1, 2, or 3     */
+
+  union
+  {
+    HB_ContextPosFormat1  cpf1;
+    HB_ContextPosFormat2  cpf2;
+    HB_ContextPosFormat3  cpf3;
+  } cpf;
+};
+
+typedef struct HB_ContextPos_  HB_ContextPos;
+
+
+/* LookupType 8 */
+
+struct  HB_ChainPosRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecords       */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecords       */
+};
+
+typedef struct HB_ChainPosRule_  HB_ChainPosRule;
+
+
+struct  HB_ChainPosRuleSet_
+{
+  HB_UShort          ChainPosRuleCount;
+                                     /* number of ChainPosRule tables */
+  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */
+};
+
+typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;
+
+
+struct  HB_ChainContextPosFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainPosRuleSetCount;
+                                     /* number of ChainPosRuleSet tables */
+  HB_ChainPosRuleSet*  ChainPosRuleSet;
+                                     /* array of ChainPosRuleSet tables  */
+};
+
+typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;
+
+
+struct  HB_ChainPosClassRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*            Backtrack;    /* array of backtrack classes      */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*            Input;        /* array of context classes        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*            Lookahead;    /* array of lookahead classes      */
+  HB_UShort             PosCount;     /* number of PosLookupRecords      */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;
+
+
+struct  HB_ChainPosClassSet_
+{
+  HB_UShort               ChainPosClassRuleCount;
+                                     /* number of ChainPosClassRule
+                                        tables                      */
+  HB_ChainPosClassRule*  ChainPosClassRule;
+                                     /* array of ChainPosClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextPosFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainPosClassSetCount;
+                                     /* number of ChainPosClassSet
+                                        tables                     */
+  HB_ChainPosClassSet*  ChainPosClassSet;
+                                     /* array of ChainPosClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;
+
+
+struct  HB_ChainContextPosFormat3_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*         BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort             InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*         InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*         LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort             PosCount;     /* number of PosLookupRecords    */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;
+
+
+struct  HB_ChainContextPos_
+{
+  HB_UShort  PosFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextPosFormat1  ccpf1;
+    HB_ChainContextPosFormat2  ccpf2;
+    HB_ChainContextPosFormat3  ccpf3;
+  } ccpf;
+};
+
+typedef struct HB_ChainContextPos_  HB_ChainContextPos;
+
+
+#if 0
+/* LookupType 10 */
+struct HB_ExtensionPos_
+{
+  HB_UShort      PosFormat;           /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GPOS_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionPos_  HB_ExtensionPos;
+#endif
+
+
+union  HB_GPOS_SubTable_
+{
+  HB_SinglePos        single;
+  HB_PairPos          pair;
+  HB_CursivePos       cursive;
+  HB_MarkBasePos      markbase;
+  HB_MarkLigPos       marklig;
+  HB_MarkMarkPos      markmark;
+  HB_ContextPos       context;
+  HB_ChainContextPos  chain;
+};
+
+typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;
+
+
+
+HB_INTERNAL HB_Error
+_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_PRIVATE_H */
index 20bb7d9..2840dae 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_H\r
-#define HARFBUZZ_GPOS_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph positioning */\r
-\r
-#define HB_GPOS_LOOKUP_SINGLE     1\r
-#define HB_GPOS_LOOKUP_PAIR       2\r
-#define HB_GPOS_LOOKUP_CURSIVE    3\r
-#define HB_GPOS_LOOKUP_MARKBASE   4\r
-#define HB_GPOS_LOOKUP_MARKLIG    5\r
-#define HB_GPOS_LOOKUP_MARKMARK   6\r
-#define HB_GPOS_LOOKUP_CONTEXT    7\r
-#define HB_GPOS_LOOKUP_CHAIN      8\r
-#define HB_GPOS_LOOKUP_EXTENSION  9\r
-\r
-/* A pointer to a function which accesses the PostScript interpreter.\r
-   Multiple Master fonts need this interface to convert a metric ID\r
-   (as stored in an OpenType font version 1.2 or higher) `metric_id'\r
-   into a metric value (returned in `metric_value').\r
-\r
-   `data' points to the user-defined structure specified during a\r
-   call to HB_GPOS_Register_MM_Function().\r
-\r
-   `metric_value' must be returned as a scaled value (but shouldn't\r
-   be rounded).                                                       */\r
-\r
-typedef HB_Error  (*HB_MMFunction)(HB_Font       font,\r
-                                   HB_UShort    metric_id,\r
-                                   HB_Fixed*      metric_value,\r
-                                   void*        data );\r
-\r
-\r
-struct  HB_GPOSHeader_\r
-{\r
-  HB_16Dot16           Version;\r
-\r
-  HB_ScriptList     ScriptList;\r
-  HB_FeatureList    FeatureList;\r
-  HB_LookupList     LookupList;\r
-\r
-  HB_GDEFHeader*    gdef;\r
-\r
-  /* this is OpenType 1.2 -- Multiple Master fonts need this\r
-     callback function to get various metric values from the\r
-     PostScript interpreter.                                 */\r
-\r
-  HB_MMFunction     mmfunc;\r
-  void*              data;\r
-};\r
-\r
-typedef struct HB_GPOSHeader_  HB_GPOSHeader;\r
-typedef HB_GPOSHeader* HB_GPOS;\r
-\r
-\r
-HB_Error  HB_Load_GPOS_Table( HB_Stream stream, \r
-                              HB_GPOSHeader** gpos,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,\r
-                                       HB_MMFunction   mmfunc,\r
-                                       void*            data );\r
-\r
-/* If `dvi' is TRUE, glyph contour points for anchor points and device\r
-   tables are ignored -- you will get device independent values.         */\r
-\r
-\r
-HB_Error  HB_GPOS_Apply_String( HB_Font           font,\r
-                               HB_GPOSHeader*   gpos,\r
-                               HB_UShort         load_flags,\r
-                               HB_Buffer        buffer,\r
-                               HB_Bool           dvi,\r
-                               HB_Bool           r2l );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_H
+#define HARFBUZZ_GPOS_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph positioning */
+
+#define HB_GPOS_LOOKUP_SINGLE     1
+#define HB_GPOS_LOOKUP_PAIR       2
+#define HB_GPOS_LOOKUP_CURSIVE    3
+#define HB_GPOS_LOOKUP_MARKBASE   4
+#define HB_GPOS_LOOKUP_MARKLIG    5
+#define HB_GPOS_LOOKUP_MARKMARK   6
+#define HB_GPOS_LOOKUP_CONTEXT    7
+#define HB_GPOS_LOOKUP_CHAIN      8
+#define HB_GPOS_LOOKUP_EXTENSION  9
+
+/* A pointer to a function which accesses the PostScript interpreter.
+   Multiple Master fonts need this interface to convert a metric ID
+   (as stored in an OpenType font version 1.2 or higher) `metric_id'
+   into a metric value (returned in `metric_value').
+
+   `data' points to the user-defined structure specified during a
+   call to HB_GPOS_Register_MM_Function().
+
+   `metric_value' must be returned as a scaled value (but shouldn't
+   be rounded).                                                       */
+
+typedef HB_Error  (*HB_MMFunction)(HB_Font       font,
+                                   HB_UShort    metric_id,
+                                   HB_Fixed*      metric_value,
+                                   void*        data );
+
+
+struct  HB_GPOSHeader_
+{
+  HB_16Dot16           Version;
+
+  HB_ScriptList     ScriptList;
+  HB_FeatureList    FeatureList;
+  HB_LookupList     LookupList;
+
+  HB_GDEFHeader*    gdef;
+
+  /* this is OpenType 1.2 -- Multiple Master fonts need this
+     callback function to get various metric values from the
+     PostScript interpreter.                                 */
+
+  HB_MMFunction     mmfunc;
+  void*              data;
+};
+
+typedef struct HB_GPOSHeader_  HB_GPOSHeader;
+typedef HB_GPOSHeader* HB_GPOS;
+
+
+HB_Error  HB_Load_GPOS_Table( HB_Stream stream, 
+                              HB_GPOSHeader** gpos,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
+
+
+HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );
+
+
+HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,
+                                       HB_MMFunction   mmfunc,
+                                       void*            data );
+
+/* If `dvi' is TRUE, glyph contour points for anchor points and device
+   tables are ignored -- you will get device independent values.         */
+
+
+HB_Error  HB_GPOS_Apply_String( HB_Font           font,
+                               HB_GPOSHeader*   gpos,
+                               HB_UShort         load_flags,
+                               HB_Buffer        buffer,
+                               HB_Bool           dvi,
+                               HB_Bool           r2l );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_H */
index f47b46c..dd5ffdf 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_PRIVATE_H\r
-#define HARFBUZZ_GSUB_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gsub.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SingleSubstFormat1_\r
-{\r
-  HB_Short  DeltaGlyphID;             /* constant added to get\r
-                                        substitution glyph index */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;\r
-\r
-\r
-struct  HB_SingleSubstFormat2_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in\r
-                                        Substitute array              */\r
-  HB_UShort*  Substitute;             /* array of substitute glyph IDs */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;\r
-\r
-\r
-struct  HB_SingleSubst_\r
-{\r
-  HB_UShort     SubstFormat;          /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  union\r
-  {\r
-    HB_SingleSubstFormat1  ssf1;\r
-    HB_SingleSubstFormat2  ssf2;\r
-  } ssf;\r
-};\r
-\r
-typedef struct HB_SingleSubst_  HB_SingleSubst;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_Sequence_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Substitute array           */\r
-  HB_UShort*  Substitute;             /* string of glyph IDs to\r
-                                        substitute                 */\r
-};\r
-\r
-typedef struct HB_Sequence_  HB_Sequence;\r
-\r
-\r
-struct  HB_MultipleSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1                  */\r
-  HB_Coverage   Coverage;            /* Coverage table            */\r
-  HB_UShort      SequenceCount;       /* number of Sequence tables */\r
-  HB_Sequence*  Sequence;            /* array of Sequence tables  */\r
-};\r
-\r
-typedef struct HB_MultipleSubst_  HB_MultipleSubst;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_AlternateSet_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Alternate array              */\r
-  HB_UShort*  Alternate;              /* array of alternate glyph IDs */\r
-};\r
-\r
-typedef struct HB_AlternateSet_  HB_AlternateSet;\r
-\r
-\r
-struct  HB_AlternateSubst_\r
-{\r
-  HB_UShort          SubstFormat;     /* always 1                      */\r
-  HB_Coverage       Coverage;        /* Coverage table                */\r
-  HB_UShort          AlternateSetCount;\r
-                                     /* number of AlternateSet tables */\r
-  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */\r
-};\r
-\r
-typedef struct HB_AlternateSubst_  HB_AlternateSubst;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_Ligature_\r
-{\r
-  HB_UShort   LigGlyph;               /* glyphID of ligature\r
-                                        to substitute                    */\r
-  HB_UShort   ComponentCount;         /* number of components in ligature */\r
-  HB_UShort*  Component;              /* array of component glyph IDs     */\r
-};\r
-\r
-typedef struct HB_Ligature_  HB_Ligature;\r
-\r
-\r
-struct  HB_LigatureSet_\r
-{\r
-  HB_UShort      LigatureCount;       /* number of Ligature tables */\r
-  HB_Ligature*  Ligature;            /* array of Ligature tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSet_  HB_LigatureSet;\r
-\r
-\r
-struct  HB_LigatureSubst_\r
-{\r
-  HB_UShort         SubstFormat;      /* always 1                     */\r
-  HB_Coverage      Coverage;         /* Coverage table               */\r
-  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */\r
-  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSubst_  HB_LigatureSubst;\r
-\r
-\r
-/* needed by both lookup type 5 and 6 */\r
-\r
-struct  HB_SubstLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_SubRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of input glyphs */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                       */\r
-  HB_UShort*              Input;      /* array of input glyph IDs     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                       */\r
-};\r
-\r
-typedef struct HB_SubRule_  HB_SubRule;\r
-\r
-\r
-struct  HB_SubRuleSet_\r
-{\r
-  HB_UShort     SubRuleCount;         /* number of SubRule tables */\r
-  HB_SubRule*  SubRule;              /* array of SubRule tables  */\r
-};\r
-\r
-typedef struct HB_SubRuleSet_  HB_SubRuleSet;\r
-\r
-\r
-struct  HB_ContextSubstFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */\r
-  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;\r
-\r
-\r
-struct  HB_SubClassRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of context classes */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                          */\r
-  HB_UShort*              Class;      /* array of classes                */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                          */\r
-};\r
-\r
-typedef struct HB_SubClassRule_  HB_SubClassRule;\r
-\r
-\r
-struct  HB_SubClassSet_\r
-{\r
-  HB_UShort          SubClassRuleCount;\r
-                                     /* number of SubClassRule tables */\r
-  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */\r
-};\r
-\r
-typedef struct HB_SubClassSet_  HB_SubClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextSubstFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            SubClassSetCount;\r
-                                     /* number of SubClassSet tables */\r
-  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;\r
-\r
-\r
-struct  HB_ContextSubstFormat3_\r
-{\r
-  HB_UShort               GlyphCount; /* number of input glyphs        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_Coverage*           Coverage;   /* array of Coverage tables      */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;\r
-\r
-\r
-struct  HB_ContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ContextSubstFormat1  csf1;\r
-    HB_ContextSubstFormat2  csf2;\r
-    HB_ContextSubstFormat3  csf3;\r
-  } csf;\r
-};\r
-\r
-typedef struct HB_ContextSubst_  HB_ContextSubst;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_ChainSubRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*              Input;      /* array of input glyph IDs         */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecords      */\r
-};\r
-\r
-typedef struct HB_ChainSubRule_  HB_ChainSubRule;\r
-\r
-\r
-struct  HB_ChainSubRuleSet_\r
-{\r
-  HB_UShort          ChainSubRuleCount;\r
-                                     /* number of ChainSubRule tables */\r
-  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainSubRuleSetCount;\r
-                                     /* number of ChainSubRuleSet tables */\r
-  HB_ChainSubRuleSet*  ChainSubRuleSet;\r
-                                     /* array of ChainSubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;\r
-\r
-\r
-struct  HB_ChainSubClassRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*              Backtrack;  /* array of backtrack classes      */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*              Input;      /* array of context classes        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*              Lookahead;  /* array of lookahead classes      */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords    */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;\r
-\r
-\r
-struct  HB_ChainSubClassSet_\r
-{\r
-  HB_UShort               ChainSubClassRuleCount;\r
-                                     /* number of ChainSubClassRule\r
-                                        tables                      */\r
-  HB_ChainSubClassRule*  ChainSubClassRule;\r
-                                     /* array of ChainSubClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextSubstFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainSubClassSetCount;\r
-                                     /* number of ChainSubClassSet\r
-                                        tables                     */\r
-  HB_ChainSubClassSet*  ChainSubClassSet;\r
-                                     /* array of ChainSubClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat3_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*           BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*           InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*           LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;\r
-\r
-\r
-struct  HB_ChainContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextSubstFormat1  ccsf1;\r
-    HB_ChainContextSubstFormat2  ccsf2;\r
-    HB_ChainContextSubstFormat3  ccsf3;\r
-  } ccsf;\r
-};\r
-\r
-typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;\r
-\r
-\r
-#if 0\r
-/* LookupType 7 */\r
-struct HB_ExtensionSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GSUB_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;\r
-#endif\r
-\r
-\r
-/* LookupType 8 */\r
-struct HB_ReverseChainContextSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_Coverage   Coverage;              /* coverage table for input glyphs */\r
-  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */\r
-  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage\r
-                                        tables                          */\r
-  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */\r
-  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage\r
-                                        tables                          */\r
-  HB_UShort      GlyphCount;          /* number of Glyph IDs             */\r
-  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */\r
-};\r
-\r
-typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;\r
-\r
-\r
-union  HB_GSUB_SubTable_\r
-{\r
-  HB_SingleSubst              single;\r
-  HB_MultipleSubst            multiple;\r
-  HB_AlternateSubst           alternate;\r
-  HB_LigatureSubst            ligature;\r
-  HB_ContextSubst             context;\r
-  HB_ChainContextSubst        chain;\r
-  HB_ReverseChainContextSubst reverse;\r
-};\r
-\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_PRIVATE_H
+#define HARFBUZZ_GSUB_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gsub.h"
+
+HB_BEGIN_HEADER
+
+
+typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;
+
+/* LookupType 1 */
+
+struct  HB_SingleSubstFormat1_
+{
+  HB_Short  DeltaGlyphID;             /* constant added to get
+                                        substitution glyph index */
+};
+
+typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;
+
+
+struct  HB_SingleSubstFormat2_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in
+                                        Substitute array              */
+  HB_UShort*  Substitute;             /* array of substitute glyph IDs */
+};
+
+typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;
+
+
+struct  HB_SingleSubst_
+{
+  HB_UShort     SubstFormat;          /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  union
+  {
+    HB_SingleSubstFormat1  ssf1;
+    HB_SingleSubstFormat2  ssf2;
+  } ssf;
+};
+
+typedef struct HB_SingleSubst_  HB_SingleSubst;
+
+
+/* LookupType 2 */
+
+struct  HB_Sequence_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Substitute array           */
+  HB_UShort*  Substitute;             /* string of glyph IDs to
+                                        substitute                 */
+};
+
+typedef struct HB_Sequence_  HB_Sequence;
+
+
+struct  HB_MultipleSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1                  */
+  HB_Coverage   Coverage;            /* Coverage table            */
+  HB_UShort      SequenceCount;       /* number of Sequence tables */
+  HB_Sequence*  Sequence;            /* array of Sequence tables  */
+};
+
+typedef struct HB_MultipleSubst_  HB_MultipleSubst;
+
+
+/* LookupType 3 */
+
+struct  HB_AlternateSet_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Alternate array              */
+  HB_UShort*  Alternate;              /* array of alternate glyph IDs */
+};
+
+typedef struct HB_AlternateSet_  HB_AlternateSet;
+
+
+struct  HB_AlternateSubst_
+{
+  HB_UShort          SubstFormat;     /* always 1                      */
+  HB_Coverage       Coverage;        /* Coverage table                */
+  HB_UShort          AlternateSetCount;
+                                     /* number of AlternateSet tables */
+  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */
+};
+
+typedef struct HB_AlternateSubst_  HB_AlternateSubst;
+
+
+/* LookupType 4 */
+
+struct  HB_Ligature_
+{
+  HB_UShort   LigGlyph;               /* glyphID of ligature
+                                        to substitute                    */
+  HB_UShort   ComponentCount;         /* number of components in ligature */
+  HB_UShort*  Component;              /* array of component glyph IDs     */
+};
+
+typedef struct HB_Ligature_  HB_Ligature;
+
+
+struct  HB_LigatureSet_
+{
+  HB_UShort      LigatureCount;       /* number of Ligature tables */
+  HB_Ligature*  Ligature;            /* array of Ligature tables  */
+};
+
+typedef struct HB_LigatureSet_  HB_LigatureSet;
+
+
+struct  HB_LigatureSubst_
+{
+  HB_UShort         SubstFormat;      /* always 1                     */
+  HB_Coverage      Coverage;         /* Coverage table               */
+  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */
+  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */
+};
+
+typedef struct HB_LigatureSubst_  HB_LigatureSubst;
+
+
+/* needed by both lookup type 5 and 6 */
+
+struct  HB_SubstLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;
+
+
+/* LookupType 5 */
+
+struct  HB_SubRule_
+{
+  HB_UShort               GlyphCount; /* total number of input glyphs */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                       */
+  HB_UShort*              Input;      /* array of input glyph IDs     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                       */
+};
+
+typedef struct HB_SubRule_  HB_SubRule;
+
+
+struct  HB_SubRuleSet_
+{
+  HB_UShort     SubRuleCount;         /* number of SubRule tables */
+  HB_SubRule*  SubRule;              /* array of SubRule tables  */
+};
+
+typedef struct HB_SubRuleSet_  HB_SubRuleSet;
+
+
+struct  HB_ContextSubstFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */
+  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;
+
+
+struct  HB_SubClassRule_
+{
+  HB_UShort               GlyphCount; /* total number of context classes */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                          */
+  HB_UShort*              Class;      /* array of classes                */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                          */
+};
+
+typedef struct HB_SubClassRule_  HB_SubClassRule;
+
+
+struct  HB_SubClassSet_
+{
+  HB_UShort          SubClassRuleCount;
+                                     /* number of SubClassRule tables */
+  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */
+};
+
+typedef struct HB_SubClassSet_  HB_SubClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextSubstFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            SubClassSetCount;
+                                     /* number of SubClassSet tables */
+  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;
+
+
+struct  HB_ContextSubstFormat3_
+{
+  HB_UShort               GlyphCount; /* number of input glyphs        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_Coverage*           Coverage;   /* array of Coverage tables      */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;
+
+
+struct  HB_ContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ContextSubstFormat1  csf1;
+    HB_ContextSubstFormat2  csf2;
+    HB_ContextSubstFormat3  csf3;
+  } csf;
+};
+
+typedef struct HB_ContextSubst_  HB_ContextSubst;
+
+
+/* LookupType 6 */
+
+struct  HB_ChainSubRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*              Input;      /* array of input glyph IDs         */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecords      */
+};
+
+typedef struct HB_ChainSubRule_  HB_ChainSubRule;
+
+
+struct  HB_ChainSubRuleSet_
+{
+  HB_UShort          ChainSubRuleCount;
+                                     /* number of ChainSubRule tables */
+  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */
+};
+
+typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;
+
+
+struct  HB_ChainContextSubstFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainSubRuleSetCount;
+                                     /* number of ChainSubRuleSet tables */
+  HB_ChainSubRuleSet*  ChainSubRuleSet;
+                                     /* array of ChainSubRuleSet tables  */
+};
+
+typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;
+
+
+struct  HB_ChainSubClassRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*              Backtrack;  /* array of backtrack classes      */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*              Input;      /* array of context classes        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*              Lookahead;  /* array of lookahead classes      */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords    */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;
+
+
+struct  HB_ChainSubClassSet_
+{
+  HB_UShort               ChainSubClassRuleCount;
+                                     /* number of ChainSubClassRule
+                                        tables                      */
+  HB_ChainSubClassRule*  ChainSubClassRule;
+                                     /* array of ChainSubClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextSubstFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainSubClassSetCount;
+                                     /* number of ChainSubClassSet
+                                        tables                     */
+  HB_ChainSubClassSet*  ChainSubClassSet;
+                                     /* array of ChainSubClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;
+
+
+struct  HB_ChainContextSubstFormat3_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*           BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort               InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*           InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*           LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;
+
+
+struct  HB_ChainContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextSubstFormat1  ccsf1;
+    HB_ChainContextSubstFormat2  ccsf2;
+    HB_ChainContextSubstFormat3  ccsf3;
+  } ccsf;
+};
+
+typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;
+
+
+#if 0
+/* LookupType 7 */
+struct HB_ExtensionSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GSUB_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;
+#endif
+
+
+/* LookupType 8 */
+struct HB_ReverseChainContextSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_Coverage   Coverage;              /* coverage table for input glyphs */
+  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */
+  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage
+                                        tables                          */
+  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */
+  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage
+                                        tables                          */
+  HB_UShort      GlyphCount;          /* number of Glyph IDs             */
+  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */
+};
+
+typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;
+
+
+union  HB_GSUB_SubTable_
+{
+  HB_SingleSubst              single;
+  HB_MultipleSubst            multiple;
+  HB_AlternateSubst           alternate;
+  HB_LigatureSubst            ligature;
+  HB_ContextSubst             context;
+  HB_ChainContextSubst        chain;
+  HB_ReverseChainContextSubst reverse;
+};
+
+
+
+
+HB_INTERNAL HB_Error
+_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_PRIVATE_H */
index 4471751..1ca3f0c 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_H\r
-#define HARFBUZZ_GSUB_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph substitution */\r
-\r
-#define HB_GSUB_LOOKUP_SINGLE        1\r
-#define HB_GSUB_LOOKUP_MULTIPLE      2\r
-#define HB_GSUB_LOOKUP_ALTERNATE     3\r
-#define HB_GSUB_LOOKUP_LIGATURE      4\r
-#define HB_GSUB_LOOKUP_CONTEXT       5\r
-#define HB_GSUB_LOOKUP_CHAIN         6\r
-#define HB_GSUB_LOOKUP_EXTENSION     7\r
-#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8\r
-\r
-\r
-/* A pointer to a function which selects the alternate glyph.  `pos' is\r
-   the position of the glyph with index `glyphID', `num_alternates'\r
-   gives the number of alternates in the `alternates' array.  `data'\r
-   points to the user-defined structure specified during a call to\r
-   HB_GSUB_Register_Alternate_Function().  The function must return an\r
-   index into the `alternates' array.                                   */\r
-\r
-typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,\r
-                                     HB_UShort   glyphID,\r
-                                     HB_UShort   num_alternates,\r
-                                     HB_UShort*  alternates,\r
-                                     void*       data );\r
-\r
-\r
-struct  HB_GSUBHeader_\r
-{\r
-  HB_UInt         offset;\r
-\r
-  HB_16Dot16         Version;\r
-\r
-  HB_ScriptList   ScriptList;\r
-  HB_FeatureList  FeatureList;\r
-  HB_LookupList   LookupList;\r
-\r
-  HB_GDEFHeader*  gdef;\r
-\r
-  /* the next two fields are used for an alternate substitution callback\r
-     function to select the proper alternate glyph.                      */\r
-\r
-  HB_AltFunction  altfunc;\r
-  void*            data;\r
-};\r
-\r
-typedef struct HB_GSUBHeader_   HB_GSUBHeader;\r
-typedef HB_GSUBHeader*  HB_GSUB;\r
-\r
-\r
-HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,\r
-                             HB_GSUBHeader** gsub,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,\r
-                                              HB_AltFunction  altfunc,\r
-                                              void*            data );\r
-\r
-\r
-HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,\r
-                               HB_Buffer        buffer );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_H
+#define HARFBUZZ_GSUB_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph substitution */
+
+#define HB_GSUB_LOOKUP_SINGLE        1
+#define HB_GSUB_LOOKUP_MULTIPLE      2
+#define HB_GSUB_LOOKUP_ALTERNATE     3
+#define HB_GSUB_LOOKUP_LIGATURE      4
+#define HB_GSUB_LOOKUP_CONTEXT       5
+#define HB_GSUB_LOOKUP_CHAIN         6
+#define HB_GSUB_LOOKUP_EXTENSION     7
+#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8
+
+
+/* A pointer to a function which selects the alternate glyph.  `pos' is
+   the position of the glyph with index `glyphID', `num_alternates'
+   gives the number of alternates in the `alternates' array.  `data'
+   points to the user-defined structure specified during a call to
+   HB_GSUB_Register_Alternate_Function().  The function must return an
+   index into the `alternates' array.                                   */
+
+typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,
+                                     HB_UShort   glyphID,
+                                     HB_UShort   num_alternates,
+                                     HB_UShort*  alternates,
+                                     void*       data );
+
+
+struct  HB_GSUBHeader_
+{
+  HB_UInt         offset;
+
+  HB_16Dot16         Version;
+
+  HB_ScriptList   ScriptList;
+  HB_FeatureList  FeatureList;
+  HB_LookupList   LookupList;
+
+  HB_GDEFHeader*  gdef;
+
+  /* the next two fields are used for an alternate substitution callback
+     function to select the proper alternate glyph.                      */
+
+  HB_AltFunction  altfunc;
+  void*            data;
+};
+
+typedef struct HB_GSUBHeader_   HB_GSUBHeader;
+typedef HB_GSUBHeader*  HB_GSUB;
+
+
+HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,
+                             HB_GSUBHeader** gsub,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,
+                                              HB_AltFunction  altfunc,
+                                              void*            data );
+
+
+HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,
+                               HB_Buffer        buffer );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_H */
index 358f587..2e86168 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_IMPL_H\r
-#define HARFBUZZ_IMPL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-#include <stdlib.h>\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef HB_INTERNAL\r
-# define HB_INTERNAL\r
-#endif\r
-\r
-#ifndef NULL\r
-# define NULL ((void *)0)\r
-#endif\r
-\r
-#ifndef FALSE\r
-# define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-# define TRUE 1\r
-#endif\r
-\r
-#ifndef TTAG_GDEF\r
-# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )\r
-#endif\r
-#ifndef TTAG_GPOS\r
-# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )\r
-#endif\r
-#ifndef TTAG_GSUB\r
-# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )\r
-#endif\r
-\r
-#ifndef HB_UNUSED\r
-# define HB_UNUSED(arg) ((arg) = (arg))\r
-#endif\r
-\r
-#define HB_LIKELY(cond) (cond)\r
-#define HB_UNLIKELY(cond) (cond)\r
-\r
-#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))\r
-\r
-\r
-\r
-#define HB_IsHighSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xd800)\r
-\r
-#define HB_IsLowSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xdc00)\r
-\r
-#define HB_SurrogateToUcs4(high, low) \\r
-    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;\r
-\r
-\r
-\r
-\r
-\r
-#define  ALLOC(_ptr,_size,_type)   \\r
-           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )\r
-\r
-#define  REALLOC(_ptr,_newsz,_type)  \\r
-           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )\r
-\r
-#define  FREE(_ptr)                    \\r
-  do {                                 \\r
-    if ( (_ptr) )                      \\r
-    {                                  \\r
-      _hb_free( _ptr );     \\r
-      _ptr = NULL;                     \\r
-    }                                  \\r
-  } while (0)\r
-\r
-#define  ALLOC_ARRAY(_ptr,_count,_type)   \\r
-           ALLOC(_ptr,(_count)*sizeof(_type),_type*)\r
-\r
-#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \\r
-           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)\r
-\r
-#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )\r
-\r
-#define ERR_HB(err)   _hb_err (err)\r
-\r
-\r
-//HB_INTERNAL\r
-HB_Pointer\r
-_hb_alloc( size_t    size,\r
-          HB_Error *perror_ );\r
-\r
-//HB_INTERNAL\r
-       HB_Pointer\r
-_hb_realloc( HB_Pointer block,\r
-            size_t     new_size,\r
-            HB_Error  *perror_ );\r
-\r
-//HB_INTERNAL \r
-       void\r
-_hb_free( HB_Pointer block );\r
-\r
-\r
-/* helper func to set a breakpoint on */\r
-//HB_INTERNAL \r
-HB_Error\r
-_hb_err(HB_Error code);\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_IMPL_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_IMPL_H
+#define HARFBUZZ_IMPL_H
+
+#include "harfbuzz-global.h"
+
+#include <stdlib.h>
+
+HB_BEGIN_HEADER
+
+#ifndef HB_INTERNAL
+# define HB_INTERNAL
+#endif
+
+#ifndef NULL
+# define NULL ((void *)0)
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef TTAG_GDEF
+# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
+#endif
+#ifndef TTAG_GPOS
+# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
+#endif
+#ifndef TTAG_GSUB
+# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
+#endif
+
+#ifndef HB_UNUSED
+# define HB_UNUSED(arg) ((arg) = (arg))
+#endif
+
+#define HB_LIKELY(cond) (cond)
+#define HB_UNLIKELY(cond) (cond)
+
+#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
+
+
+
+#define HB_IsHighSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xd800)
+
+#define HB_IsLowSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xdc00)
+
+#define HB_SurrogateToUcs4(high, low) \
+    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;
+
+
+
+
+
+#define  ALLOC(_ptr,_size,_type)   \
+           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )
+
+#define  REALLOC(_ptr,_newsz,_type)  \
+           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
+
+#define  FREE(_ptr)                    \
+  do {                                 \
+    if ( (_ptr) )                      \
+    {                                  \
+      _hb_free( _ptr );     \
+      _ptr = NULL;                     \
+    }                                  \
+  } while (0)
+
+#define  ALLOC_ARRAY(_ptr,_count,_type)   \
+           ALLOC(_ptr,(_count)*sizeof(_type),_type*)
+
+#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
+           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)
+
+#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
+
+#define ERR_HB(err)   _hb_err (err)
+
+
+//HB_INTERNAL
+HB_Pointer
+_hb_alloc( size_t    size,
+          HB_Error *perror_ );
+
+//HB_INTERNAL
+       HB_Pointer
+_hb_realloc( HB_Pointer block,
+            size_t     new_size,
+            HB_Error  *perror_ );
+
+//HB_INTERNAL 
+       void
+_hb_free( HB_Pointer block );
+
+
+/* helper func to set a breakpoint on */
+//HB_INTERNAL 
+HB_Error
+_hb_err(HB_Error code);
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_IMPL_H */
index 02aae80..73dd383 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_PRIVATE_H\r
-#define HARFBUZZ_OPEN_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-gpos-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-struct  HB_SubTable_\r
-{\r
-  union\r
-  {\r
-    HB_GSUB_SubTable  gsub;\r
-    HB_GPOS_SubTable  gpos;\r
-  } st;\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,\r
-                          HB_Stream     input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,\r
-                           HB_Stream         input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_LookupList( HB_LookupList*  ll,\r
-                          HB_Stream        input,\r
-                          HB_Type         type );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Coverage( HB_Coverage* c,\r
-                        HB_Stream      input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,\r
-                               HB_UShort             limit,\r
-                               HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,\r
-                                              HB_UShort             limit,\r
-                                              HB_UInt              class_offset,\r
-                                              HB_UInt              base_offset,\r
-                                              HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Device( HB_Device* d,\r
-                      HB_Stream    input );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );\r
-HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );\r
-HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,\r
-                      HB_Type         type );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );\r
-HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );\r
-HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Coverage_Index( HB_Coverage* c,\r
-                         HB_UShort      glyphID,\r
-                         HB_UShort*     index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Class( HB_ClassDefinition* cd,\r
-                    HB_UShort             glyphID,\r
-                   HB_UShort*          klass,\r
-                    HB_UShort*            index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Device( HB_Device* d,\r
-                     HB_UShort    size,\r
-                     HB_Short*    value );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_PRIVATE_H
+#define HARFBUZZ_OPEN_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-gpos-private.h"
+
+HB_BEGIN_HEADER
+
+
+struct  HB_SubTable_
+{
+  union
+  {
+    HB_GSUB_SubTable  gsub;
+    HB_GPOS_SubTable  gpos;
+  } st;
+};
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+                          HB_Stream     input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+                           HB_Stream         input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_LookupList( HB_LookupList*  ll,
+                          HB_Stream        input,
+                          HB_Type         type );
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Coverage( HB_Coverage* c,
+                        HB_Stream      input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+                               HB_UShort             limit,
+                               HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+                                              HB_UShort             limit,
+                                              HB_UInt              class_offset,
+                                              HB_UInt              base_offset,
+                                              HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Device( HB_Device* d,
+                      HB_Stream    input );
+
+HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );
+HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );
+HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,
+                      HB_Type         type );
+
+HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );
+HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );
+HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );
+
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Coverage_Index( HB_Coverage* c,
+                         HB_UShort      glyphID,
+                         HB_UShort*     index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+                    HB_UShort             glyphID,
+                   HB_UShort*          klass,
+                    HB_UShort*            index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Device( HB_Device* d,
+                     HB_UShort    size,
+                     HB_Short*    value );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_PRIVATE_H */
index 8bc33dc..bdc6358 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_H\r
-#define HARFBUZZ_OPEN_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* Use this if a feature applies to all glyphs */\r
-#define HB_ALL_GLYPHS                    0xFFFF\r
-\r
-#define HB_DEFAULT_LANGUAGE              0xFFFF\r
-\r
-#define HB_MAX_NESTING_LEVEL             100\r
-\r
-\r
-/* Script list related structures */\r
-\r
-struct  HB_LangSys_\r
-{\r
-  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */\r
-  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */\r
-  HB_UShort   FeatureCount;           /* number of Feature indices */\r
-  HB_UShort*  FeatureIndex;           /* array of Feature indices  */\r
-};\r
-\r
-typedef struct HB_LangSys_  HB_LangSys;\r
-\r
-\r
-struct  HB_LangSysRecord_\r
-{\r
-  HB_UInt     LangSysTag;            /* LangSysTag identifier */\r
-  HB_LangSys  LangSys;               /* LangSys table         */\r
-};\r
-\r
-typedef struct HB_LangSysRecord_  HB_LangSysRecord;\r
-\r
-\r
-struct  HB_ScriptTable_\r
-{\r
-  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */\r
-  HB_UShort           LangSysCount;   /* number of LangSysRecords */\r
-  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptTable_  HB_ScriptTable;\r
-\r
-\r
-struct  HB_ScriptRecord_\r
-{\r
-  HB_UInt        ScriptTag;              /* ScriptTag identifier */\r
-  HB_ScriptTable  Script;                 /* Script table         */\r
-};\r
-\r
-typedef struct HB_ScriptRecord_  HB_ScriptRecord;\r
-\r
-\r
-struct  HB_ScriptList_\r
-{\r
-  HB_UShort          ScriptCount;     /* number of ScriptRecords */\r
-  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptList_  HB_ScriptList;\r
-\r
-\r
-/* Feature list related structures */\r
-\r
-struct HB_Feature_\r
-{\r
-  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */\r
-  HB_UShort   LookupListCount;        /* number of LookupList indices */\r
-  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */\r
-};\r
-\r
-typedef struct HB_Feature_  HB_Feature;\r
-\r
-\r
-struct  HB_FeatureRecord_\r
-{\r
-  HB_UInt     FeatureTag;            /* FeatureTag identifier */\r
-  HB_Feature  Feature;               /* Feature table         */\r
-};\r
-\r
-typedef struct HB_FeatureRecord_  HB_FeatureRecord;\r
-\r
-\r
-struct  HB_FeatureList_\r
-{\r
-  HB_UShort           FeatureCount;   /* number of FeatureRecords */\r
-  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */\r
-  HB_UShort*           ApplyOrder;     /* order to apply features */\r
-  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */\r
-};\r
-\r
-typedef struct HB_FeatureList_  HB_FeatureList;\r
-\r
-\r
-/* Lookup list related structures */\r
-\r
-typedef struct HB_SubTable_  HB_SubTable;\r
-\r
-\r
-struct  HB_Lookup_\r
-{\r
-  HB_UShort      LookupType;          /* Lookup type         */\r
-  HB_UShort      LookupFlag;          /* Lookup qualifiers   */\r
-  HB_UShort      SubTableCount;       /* number of SubTables */\r
-  HB_SubTable*  SubTable;            /* array of SubTables  */\r
-};\r
-\r
-typedef struct HB_Lookup_  HB_Lookup;\r
-\r
-\r
-/* The `Properties' field is not defined in the OpenType specification but\r
-   is needed for processing lookups.  If properties[n] is > 0, the\r
-   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will\r
-   process Lookup[n] for glyphs which have the specific bit not set in\r
-   the `properties' field of the input string object.                  */\r
-\r
-struct  HB_LookupList_\r
-{\r
-  HB_UShort    LookupCount;           /* number of Lookups       */\r
-  HB_Lookup*  Lookup;                /* array of Lookup records */\r
-  HB_UInt*     Properties;            /* array of flags          */\r
-};\r
-\r
-typedef struct HB_LookupList_  HB_LookupList;\r
-\r
-\r
-/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the\r
-   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in\r
-   OpenType 1.3 -- if set, the last glyph in a cursive attachment\r
-   sequence has to be positioned on the baseline -- regardless of the\r
-   writing direction.                                                    */\r
-\r
-#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001\r
-#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002\r
-#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004\r
-#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008\r
-#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00\r
-\r
-\r
-struct  HB_CoverageFormat1_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */\r
-  HB_UShort*  GlyphArray;             /* array of glyph IDs             */\r
-};\r
-\r
-typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;\r
-\r
-\r
-struct HB_RangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range */\r
-  HB_UShort  End;                     /* last glyph ID in the range  */\r
-  HB_UShort  StartCoverageIndex;      /* coverage index of first\r
-                                        glyph ID in the range       */\r
-};\r
-\r
-typedef struct HB_RangeRecord_  HB_RangeRecord;\r
-\r
-\r
-struct  HB_CoverageFormat2_\r
-{\r
-  HB_UShort         RangeCount;       /* number of RangeRecords */\r
-  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */\r
-};\r
-\r
-typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;\r
-\r
-\r
-struct  HB_Coverage_\r
-{\r
-  HB_UShort  CoverageFormat;          /* 1 or 2 */\r
-\r
-  union\r
-  {\r
-    HB_CoverageFormat1  cf1;\r
-    HB_CoverageFormat2  cf2;\r
-  } cf;\r
-};\r
-\r
-typedef struct HB_Coverage_  HB_Coverage;\r
-\r
-\r
-struct  HB_ClassDefFormat1_\r
-{\r
-  HB_UShort   StartGlyph;             /* first glyph ID of the\r
-                                        ClassValueArray             */\r
-  HB_UShort   GlyphCount;             /* size of the ClassValueArray */\r
-  HB_UShort*  ClassValueArray;        /* array of class values       */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;\r
-\r
-\r
-struct  HB_ClassRangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range    */\r
-  HB_UShort  End;                     /* last glyph ID in the range     */\r
-  HB_UShort  Class;                   /* applied to all glyphs in range */\r
-};\r
-\r
-typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;\r
-\r
-\r
-struct  HB_ClassDefFormat2_\r
-{\r
-  HB_UShort              ClassRangeCount;\r
-                                     /* number of ClassRangeRecords */\r
-  HB_ClassRangeRecord*  ClassRangeRecord;\r
-                                     /* array of ClassRangeRecords  */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;\r
-\r
-\r
-struct  HB_ClassDefinition_\r
-{\r
-  HB_Bool    loaded;\r
-\r
-  HB_UShort  ClassFormat;             /* 1 or 2                      */\r
-\r
-  union\r
-  {\r
-    HB_ClassDefFormat1  cd1;\r
-    HB_ClassDefFormat2  cd2;\r
-  } cd;\r
-};\r
-\r
-typedef struct HB_ClassDefinition_  HB_ClassDefinition;\r
-\r
-\r
-struct HB_Device_\r
-{\r
-  HB_UShort   StartSize;              /* smallest size to correct      */\r
-  HB_UShort   EndSize;                /* largest size to correct       */\r
-  HB_UShort   DeltaFormat;            /* DeltaValue array data format:\r
-                                        1, 2, or 3                    */\r
-  HB_UShort*  DeltaValue;             /* array of compressed data      */\r
-};\r
-\r
-typedef struct HB_Device_  HB_Device;\r
-\r
-\r
-enum  HB_Type_\r
-{\r
-  HB_Type_GSUB,\r
-  HB_Type_GPOS\r
-};\r
-\r
-typedef enum HB_Type_  HB_Type;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_H
+#define HARFBUZZ_OPEN_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* Use this if a feature applies to all glyphs */
+#define HB_ALL_GLYPHS                    0xFFFF
+
+#define HB_DEFAULT_LANGUAGE              0xFFFF
+
+#define HB_MAX_NESTING_LEVEL             100
+
+
+/* Script list related structures */
+
+struct  HB_LangSys_
+{
+  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */
+  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */
+  HB_UShort   FeatureCount;           /* number of Feature indices */
+  HB_UShort*  FeatureIndex;           /* array of Feature indices  */
+};
+
+typedef struct HB_LangSys_  HB_LangSys;
+
+
+struct  HB_LangSysRecord_
+{
+  HB_UInt     LangSysTag;            /* LangSysTag identifier */
+  HB_LangSys  LangSys;               /* LangSys table         */
+};
+
+typedef struct HB_LangSysRecord_  HB_LangSysRecord;
+
+
+struct  HB_ScriptTable_
+{
+  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */
+  HB_UShort           LangSysCount;   /* number of LangSysRecords */
+  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */
+};
+
+typedef struct HB_ScriptTable_  HB_ScriptTable;
+
+
+struct  HB_ScriptRecord_
+{
+  HB_UInt        ScriptTag;              /* ScriptTag identifier */
+  HB_ScriptTable  Script;                 /* Script table         */
+};
+
+typedef struct HB_ScriptRecord_  HB_ScriptRecord;
+
+
+struct  HB_ScriptList_
+{
+  HB_UShort          ScriptCount;     /* number of ScriptRecords */
+  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */
+};
+
+typedef struct HB_ScriptList_  HB_ScriptList;
+
+
+/* Feature list related structures */
+
+struct HB_Feature_
+{
+  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */
+  HB_UShort   LookupListCount;        /* number of LookupList indices */
+  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */
+};
+
+typedef struct HB_Feature_  HB_Feature;
+
+
+struct  HB_FeatureRecord_
+{
+  HB_UInt     FeatureTag;            /* FeatureTag identifier */
+  HB_Feature  Feature;               /* Feature table         */
+};
+
+typedef struct HB_FeatureRecord_  HB_FeatureRecord;
+
+
+struct  HB_FeatureList_
+{
+  HB_UShort           FeatureCount;   /* number of FeatureRecords */
+  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */
+  HB_UShort*           ApplyOrder;     /* order to apply features */
+  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */
+};
+
+typedef struct HB_FeatureList_  HB_FeatureList;
+
+
+/* Lookup list related structures */
+
+typedef struct HB_SubTable_  HB_SubTable;
+
+
+struct  HB_Lookup_
+{
+  HB_UShort      LookupType;          /* Lookup type         */
+  HB_UShort      LookupFlag;          /* Lookup qualifiers   */
+  HB_UShort      SubTableCount;       /* number of SubTables */
+  HB_SubTable*  SubTable;            /* array of SubTables  */
+};
+
+typedef struct HB_Lookup_  HB_Lookup;
+
+
+/* The `Properties' field is not defined in the OpenType specification but
+   is needed for processing lookups.  If properties[n] is > 0, the
+   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will
+   process Lookup[n] for glyphs which have the specific bit not set in
+   the `properties' field of the input string object.                  */
+
+struct  HB_LookupList_
+{
+  HB_UShort    LookupCount;           /* number of Lookups       */
+  HB_Lookup*  Lookup;                /* array of Lookup records */
+  HB_UInt*     Properties;            /* array of flags          */
+};
+
+typedef struct HB_LookupList_  HB_LookupList;
+
+
+/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the
+   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in
+   OpenType 1.3 -- if set, the last glyph in a cursive attachment
+   sequence has to be positioned on the baseline -- regardless of the
+   writing direction.                                                    */
+
+#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001
+#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002
+#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004
+#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008
+#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00
+
+
+struct  HB_CoverageFormat1_
+{
+  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */
+  HB_UShort*  GlyphArray;             /* array of glyph IDs             */
+};
+
+typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;
+
+
+struct HB_RangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range */
+  HB_UShort  End;                     /* last glyph ID in the range  */
+  HB_UShort  StartCoverageIndex;      /* coverage index of first
+                                        glyph ID in the range       */
+};
+
+typedef struct HB_RangeRecord_  HB_RangeRecord;
+
+
+struct  HB_CoverageFormat2_
+{
+  HB_UShort         RangeCount;       /* number of RangeRecords */
+  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */
+};
+
+typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;
+
+
+struct  HB_Coverage_
+{
+  HB_UShort  CoverageFormat;          /* 1 or 2 */
+
+  union
+  {
+    HB_CoverageFormat1  cf1;
+    HB_CoverageFormat2  cf2;
+  } cf;
+};
+
+typedef struct HB_Coverage_  HB_Coverage;
+
+
+struct  HB_ClassDefFormat1_
+{
+  HB_UShort   StartGlyph;             /* first glyph ID of the
+                                        ClassValueArray             */
+  HB_UShort   GlyphCount;             /* size of the ClassValueArray */
+  HB_UShort*  ClassValueArray;        /* array of class values       */
+};
+
+typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;
+
+
+struct  HB_ClassRangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range    */
+  HB_UShort  End;                     /* last glyph ID in the range     */
+  HB_UShort  Class;                   /* applied to all glyphs in range */
+};
+
+typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;
+
+
+struct  HB_ClassDefFormat2_
+{
+  HB_UShort              ClassRangeCount;
+                                     /* number of ClassRangeRecords */
+  HB_ClassRangeRecord*  ClassRangeRecord;
+                                     /* array of ClassRangeRecords  */
+};
+
+typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;
+
+
+struct  HB_ClassDefinition_
+{
+  HB_Bool    loaded;
+
+  HB_UShort  ClassFormat;             /* 1 or 2                      */
+
+  union
+  {
+    HB_ClassDefFormat1  cd1;
+    HB_ClassDefFormat2  cd2;
+  } cd;
+};
+
+typedef struct HB_ClassDefinition_  HB_ClassDefinition;
+
+
+struct HB_Device_
+{
+  HB_UShort   StartSize;              /* smallest size to correct      */
+  HB_UShort   EndSize;                /* largest size to correct       */
+  HB_UShort   DeltaFormat;            /* DeltaValue array data format:
+                                        1, 2, or 3                    */
+  HB_UShort*  DeltaValue;             /* array of compressed data      */
+};
+
+typedef struct HB_Device_  HB_Device;
+
+
+enum  HB_Type_
+{
+  HB_Type_GSUB,
+  HB_Type_GPOS
+};
+
+typedef enum HB_Type_  HB_Type;
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_H */
index 82c510a..e4b5f9a 100755 (executable)
-/*\r
- * Copyright (C) 2006  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor\r
- */\r
-\r
-#include <stdint.h>\r
-\r
-/* Base Types */\r
-\r
-typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */\r
-typedef char HB_Boolean;\r
-typedef hb_uint32 HB_Fixed; /* 26.6 */\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_uint32 HB_Unichar;\r
-\r
-/* Metrics reported by the font backend for use of the shaper */\r
-typedef struct _HB_GlyphMetrics HB_GlyphMetrics;\r
-struct _HB_GlyphMetrics\r
-{\r
-    HB_Fixed advance;\r
-    \r
-    /* Do we need ink/logical extents for the glyph here? */\r
-};\r
-\r
-/*\r
- * HB_Font: Abstract font interface.\r
- *  First pass of this might just have FT_Face *getFace();\r
- */\r
-typedef struct _HB_Font HB_Font;\r
-typedef struct _HB_FontClass HB_FontClass;\r
-\r
-struct HB_FontClass {\r
-    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);\r
-    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);\r
-    HB_Boolean (*freeSFontTable)(void **cookie);\r
-};\r
-\r
-struct _HB_Font {\r
-    HB_FontClass *clazz;\r
-};\r
-\r
-/*\r
- * Language tags, of the form en-us; represented as interned, canonicalized\r
- * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")\r
- * both return the same (pointer-comparable) HB_Language).\r
- */\r
-typedef struct HB_Language_ *HB_Language;\r
-\r
-HB_Language hb_language_from_string(const char *str);\r
-const char *hb_language_to_string(HB_Language language);\r
-\r
-/* Special treatment for the edges of runs.\r
- */\r
-typedef enum {\r
-    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,\r
-    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,\r
-    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */\r
-} HB_RunEdge;\r
-\r
-/* Defines optional informaiton in HB_ShapeInput; this allows extension\r
- * of HB_ShapeInput while keeping binary compatibility\r
- */\r
-typedef enum {\r
-    HB_SHAPE_START_TYPE = 1 << 0,\r
-    HB_SHAPE_END_TYPE   = 1 << 1\r
-} HB_ShapeFlags;\r
-\r
-/* Attributes types are described by "interned strings"; this is a little\r
- * annoying if you want to write a switch statement, but keeps things\r
- * simple.\r
- */\r
-typedef struct _HB_AttributeType *HB_AttributeType;\r
-\r
-HB_AttributeType hb_attribute_type_from_string(const char *str);\r
-const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);\r
-\r
-struct HB_Attribute {\r
-    HB_AttributeType type;\r
-    int start; \r
-    int end;\r
-};\r
-\r
-\r
-/**\r
- * You could handle this like HB_Language, but an enum seems a little nicer;\r
- * another approach would be to use OpenType script tags.\r
- */\r
-typedef enum {\r
-    HB_SCRIPT_LATIN\r
-    /* ... */\r
-} HB_ShapeScript;\r
-\r
-/* This is just the subset of direction information needed by the shaper */\r
-typedef enum {\r
-    HB_DIRECTION_LTR,\r
-    HB_DIRECTION_RTL,\r
-    HB_DIRECTION_TTB\r
-} HB_Direction;\r
-\r
-typedef struct _HB_ShapeInput HB_ShapeInput;\r
-struct _HB_ShapeInput {\r
-    /* Defines what fields the caller has initialized - fields not in\r
-     * the enum are mandatory.\r
-     */\r
-    HB_ShapeFlags flags;\r
-    \r
-    HB_CodePoint *text;\r
-    int length;       /* total length of text to shape */\r
-    int shape_offset; /* start of section to shape */\r
-    int shape_length; /* number of code points to shape */\r
-\r
-    HB_Direction direction;\r
-    HB_ShapeScript script;\r
-    HB_Language language;\r
-\r
-    HB_AttributeType *attributes;\r
-    int n_attributes;\r
-\r
-    HB_RunEdge start_type;\r
-    HB_RunEdge end_type;\r
-};\r
-\r
-struct HB_GlyphItem {\r
-    HB_Glyph glyph;\r
-    \r
-    HB_Fixed x_offset;\r
-    HB_Fixed y_offset;\r
-    HB_Fixed advance;\r
-\r
-    /* Add kashida information, etc, here */\r
-};\r
-\r
-typedef enum {\r
-    HB_RESULT_SUCCESS,\r
-    HB_RESULT_NO_MEMORY,\r
-    HB_SHAPE_RESULT_FAILED\r
-} HB_Result;\r
-\r
-/*\r
- * Buffer for output \r
- */\r
-typedef struct _HB_GlyphBuffer HB_GlyphBuffer;\r
-struct _HB_GlyphBuffer {\r
-    int glyph_item_size;\r
-    int total_glyphs;\r
-    \r
-    int *log_clusters; /* Uniscribe style */\r
-    int cluster_space;\r
-  \r
-    int glyph_space;\r
-    void *glyph_buffer;\r
-};\r
-\r
-/* Making this self-allocating simplifies writing shapers and\r
- * also keeps things easier for caller. item_size passed in\r
- * must be at least sizeof(HB_GlyphItem) but can be bigger,\r
- * to accomodate application structures that extend HB_GlyphItem.\r
- * The allocated items will be zero-initialized.\r
- *\r
- * (Hack: Harfbuzz could choose to use even a *bigger* item size\r
- * and stick internal information before the public item structure.\r
- * This hack could possibly be used to unify this with HB_Buffer)\r
- */\r
-HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);\r
-void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);\r
-HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);\r
-HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);\r
-void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);\r
-\r
-\r
-/* Accessor for a particular glyph */\r
-#define HB_GLYPH_BUFFER_ITEM(buffer, index)\r
-\r
-/*\r
- * Main shaping function\r
- */\r
-HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);\r
+/*
+ * Copyright (C) 2006  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor
+ */
+
+#include <stdint.h>
+
+/* Base Types */
+
+typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */
+typedef char HB_Boolean;
+typedef hb_uint32 HB_Fixed; /* 26.6 */
+typedef hb_uint32 HB_Glyph;
+typedef hb_uint32 HB_Unichar;
+
+/* Metrics reported by the font backend for use of the shaper */
+typedef struct _HB_GlyphMetrics HB_GlyphMetrics;
+struct _HB_GlyphMetrics
+{
+    HB_Fixed advance;
+    
+    /* Do we need ink/logical extents for the glyph here? */
+};
+
+/*
+ * HB_Font: Abstract font interface.
+ *  First pass of this might just have FT_Face *getFace();
+ */
+typedef struct _HB_Font HB_Font;
+typedef struct _HB_FontClass HB_FontClass;
+
+struct HB_FontClass {
+    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);
+    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);
+    HB_Boolean (*freeSFontTable)(void **cookie);
+};
+
+struct _HB_Font {
+    HB_FontClass *clazz;
+};
+
+/*
+ * Language tags, of the form en-us; represented as interned, canonicalized
+ * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")
+ * both return the same (pointer-comparable) HB_Language).
+ */
+typedef struct HB_Language_ *HB_Language;
+
+HB_Language hb_language_from_string(const char *str);
+const char *hb_language_to_string(HB_Language language);
+
+/* Special treatment for the edges of runs.
+ */
+typedef enum {
+    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,
+    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,
+    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */
+} HB_RunEdge;
+
+/* Defines optional informaiton in HB_ShapeInput; this allows extension
+ * of HB_ShapeInput while keeping binary compatibility
+ */
+typedef enum {
+    HB_SHAPE_START_TYPE = 1 << 0,
+    HB_SHAPE_END_TYPE   = 1 << 1
+} HB_ShapeFlags;
+
+/* Attributes types are described by "interned strings"; this is a little
+ * annoying if you want to write a switch statement, but keeps things
+ * simple.
+ */
+typedef struct _HB_AttributeType *HB_AttributeType;
+
+HB_AttributeType hb_attribute_type_from_string(const char *str);
+const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);
+
+struct HB_Attribute {
+    HB_AttributeType type;
+    int start; 
+    int end;
+};
+
+
+/**
+ * You could handle this like HB_Language, but an enum seems a little nicer;
+ * another approach would be to use OpenType script tags.
+ */
+typedef enum {
+    HB_SCRIPT_LATIN
+    /* ... */
+} HB_ShapeScript;
+
+/* This is just the subset of direction information needed by the shaper */
+typedef enum {
+    HB_DIRECTION_LTR,
+    HB_DIRECTION_RTL,
+    HB_DIRECTION_TTB
+} HB_Direction;
+
+typedef struct _HB_ShapeInput HB_ShapeInput;
+struct _HB_ShapeInput {
+    /* Defines what fields the caller has initialized - fields not in
+     * the enum are mandatory.
+     */
+    HB_ShapeFlags flags;
+    
+    HB_CodePoint *text;
+    int length;       /* total length of text to shape */
+    int shape_offset; /* start of section to shape */
+    int shape_length; /* number of code points to shape */
+
+    HB_Direction direction;
+    HB_ShapeScript script;
+    HB_Language language;
+
+    HB_AttributeType *attributes;
+    int n_attributes;
+
+    HB_RunEdge start_type;
+    HB_RunEdge end_type;
+};
+
+struct HB_GlyphItem {
+    HB_Glyph glyph;
+    
+    HB_Fixed x_offset;
+    HB_Fixed y_offset;
+    HB_Fixed advance;
+
+    /* Add kashida information, etc, here */
+};
+
+typedef enum {
+    HB_RESULT_SUCCESS,
+    HB_RESULT_NO_MEMORY,
+    HB_SHAPE_RESULT_FAILED
+} HB_Result;
+
+/*
+ * Buffer for output 
+ */
+typedef struct _HB_GlyphBuffer HB_GlyphBuffer;
+struct _HB_GlyphBuffer {
+    int glyph_item_size;
+    int total_glyphs;
+    
+    int *log_clusters; /* Uniscribe style */
+    int cluster_space;
+  
+    int glyph_space;
+    void *glyph_buffer;
+};
+
+/* Making this self-allocating simplifies writing shapers and
+ * also keeps things easier for caller. item_size passed in
+ * must be at least sizeof(HB_GlyphItem) but can be bigger,
+ * to accomodate application structures that extend HB_GlyphItem.
+ * The allocated items will be zero-initialized.
+ *
+ * (Hack: Harfbuzz could choose to use even a *bigger* item size
+ * and stick internal information before the public item structure.
+ * This hack could possibly be used to unify this with HB_Buffer)
+ */
+HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);
+void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);
+HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);
+HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);
+void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);
+
+
+/* Accessor for a particular glyph */
+#define HB_GLYPH_BUFFER_ITEM(buffer, index)
+
+/*
+ * Main shaping function
+ */
+HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);
index bb0ae9f..e4e7ebc 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_PRIVATE_H\r
-#define HARFBUZZ_SHAPER_PRIVATE_H\r
-\r
-HB_BEGIN_HEADER\r
-enum {\r
-    C_DOTTED_CIRCLE = 0x25CC\r
-};\r
-\r
-typedef enum \r
-{\r
-    HB_Combining_BelowLeftAttached       = 200,\r
-    HB_Combining_BelowAttached           = 202,\r
-    HB_Combining_BelowRightAttached      = 204,\r
-    HB_Combining_LeftAttached            = 208,\r
-    HB_Combining_RightAttached           = 210,\r
-    HB_Combining_AboveLeftAttached       = 212,\r
-    HB_Combining_AboveAttached           = 214,\r
-    HB_Combining_AboveRightAttached      = 216,\r
-\r
-    HB_Combining_BelowLeft               = 218,\r
-    HB_Combining_Below                   = 220,\r
-    HB_Combining_BelowRight              = 222,\r
-    HB_Combining_Left                    = 224,\r
-    HB_Combining_Right                   = 226,\r
-    HB_Combining_AboveLeft               = 228,\r
-    HB_Combining_Above                   = 230,\r
-    HB_Combining_AboveRight              = 232,\r
-\r
-    HB_Combining_DoubleBelow             = 233,\r
-    HB_Combining_DoubleAbove             = 234,\r
-    HB_Combining_IotaSubscript           = 240\r
-} HB_CombiningClass;\r
-\r
-typedef enum {\r
-    CcmpProperty = 0x1,\r
-    InitProperty = 0x2,\r
-    IsolProperty = 0x4,\r
-    FinaProperty = 0x8,\r
-    MediProperty = 0x10,\r
-    RligProperty = 0x20,\r
-    CaltProperty = 0x40,\r
-    LigaProperty = 0x80,\r
-    DligProperty = 0x100,\r
-    CswhProperty = 0x200,\r
-    MsetProperty = 0x400,\r
-\r
-    /* used by indic and myanmar shaper */\r
-    NuktaProperty = 0x4,\r
-    AkhantProperty = 0x8,\r
-    RephProperty = 0x10,\r
-    PreFormProperty = 0x20,\r
-    BelowFormProperty = 0x40,\r
-    AboveFormProperty = 0x80,\r
-    HalfFormProperty = 0x100,\r
-    PostFormProperty = 0x200,\r
-    VattuProperty = 0x400,\r
-    PreSubstProperty = 0x800,\r
-    BelowSubstProperty = 0x1000,\r
-    AboveSubstProperty = 0x2000,\r
-    PostSubstProperty = 0x4000,\r
-    HalantProperty = 0x8000,\r
-    CligProperty = 0x10000\r
-\r
-} HB_OpenTypeProperty;\r
-\r
-/* return true if ok. */\r
-typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);\r
-typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    HB_ShapeFunction shape;\r
-    HB_AttributeFunction charAttributes;\r
-} HB_ScriptEngine;\r
-\r
-extern const HB_ScriptEngine HB_ScriptEngines[];\r
-\r
-extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);\r
-\r
-extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    hb_uint32 tag;\r
-    hb_uint32 property;\r
-} HB_OpenTypeFeature;\r
-\r
-#define PositioningProperties 0x80000000\r
-\r
-HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);\r
-\r
-HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);\r
-HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);\r
-\r
-void HB_HeuristicPosition(HB_ShaperItem *item);\r
-void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);\r
-\r
-#define HB_IsControlChar(uc) \\r
-    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \\r
-     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \\r
-     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))\r
-\r
-HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);\r
-\r
-#define HB_GetGlyphAdvances(shaper_item) \\r
-    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \\r
-                                               shaper_item->glyphs, shaper_item->num_glyphs, \\r
-                                               shaper_item->advances, \\r
-                                               shaper_item->face->current_flags);\r
-\r
-#define HB_DECLARE_STACKARRAY(Type, Name) \\r
-    Type stack##Name[64]; \ \r
-    Type *Name = stack##Name;\r
-\r
-#define HB_INIT_STACKARRAY(Type, Name, Length) \\r
-    if ((Length) >= 64) \\r
-        Name = (Type *)malloc((Length) * sizeof(Type));\r
-\r
-#define HB_STACKARRAY(Type, Name, Length) \\r
-    HB_DECLARE_STACKARRAY(Type, Name) \\r
-    HB_INIT_STACKARRAY(Type, Name, Length)\r
-\r
-#define HB_FREE_STACKARRAY(Name) \\r
-    if (stack##Name != Name) \\r
-        free(Name);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_PRIVATE_H
+#define HARFBUZZ_SHAPER_PRIVATE_H
+
+HB_BEGIN_HEADER
+enum {
+    C_DOTTED_CIRCLE = 0x25CC
+};
+
+typedef enum 
+{
+    HB_Combining_BelowLeftAttached       = 200,
+    HB_Combining_BelowAttached           = 202,
+    HB_Combining_BelowRightAttached      = 204,
+    HB_Combining_LeftAttached            = 208,
+    HB_Combining_RightAttached           = 210,
+    HB_Combining_AboveLeftAttached       = 212,
+    HB_Combining_AboveAttached           = 214,
+    HB_Combining_AboveRightAttached      = 216,
+
+    HB_Combining_BelowLeft               = 218,
+    HB_Combining_Below                   = 220,
+    HB_Combining_BelowRight              = 222,
+    HB_Combining_Left                    = 224,
+    HB_Combining_Right                   = 226,
+    HB_Combining_AboveLeft               = 228,
+    HB_Combining_Above                   = 230,
+    HB_Combining_AboveRight              = 232,
+
+    HB_Combining_DoubleBelow             = 233,
+    HB_Combining_DoubleAbove             = 234,
+    HB_Combining_IotaSubscript           = 240
+} HB_CombiningClass;
+
+typedef enum {
+    CcmpProperty = 0x1,
+    InitProperty = 0x2,
+    IsolProperty = 0x4,
+    FinaProperty = 0x8,
+    MediProperty = 0x10,
+    RligProperty = 0x20,
+    CaltProperty = 0x40,
+    LigaProperty = 0x80,
+    DligProperty = 0x100,
+    CswhProperty = 0x200,
+    MsetProperty = 0x400,
+
+    /* used by indic and myanmar shaper */
+    NuktaProperty = 0x4,
+    AkhantProperty = 0x8,
+    RephProperty = 0x10,
+    PreFormProperty = 0x20,
+    BelowFormProperty = 0x40,
+    AboveFormProperty = 0x80,
+    HalfFormProperty = 0x100,
+    PostFormProperty = 0x200,
+    VattuProperty = 0x400,
+    PreSubstProperty = 0x800,
+    BelowSubstProperty = 0x1000,
+    AboveSubstProperty = 0x2000,
+    PostSubstProperty = 0x4000,
+    HalantProperty = 0x8000,
+    CligProperty = 0x10000
+
+} HB_OpenTypeProperty;
+
+/* return true if ok. */
+typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);
+typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    HB_ShapeFunction shape;
+    HB_AttributeFunction charAttributes;
+} HB_ScriptEngine;
+
+extern const HB_ScriptEngine HB_ScriptEngines[];
+
+extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);
+
+extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    hb_uint32 tag;
+    hb_uint32 property;
+} HB_OpenTypeFeature;
+
+#define PositioningProperties 0x80000000
+
+HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);
+
+HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);
+HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);
+
+void HB_HeuristicPosition(HB_ShaperItem *item);
+void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);
+
+#define HB_IsControlChar(uc) \
+    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \
+     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \
+     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))
+
+HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);
+
+#define HB_GetGlyphAdvances(shaper_item) \
+    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \
+                                               shaper_item->glyphs, shaper_item->num_glyphs, \
+                                               shaper_item->advances, \
+                                               shaper_item->face->current_flags);
+
+#define HB_DECLARE_STACKARRAY(Type, Name) \
+    Type stack##Name[64]; \ 
+    Type *Name = stack##Name;
+
+#define HB_INIT_STACKARRAY(Type, Name, Length) \
+    if ((Length) >= 64) \
+        Name = (Type *)malloc((Length) * sizeof(Type));
+
+#define HB_STACKARRAY(Type, Name, Length) \
+    HB_DECLARE_STACKARRAY(Type, Name) \
+    HB_INIT_STACKARRAY(Type, Name, Length)
+
+#define HB_FREE_STACKARRAY(Name) \
+    if (stack##Name != Name) \
+        free(Name);
+
+HB_END_HEADER
+
+#endif
index c74c664..9bdc8c6 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_H\r
-#define HARFBUZZ_SHAPER_H\r
-\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-external.h" \r
-#include "harfbuzz-stream-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef enum {\r
-        HB_Script_Common,\r
-        HB_Script_Greek,\r
-        HB_Script_Cyrillic,\r
-        HB_Script_Armenian,\r
-        HB_Script_Hebrew,\r
-        HB_Script_Arabic,\r
-        HB_Script_Syriac,\r
-        HB_Script_Thaana,\r
-        HB_Script_Devanagari,\r
-        HB_Script_Bengali,\r
-        HB_Script_Gurmukhi,\r
-        HB_Script_Gujarati,\r
-        HB_Script_Oriya,\r
-        HB_Script_Tamil,\r
-        HB_Script_Telugu,\r
-        HB_Script_Kannada,\r
-        HB_Script_Malayalam,\r
-        HB_Script_Sinhala,\r
-        HB_Script_Thai,\r
-        HB_Script_Lao,\r
-        HB_Script_Tibetan,\r
-        HB_Script_Myanmar,\r
-        HB_Script_Georgian,\r
-        HB_Script_Hangul,\r
-        HB_Script_Ogham,\r
-        HB_Script_Runic,\r
-        HB_Script_Khmer,\r
-        HB_Script_Nko,\r
-        HB_Script_Inherited,\r
-        HB_ScriptCount = HB_Script_Inherited\r
-        /*\r
-        HB_Script_Latin = Common,\r
-        HB_Script_Ethiopic = Common,\r
-        HB_Script_Cherokee = Common,\r
-        HB_Script_CanadianAboriginal = Common,\r
-        HB_Script_Mongolian = Common,\r
-        HB_Script_Hiragana = Common,\r
-        HB_Script_Katakana = Common,\r
-        HB_Script_Bopomofo = Common,\r
-        HB_Script_Han = Common,\r
-        HB_Script_Yi = Common,\r
-        HB_Script_OldItalic = Common,\r
-        HB_Script_Gothic = Common,\r
-        HB_Script_Deseret = Common,\r
-        HB_Script_Tagalog = Common,\r
-        HB_Script_Hanunoo = Common,\r
-        HB_Script_Buhid = Common,\r
-        HB_Script_Tagbanwa = Common,\r
-        HB_Script_Limbu = Common,\r
-        HB_Script_TaiLe = Common,\r
-        HB_Script_LinearB = Common,\r
-        HB_Script_Ugaritic = Common,\r
-        HB_Script_Shavian = Common,\r
-        HB_Script_Osmanya = Common,\r
-        HB_Script_Cypriot = Common,\r
-        HB_Script_Braille = Common,\r
-        HB_Script_Buginese = Common,\r
-        HB_Script_Coptic = Common,\r
-        HB_Script_NewTaiLue = Common,\r
-        HB_Script_Glagolitic = Common,\r
-        HB_Script_Tifinagh = Common,\r
-        HB_Script_SylotiNagri = Common,\r
-        HB_Script_OldPersian = Common,\r
-        HB_Script_Kharoshthi = Common,\r
-        HB_Script_Balinese = Common,\r
-        HB_Script_Cuneiform = Common,\r
-        HB_Script_Phoenician = Common,\r
-        HB_Script_PhagsPa = Common,\r
-        */\r
-} HB_Script;\r
-\r
-typedef struct\r
-{\r
-    hb_uint32 pos;\r
-    hb_uint32 length;\r
-    HB_Script script;\r
-    hb_uint8 bidiLevel;\r
-} HB_ScriptItem;\r
-\r
-typedef enum {\r
-    HB_NoBreak,\r
-    HB_SoftHyphen,\r
-    HB_Break,\r
-    HB_ForcedBreak\r
-} HB_LineBreakType;\r
-\r
-\r
-typedef struct {\r
-    /*HB_LineBreakType*/ unsigned lineBreakType  :2;\r
-    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */\r
-    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */\r
-    /*HB_Bool*/ unsigned wordBoundary            :1;\r
-    /*HB_Bool*/ unsigned sentenceBoundary        :1;\r
-    unsigned unused                  :2;\r
-} HB_CharAttributes;\r
-\r
-void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                              const HB_ScriptItem *items, hb_uint32 numItems,\r
-                              HB_CharAttributes *attributes);\r
-\r
-\r
-typedef enum {\r
-    HB_LeftToRight = 0,\r
-    HB_RightToLeft = 1\r
-} HB_StringToGlyphsFlags;\r
-\r
-typedef enum {\r
-    HB_ShaperFlag_Default = 0,\r
-    HB_ShaperFlag_NoKerning = 1,\r
-    HB_ShaperFlag_UseDesignMetrics = 2\r
-} HB_ShaperFlag;\r
-\r
-/* \r
-   highest value means highest priority for justification. Justification is done by first inserting kashidas\r
-   starting with the highest priority positions, then stretching spaces, afterwards extending inter char\r
-   spacing, and last spacing between arabic words.\r
-   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.\r
-*/\r
-typedef enum {\r
-    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */\r
-    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */\r
-    HB_Character      = 2,   /* Inter-character justification point follows this glyph */\r
-    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */\r
-    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */\r
-    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */\r
-    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */\r
-    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */\r
-    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */\r
-    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */\r
-    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */\r
-} HB_JustificationClass;\r
-\r
-/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep\r
- * it like that. If this is a problem please tell Trolltech :)\r
- */\r
-typedef struct {\r
-    unsigned justification   :4;  /* Justification class */\r
-    unsigned clusterStart    :1;  /* First glyph of representation of cluster */\r
-    unsigned mark            :1;  /* needs to be positioned around base char */\r
-    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */\r
-    unsigned dontPrint       :1;\r
-    unsigned combiningClass  :8;\r
-} HB_GlyphAttributes;\r
-\r
-typedef struct HB_FaceRec_ {\r
-    HB_Bool isSymbolFont;\r
-\r
-    HB_GDEF gdef;\r
-    HB_GSUB gsub;\r
-    HB_GPOS gpos;\r
-    HB_Bool supported_scripts[HB_ScriptCount];\r
-    HB_Buffer buffer;\r
-    HB_Script current_script;\r
-    int current_flags; /* HB_ShaperFlags */\r
-    HB_Bool has_opentype_kerning;\r
-    HB_Bool glyphs_substituted;\r
-    HB_GlyphAttributes *tmpAttributes;\r
-    unsigned int *tmpLogClusters;\r
-    int length;\r
-    int orig_nglyphs;\r
-} HB_FaceRec;\r
-\r
-typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);\r
-\r
-HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);\r
-void HB_FreeFace(HB_Face face);\r
-\r
-typedef struct {\r
-    HB_Fixed x, y;\r
-    HB_Fixed width, height;\r
-    HB_Fixed xOffset, yOffset;\r
-} HB_GlyphMetrics;\r
-\r
-typedef enum {\r
-    HB_FontAscent\r
-} HB_FontMetric;\r
-\r
-typedef struct {\r
-    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);\r
-    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);\r
-    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);\r
-    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */\r
-    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);\r
-    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);\r
-} HB_FontClass;\r
-\r
-typedef struct HB_Font_ {\r
-    const HB_FontClass *klass;\r
-\r
-    /* Metrics */\r
-    HB_UShort x_ppem, y_ppem;\r
-    HB_16Dot16 x_scale, y_scale;\r
-\r
-    void *userData;\r
-} HB_FontRec;\r
-\r
-typedef struct HB_ShaperItem_ HB_ShaperItem;\r
-\r
-struct HB_ShaperItem_ {\r
-    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */\r
-    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */\r
-    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */\r
-    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */\r
-    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */\r
-    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */\r
-    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */\r
-    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */\r
-\r
-    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */\r
-                                            /* output: required capacity (may be larger than actual capacity) */\r
-\r
-    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */\r
-    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */\r
-    HB_Fixed *advances;                     /* output: <num_glyphs> advances */\r
-    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */\r
-    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */\r
-\r
-    /* internal */\r
-    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */\r
-};\r
-\r
-HB_Bool HB_ShapeItem(HB_ShaperItem *item);\r
-\r
-\r
-extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-//#ifdef __cplusplus\r
-//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;\r
-//#endif\r
-\r
-extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_H
+#define HARFBUZZ_SHAPER_H
+
+#include "harfbuzz-global.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-external.h" 
+#include "harfbuzz-stream-private.h"
+
+HB_BEGIN_HEADER
+
+typedef enum {
+        HB_Script_Common,
+        HB_Script_Greek,
+        HB_Script_Cyrillic,
+        HB_Script_Armenian,
+        HB_Script_Hebrew,
+        HB_Script_Arabic,
+        HB_Script_Syriac,
+        HB_Script_Thaana,
+        HB_Script_Devanagari,
+        HB_Script_Bengali,
+        HB_Script_Gurmukhi,
+        HB_Script_Gujarati,
+        HB_Script_Oriya,
+        HB_Script_Tamil,
+        HB_Script_Telugu,
+        HB_Script_Kannada,
+        HB_Script_Malayalam,
+        HB_Script_Sinhala,
+        HB_Script_Thai,
+        HB_Script_Lao,
+        HB_Script_Tibetan,
+        HB_Script_Myanmar,
+        HB_Script_Georgian,
+        HB_Script_Hangul,
+        HB_Script_Ogham,
+        HB_Script_Runic,
+        HB_Script_Khmer,
+        HB_Script_Nko,
+        HB_Script_Inherited,
+        HB_ScriptCount = HB_Script_Inherited
+        /*
+        HB_Script_Latin = Common,
+        HB_Script_Ethiopic = Common,
+        HB_Script_Cherokee = Common,
+        HB_Script_CanadianAboriginal = Common,
+        HB_Script_Mongolian = Common,
+        HB_Script_Hiragana = Common,
+        HB_Script_Katakana = Common,
+        HB_Script_Bopomofo = Common,
+        HB_Script_Han = Common,
+        HB_Script_Yi = Common,
+        HB_Script_OldItalic = Common,
+        HB_Script_Gothic = Common,
+        HB_Script_Deseret = Common,
+        HB_Script_Tagalog = Common,
+        HB_Script_Hanunoo = Common,
+        HB_Script_Buhid = Common,
+        HB_Script_Tagbanwa = Common,
+        HB_Script_Limbu = Common,
+        HB_Script_TaiLe = Common,
+        HB_Script_LinearB = Common,
+        HB_Script_Ugaritic = Common,
+        HB_Script_Shavian = Common,
+        HB_Script_Osmanya = Common,
+        HB_Script_Cypriot = Common,
+        HB_Script_Braille = Common,
+        HB_Script_Buginese = Common,
+        HB_Script_Coptic = Common,
+        HB_Script_NewTaiLue = Common,
+        HB_Script_Glagolitic = Common,
+        HB_Script_Tifinagh = Common,
+        HB_Script_SylotiNagri = Common,
+        HB_Script_OldPersian = Common,
+        HB_Script_Kharoshthi = Common,
+        HB_Script_Balinese = Common,
+        HB_Script_Cuneiform = Common,
+        HB_Script_Phoenician = Common,
+        HB_Script_PhagsPa = Common,
+        */
+} HB_Script;
+
+typedef struct
+{
+    hb_uint32 pos;
+    hb_uint32 length;
+    HB_Script script;
+    hb_uint8 bidiLevel;
+} HB_ScriptItem;
+
+typedef enum {
+    HB_NoBreak,
+    HB_SoftHyphen,
+    HB_Break,
+    HB_ForcedBreak
+} HB_LineBreakType;
+
+
+typedef struct {
+    /*HB_LineBreakType*/ unsigned lineBreakType  :2;
+    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */
+    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */
+    /*HB_Bool*/ unsigned wordBoundary            :1;
+    /*HB_Bool*/ unsigned sentenceBoundary        :1;
+    unsigned unused                  :2;
+} HB_CharAttributes;
+
+void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                              const HB_ScriptItem *items, hb_uint32 numItems,
+                              HB_CharAttributes *attributes);
+
+
+typedef enum {
+    HB_LeftToRight = 0,
+    HB_RightToLeft = 1
+} HB_StringToGlyphsFlags;
+
+typedef enum {
+    HB_ShaperFlag_Default = 0,
+    HB_ShaperFlag_NoKerning = 1,
+    HB_ShaperFlag_UseDesignMetrics = 2
+} HB_ShaperFlag;
+
+/* 
+   highest value means highest priority for justification. Justification is done by first inserting kashidas
+   starting with the highest priority positions, then stretching spaces, afterwards extending inter char
+   spacing, and last spacing between arabic words.
+   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.
+*/
+typedef enum {
+    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */
+    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */
+    HB_Character      = 2,   /* Inter-character justification point follows this glyph */
+    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */
+    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */
+    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */
+    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */
+    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
+    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */
+    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */
+    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */
+} HB_JustificationClass;
+
+/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep
+ * it like that. If this is a problem please tell Trolltech :)
+ */
+typedef struct {
+    unsigned justification   :4;  /* Justification class */
+    unsigned clusterStart    :1;  /* First glyph of representation of cluster */
+    unsigned mark            :1;  /* needs to be positioned around base char */
+    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */
+    unsigned dontPrint       :1;
+    unsigned combiningClass  :8;
+} HB_GlyphAttributes;
+
+typedef struct HB_FaceRec_ {
+    HB_Bool isSymbolFont;
+
+    HB_GDEF gdef;
+    HB_GSUB gsub;
+    HB_GPOS gpos;
+    HB_Bool supported_scripts[HB_ScriptCount];
+    HB_Buffer buffer;
+    HB_Script current_script;
+    int current_flags; /* HB_ShaperFlags */
+    HB_Bool has_opentype_kerning;
+    HB_Bool glyphs_substituted;
+    HB_GlyphAttributes *tmpAttributes;
+    unsigned int *tmpLogClusters;
+    int length;
+    int orig_nglyphs;
+} HB_FaceRec;
+
+typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
+
+HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);
+void HB_FreeFace(HB_Face face);
+
+typedef struct {
+    HB_Fixed x, y;
+    HB_Fixed width, height;
+    HB_Fixed xOffset, yOffset;
+} HB_GlyphMetrics;
+
+typedef enum {
+    HB_FontAscent
+} HB_FontMetric;
+
+typedef struct {
+    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
+    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);
+    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
+    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */
+    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
+    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);
+} HB_FontClass;
+
+typedef struct HB_Font_ {
+    const HB_FontClass *klass;
+
+    /* Metrics */
+    HB_UShort x_ppem, y_ppem;
+    HB_16Dot16 x_scale, y_scale;
+
+    void *userData;
+} HB_FontRec;
+
+typedef struct HB_ShaperItem_ HB_ShaperItem;
+
+struct HB_ShaperItem_ {
+    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */
+    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */
+    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */
+    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */
+    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */
+    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */
+    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */
+    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */
+
+    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */
+                                            /* output: required capacity (may be larger than actual capacity) */
+
+    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */
+    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */
+    HB_Fixed *advances;                     /* output: <num_glyphs> advances */
+    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */
+    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */
+
+    /* internal */
+    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */
+};
+
+HB_Bool HB_ShapeItem(HB_ShaperItem *item);
+
+
+extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+//#ifdef __cplusplus
+//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;
+//#endif
+
+extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+
+
+HB_END_HEADER
+
+#endif
index 322cf08..7dd41ad 100755 (executable)
@@ -1,81 +1,81 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_PRIVATE_H\r
-#define HARFBUZZ_STREAM_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-HB_INTERNAL void\r
-_hb_close_stream( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Int\r
-_hb_stream_pos( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_seek( HB_Stream stream,\r
-                 HB_UInt   pos );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_frame_enter( HB_Stream stream,\r
-                        HB_UInt   size );\r
-\r
-HB_INTERNAL    void\r
-_hb_stream_frame_exit( HB_Stream stream );\r
-\r
-/* convenience macros */\r
-\r
-#define  SET_ERR(c)   ( (error = (c)) != 0 )\r
-\r
-#define  GOTO_Table(tag) (0)\r
-#define  FILE_Pos()      _hb_stream_pos( stream )\r
-#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )\r
-#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )\r
-#define  FORGET_Frame()      _hb_stream_frame_exit( stream )\r
-\r
-#define  GET_Byte()      (*stream->cursor++)\r
-#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \\r
-                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \\r
-                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-\r
-\r
-#define  GET_Char()      ((HB_Char)GET_Byte())\r
-#define  GET_UShort()    ((HB_UShort)GET_Short())\r
-#define  GET_ULong()     ((HB_UInt)GET_Long())\r
-#define  GET_Tag4()      GET_ULong()\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_STREAM_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_PRIVATE_H
+#define HARFBUZZ_STREAM_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+HB_INTERNAL void
+_hb_close_stream( HB_Stream stream );
+
+HB_INTERNAL    HB_Int
+_hb_stream_pos( HB_Stream stream );
+
+HB_INTERNAL    HB_Error
+_hb_stream_seek( HB_Stream stream,
+                 HB_UInt   pos );
+
+HB_INTERNAL    HB_Error
+_hb_stream_frame_enter( HB_Stream stream,
+                        HB_UInt   size );
+
+HB_INTERNAL    void
+_hb_stream_frame_exit( HB_Stream stream );
+
+/* convenience macros */
+
+#define  SET_ERR(c)   ( (error = (c)) != 0 )
+
+#define  GOTO_Table(tag) (0)
+#define  FILE_Pos()      _hb_stream_pos( stream )
+#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )
+#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )
+#define  FORGET_Frame()      _hb_stream_frame_exit( stream )
+
+#define  GET_Byte()      (*stream->cursor++)
+#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \
+                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \
+                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+
+
+#define  GET_Char()      ((HB_Char)GET_Byte())
+#define  GET_UShort()    ((HB_UShort)GET_Short())
+#define  GET_ULong()     ((HB_UInt)GET_Long())
+#define  GET_Tag4()      GET_ULong()
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_STREAM_PRIVATE_H */
index e49c307..07578d5 100755 (executable)
@@ -1,42 +1,42 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_H\r
-#define HARFBUZZ_STREAM_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_StreamRec_\r
-{\r
-    HB_Byte*       base;\r
-    HB_UInt        size;\r
-    HB_UInt        pos;\r
-    \r
-    HB_Byte*       cursor;\r
-} HB_StreamRec;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_H
+#define HARFBUZZ_STREAM_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_StreamRec_
+{
+    HB_Byte*       base;
+    HB_UInt        size;
+    HB_UInt        pos;
+    
+    HB_Byte*       cursor;
+} HB_StreamRec;
+
+
+HB_END_HEADER
+
+#endif
index d127458..8d86779 100755 (executable)
@@ -1,49 +1,49 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_H\r
-#define HARFBUZZ_H\r
-\r
-#include "harfbuzz-external.h"\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-buffer.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-shaper.h"\r
-\r
-#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */\r
-#define HB_ZWJ           0x200D   /** Zero Width Joiner */\r
-#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */\r
-\r
-#define HB_INITIAL_NO_OF_GLYPH 64\r
-\r
-extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;\r
-extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;\r
-extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_H
+#define HARFBUZZ_H
+
+#include "harfbuzz-external.h"
+#include "harfbuzz-impl.h"
+#include "harfbuzz-global.h"
+#include "harfbuzz-buffer.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-shaper.h"
+
+#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */
+#define HB_ZWJ           0x200D   /** Zero Width Joiner */
+#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */
+
+#define HB_INITIAL_NO_OF_GLYPH 64
+
+extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;
+extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;
+extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;
+
+#endif /* HARFBUZZ_OPEN_H */
index 20e40e6..0ff1a4e 100755 (executable)
-\r
-/*\r
- * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef __hb_unicode_tables_h__\r
-#define __hb_unicode_tables_h__\r
-\r
-#include "math.h"\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-typedef struct\r
-{\r
-       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable\r
-       HB_Script *pSubTable;\r
-\r
-}unicodeScriptTableStruct;\r
-\r
-HB_Script subTableThanaSyriac[] = \r
-{\r
-       HB_Script_Syriac,//0x00\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x08\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x10\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x18\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x20\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x28\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x30\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x38\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x40\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x48\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,//0x4f\r
-\r
-       HB_Script_Common,//0x50\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x58\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x60\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x68\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x70\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x78\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Thaana,//0x80\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x88\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x90\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x98\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,//0xbf\r
-};\r
-\r
-HB_Script subTableDevaBengali[] = \r
-{\r
-       HB_Script_Devanagari,//0x00\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x08\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x10\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x18\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x20\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x28\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x30\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x38\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x40\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x48\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x4f\r
-\r
-       HB_Script_Devanagari,//0x50\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x58\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x60\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x68\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x70\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x78\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x7f\r
-\r
-\r
-       HB_Script_Bengali,//0x80\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x88\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x90\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0x98\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xb0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xb8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xc0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xc8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xe0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xe8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableGuruGuarati[]=\r
-{\r
-       HB_Script_Gurmukhi,//0x00\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x08\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x10\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x18\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x20\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x28\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x30\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x38\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x40\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x48\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x4f\r
-\r
-       HB_Script_Gurmukhi,//0x50\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x58\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x60\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x68\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x70\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x78\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x7f\r
-\r
-\r
-       HB_Script_Gujarati,//0x80\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x88\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x90\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0x98\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xb0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xb8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xc0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xc8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xe0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xe8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOriyaTamil[]=\r
-{\r
-       HB_Script_Oriya,//0x00\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x08\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x10\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x18\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x20\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x28\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x30\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x38\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x40\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x48\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x4f\r
-\r
-       HB_Script_Oriya,//0x50\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x58\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x60\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x68\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x70\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x78\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x7f\r
-\r
-\r
-       HB_Script_Tamil,//0x80\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x88\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x90\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0x98\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xb0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xb8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xc0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xc8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xe0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xe8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableTelukannada[]=\r
-{\r
-       HB_Script_Telugu,//0x00\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x08\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x10\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x18\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x20\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x28\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x30\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x38\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x40\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x48\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x4f\r
-\r
-       HB_Script_Telugu,//0x50\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x58\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x60\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x68\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x70\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x78\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x7f\r
-\r
-\r
-       HB_Script_Kannada,//0x80\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x88\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x90\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0x98\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xb0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xb8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xc0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xc8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xe0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xe8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMalSinhala[]=\r
-{\r
-       HB_Script_Malayalam,//0x00\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x08\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x10\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x18\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x20\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x28\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x30\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x38\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x40\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x48\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x4f\r
-\r
-       HB_Script_Malayalam,//0x50\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x58\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x60\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x68\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x70\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x78\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x7f\r
-\r
-\r
-       HB_Script_Sinhala,//0x80\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x88\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x90\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0x98\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xb0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xb8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xc0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xc8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xe0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xe8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableThaiLao[]=\r
-{\r
-       HB_Script_Thai,//0x00\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x08\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x10\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x18\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x20\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x28\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x30\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x38\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x40\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x48\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x4f\r
-\r
-       HB_Script_Thai,//0x50\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x58\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x60\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x68\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x70\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x78\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x7f\r
-\r
-\r
-       HB_Script_Lao,//0x80\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x88\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x90\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0x98\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xb0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xb8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xc0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xc8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xe0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xe8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMyanGeorgian[] =\r
-{\r
-       HB_Script_Myanmar,//0x00\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x08\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x10\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x18\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x20\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x28\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x30\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x38\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x40\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x48\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x4f\r
-\r
-       HB_Script_Myanmar,//0x50\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x58\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x60\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x68\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x70\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x78\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x7f\r
-\r
-\r
-       HB_Script_Myanmar,//0x80\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x88\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x90\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x98\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Georgian,//0xa0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xa8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xb0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xb8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xc0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xc8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xe0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xe8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOghamRunic[] = \r
-{\r
-       HB_Script_Ogham,//0x00\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x08\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x10\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x18\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x20\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x28\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x30\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x38\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x40\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x48\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x4f\r
-\r
-       HB_Script_Ogham,//0x50\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x58\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x60\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x68\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x70\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x78\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x7f\r
-\r
-\r
-       HB_Script_Ogham,//0x80\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x88\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x90\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x98\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Runic,//0xa0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xa8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xb0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xb8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xc0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xc8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xe0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xe8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,//0xff\r
-\r
-};\r
-\r
-#define VFE_UNICODE_MAX_SCRIPT 256\r
-\r
-static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=\r
-{\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Greek, 0},\r
-\r
-       {HB_Script_Cyrillic, 0},//0x04\r
-       {HB_Script_Armenian, 0},\r
-       {HB_Script_Arabic, 0},\r
-       {0xc0, subTableThanaSyriac},\r
-\r
-       {HB_Script_Common, 0},//0x08\r
-       {0x100, subTableDevaBengali},\r
-       {0x100, subTableGuruGuarati},\r
-       {0x100, subTableOriyaTamil},\r
-       \r
-       {0x100, subTableTelukannada},//0x0c\r
-       {0x100, subTableMalSinhala},\r
-       {0x100, subTableThaiLao},\r
-       {HB_Script_Tibetan, 0},\r
-\r
-       {0x100, subTableMyanGeorgian},//0x10\r
-       {HB_Script_Hangul, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x14\r
-       {HB_Script_Common, 0},\r
-       {0x100, subTableOghamRunic},\r
-       {HB_Script_Khmer, 0},\r
-\r
-       {HB_Script_Common, 0},//0x18\r
-       {HB_Script_Khmer, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x1c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x20\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x24\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x28\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x2c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x30\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x34\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x38\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x3c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x44\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x48\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x4c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x50\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x54\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x58\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x5c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x60\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x64\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x68\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x6c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x70\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x74\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x78\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x7c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x80\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x84\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x88\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x8c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x94\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x98\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x9c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xac\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xbc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xcc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xdc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xec\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xfc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},//ff\r
-};\r
-\r
-#endif /* __hb_unicode_tables_h__ */\r
-\r
+
+/*
+ * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef __hb_unicode_tables_h__
+#define __hb_unicode_tables_h__
+
+#include "math.h"
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+typedef struct
+{
+       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable
+       HB_Script *pSubTable;
+
+}unicodeScriptTableStruct;
+
+HB_Script subTableThanaSyriac[] = 
+{
+       HB_Script_Syriac,//0x00
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x08
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x10
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x18
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x20
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x28
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x30
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x38
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x40
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x48
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,//0x4f
+
+       HB_Script_Common,//0x50
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x58
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x60
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x68
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x70
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x78
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Thaana,//0x80
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x88
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x90
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x98
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,//0xbf
+};
+
+HB_Script subTableDevaBengali[] = 
+{
+       HB_Script_Devanagari,//0x00
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x08
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x10
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x18
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x20
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x28
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x30
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x38
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x40
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x48
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x4f
+
+       HB_Script_Devanagari,//0x50
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x58
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x60
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x68
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x70
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x78
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x7f
+
+
+       HB_Script_Bengali,//0x80
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x88
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x90
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0x98
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xb0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xb8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xc0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xc8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xe0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xe8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,//0xff
+
+};
+
+
+HB_Script subTableGuruGuarati[]=
+{
+       HB_Script_Gurmukhi,//0x00
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x08
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x10
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x18
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x20
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x28
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x30
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x38
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x40
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x48
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x4f
+
+       HB_Script_Gurmukhi,//0x50
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x58
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x60
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x68
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x70
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x78
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x7f
+
+
+       HB_Script_Gujarati,//0x80
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x88
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x90
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0x98
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xb0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xb8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xc0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xc8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xe0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xe8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,//0xff
+
+};
+
+HB_Script subTableOriyaTamil[]=
+{
+       HB_Script_Oriya,//0x00
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x08
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x10
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x18
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x20
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x28
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x30
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x38
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x40
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x48
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x4f
+
+       HB_Script_Oriya,//0x50
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x58
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x60
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x68
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x70
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x78
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x7f
+
+
+       HB_Script_Tamil,//0x80
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x88
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x90
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0x98
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xb0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xb8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xc0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xc8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xe0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xe8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,//0xff
+
+};
+
+
+HB_Script subTableTelukannada[]=
+{
+       HB_Script_Telugu,//0x00
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x08
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x10
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x18
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x20
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x28
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x30
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x38
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x40
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x48
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x4f
+
+       HB_Script_Telugu,//0x50
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x58
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x60
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x68
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x70
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x78
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x7f
+
+
+       HB_Script_Kannada,//0x80
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x88
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x90
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0x98
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xb0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xb8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xc0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xc8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xe0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xe8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,//0xff
+
+};
+
+HB_Script subTableMalSinhala[]=
+{
+       HB_Script_Malayalam,//0x00
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x08
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x10
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x18
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x20
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x28
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x30
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x38
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x40
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x48
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x4f
+
+       HB_Script_Malayalam,//0x50
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x58
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x60
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x68
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x70
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x78
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x7f
+
+
+       HB_Script_Sinhala,//0x80
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x88
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x90
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0x98
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xb0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xb8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xc0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xc8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xe0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xe8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,//0xff
+
+};
+
+HB_Script subTableThaiLao[]=
+{
+       HB_Script_Thai,//0x00
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x08
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x10
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x18
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x20
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x28
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x30
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x38
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x40
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x48
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x4f
+
+       HB_Script_Thai,//0x50
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x58
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x60
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x68
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x70
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x78
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x7f
+
+
+       HB_Script_Lao,//0x80
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x88
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x90
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0x98
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xb0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xb8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xc0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xc8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xe0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xe8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,//0xff
+
+};
+
+HB_Script subTableMyanGeorgian[] =
+{
+       HB_Script_Myanmar,//0x00
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x08
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x10
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x18
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x20
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x28
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x30
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x38
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x40
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x48
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x4f
+
+       HB_Script_Myanmar,//0x50
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x58
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x60
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x68
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x70
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x78
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x7f
+
+
+       HB_Script_Myanmar,//0x80
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x88
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x90
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x98
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Georgian,//0xa0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xa8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xb0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xb8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xc0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xc8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xe0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xe8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,//0xff
+
+};
+
+HB_Script subTableOghamRunic[] = 
+{
+       HB_Script_Ogham,//0x00
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x08
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x10
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x18
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x20
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x28
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x30
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x38
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x40
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x48
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x4f
+
+       HB_Script_Ogham,//0x50
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x58
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x60
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x68
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x70
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x78
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x7f
+
+
+       HB_Script_Ogham,//0x80
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x88
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x90
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x98
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Runic,//0xa0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xa8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xb0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xb8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xc0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xc8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xe0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xe8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,//0xff
+
+};
+
+#define VFE_UNICODE_MAX_SCRIPT 256
+
+static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=
+{
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Greek, 0},
+
+       {HB_Script_Cyrillic, 0},//0x04
+       {HB_Script_Armenian, 0},
+       {HB_Script_Arabic, 0},
+       {0xc0, subTableThanaSyriac},
+
+       {HB_Script_Common, 0},//0x08
+       {0x100, subTableDevaBengali},
+       {0x100, subTableGuruGuarati},
+       {0x100, subTableOriyaTamil},
+       
+       {0x100, subTableTelukannada},//0x0c
+       {0x100, subTableMalSinhala},
+       {0x100, subTableThaiLao},
+       {HB_Script_Tibetan, 0},
+
+       {0x100, subTableMyanGeorgian},//0x10
+       {HB_Script_Hangul, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x14
+       {HB_Script_Common, 0},
+       {0x100, subTableOghamRunic},
+       {HB_Script_Khmer, 0},
+
+       {HB_Script_Common, 0},//0x18
+       {HB_Script_Khmer, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x1c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x20
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x24
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x28
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x2c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x30
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x34
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x38
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x3c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x44
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x48
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x4c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x50
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x54
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x58
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x5c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x60
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x64
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x68
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x6c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x70
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x74
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x78
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x7c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x80
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x84
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x88
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x8c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x94
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x98
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x9c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xac
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xbc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xcc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xdc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xec
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xfc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},//ff
+};
+
+#endif /* __hb_unicode_tables_h__ */
+
index 6409936..6c560e4 100755 (executable)
Binary files a/harfbuzz-0.1/debian/tmp/usr/lib/libharfbuzz.so and b/harfbuzz-0.1/debian/tmp/usr/lib/libharfbuzz.so differ
index fe0fb0f..1eea147 100755 (executable)
Binary files a/harfbuzz-0.1/harfbuzz-dump.o and b/harfbuzz-0.1/harfbuzz-dump.o differ
index 21142a3..239d669 100755 (executable)
Binary files a/harfbuzz-0.1/harfbuzz-external.o and b/harfbuzz-0.1/harfbuzz-external.o differ
index f7d5533..49d69f5 100755 (executable)
Binary files a/harfbuzz-0.1/harfbuzz-shaper-all.o and b/harfbuzz-0.1/harfbuzz-shaper-all.o differ
index e22122c..808e60b 100755 (executable)
Binary files a/harfbuzz-0.1/harfbuzz.o and b/harfbuzz-0.1/harfbuzz.o differ
index 1b039ba..5065f2e 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_PRIVATE_H\r
-#define HARFBUZZ_BUFFER_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_swap( HB_Buffer buffer );\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_clear_output( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_clear_positions( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyphs( HB_Buffer  buffer,\r
-                             HB_UShort  num_in,\r
-                             HB_UShort  num_out,\r
-                             HB_UShort *glyph_data,\r
-                             HB_UShort  component,\r
-                             HB_UShort  ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyph ( HB_Buffer buffer,\r
-                             HB_UInt   glyph_index,\r
-                             HB_UShort component,\r
-                             HB_UShort ligID );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer );\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_replace_output_glyph ( HB_Buffer buffer,\r
-                                 HB_UInt   glyph_index,\r
-                                 HB_Bool   inplace );\r
-\r
-HB_INTERNAL HB_UShort\r
-_hb_buffer_allocate_ligid( HB_Buffer buffer );\r
-\r
-\r
-/* convenience macros */\r
-\r
-#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)\r
-#define IN_ITEM( pos )         (&buffer->in_string[(pos)])\r
-#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)\r
-#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])\r
-#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)\r
-#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)\r
-#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)\r
-#define POSITION( pos )        (&buffer->positions[(pos)])\r
-#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)\r
-#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])\r
-\r
-#define CHECK_Property( gdef, index, flags, property )                                 \\r
-          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \\r
-                                      (property) ) ) != HB_Err_Ok )\r
-\r
-#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \\r
-          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \\r
-                                                   (num_in), (num_out),                \\r
-                                                    (glyph_data), (component), (ligID)  \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \\r
-          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \\r
-                                                    (glyph_index), (component), (ligID) \\r
-                                                  ) ) != HB_Err_Ok )\r
-#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \\r
-          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \\r
-                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )\r
-#define COPY_Glyph( buffer )                                                           \\r
-         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_PRIVATE_H
+#define HARFBUZZ_BUFFER_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+#define HB_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
+
+HB_INTERNAL void
+_hb_buffer_swap( HB_Buffer buffer );
+
+HB_INTERNAL void
+_hb_buffer_clear_output( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_clear_positions( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyphs( HB_Buffer  buffer,
+                             HB_UShort  num_in,
+                             HB_UShort  num_out,
+                             HB_UShort *glyph_data,
+                             HB_UShort  component,
+                             HB_UShort  ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyph ( HB_Buffer buffer,
+                             HB_UInt   glyph_index,
+                             HB_UShort component,
+                             HB_UShort ligID );
+
+HB_INTERNAL HB_Error
+_hb_buffer_copy_output_glyph ( HB_Buffer buffer );
+
+HB_INTERNAL HB_Error
+_hb_buffer_replace_output_glyph ( HB_Buffer buffer,
+                                 HB_UInt   glyph_index,
+                                 HB_Bool   inplace );
+
+HB_INTERNAL HB_UShort
+_hb_buffer_allocate_ligid( HB_Buffer buffer );
+
+
+/* convenience macros */
+
+#define IN_GLYPH( pos )        (buffer->in_string[(pos)].gindex)
+#define IN_ITEM( pos )         (&buffer->in_string[(pos)])
+#define IN_CURGLYPH()          (buffer->in_string[buffer->in_pos].gindex)
+#define IN_CURITEM()           (&buffer->in_string[buffer->in_pos])
+#define IN_PROPERTIES( pos )   (buffer->in_string[(pos)].properties)
+#define IN_LIGID( pos )        (buffer->in_string[(pos)].ligID)
+#define IN_COMPONENT( pos )    (buffer->in_string[(pos)].component)
+#define POSITION( pos )        (&buffer->positions[(pos)])
+#define OUT_GLYPH( pos )       (buffer->out_string[(pos)].gindex)
+#define OUT_ITEM( pos )        (&buffer->out_string[(pos)])
+
+#define CHECK_Property( gdef, index, flags, property )                                 \
+          ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags),               \
+                                      (property) ) ) != HB_Err_Ok )
+
+#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID )             \
+          ( ( error = _hb_buffer_add_output_glyphs( (buffer),                            \
+                                                   (num_in), (num_out),                \
+                                                    (glyph_data), (component), (ligID)  \
+                                                  ) ) != HB_Err_Ok )
+#define ADD_Glyph( buffer, glyph_index, component, ligID )                             \
+          ( ( error = _hb_buffer_add_output_glyph( (buffer),                             \
+                                                    (glyph_index), (component), (ligID) \
+                                                  ) ) != HB_Err_Ok )
+#define REPLACE_Glyph( buffer, glyph_index, nesting_level )                            \
+          ( ( error = _hb_buffer_replace_output_glyph( (buffer), (glyph_index),                \
+                                                     (nesting_level) == 1 ) ) != HB_Err_Ok )
+#define COPY_Glyph( buffer )                                                           \
+         ( (error = _hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_PRIVATE_H */
index e215e9f..b134407 100755 (executable)
@@ -1,94 +1,94 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_BUFFER_H\r
-#define HARFBUZZ_BUFFER_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_GlyphItemRec_ {\r
-  HB_UInt     gindex;\r
-  HB_UInt     properties;\r
-  HB_UInt     cluster;\r
-  HB_UShort   component;\r
-  HB_UShort   ligID;\r
-  HB_UShort   gproperties;\r
-} HB_GlyphItemRec, *HB_GlyphItem;\r
-\r
-typedef struct HB_PositionRec_ {\r
-  HB_Fixed   x_pos;\r
-  HB_Fixed   y_pos;\r
-  HB_Fixed   x_advance;\r
-  HB_Fixed   y_advance;\r
-  HB_UShort  back;            /* number of glyphs to go back\r
-                                for drawing current glyph   */\r
-  HB_Bool    new_advance;     /* if set, the advance width values are\r
-                                absolute, i.e., they won't be\r
-                                added to the original glyph's value\r
-                                but rather replace them.            */\r
-  HB_Short  cursive_chain;   /* character to which this connects,\r
-                                may be positive or negative; used\r
-                                only internally                     */\r
-} HB_PositionRec, *HB_Position;\r
-\r
-\r
-typedef struct HB_BufferRec_{ \r
-  HB_UInt    allocated;\r
-\r
-  HB_UInt    in_length;\r
-  HB_UInt    out_length;\r
-  HB_UInt    in_pos;\r
-  HB_UInt    out_pos;\r
-  \r
-  HB_Bool       separate_out;\r
-  HB_GlyphItem  in_string;\r
-  HB_GlyphItem  out_string;\r
-  HB_GlyphItem  alt_string;\r
-  HB_Position   positions;\r
-  HB_UShort      max_ligID;\r
-} HB_BufferRec, *HB_Buffer;\r
-\r
-HB_Error\r
-hb_buffer_new( HB_Buffer *buffer );\r
-\r
-void\r
-hb_buffer_free( HB_Buffer buffer );\r
-\r
-void\r
-hb_buffer_clear( HB_Buffer buffer );\r
-\r
-HB_Error\r
-hb_buffer_add_glyph( HB_Buffer buffer,\r
-                     HB_UInt    glyph_index,\r
-                     HB_UInt    properties,\r
-                     HB_UInt    cluster );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_BUFFER_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_BUFFER_H
+#define HARFBUZZ_BUFFER_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_GlyphItemRec_ {
+  HB_UInt     gindex;
+  HB_UInt     properties;
+  HB_UInt     cluster;
+  HB_UShort   component;
+  HB_UShort   ligID;
+  HB_UShort   gproperties;
+} HB_GlyphItemRec, *HB_GlyphItem;
+
+typedef struct HB_PositionRec_ {
+  HB_Fixed   x_pos;
+  HB_Fixed   y_pos;
+  HB_Fixed   x_advance;
+  HB_Fixed   y_advance;
+  HB_UShort  back;            /* number of glyphs to go back
+                                for drawing current glyph   */
+  HB_Bool    new_advance;     /* if set, the advance width values are
+                                absolute, i.e., they won't be
+                                added to the original glyph's value
+                                but rather replace them.            */
+  HB_Short  cursive_chain;   /* character to which this connects,
+                                may be positive or negative; used
+                                only internally                     */
+} HB_PositionRec, *HB_Position;
+
+
+typedef struct HB_BufferRec_{ 
+  HB_UInt    allocated;
+
+  HB_UInt    in_length;
+  HB_UInt    out_length;
+  HB_UInt    in_pos;
+  HB_UInt    out_pos;
+  
+  HB_Bool       separate_out;
+  HB_GlyphItem  in_string;
+  HB_GlyphItem  out_string;
+  HB_GlyphItem  alt_string;
+  HB_Position   positions;
+  HB_UShort      max_ligID;
+} HB_BufferRec, *HB_Buffer;
+
+HB_Error
+hb_buffer_new( HB_Buffer *buffer );
+
+void
+hb_buffer_free( HB_Buffer buffer );
+
+void
+hb_buffer_clear( HB_Buffer buffer );
+
+HB_Error
+hb_buffer_add_glyph( HB_Buffer buffer,
+                     HB_UInt    glyph_index,
+                     HB_UInt    properties,
+                     HB_UInt    cluster );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_BUFFER_H */
index 5d552e7..ea4a62b 100755 (executable)
@@ -1,41 +1,41 @@
-/*\r
- * Copyright (C) 2000, 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#ifndef HARFBUZZ_DUMP_H\r
-#define HARFBUZZ_DUMP_H\r
-\r
-#include <stdio.h>\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);\r
-void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_DUMP_H */\r
+/*
+ * Copyright (C) 2000, 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#ifndef HARFBUZZ_DUMP_H
+#define HARFBUZZ_DUMP_H
+
+#include <stdio.h>
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+void HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream);
+void HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream);
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_DUMP_H */
index d2e36d6..d064f87 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_EXTERNAL_H\r
-#define HARFBUZZ_EXTERNAL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* This header contains some methods that are not part of\r
-   Harfbuzz itself, but referenced by it.\r
-   They need to be provided by the application/library\r
-*/\r
-\r
-\r
-/*\r
- see http://www.unicode.org/reports/tr14/tr14-19.html\r
- we don't use the XX, AI and CB properties and map them to AL instead.\r
- as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.\r
-*/\r
-typedef enum {\r
-    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,\r
-    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,\r
-    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,\r
-    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,\r
-    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,\r
-    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,\r
-    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK\r
-} HB_LineBreakClass;\r
-\r
-typedef enum \r
-{\r
-    HB_NoCategory,\r
-\r
-    HB_Mark_NonSpacing,          /*   Mn */\r
-    HB_Mark_SpacingCombining,    /*   Mc */\r
-    HB_Mark_Enclosing,           /*   Me */\r
-\r
-    HB_Number_DecimalDigit,      /*   Nd */\r
-    HB_Number_Letter,            /*   Nl */\r
-    HB_Number_Other,             /*   No */\r
-\r
-    HB_Separator_Space,          /*   Zs */\r
-    HB_Separator_Line,           /*   Zl */\r
-    HB_Separator_Paragraph,      /*   Zp */\r
-\r
-    HB_Other_Control,            /*   Cc */\r
-    HB_Other_Format,             /*   Cf */\r
-    HB_Other_Surrogate,          /*   Cs */\r
-    HB_Other_PrivateUse,         /*   Co */\r
-    HB_Other_NotAssigned,        /*   Cn */\r
-\r
-    HB_Letter_Uppercase,         /*   Lu */\r
-    HB_Letter_Lowercase,         /*   Ll */\r
-    HB_Letter_Titlecase,         /*   Lt */\r
-    HB_Letter_Modifier,          /*   Lm */\r
-    HB_Letter_Other,             /*   Lo */\r
-\r
-    HB_Punctuation_Connector,    /*   Pc */\r
-    HB_Punctuation_Dash,         /*   Pd */\r
-    HB_Punctuation_Open,         /*   Ps */\r
-    HB_Punctuation_Close,        /*   Pe */\r
-    HB_Punctuation_InitialQuote, /*   Pi */\r
-    HB_Punctuation_FinalQuote,   /*   Pf */\r
-    HB_Punctuation_Other,        /*   Po */\r
-\r
-    HB_Symbol_Math,              /*   Sm */\r
-    HB_Symbol_Currency,          /*   Sc */\r
-    HB_Symbol_Modifier,          /*   Sk */\r
-    HB_Symbol_Other              /*   So */\r
-} HB_CharCategory;\r
-\r
-typedef enum\r
-{\r
-    HB_Grapheme_Other, \r
-    HB_Grapheme_CR,\r
-    HB_Grapheme_LF,\r
-    HB_Grapheme_Control,\r
-    HB_Grapheme_Extend,\r
-    HB_Grapheme_L, \r
-    HB_Grapheme_V, \r
-    HB_Grapheme_T, \r
-    HB_Grapheme_LV, \r
-    HB_Grapheme_LVT\r
-} HB_GraphemeClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Word_Other,\r
-    HB_Word_Format,\r
-    HB_Word_Katakana,\r
-    HB_Word_ALetter,\r
-    HB_Word_MidLetter,\r
-    HB_Word_MidNum,\r
-    HB_Word_Numeric,\r
-    HB_Word_ExtendNumLet\r
-} HB_WordClass;\r
-\r
-\r
-typedef enum\r
-{\r
-    HB_Sentence_Other,\r
-    HB_Sentence_Sep,\r
-    HB_Sentence_Format,\r
-    HB_Sentence_Sp,\r
-    HB_Sentence_Lower,\r
-    HB_Sentence_Upper,\r
-    HB_Sentence_OLetter,\r
-    HB_Sentence_Numeric,\r
-    HB_Sentence_ATerm,\r
-    HB_Sentence_STerm,\r
-    HB_Sentence_Close\r
-} HB_SentenceClass;\r
-\r
-HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);\r
-HB_WordClass HB_GetWordClass(HB_UChar32 ch);\r
-HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);\r
-HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);\r
-\r
-void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);\r
-void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);\r
-HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);\r
-int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);\r
-HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);\r
-\r
-void *HB_Library_Resolve(const char *library, const char *symbol);\r
-\r
-void *HB_TextCodecForMib(int mib);\r
-char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);\r
-void HB_TextCodec_FreeResult(char *);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_EXTERNAL_H
+#define HARFBUZZ_EXTERNAL_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* This header contains some methods that are not part of
+   Harfbuzz itself, but referenced by it.
+   They need to be provided by the application/library
+*/
+
+
+/*
+ see http://www.unicode.org/reports/tr14/tr14-19.html
+ we don't use the XX, AI and CB properties and map them to AL instead.
+ as we don't support any EBDIC based OS'es, NL is ignored and mapped to AL as well.
+*/
+typedef enum {
+    HB_LineBreak_OP, HB_LineBreak_CL, HB_LineBreak_QU, HB_LineBreak_GL, HB_LineBreak_NS,
+    HB_LineBreak_EX, HB_LineBreak_SY, HB_LineBreak_IS, HB_LineBreak_PR, HB_LineBreak_PO,
+    HB_LineBreak_NU, HB_LineBreak_AL, HB_LineBreak_ID, HB_LineBreak_IN, HB_LineBreak_HY,
+    HB_LineBreak_BA, HB_LineBreak_BB, HB_LineBreak_B2, HB_LineBreak_ZW, HB_LineBreak_CM,
+    HB_LineBreak_WJ, HB_LineBreak_H2, HB_LineBreak_H3, HB_LineBreak_JL, HB_LineBreak_JV,
+    HB_LineBreak_JT, HB_LineBreak_SA, HB_LineBreak_SG,
+    HB_LineBreak_SP, HB_LineBreak_CR, HB_LineBreak_LF, HB_LineBreak_BK
+} HB_LineBreakClass;
+
+typedef enum 
+{
+    HB_NoCategory,
+
+    HB_Mark_NonSpacing,          /*   Mn */
+    HB_Mark_SpacingCombining,    /*   Mc */
+    HB_Mark_Enclosing,           /*   Me */
+
+    HB_Number_DecimalDigit,      /*   Nd */
+    HB_Number_Letter,            /*   Nl */
+    HB_Number_Other,             /*   No */
+
+    HB_Separator_Space,          /*   Zs */
+    HB_Separator_Line,           /*   Zl */
+    HB_Separator_Paragraph,      /*   Zp */
+
+    HB_Other_Control,            /*   Cc */
+    HB_Other_Format,             /*   Cf */
+    HB_Other_Surrogate,          /*   Cs */
+    HB_Other_PrivateUse,         /*   Co */
+    HB_Other_NotAssigned,        /*   Cn */
+
+    HB_Letter_Uppercase,         /*   Lu */
+    HB_Letter_Lowercase,         /*   Ll */
+    HB_Letter_Titlecase,         /*   Lt */
+    HB_Letter_Modifier,          /*   Lm */
+    HB_Letter_Other,             /*   Lo */
+
+    HB_Punctuation_Connector,    /*   Pc */
+    HB_Punctuation_Dash,         /*   Pd */
+    HB_Punctuation_Open,         /*   Ps */
+    HB_Punctuation_Close,        /*   Pe */
+    HB_Punctuation_InitialQuote, /*   Pi */
+    HB_Punctuation_FinalQuote,   /*   Pf */
+    HB_Punctuation_Other,        /*   Po */
+
+    HB_Symbol_Math,              /*   Sm */
+    HB_Symbol_Currency,          /*   Sc */
+    HB_Symbol_Modifier,          /*   Sk */
+    HB_Symbol_Other              /*   So */
+} HB_CharCategory;
+
+typedef enum
+{
+    HB_Grapheme_Other, 
+    HB_Grapheme_CR,
+    HB_Grapheme_LF,
+    HB_Grapheme_Control,
+    HB_Grapheme_Extend,
+    HB_Grapheme_L, 
+    HB_Grapheme_V, 
+    HB_Grapheme_T, 
+    HB_Grapheme_LV, 
+    HB_Grapheme_LVT
+} HB_GraphemeClass;
+
+
+typedef enum
+{
+    HB_Word_Other,
+    HB_Word_Format,
+    HB_Word_Katakana,
+    HB_Word_ALetter,
+    HB_Word_MidLetter,
+    HB_Word_MidNum,
+    HB_Word_Numeric,
+    HB_Word_ExtendNumLet
+} HB_WordClass;
+
+
+typedef enum
+{
+    HB_Sentence_Other,
+    HB_Sentence_Sep,
+    HB_Sentence_Format,
+    HB_Sentence_Sp,
+    HB_Sentence_Lower,
+    HB_Sentence_Upper,
+    HB_Sentence_OLetter,
+    HB_Sentence_Numeric,
+    HB_Sentence_ATerm,
+    HB_Sentence_STerm,
+    HB_Sentence_Close
+} HB_SentenceClass;
+
+HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch);
+HB_WordClass HB_GetWordClass(HB_UChar32 ch);
+HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch);
+HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch);
+
+void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak);
+void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass);
+HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch);
+int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch);
+HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch);
+
+void *HB_Library_Resolve(const char *library, const char *symbol);
+
+void *HB_TextCodecForMib(int mib);
+char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);
+void HB_TextCodec_FreeResult(char *);
+
+HB_END_HEADER
+
+#endif
index 78543cd..da06b6f 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_PRIVATE_H\r
-#define HARFBUZZ_GDEF_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-buffer-private.h"\r
-#include "harfbuzz-gdef.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Attachment related structures */\r
-\r
-struct  HB_AttachPoint_\r
-{\r
-  HB_UShort   PointCount;             /* size of the PointIndex array */\r
-  HB_UShort*  PointIndex;             /* array of contour points      */\r
-};\r
-\r
-/* Ligature Caret related structures */\r
-\r
-struct  HB_CaretValueFormat1_\r
-{\r
-  HB_Short  Coordinate;               /* x or y value (in design units) */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;\r
-\r
-\r
-struct  HB_CaretValueFormat2_\r
-{\r
-  HB_UShort  CaretValuePoint;         /* contour point index on glyph */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;\r
-\r
-\r
-struct  HB_CaretValueFormat3_\r
-{\r
-  HB_Short    Coordinate;             /* x or y value (in design units) */\r
-  HB_Device  Device;                 /* Device table for x or y value  */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;\r
-\r
-\r
-struct  HB_CaretValueFormat4_\r
-{\r
-  HB_UShort  IdCaretValue;            /* metric ID */\r
-};\r
-\r
-typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;\r
-\r
-\r
-struct  HB_CaretValue_\r
-{\r
-  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */\r
-\r
-  union\r
-  {\r
-    HB_CaretValueFormat1  cvf1;\r
-    HB_CaretValueFormat2  cvf2;\r
-    HB_CaretValueFormat3  cvf3;\r
-    HB_CaretValueFormat4  cvf4;\r
-  } cvf;\r
-};\r
-\r
-typedef struct HB_CaretValue_  HB_CaretValue;\r
-\r
-\r
-struct  HB_LigGlyph_\r
-{\r
-  HB_Bool          loaded;\r
-\r
-  HB_UShort        CaretCount;        /* number of caret values */\r
-  HB_CaretValue*  CaretValue;        /* array of caret values  */\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,\r
-                                      HB_UShort        glyphID,\r
-                                      HB_UShort        property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,\r
-                                  HB_GlyphItem    item,\r
-                                  HB_UShort        flags,\r
-                                  HB_UShort*       property );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,\r
-                                                 HB_Stream      input,\r
-                                                 HB_Lookup*     lo,\r
-                                                 HB_UShort      num_lookups );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_PRIVATE_H
+#define HARFBUZZ_GDEF_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-buffer-private.h"
+#include "harfbuzz-gdef.h"
+
+HB_BEGIN_HEADER
+
+
+/* Attachment related structures */
+
+struct  HB_AttachPoint_
+{
+  HB_UShort   PointCount;             /* size of the PointIndex array */
+  HB_UShort*  PointIndex;             /* array of contour points      */
+};
+
+/* Ligature Caret related structures */
+
+struct  HB_CaretValueFormat1_
+{
+  HB_Short  Coordinate;               /* x or y value (in design units) */
+};
+
+typedef struct HB_CaretValueFormat1_  HB_CaretValueFormat1;
+
+
+struct  HB_CaretValueFormat2_
+{
+  HB_UShort  CaretValuePoint;         /* contour point index on glyph */
+};
+
+typedef struct HB_CaretValueFormat2_  HB_CaretValueFormat2;
+
+
+struct  HB_CaretValueFormat3_
+{
+  HB_Short    Coordinate;             /* x or y value (in design units) */
+  HB_Device  Device;                 /* Device table for x or y value  */
+};
+
+typedef struct HB_CaretValueFormat3_  HB_CaretValueFormat3;
+
+
+struct  HB_CaretValueFormat4_
+{
+  HB_UShort  IdCaretValue;            /* metric ID */
+};
+
+typedef struct HB_CaretValueFormat4_  HB_CaretValueFormat4;
+
+
+struct  HB_CaretValue_
+{
+  HB_UShort  CaretValueFormat;        /* 1, 2, 3, or 4 */
+
+  union
+  {
+    HB_CaretValueFormat1  cvf1;
+    HB_CaretValueFormat2  cvf2;
+    HB_CaretValueFormat3  cvf3;
+    HB_CaretValueFormat4  cvf4;
+  } cvf;
+};
+
+typedef struct HB_CaretValue_  HB_CaretValue;
+
+
+struct  HB_LigGlyph_
+{
+  HB_Bool          loaded;
+
+  HB_UShort        CaretCount;        /* number of caret values */
+  HB_CaretValue*  CaretValue;        /* array of caret values  */
+};
+
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+                                      HB_UShort        glyphID,
+                                      HB_UShort        property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+                                  HB_GlyphItem    item,
+                                  HB_UShort        flags,
+                                  HB_UShort*       property );
+
+HB_INTERNAL HB_Error
+_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,
+                                                 HB_Stream      input,
+                                                 HB_Lookup*     lo,
+                                                 HB_UShort      num_lookups );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_PRIVATE_H */
index bf7a70e..b6dcadc 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GDEF_H\r
-#define HARFBUZZ_GDEF_H\r
-\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding\r
- * flag in the LookupFlag field.     */\r
-#define HB_GDEF_BASE_GLYPH  0x0002\r
-#define HB_GDEF_LIGATURE    0x0004\r
-#define HB_GDEF_MARK        0x0008\r
-#define HB_GDEF_COMPONENT   0x0010\r
-\r
-\r
-typedef struct HB_AttachPoint_  HB_AttachPoint;\r
-\r
-\r
-struct  HB_AttachList_\r
-{\r
-  HB_Bool           loaded;\r
-\r
-  HB_Coverage       Coverage;         /* Coverage table              */\r
-  HB_UShort         GlyphCount;       /* number of glyphs with\r
-                                        attachments                 */\r
-  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */\r
-};\r
-\r
-typedef struct HB_AttachList_  HB_AttachList;\r
-\r
-typedef struct HB_LigGlyph_  HB_LigGlyph;\r
-\r
-struct  HB_LigCaretList_\r
-{\r
-  HB_Bool        loaded;\r
-\r
-  HB_Coverage    Coverage;            /* Coverage table            */\r
-  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */\r
-  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */\r
-};\r
-\r
-typedef struct HB_LigCaretList_  HB_LigCaretList;\r
-\r
-\r
-\r
-/* The `NewGlyphClasses' field is not defined in the TTO specification.\r
-   We use it for fonts with a constructed `GlyphClassDef' structure\r
-   (i.e., which don't have a GDEF table) to collect glyph classes\r
-   assigned during the lookup process.  The number of arrays in this\r
-   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth\r
-   array then contains the glyph class values of the glyphs not covered\r
-   by the ClassRangeRecords structures with index n-1 and n.  We store\r
-   glyph class values for four glyphs in a single array element.\r
-\r
-   `LastGlyph' is identical to the number of glyphs minus one in the\r
-   font; we need it only if `NewGlyphClasses' is not NULL (to have an\r
-   upper bound for the last array).\r
-\r
-   Note that we first store the file offset to the `MarkAttachClassDef'\r
-   field (which has been introduced in OpenType 1.2) -- since the\r
-   `Version' field value hasn't been increased to indicate that we have\r
-   one more field for some obscure reason, we must parse the GSUB table\r
-   to find out whether class values refer to this table.  Only then we\r
-   can finally load the MarkAttachClassDef structure if necessary.      */\r
-\r
-struct  HB_GDEFHeader_\r
-{\r
-  HB_UInt             offset;\r
-\r
-  HB_16Dot16             Version;\r
-\r
-  HB_ClassDefinition   GlyphClassDef;\r
-  HB_AttachList        AttachList;\r
-  HB_LigCaretList      LigCaretList;\r
-  HB_UInt             MarkAttachClassDef_offset;\r
-  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */\r
-\r
-  HB_UShort            LastGlyph;\r
-  HB_UShort**          NewGlyphClasses;\r
-};\r
-\r
-typedef struct HB_GDEFHeader_   HB_GDEFHeader;\r
-typedef struct HB_GDEFHeader_*  HB_GDEF;\r
-\r
-\r
-HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );\r
-      \r
-\r
-HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,\r
-                             HB_GDEFHeader** gdef );\r
-\r
-\r
-HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );\r
-\r
-\r
-HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,\r
-                                     HB_UShort        glyphID,\r
-                                     HB_UShort*       property );\r
-\r
-HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,\r
-                                        HB_UShort        num_glyphs,\r
-                                        HB_UShort        glyph_count,\r
-                                        HB_UShort*       glyph_array,\r
-                                        HB_UShort*       class_array );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GDEF_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GDEF_H
+#define HARFBUZZ_GDEF_H
+
+#include "harfbuzz-open.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+/* GDEF glyph properties.  Note that HB_GDEF_COMPONENT has no corresponding
+ * flag in the LookupFlag field.     */
+#define HB_GDEF_BASE_GLYPH  0x0002
+#define HB_GDEF_LIGATURE    0x0004
+#define HB_GDEF_MARK        0x0008
+#define HB_GDEF_COMPONENT   0x0010
+
+
+typedef struct HB_AttachPoint_  HB_AttachPoint;
+
+
+struct  HB_AttachList_
+{
+  HB_Bool           loaded;
+
+  HB_Coverage       Coverage;         /* Coverage table              */
+  HB_UShort         GlyphCount;       /* number of glyphs with
+                                        attachments                 */
+  HB_AttachPoint*   AttachPoint;      /* array of AttachPoint tables */
+};
+
+typedef struct HB_AttachList_  HB_AttachList;
+
+typedef struct HB_LigGlyph_  HB_LigGlyph;
+
+struct  HB_LigCaretList_
+{
+  HB_Bool        loaded;
+
+  HB_Coverage    Coverage;            /* Coverage table            */
+  HB_UShort      LigGlyphCount;       /* number of ligature glyphs */
+  HB_LigGlyph*   LigGlyph;            /* array of LigGlyph tables  */
+};
+
+typedef struct HB_LigCaretList_  HB_LigCaretList;
+
+
+
+/* The `NewGlyphClasses' field is not defined in the TTO specification.
+   We use it for fonts with a constructed `GlyphClassDef' structure
+   (i.e., which don't have a GDEF table) to collect glyph classes
+   assigned during the lookup process.  The number of arrays in this
+   pointer array is GlyphClassDef->cd.cd2.ClassRangeCount+1; the nth
+   array then contains the glyph class values of the glyphs not covered
+   by the ClassRangeRecords structures with index n-1 and n.  We store
+   glyph class values for four glyphs in a single array element.
+
+   `LastGlyph' is identical to the number of glyphs minus one in the
+   font; we need it only if `NewGlyphClasses' is not NULL (to have an
+   upper bound for the last array).
+
+   Note that we first store the file offset to the `MarkAttachClassDef'
+   field (which has been introduced in OpenType 1.2) -- since the
+   `Version' field value hasn't been increased to indicate that we have
+   one more field for some obscure reason, we must parse the GSUB table
+   to find out whether class values refer to this table.  Only then we
+   can finally load the MarkAttachClassDef structure if necessary.      */
+
+struct  HB_GDEFHeader_
+{
+  HB_UInt             offset;
+
+  HB_16Dot16             Version;
+
+  HB_ClassDefinition   GlyphClassDef;
+  HB_AttachList        AttachList;
+  HB_LigCaretList      LigCaretList;
+  HB_UInt             MarkAttachClassDef_offset;
+  HB_ClassDefinition   MarkAttachClassDef;        /* new in OT 1.2 */
+
+  HB_UShort            LastGlyph;
+  HB_UShort**          NewGlyphClasses;
+};
+
+typedef struct HB_GDEFHeader_   HB_GDEFHeader;
+typedef struct HB_GDEFHeader_*  HB_GDEF;
+
+
+HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr );
+      
+
+HB_Error  HB_Load_GDEF_Table( HB_Stream       stream,
+                             HB_GDEFHeader** gdef );
+
+
+HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
+
+
+HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
+                                     HB_UShort        glyphID,
+                                     HB_UShort*       property );
+
+HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
+                                        HB_UShort        num_glyphs,
+                                        HB_UShort        glyph_count,
+                                        HB_UShort*       glyph_array,
+                                        HB_UShort*       class_array );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GDEF_H */
index 9b8bfbf..0bb5669 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- */\r
-\r
-#ifndef HARFBUZZ_GLOBAL_H\r
-#define HARFBUZZ_GLOBAL_H\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#ifdef __cplusplus\r
-#define HB_BEGIN_HEADER  extern "C" {\r
-#define HB_END_HEADER  }\r
-#else\r
-#define HB_BEGIN_HEADER  /* nothing */\r
-#define HB_END_HEADER  /* nothing */\r
-#endif\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef FALSE\r
-#define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-#define TRUE (!FALSE)\r
-#endif\r
-\r
-#ifndef false\r
-#define false 0\r
-#endif\r
-\r
-#ifndef true\r
-#define true (!FALSE)\r
-#endif\r
-\r
-#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \\r
-          ( ( (HB_UInt)_x1 << 24 ) |     \\r
-            ( (HB_UInt)_x2 << 16 ) |     \\r
-            ( (HB_UInt)_x3 <<  8 ) |     \\r
-              (HB_UInt)_x4         )\r
-\r
-typedef char hb_int8;\r
-typedef unsigned char hb_uint8;\r
-typedef short hb_int16;\r
-typedef unsigned short hb_uint16;\r
-typedef int hb_int32;\r
-typedef unsigned int hb_uint32;\r
-\r
-typedef hb_uint8 HB_Bool;\r
-typedef hb_uint8 bool;\r
-\r
-typedef hb_uint8 HB_Byte;\r
-typedef hb_uint16 HB_UShort;\r
-typedef hb_uint32 HB_UInt;\r
-typedef hb_int8 HB_Char;\r
-typedef hb_int16 HB_Short;\r
-typedef hb_int32 HB_Int;\r
-\r
-typedef hb_uint16 HB_UChar16;\r
-typedef hb_uint32 HB_UChar32;\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_int32 HB_Fixed; /* 26.6 */\r
-\r
-#define HB_FIXED_CONSTANT(v) ((v) * 64)\r
-#define HB_FIXED_ROUND(v) (((v)+32) & -64)\r
-\r
-typedef hb_int32 HB_16Dot16; /* 16.16 */\r
-\r
-typedef void * HB_Pointer;\r
-typedef hb_uint32 HB_Tag;\r
-\r
-typedef enum {\r
-  /* no error */\r
-  HB_Err_Ok                           = 0x0000,\r
-  HB_Err_Not_Covered                  = 0xFFFF,\r
-\r
-  /* _hb_err() is called whenever returning the following errors,\r
-   * and in a couple places for HB_Err_Not_Covered too. */\r
-\r
-  /* programmer error */\r
-  HB_Err_Invalid_Argument             = 0x1A66,\r
-\r
-  /* font error */\r
-  HB_Err_Invalid_SubTable_Format      = 0x157F,\r
-  HB_Err_Invalid_SubTable             = 0x1570,\r
-  HB_Err_Read_Error                   = 0x6EAD,\r
-\r
-  /* system error */\r
-  HB_Err_Out_Of_Memory                = 0xDEAD\r
-} HB_Error;\r
-\r
-typedef struct {\r
-    HB_Fixed x;\r
-    HB_Fixed y;\r
-} HB_FixedPoint;\r
-\r
-typedef struct HB_Font_ *HB_Font;\r
-typedef struct HB_StreamRec_ *HB_Stream;\r
-typedef struct HB_FaceRec_ *HB_Face;\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ */
+
+#ifndef HARFBUZZ_GLOBAL_H
+#define HARFBUZZ_GLOBAL_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+#define HB_BEGIN_HEADER  extern "C" {
+#define HB_END_HEADER  }
+#else
+#define HB_BEGIN_HEADER  /* nothing */
+#define HB_END_HEADER  /* nothing */
+#endif
+
+HB_BEGIN_HEADER
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+#ifndef false
+#define false 0
+#endif
+
+#ifndef true
+#define true (!FALSE)
+#endif
+
+#define HB_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
+          ( ( (HB_UInt)_x1 << 24 ) |     \
+            ( (HB_UInt)_x2 << 16 ) |     \
+            ( (HB_UInt)_x3 <<  8 ) |     \
+              (HB_UInt)_x4         )
+
+typedef char hb_int8;
+typedef unsigned char hb_uint8;
+typedef short hb_int16;
+typedef unsigned short hb_uint16;
+typedef int hb_int32;
+typedef unsigned int hb_uint32;
+
+typedef hb_uint8 HB_Bool;
+typedef hb_uint8 bool;
+
+typedef hb_uint8 HB_Byte;
+typedef hb_uint16 HB_UShort;
+typedef hb_uint32 HB_UInt;
+typedef hb_int8 HB_Char;
+typedef hb_int16 HB_Short;
+typedef hb_int32 HB_Int;
+
+typedef hb_uint16 HB_UChar16;
+typedef hb_uint32 HB_UChar32;
+typedef hb_uint32 HB_Glyph;
+typedef hb_int32 HB_Fixed; /* 26.6 */
+
+#define HB_FIXED_CONSTANT(v) ((v) * 64)
+#define HB_FIXED_ROUND(v) (((v)+32) & -64)
+
+typedef hb_int32 HB_16Dot16; /* 16.16 */
+
+typedef void * HB_Pointer;
+typedef hb_uint32 HB_Tag;
+
+typedef enum {
+  /* no error */
+  HB_Err_Ok                           = 0x0000,
+  HB_Err_Not_Covered                  = 0xFFFF,
+
+  /* _hb_err() is called whenever returning the following errors,
+   * and in a couple places for HB_Err_Not_Covered too. */
+
+  /* programmer error */
+  HB_Err_Invalid_Argument             = 0x1A66,
+
+  /* font error */
+  HB_Err_Invalid_SubTable_Format      = 0x157F,
+  HB_Err_Invalid_SubTable             = 0x1570,
+  HB_Err_Read_Error                   = 0x6EAD,
+
+  /* system error */
+  HB_Err_Out_Of_Memory                = 0xDEAD
+} HB_Error;
+
+typedef struct {
+    HB_Fixed x;
+    HB_Fixed y;
+} HB_FixedPoint;
+
+typedef struct HB_Font_ *HB_Font;
+typedef struct HB_StreamRec_ *HB_Stream;
+typedef struct HB_FaceRec_ *HB_Face;
+
+HB_END_HEADER
+
+#endif
index c2865ba..4110700 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_PRIVATE_H\r
-#define HARFBUZZ_GPOS_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gpos.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* shared tables */\r
-\r
-struct  HB_ValueRecord_\r
-{\r
-  HB_Short    XPlacement;             /* horizontal adjustment for\r
-                                        placement                      */\r
-  HB_Short    YPlacement;             /* vertical adjustment for\r
-                                        placement                      */\r
-  HB_Short    XAdvance;               /* horizontal adjustment for\r
-                                        advance                        */\r
-  HB_Short    YAdvance;               /* vertical adjustment for\r
-                                        advance                        */\r
-  HB_Device  XPlacementDevice;       /* device table for horizontal\r
-                                        placement                      */\r
-  HB_Device  YPlacementDevice;       /* device table for vertical\r
-                                        placement                      */\r
-  HB_Device  XAdvanceDevice;         /* device table for horizontal\r
-                                        advance                        */\r
-  HB_Device  YAdvanceDevice;         /* device table for vertical\r
-                                        advance                        */\r
-  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */\r
-  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */\r
-  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */\r
-  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */\r
-};\r
-\r
-typedef struct HB_ValueRecord_  HB_ValueRecord;\r
-\r
-\r
-/* Mask values to scan the value format of the ValueRecord structure.\r
- We always expand compressed ValueRecords of the font.              */\r
-\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008\r
-#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010\r
-#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020\r
-#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040\r
-#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200\r
-#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400\r
-#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800\r
-\r
-\r
-struct  HB_AnchorFormat1_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value */\r
-  HB_Short   YCoordinate;             /* vertical value   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;\r
-\r
-\r
-struct  HB_AnchorFormat2_\r
-{\r
-  HB_Short   XCoordinate;             /* horizontal value             */\r
-  HB_Short   YCoordinate;             /* vertical value               */\r
-  HB_UShort  AnchorPoint;             /* index to glyph contour point */\r
-};\r
-\r
-typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;\r
-\r
-\r
-struct  HB_AnchorFormat3_\r
-{\r
-  HB_Short    XCoordinate;            /* horizontal value              */\r
-  HB_Short    YCoordinate;            /* vertical value                */\r
-  HB_Device  XDeviceTable;           /* device table for X coordinate */\r
-  HB_Device  YDeviceTable;           /* device table for Y coordinate */\r
-};\r
-\r
-typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;\r
-\r
-\r
-struct  HB_AnchorFormat4_\r
-{\r
-  HB_UShort  XIdAnchor;               /* horizontal metric ID */\r
-  HB_UShort  YIdAnchor;               /* vertical metric ID   */\r
-};\r
-\r
-typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;\r
-\r
-\r
-struct  HB_Anchor_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates\r
-                                        that there is no Anchor table */\r
-\r
-  union\r
-  {\r
-    HB_AnchorFormat1  af1;\r
-    HB_AnchorFormat2  af2;\r
-    HB_AnchorFormat3  af3;\r
-    HB_AnchorFormat4  af4;\r
-  } af;\r
-};\r
-\r
-typedef struct HB_Anchor_  HB_Anchor;\r
-\r
-\r
-struct  HB_MarkRecord_\r
-{\r
-  HB_UShort   Class;                  /* mark class   */\r
-  HB_Anchor  MarkAnchor;             /* anchor table */\r
-};\r
-\r
-typedef struct HB_MarkRecord_  HB_MarkRecord;\r
-\r
-\r
-struct  HB_MarkArray_\r
-{\r
-  HB_UShort        MarkCount;         /* number of MarkRecord tables */\r
-  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */\r
-};\r
-\r
-typedef struct HB_MarkArray_  HB_MarkArray;\r
-\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SinglePosFormat1_\r
-{\r
-  HB_ValueRecord  Value;             /* ValueRecord for all covered\r
-                                        glyphs                      */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;\r
-\r
-\r
-struct  HB_SinglePosFormat2_\r
-{\r
-  HB_UShort         ValueCount;       /* number of ValueRecord tables */\r
-  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;\r
-\r
-\r
-struct  HB_SinglePos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  HB_UShort     ValueFormat;          /* format of ValueRecord table */\r
-\r
-  union\r
-  {\r
-    HB_SinglePosFormat1  spf1;\r
-    HB_SinglePosFormat2  spf2;\r
-  } spf;\r
-};\r
-\r
-typedef struct HB_SinglePos_  HB_SinglePos;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_PairValueRecord_\r
-{\r
-  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_PairValueRecord_  HB_PairValueRecord;\r
-\r
-\r
-struct  HB_PairSet_\r
-{\r
-  HB_UShort             PairValueCount;\r
-                                     /* number of PairValueRecord tables */\r
-  HB_PairValueRecord*  PairValueRecord;\r
-                                     /* array of PairValueRecord tables  */\r
-};\r
-\r
-typedef struct HB_PairSet_  HB_PairSet;\r
-\r
-\r
-struct  HB_PairPosFormat1_\r
-{\r
-  HB_UShort     PairSetCount;         /* number of PairSet tables    */\r
-  HB_PairSet*  PairSet;              /* array of PairSet tables     */\r
-};\r
-\r
-typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;\r
-\r
-\r
-struct  HB_Class2Record_\r
-{\r
-  HB_ValueRecord  Value1;            /* pos. data for first glyph  */\r
-  HB_ValueRecord  Value2;            /* pos. data for second glyph */\r
-};\r
-\r
-typedef struct HB_Class2Record_  HB_Class2Record;\r
-\r
-\r
-struct  HB_Class1Record_\r
-{\r
-  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */\r
-};\r
-\r
-typedef struct HB_Class1Record_  HB_Class1Record;\r
-\r
-\r
-struct  HB_PairPosFormat2_\r
-{\r
-  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */\r
-  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */\r
-  HB_UShort            Class1Count;   /* number of classes in ClassDef1\r
-                                        table                          */\r
-  HB_UShort            Class2Count;   /* number of classes in ClassDef2\r
-                                        table                          */\r
-  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */\r
-};\r
-\r
-typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;\r
-\r
-\r
-struct  HB_PairPos_\r
-{\r
-  HB_UShort     PosFormat;            /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-  HB_UShort     ValueFormat1;         /* format of ValueRecord table\r
-                                        for first glyph             */\r
-  HB_UShort     ValueFormat2;         /* format of ValueRecord table\r
-                                        for second glyph            */\r
-\r
-  union\r
-  {\r
-    HB_PairPosFormat1  ppf1;\r
-    HB_PairPosFormat2  ppf2;\r
-  } ppf;\r
-};\r
-\r
-typedef struct HB_PairPos_  HB_PairPos;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_EntryExitRecord_\r
-{\r
-  HB_Anchor  EntryAnchor;            /* entry Anchor table */\r
-  HB_Anchor  ExitAnchor;             /* exit Anchor table  */\r
-};\r
-\r
-\r
-typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;\r
-\r
-struct  HB_CursivePos_\r
-{\r
-  HB_UShort             PosFormat;    /* always 1                         */\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             EntryExitCount;\r
-                                     /* number of EntryExitRecord tables */\r
-  HB_EntryExitRecord*  EntryExitRecord;\r
-                                     /* array of EntryExitRecord tables  */\r
-};\r
-\r
-typedef struct HB_CursivePos_  HB_CursivePos;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_BaseRecord_\r
-{\r
-  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_BaseRecord_  HB_BaseRecord;\r
-\r
-\r
-struct  HB_BaseArray_\r
-{\r
-  HB_UShort        BaseCount;         /* number of BaseRecord tables */\r
-  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */\r
-};\r
-\r
-typedef struct HB_BaseArray_  HB_BaseArray;\r
-\r
-\r
-struct  HB_MarkBasePos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1                  */\r
-  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */\r
-  HB_Coverage   BaseCoverage;        /* base glyph coverage table */\r
-  HB_UShort      ClassCount;          /* number of mark classes    */\r
-  HB_MarkArray  MarkArray;           /* mark array table          */\r
-  HB_BaseArray  BaseArray;           /* base array table          */\r
-};\r
-\r
-typedef struct HB_MarkBasePos_  HB_MarkBasePos;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_ComponentRecord_\r
-{\r
-  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor\r
-                                        tables                         */\r
-};\r
-\r
-typedef struct HB_ComponentRecord_  HB_ComponentRecord;\r
-\r
-\r
-struct  HB_LigatureAttach_\r
-{\r
-  HB_UShort             ComponentCount;\r
-                                     /* number of ComponentRecord tables */\r
-  HB_ComponentRecord*  ComponentRecord;\r
-                                     /* array of ComponentRecord tables  */\r
-};\r
-\r
-typedef struct HB_LigatureAttach_  HB_LigatureAttach;\r
-\r
-\r
-struct  HB_LigatureArray_\r
-{\r
-  HB_UShort            LigatureCount; /* number of LigatureAttach tables */\r
-  HB_LigatureAttach*  LigatureAttach;\r
-                                     /* array of LigatureAttach tables  */\r
-};\r
-\r
-typedef struct HB_LigatureArray_  HB_LigatureArray;\r
-\r
-\r
-struct  HB_MarkLigPos_\r
-{\r
-  HB_UShort          PosFormat;       /* always 1                      */\r
-  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */\r
-  HB_Coverage       LigatureCoverage;\r
-                                     /* ligature glyph coverage table */\r
-  HB_UShort          ClassCount;      /* number of mark classes        */\r
-  HB_MarkArray      MarkArray;       /* mark array table              */\r
-  HB_LigatureArray  LigatureArray;   /* ligature array table          */\r
-};\r
-\r
-typedef struct HB_MarkLigPos_  HB_MarkLigPos;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_Mark2Record_\r
-{\r
-  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_Mark2Record_  HB_Mark2Record;\r
-\r
-\r
-struct  HB_Mark2Array_\r
-{\r
-  HB_UShort         Mark2Count;       /* number of Mark2Record tables */\r
-  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */\r
-};\r
-\r
-typedef struct HB_Mark2Array_  HB_Mark2Array;\r
-\r
-\r
-struct  HB_MarkMarkPos_\r
-{\r
-  HB_UShort       PosFormat;          /* always 1                         */\r
-  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */\r
-  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */\r
-  HB_UShort       ClassCount;         /* number of combining mark classes */\r
-  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */\r
-  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */\r
-};\r
-\r
-typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;\r
-\r
-\r
-/* needed by both lookup type 7 and 8 */\r
-\r
-struct  HB_PosLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;\r
-\r
-\r
-/* LookupType 7 */\r
-\r
-struct  HB_PosRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of input glyphs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosRule_  HB_PosRule;\r
-\r
-\r
-struct  HB_PosRuleSet_\r
-{\r
-  HB_UShort     PosRuleCount;         /* number of PosRule tables */\r
-  HB_PosRule*  PosRule;              /* array of PosRule tables  */\r
-};\r
-\r
-typedef struct HB_PosRuleSet_  HB_PosRuleSet;\r
-\r
-\r
-struct  HB_ContextPosFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */\r
-  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;\r
-\r
-\r
-struct  HB_PosClassRule_\r
-{\r
-  HB_UShort             GlyphCount;   /* total number of context classes  */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_UShort*            Class;        /* array of classes                 */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_PosClassRule_  HB_PosClassRule;\r
-\r
-\r
-struct  HB_PosClassSet_\r
-{\r
-  HB_UShort          PosClassRuleCount;\r
-                                     /* number of PosClassRule tables */\r
-  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */\r
-};\r
-\r
-typedef struct HB_PosClassSet_  HB_PosClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextPosFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            PosClassSetCount;\r
-                                     /* number of PosClassSet tables */\r
-  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;\r
-\r
-\r
-struct  HB_ContextPosFormat3_\r
-{\r
-  HB_UShort             GlyphCount;   /* number of input glyphs           */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecord tables */\r
-  HB_Coverage*         Coverage;     /* array of Coverage tables         */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecord tables  */\r
-};\r
-\r
-typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;\r
-\r
-\r
-struct  HB_ContextPos_\r
-{\r
-  HB_UShort  PosFormat;               /* 1, 2, or 3     */\r
-\r
-  union\r
-  {\r
-    HB_ContextPosFormat1  cpf1;\r
-    HB_ContextPosFormat2  cpf2;\r
-    HB_ContextPosFormat3  cpf3;\r
-  } cpf;\r
-};\r
-\r
-typedef struct HB_ContextPos_  HB_ContextPos;\r
-\r
-\r
-/* LookupType 8 */\r
-\r
-struct  HB_ChainPosRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*            Input;        /* array of input glyph IDs         */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords       */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of PosLookupRecords       */\r
-};\r
-\r
-typedef struct HB_ChainPosRule_  HB_ChainPosRule;\r
-\r
-\r
-struct  HB_ChainPosRuleSet_\r
-{\r
-  HB_UShort          ChainPosRuleCount;\r
-                                     /* number of ChainPosRule tables */\r
-  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;\r
-\r
-\r
-struct  HB_ChainContextPosFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainPosRuleSetCount;\r
-                                     /* number of ChainPosRuleSet tables */\r
-  HB_ChainPosRuleSet*  ChainPosRuleSet;\r
-                                     /* array of ChainPosRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;\r
-\r
-\r
-struct  HB_ChainPosClassRule_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*            Backtrack;    /* array of backtrack classes      */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*            Input;        /* array of context classes        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*            Lookahead;    /* array of lookahead classes      */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords      */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;\r
-\r
-\r
-struct  HB_ChainPosClassSet_\r
-{\r
-  HB_UShort               ChainPosClassRuleCount;\r
-                                     /* number of ChainPosClassRule\r
-                                        tables                      */\r
-  HB_ChainPosClassRule*  ChainPosClassRule;\r
-                                     /* array of ChainPosClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextPosFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainPosClassSetCount;\r
-                                     /* number of ChainPosClassSet\r
-                                        tables                     */\r
-  HB_ChainPosClassSet*  ChainPosClassSet;\r
-                                     /* array of ChainPosClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;\r
-\r
-\r
-struct  HB_ChainContextPosFormat3_\r
-{\r
-  HB_UShort             BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*         BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort             InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*         InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort             LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*         LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort             PosCount;     /* number of PosLookupRecords    */\r
-  HB_PosLookupRecord*  PosLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;\r
-\r
-\r
-struct  HB_ChainContextPos_\r
-{\r
-  HB_UShort  PosFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextPosFormat1  ccpf1;\r
-    HB_ChainContextPosFormat2  ccpf2;\r
-    HB_ChainContextPosFormat3  ccpf3;\r
-  } ccpf;\r
-};\r
-\r
-typedef struct HB_ChainContextPos_  HB_ChainContextPos;\r
-\r
-\r
-#if 0\r
-/* LookupType 10 */\r
-struct HB_ExtensionPos_\r
-{\r
-  HB_UShort      PosFormat;           /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GPOS_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionPos_  HB_ExtensionPos;\r
-#endif\r
-\r
-\r
-union  HB_GPOS_SubTable_\r
-{\r
-  HB_SinglePos        single;\r
-  HB_PairPos          pair;\r
-  HB_CursivePos       cursive;\r
-  HB_MarkBasePos      markbase;\r
-  HB_MarkLigPos       marklig;\r
-  HB_MarkMarkPos      markmark;\r
-  HB_ContextPos       context;\r
-  HB_ChainContextPos  chain;\r
-};\r
-\r
-typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_PRIVATE_H
+#define HARFBUZZ_GPOS_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gpos.h"
+
+HB_BEGIN_HEADER
+
+
+/* shared tables */
+
+struct  HB_ValueRecord_
+{
+  HB_Short    XPlacement;             /* horizontal adjustment for
+                                        placement                      */
+  HB_Short    YPlacement;             /* vertical adjustment for
+                                        placement                      */
+  HB_Short    XAdvance;               /* horizontal adjustment for
+                                        advance                        */
+  HB_Short    YAdvance;               /* vertical adjustment for
+                                        advance                        */
+  HB_Device  XPlacementDevice;       /* device table for horizontal
+                                        placement                      */
+  HB_Device  YPlacementDevice;       /* device table for vertical
+                                        placement                      */
+  HB_Device  XAdvanceDevice;         /* device table for horizontal
+                                        advance                        */
+  HB_Device  YAdvanceDevice;         /* device table for vertical
+                                        advance                        */
+  HB_UShort   XIdPlacement;           /* horizontal placement metric ID */
+  HB_UShort   YIdPlacement;           /* vertical placement metric ID   */
+  HB_UShort   XIdAdvance;             /* horizontal advance metric ID   */
+  HB_UShort   YIdAdvance;             /* vertical advance metric ID     */
+};
+
+typedef struct HB_ValueRecord_  HB_ValueRecord;
+
+
+/* Mask values to scan the value format of the ValueRecord structure.
+ We always expand compressed ValueRecords of the font.              */
+
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT         0x0001
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT         0x0002
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE           0x0004
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE           0x0008
+#define HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE  0x0010
+#define HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE  0x0020
+#define HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE    0x0040
+#define HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE    0x0080
+#define HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT      0x0100
+#define HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT      0x0200
+#define HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE        0x0400
+#define HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE        0x0800
+
+
+struct  HB_AnchorFormat1_
+{
+  HB_Short   XCoordinate;             /* horizontal value */
+  HB_Short   YCoordinate;             /* vertical value   */
+};
+
+typedef struct HB_AnchorFormat1_  HB_AnchorFormat1;
+
+
+struct  HB_AnchorFormat2_
+{
+  HB_Short   XCoordinate;             /* horizontal value             */
+  HB_Short   YCoordinate;             /* vertical value               */
+  HB_UShort  AnchorPoint;             /* index to glyph contour point */
+};
+
+typedef struct HB_AnchorFormat2_  HB_AnchorFormat2;
+
+
+struct  HB_AnchorFormat3_
+{
+  HB_Short    XCoordinate;            /* horizontal value              */
+  HB_Short    YCoordinate;            /* vertical value                */
+  HB_Device  XDeviceTable;           /* device table for X coordinate */
+  HB_Device  YDeviceTable;           /* device table for Y coordinate */
+};
+
+typedef struct HB_AnchorFormat3_  HB_AnchorFormat3;
+
+
+struct  HB_AnchorFormat4_
+{
+  HB_UShort  XIdAnchor;               /* horizontal metric ID */
+  HB_UShort  YIdAnchor;               /* vertical metric ID   */
+};
+
+typedef struct HB_AnchorFormat4_  HB_AnchorFormat4;
+
+
+struct  HB_Anchor_
+{
+  HB_UShort  PosFormat;               /* 1, 2, 3, or 4 -- 0 indicates
+                                        that there is no Anchor table */
+
+  union
+  {
+    HB_AnchorFormat1  af1;
+    HB_AnchorFormat2  af2;
+    HB_AnchorFormat3  af3;
+    HB_AnchorFormat4  af4;
+  } af;
+};
+
+typedef struct HB_Anchor_  HB_Anchor;
+
+
+struct  HB_MarkRecord_
+{
+  HB_UShort   Class;                  /* mark class   */
+  HB_Anchor  MarkAnchor;             /* anchor table */
+};
+
+typedef struct HB_MarkRecord_  HB_MarkRecord;
+
+
+struct  HB_MarkArray_
+{
+  HB_UShort        MarkCount;         /* number of MarkRecord tables */
+  HB_MarkRecord*  MarkRecord;        /* array of MarkRecord tables  */
+};
+
+typedef struct HB_MarkArray_  HB_MarkArray;
+
+
+/* LookupType 1 */
+
+struct  HB_SinglePosFormat1_
+{
+  HB_ValueRecord  Value;             /* ValueRecord for all covered
+                                        glyphs                      */
+};
+
+typedef struct HB_SinglePosFormat1_  HB_SinglePosFormat1;
+
+
+struct  HB_SinglePosFormat2_
+{
+  HB_UShort         ValueCount;       /* number of ValueRecord tables */
+  HB_ValueRecord*  Value;            /* array of ValueRecord tables  */
+};
+
+typedef struct HB_SinglePosFormat2_  HB_SinglePosFormat2;
+
+
+struct  HB_SinglePos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  HB_UShort     ValueFormat;          /* format of ValueRecord table */
+
+  union
+  {
+    HB_SinglePosFormat1  spf1;
+    HB_SinglePosFormat2  spf2;
+  } spf;
+};
+
+typedef struct HB_SinglePos_  HB_SinglePos;
+
+
+/* LookupType 2 */
+
+struct  HB_PairValueRecord_
+{
+  HB_UShort        SecondGlyph;       /* glyph ID for second glyph  */
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_PairValueRecord_  HB_PairValueRecord;
+
+
+struct  HB_PairSet_
+{
+  HB_UShort             PairValueCount;
+                                     /* number of PairValueRecord tables */
+  HB_PairValueRecord*  PairValueRecord;
+                                     /* array of PairValueRecord tables  */
+};
+
+typedef struct HB_PairSet_  HB_PairSet;
+
+
+struct  HB_PairPosFormat1_
+{
+  HB_UShort     PairSetCount;         /* number of PairSet tables    */
+  HB_PairSet*  PairSet;              /* array of PairSet tables     */
+};
+
+typedef struct HB_PairPosFormat1_  HB_PairPosFormat1;
+
+
+struct  HB_Class2Record_
+{
+  HB_ValueRecord  Value1;            /* pos. data for first glyph  */
+  HB_ValueRecord  Value2;            /* pos. data for second glyph */
+};
+
+typedef struct HB_Class2Record_  HB_Class2Record;
+
+
+struct  HB_Class1Record_
+{
+  HB_Class2Record*  Class2Record;    /* array of Class2Record tables */
+};
+
+typedef struct HB_Class1Record_  HB_Class1Record;
+
+
+struct  HB_PairPosFormat2_
+{
+  HB_ClassDefinition  ClassDef1;     /* class def. for first glyph     */
+  HB_ClassDefinition  ClassDef2;     /* class def. for second glyph    */
+  HB_UShort            Class1Count;   /* number of classes in ClassDef1
+                                        table                          */
+  HB_UShort            Class2Count;   /* number of classes in ClassDef2
+                                        table                          */
+  HB_Class1Record*    Class1Record;  /* array of Class1Record tables   */
+};
+
+typedef struct HB_PairPosFormat2_  HB_PairPosFormat2;
+
+
+struct  HB_PairPos_
+{
+  HB_UShort     PosFormat;            /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+  HB_UShort     ValueFormat1;         /* format of ValueRecord table
+                                        for first glyph             */
+  HB_UShort     ValueFormat2;         /* format of ValueRecord table
+                                        for second glyph            */
+
+  union
+  {
+    HB_PairPosFormat1  ppf1;
+    HB_PairPosFormat2  ppf2;
+  } ppf;
+};
+
+typedef struct HB_PairPos_  HB_PairPos;
+
+
+/* LookupType 3 */
+
+struct  HB_EntryExitRecord_
+{
+  HB_Anchor  EntryAnchor;            /* entry Anchor table */
+  HB_Anchor  ExitAnchor;             /* exit Anchor table  */
+};
+
+
+typedef struct HB_EntryExitRecord_  HB_EntryExitRecord;
+
+struct  HB_CursivePos_
+{
+  HB_UShort             PosFormat;    /* always 1                         */
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             EntryExitCount;
+                                     /* number of EntryExitRecord tables */
+  HB_EntryExitRecord*  EntryExitRecord;
+                                     /* array of EntryExitRecord tables  */
+};
+
+typedef struct HB_CursivePos_  HB_CursivePos;
+
+
+/* LookupType 4 */
+
+struct  HB_BaseRecord_
+{
+  HB_Anchor*  BaseAnchor;            /* array of base glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_BaseRecord_  HB_BaseRecord;
+
+
+struct  HB_BaseArray_
+{
+  HB_UShort        BaseCount;         /* number of BaseRecord tables */
+  HB_BaseRecord*  BaseRecord;        /* array of BaseRecord tables  */
+};
+
+typedef struct HB_BaseArray_  HB_BaseArray;
+
+
+struct  HB_MarkBasePos_
+{
+  HB_UShort      PosFormat;           /* always 1                  */
+  HB_Coverage   MarkCoverage;        /* mark glyph coverage table */
+  HB_Coverage   BaseCoverage;        /* base glyph coverage table */
+  HB_UShort      ClassCount;          /* number of mark classes    */
+  HB_MarkArray  MarkArray;           /* mark array table          */
+  HB_BaseArray  BaseArray;           /* base array table          */
+};
+
+typedef struct HB_MarkBasePos_  HB_MarkBasePos;
+
+
+/* LookupType 5 */
+
+struct  HB_ComponentRecord_
+{
+  HB_Anchor*  LigatureAnchor;        /* array of ligature glyph anchor
+                                        tables                         */
+};
+
+typedef struct HB_ComponentRecord_  HB_ComponentRecord;
+
+
+struct  HB_LigatureAttach_
+{
+  HB_UShort             ComponentCount;
+                                     /* number of ComponentRecord tables */
+  HB_ComponentRecord*  ComponentRecord;
+                                     /* array of ComponentRecord tables  */
+};
+
+typedef struct HB_LigatureAttach_  HB_LigatureAttach;
+
+
+struct  HB_LigatureArray_
+{
+  HB_UShort            LigatureCount; /* number of LigatureAttach tables */
+  HB_LigatureAttach*  LigatureAttach;
+                                     /* array of LigatureAttach tables  */
+};
+
+typedef struct HB_LigatureArray_  HB_LigatureArray;
+
+
+struct  HB_MarkLigPos_
+{
+  HB_UShort          PosFormat;       /* always 1                      */
+  HB_Coverage       MarkCoverage;    /* mark glyph coverage table     */
+  HB_Coverage       LigatureCoverage;
+                                     /* ligature glyph coverage table */
+  HB_UShort          ClassCount;      /* number of mark classes        */
+  HB_MarkArray      MarkArray;       /* mark array table              */
+  HB_LigatureArray  LigatureArray;   /* ligature array table          */
+};
+
+typedef struct HB_MarkLigPos_  HB_MarkLigPos;
+
+
+/* LookupType 6 */
+
+struct  HB_Mark2Record_
+{
+  HB_Anchor*  Mark2Anchor;           /* array of mark glyph anchor
+                                        tables                     */
+};
+
+typedef struct HB_Mark2Record_  HB_Mark2Record;
+
+
+struct  HB_Mark2Array_
+{
+  HB_UShort         Mark2Count;       /* number of Mark2Record tables */
+  HB_Mark2Record*  Mark2Record;      /* array of Mark2Record tables  */
+};
+
+typedef struct HB_Mark2Array_  HB_Mark2Array;
+
+
+struct  HB_MarkMarkPos_
+{
+  HB_UShort       PosFormat;          /* always 1                         */
+  HB_Coverage    Mark1Coverage;      /* first mark glyph coverage table  */
+  HB_Coverage    Mark2Coverage;      /* second mark glyph coverave table */
+  HB_UShort       ClassCount;         /* number of combining mark classes */
+  HB_MarkArray   Mark1Array;         /* MarkArray table for first mark   */
+  HB_Mark2Array  Mark2Array;         /* MarkArray table for second mark  */
+};
+
+typedef struct HB_MarkMarkPos_  HB_MarkMarkPos;
+
+
+/* needed by both lookup type 7 and 8 */
+
+struct  HB_PosLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_PosLookupRecord_  HB_PosLookupRecord;
+
+
+/* LookupType 7 */
+
+struct  HB_PosRule_
+{
+  HB_UShort             GlyphCount;   /* total number of input glyphs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosRule_  HB_PosRule;
+
+
+struct  HB_PosRuleSet_
+{
+  HB_UShort     PosRuleCount;         /* number of PosRule tables */
+  HB_PosRule*  PosRule;              /* array of PosRule tables  */
+};
+
+typedef struct HB_PosRuleSet_  HB_PosRuleSet;
+
+
+struct  HB_ContextPosFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        PosRuleSetCount;   /* number of PosRuleSet tables */
+  HB_PosRuleSet*  PosRuleSet;        /* array of PosRuleSet tables  */
+};
+
+typedef struct HB_ContextPosFormat1_  HB_ContextPosFormat1;
+
+
+struct  HB_PosClassRule_
+{
+  HB_UShort             GlyphCount;   /* total number of context classes  */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_UShort*            Class;        /* array of classes                 */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_PosClassRule_  HB_PosClassRule;
+
+
+struct  HB_PosClassSet_
+{
+  HB_UShort          PosClassRuleCount;
+                                     /* number of PosClassRule tables */
+  HB_PosClassRule*  PosClassRule;    /* array of PosClassRule tables  */
+};
+
+typedef struct HB_PosClassSet_  HB_PosClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextPosFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            PosClassSetCount;
+                                     /* number of PosClassSet tables */
+  HB_PosClassSet*     PosClassSet;   /* array of PosClassSet tables  */
+};
+
+typedef struct HB_ContextPosFormat2_  HB_ContextPosFormat2;
+
+
+struct  HB_ContextPosFormat3_
+{
+  HB_UShort             GlyphCount;   /* number of input glyphs           */
+  HB_UShort             PosCount;     /* number of PosLookupRecord tables */
+  HB_Coverage*         Coverage;     /* array of Coverage tables         */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecord tables  */
+};
+
+typedef struct HB_ContextPosFormat3_  HB_ContextPosFormat3;
+
+
+struct  HB_ContextPos_
+{
+  HB_UShort  PosFormat;               /* 1, 2, or 3     */
+
+  union
+  {
+    HB_ContextPosFormat1  cpf1;
+    HB_ContextPosFormat2  cpf2;
+    HB_ContextPosFormat3  cpf3;
+  } cpf;
+};
+
+typedef struct HB_ContextPos_  HB_ContextPos;
+
+
+/* LookupType 8 */
+
+struct  HB_ChainPosRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*            Backtrack;    /* array of backtrack glyph IDs     */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*            Input;        /* array of input glyph IDs         */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*            Lookahead;    /* array of lookahead glyph IDs     */
+  HB_UShort             PosCount;     /* number of PosLookupRecords       */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of PosLookupRecords       */
+};
+
+typedef struct HB_ChainPosRule_  HB_ChainPosRule;
+
+
+struct  HB_ChainPosRuleSet_
+{
+  HB_UShort          ChainPosRuleCount;
+                                     /* number of ChainPosRule tables */
+  HB_ChainPosRule*  ChainPosRule;    /* array of ChainPosRule tables  */
+};
+
+typedef struct HB_ChainPosRuleSet_  HB_ChainPosRuleSet;
+
+
+struct  HB_ChainContextPosFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainPosRuleSetCount;
+                                     /* number of ChainPosRuleSet tables */
+  HB_ChainPosRuleSet*  ChainPosRuleSet;
+                                     /* array of ChainPosRuleSet tables  */
+};
+
+typedef struct HB_ChainContextPosFormat1_  HB_ChainContextPosFormat1;
+
+
+struct  HB_ChainPosClassRule_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*            Backtrack;    /* array of backtrack classes      */
+  HB_UShort             InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*            Input;        /* array of context classes        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*            Lookahead;    /* array of lookahead classes      */
+  HB_UShort             PosCount;     /* number of PosLookupRecords      */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainPosClassRule_  HB_ChainPosClassRule;
+
+
+struct  HB_ChainPosClassSet_
+{
+  HB_UShort               ChainPosClassRuleCount;
+                                     /* number of ChainPosClassRule
+                                        tables                      */
+  HB_ChainPosClassRule*  ChainPosClassRule;
+                                     /* array of ChainPosClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainPosClassSet_  HB_ChainPosClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextPosFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainPosClassSetCount;
+                                     /* number of ChainPosClassSet
+                                        tables                     */
+  HB_ChainPosClassSet*  ChainPosClassSet;
+                                     /* array of ChainPosClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextPosFormat2_  HB_ChainContextPosFormat2;
+
+
+struct  HB_ChainContextPosFormat3_
+{
+  HB_UShort             BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*         BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort             InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*         InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort             LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*         LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort             PosCount;     /* number of PosLookupRecords    */
+  HB_PosLookupRecord*  PosLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextPosFormat3_  HB_ChainContextPosFormat3;
+
+
+struct  HB_ChainContextPos_
+{
+  HB_UShort  PosFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextPosFormat1  ccpf1;
+    HB_ChainContextPosFormat2  ccpf2;
+    HB_ChainContextPosFormat3  ccpf3;
+  } ccpf;
+};
+
+typedef struct HB_ChainContextPos_  HB_ChainContextPos;
+
+
+#if 0
+/* LookupType 10 */
+struct HB_ExtensionPos_
+{
+  HB_UShort      PosFormat;           /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GPOS_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionPos_  HB_ExtensionPos;
+#endif
+
+
+union  HB_GPOS_SubTable_
+{
+  HB_SinglePos        single;
+  HB_PairPos          pair;
+  HB_CursivePos       cursive;
+  HB_MarkBasePos      markbase;
+  HB_MarkLigPos       marklig;
+  HB_MarkMarkPos      markmark;
+  HB_ContextPos       context;
+  HB_ChainContextPos  chain;
+};
+
+typedef union HB_GPOS_SubTable_  HB_GPOS_SubTable;
+
+
+
+HB_INTERNAL HB_Error
+_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_PRIVATE_H */
index 20bb7d9..2840dae 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GPOS_H\r
-#define HARFBUZZ_GPOS_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph positioning */\r
-\r
-#define HB_GPOS_LOOKUP_SINGLE     1\r
-#define HB_GPOS_LOOKUP_PAIR       2\r
-#define HB_GPOS_LOOKUP_CURSIVE    3\r
-#define HB_GPOS_LOOKUP_MARKBASE   4\r
-#define HB_GPOS_LOOKUP_MARKLIG    5\r
-#define HB_GPOS_LOOKUP_MARKMARK   6\r
-#define HB_GPOS_LOOKUP_CONTEXT    7\r
-#define HB_GPOS_LOOKUP_CHAIN      8\r
-#define HB_GPOS_LOOKUP_EXTENSION  9\r
-\r
-/* A pointer to a function which accesses the PostScript interpreter.\r
-   Multiple Master fonts need this interface to convert a metric ID\r
-   (as stored in an OpenType font version 1.2 or higher) `metric_id'\r
-   into a metric value (returned in `metric_value').\r
-\r
-   `data' points to the user-defined structure specified during a\r
-   call to HB_GPOS_Register_MM_Function().\r
-\r
-   `metric_value' must be returned as a scaled value (but shouldn't\r
-   be rounded).                                                       */\r
-\r
-typedef HB_Error  (*HB_MMFunction)(HB_Font       font,\r
-                                   HB_UShort    metric_id,\r
-                                   HB_Fixed*      metric_value,\r
-                                   void*        data );\r
-\r
-\r
-struct  HB_GPOSHeader_\r
-{\r
-  HB_16Dot16           Version;\r
-\r
-  HB_ScriptList     ScriptList;\r
-  HB_FeatureList    FeatureList;\r
-  HB_LookupList     LookupList;\r
-\r
-  HB_GDEFHeader*    gdef;\r
-\r
-  /* this is OpenType 1.2 -- Multiple Master fonts need this\r
-     callback function to get various metric values from the\r
-     PostScript interpreter.                                 */\r
-\r
-  HB_MMFunction     mmfunc;\r
-  void*              data;\r
-};\r
-\r
-typedef struct HB_GPOSHeader_  HB_GPOSHeader;\r
-typedef HB_GPOSHeader* HB_GPOS;\r
-\r
-\r
-HB_Error  HB_Load_GPOS_Table( HB_Stream stream, \r
-                              HB_GPOSHeader** gpos,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );\r
-\r
-\r
-HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,\r
-                                       HB_MMFunction   mmfunc,\r
-                                       void*            data );\r
-\r
-/* If `dvi' is TRUE, glyph contour points for anchor points and device\r
-   tables are ignored -- you will get device independent values.         */\r
-\r
-\r
-HB_Error  HB_GPOS_Apply_String( HB_Font           font,\r
-                               HB_GPOSHeader*   gpos,\r
-                               HB_UShort         load_flags,\r
-                               HB_Buffer        buffer,\r
-                               HB_Bool           dvi,\r
-                               HB_Bool           r2l );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GPOS_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GPOS_H
+#define HARFBUZZ_GPOS_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph positioning */
+
+#define HB_GPOS_LOOKUP_SINGLE     1
+#define HB_GPOS_LOOKUP_PAIR       2
+#define HB_GPOS_LOOKUP_CURSIVE    3
+#define HB_GPOS_LOOKUP_MARKBASE   4
+#define HB_GPOS_LOOKUP_MARKLIG    5
+#define HB_GPOS_LOOKUP_MARKMARK   6
+#define HB_GPOS_LOOKUP_CONTEXT    7
+#define HB_GPOS_LOOKUP_CHAIN      8
+#define HB_GPOS_LOOKUP_EXTENSION  9
+
+/* A pointer to a function which accesses the PostScript interpreter.
+   Multiple Master fonts need this interface to convert a metric ID
+   (as stored in an OpenType font version 1.2 or higher) `metric_id'
+   into a metric value (returned in `metric_value').
+
+   `data' points to the user-defined structure specified during a
+   call to HB_GPOS_Register_MM_Function().
+
+   `metric_value' must be returned as a scaled value (but shouldn't
+   be rounded).                                                       */
+
+typedef HB_Error  (*HB_MMFunction)(HB_Font       font,
+                                   HB_UShort    metric_id,
+                                   HB_Fixed*      metric_value,
+                                   void*        data );
+
+
+struct  HB_GPOSHeader_
+{
+  HB_16Dot16           Version;
+
+  HB_ScriptList     ScriptList;
+  HB_FeatureList    FeatureList;
+  HB_LookupList     LookupList;
+
+  HB_GDEFHeader*    gdef;
+
+  /* this is OpenType 1.2 -- Multiple Master fonts need this
+     callback function to get various metric values from the
+     PostScript interpreter.                                 */
+
+  HB_MMFunction     mmfunc;
+  void*              data;
+};
+
+typedef struct HB_GPOSHeader_  HB_GPOSHeader;
+typedef HB_GPOSHeader* HB_GPOS;
+
+
+HB_Error  HB_Load_GPOS_Table( HB_Stream stream, 
+                              HB_GPOSHeader** gpos,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
+
+
+HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos );
+
+
+HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,
+                                       HB_MMFunction   mmfunc,
+                                       void*            data );
+
+/* If `dvi' is TRUE, glyph contour points for anchor points and device
+   tables are ignored -- you will get device independent values.         */
+
+
+HB_Error  HB_GPOS_Apply_String( HB_Font           font,
+                               HB_GPOSHeader*   gpos,
+                               HB_UShort         load_flags,
+                               HB_Buffer        buffer,
+                               HB_Bool           dvi,
+                               HB_Bool           r2l );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GPOS_H */
index f47b46c..dd5ffdf 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_PRIVATE_H\r
-#define HARFBUZZ_GSUB_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include "harfbuzz-gsub.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;\r
-\r
-/* LookupType 1 */\r
-\r
-struct  HB_SingleSubstFormat1_\r
-{\r
-  HB_Short  DeltaGlyphID;             /* constant added to get\r
-                                        substitution glyph index */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;\r
-\r
-\r
-struct  HB_SingleSubstFormat2_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in\r
-                                        Substitute array              */\r
-  HB_UShort*  Substitute;             /* array of substitute glyph IDs */\r
-};\r
-\r
-typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;\r
-\r
-\r
-struct  HB_SingleSubst_\r
-{\r
-  HB_UShort     SubstFormat;          /* 1 or 2         */\r
-  HB_Coverage  Coverage;             /* Coverage table */\r
-\r
-  union\r
-  {\r
-    HB_SingleSubstFormat1  ssf1;\r
-    HB_SingleSubstFormat2  ssf2;\r
-  } ssf;\r
-};\r
-\r
-typedef struct HB_SingleSubst_  HB_SingleSubst;\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-struct  HB_Sequence_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Substitute array           */\r
-  HB_UShort*  Substitute;             /* string of glyph IDs to\r
-                                        substitute                 */\r
-};\r
-\r
-typedef struct HB_Sequence_  HB_Sequence;\r
-\r
-\r
-struct  HB_MultipleSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1                  */\r
-  HB_Coverage   Coverage;            /* Coverage table            */\r
-  HB_UShort      SequenceCount;       /* number of Sequence tables */\r
-  HB_Sequence*  Sequence;            /* array of Sequence tables  */\r
-};\r
-\r
-typedef struct HB_MultipleSubst_  HB_MultipleSubst;\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-struct  HB_AlternateSet_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyph IDs in the\r
-                                        Alternate array              */\r
-  HB_UShort*  Alternate;              /* array of alternate glyph IDs */\r
-};\r
-\r
-typedef struct HB_AlternateSet_  HB_AlternateSet;\r
-\r
-\r
-struct  HB_AlternateSubst_\r
-{\r
-  HB_UShort          SubstFormat;     /* always 1                      */\r
-  HB_Coverage       Coverage;        /* Coverage table                */\r
-  HB_UShort          AlternateSetCount;\r
-                                     /* number of AlternateSet tables */\r
-  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */\r
-};\r
-\r
-typedef struct HB_AlternateSubst_  HB_AlternateSubst;\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-struct  HB_Ligature_\r
-{\r
-  HB_UShort   LigGlyph;               /* glyphID of ligature\r
-                                        to substitute                    */\r
-  HB_UShort   ComponentCount;         /* number of components in ligature */\r
-  HB_UShort*  Component;              /* array of component glyph IDs     */\r
-};\r
-\r
-typedef struct HB_Ligature_  HB_Ligature;\r
-\r
-\r
-struct  HB_LigatureSet_\r
-{\r
-  HB_UShort      LigatureCount;       /* number of Ligature tables */\r
-  HB_Ligature*  Ligature;            /* array of Ligature tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSet_  HB_LigatureSet;\r
-\r
-\r
-struct  HB_LigatureSubst_\r
-{\r
-  HB_UShort         SubstFormat;      /* always 1                     */\r
-  HB_Coverage      Coverage;         /* Coverage table               */\r
-  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */\r
-  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */\r
-};\r
-\r
-typedef struct HB_LigatureSubst_  HB_LigatureSubst;\r
-\r
-\r
-/* needed by both lookup type 5 and 6 */\r
-\r
-struct  HB_SubstLookupRecord_\r
-{\r
-  HB_UShort  SequenceIndex;           /* index into current\r
-                                        glyph sequence               */\r
-  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */\r
-};\r
-\r
-typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-struct  HB_SubRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of input glyphs */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                       */\r
-  HB_UShort*              Input;      /* array of input glyph IDs     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                       */\r
-};\r
-\r
-typedef struct HB_SubRule_  HB_SubRule;\r
-\r
-\r
-struct  HB_SubRuleSet_\r
-{\r
-  HB_UShort     SubRuleCount;         /* number of SubRule tables */\r
-  HB_SubRule*  SubRule;              /* array of SubRule tables  */\r
-};\r
-\r
-typedef struct HB_SubRuleSet_  HB_SubRuleSet;\r
-\r
-\r
-struct  HB_ContextSubstFormat1_\r
-{\r
-  HB_Coverage     Coverage;          /* Coverage table              */\r
-  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */\r
-  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;\r
-\r
-\r
-struct  HB_SubClassRule_\r
-{\r
-  HB_UShort               GlyphCount; /* total number of context classes */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecord\r
-                                        tables                          */\r
-  HB_UShort*              Class;      /* array of classes                */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecord\r
-                                        tables                          */\r
-};\r
-\r
-typedef struct HB_SubClassRule_  HB_SubClassRule;\r
-\r
-\r
-struct  HB_SubClassSet_\r
-{\r
-  HB_UShort          SubClassRuleCount;\r
-                                     /* number of SubClassRule tables */\r
-  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */\r
-};\r
-\r
-typedef struct HB_SubClassSet_  HB_SubClassSet;\r
-\r
-\r
-/* The `MaxContextLength' field is not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the context rules.                    */\r
-\r
-struct  HB_ContextSubstFormat2_\r
-{\r
-  HB_UShort            MaxContextLength;\r
-                                     /* maximal context length       */\r
-  HB_Coverage         Coverage;      /* Coverage table               */\r
-  HB_ClassDefinition  ClassDef;      /* ClassDef table               */\r
-  HB_UShort            SubClassSetCount;\r
-                                     /* number of SubClassSet tables */\r
-  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;\r
-\r
-\r
-struct  HB_ContextSubstFormat3_\r
-{\r
-  HB_UShort               GlyphCount; /* number of input glyphs        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_Coverage*           Coverage;   /* array of Coverage tables      */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;\r
-\r
-\r
-struct  HB_ContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ContextSubstFormat1  csf1;\r
-    HB_ContextSubstFormat2  csf2;\r
-    HB_ContextSubstFormat3  csf3;\r
-  } csf;\r
-};\r
-\r
-typedef struct HB_ContextSubst_  HB_ContextSubst;\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-struct  HB_ChainSubRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack glyphs */\r
-  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of input glyphs     */\r
-  HB_UShort*              Input;      /* array of input glyph IDs         */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead glyphs */\r
-  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords     */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of SubstLookupRecords      */\r
-};\r
-\r
-typedef struct HB_ChainSubRule_  HB_ChainSubRule;\r
-\r
-\r
-struct  HB_ChainSubRuleSet_\r
-{\r
-  HB_UShort          ChainSubRuleCount;\r
-                                     /* number of ChainSubRule tables */\r
-  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */\r
-};\r
-\r
-typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat1_\r
-{\r
-  HB_Coverage          Coverage;     /* Coverage table                   */\r
-  HB_UShort             ChainSubRuleSetCount;\r
-                                     /* number of ChainSubRuleSet tables */\r
-  HB_ChainSubRuleSet*  ChainSubRuleSet;\r
-                                     /* array of ChainSubRuleSet tables  */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;\r
-\r
-\r
-struct  HB_ChainSubClassRule_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* total number of backtrack\r
-                                        classes                         */\r
-  HB_UShort*              Backtrack;  /* array of backtrack classes      */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* total number of context classes */\r
-  HB_UShort*              Input;      /* array of context classes        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* total number of lookahead\r
-                                        classes                         */\r
-  HB_UShort*              Lookahead;  /* array of lookahead classes      */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords    */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups   */\r
-};\r
-\r
-typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;\r
-\r
-\r
-struct  HB_ChainSubClassSet_\r
-{\r
-  HB_UShort               ChainSubClassRuleCount;\r
-                                     /* number of ChainSubClassRule\r
-                                        tables                      */\r
-  HB_ChainSubClassRule*  ChainSubClassRule;\r
-                                     /* array of ChainSubClassRule\r
-                                        tables                      */\r
-};\r
-\r
-typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;\r
-\r
-\r
-/* The `MaxXXXLength' fields are not defined in the TTO specification\r
-   but simplifies the implementation of this format.  It holds the\r
-   maximal context length used in the specific context rules.         */\r
-\r
-struct  HB_ChainContextSubstFormat2_\r
-{\r
-  HB_Coverage           Coverage;    /* Coverage table             */\r
-\r
-  HB_UShort              MaxBacktrackLength;\r
-                                     /* maximal backtrack length   */\r
-  HB_ClassDefinition    BacktrackClassDef;\r
-                                     /* BacktrackClassDef table    */\r
-  HB_UShort              MaxInputLength;\r
-                                     /* maximal input length       */\r
-  HB_ClassDefinition    InputClassDef;\r
-                                     /* InputClassDef table        */\r
-  HB_UShort              MaxLookaheadLength;\r
-                                     /* maximal lookahead length   */\r
-  HB_ClassDefinition    LookaheadClassDef;\r
-                                     /* LookaheadClassDef table    */\r
-\r
-  HB_UShort              ChainSubClassSetCount;\r
-                                     /* number of ChainSubClassSet\r
-                                        tables                     */\r
-  HB_ChainSubClassSet*  ChainSubClassSet;\r
-                                     /* array of ChainSubClassSet\r
-                                        tables                     */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;\r
-\r
-\r
-struct  HB_ChainContextSubstFormat3_\r
-{\r
-  HB_UShort               BacktrackGlyphCount;\r
-                                     /* number of backtrack glyphs    */\r
-  HB_Coverage*           BacktrackCoverage;\r
-                                     /* array of backtrack Coverage\r
-                                        tables                        */\r
-  HB_UShort               InputGlyphCount;\r
-                                     /* number of input glyphs        */\r
-  HB_Coverage*           InputCoverage;\r
-                                     /* array of input coverage\r
-                                        tables                        */\r
-  HB_UShort               LookaheadGlyphCount;\r
-                                     /* number of lookahead glyphs    */\r
-  HB_Coverage*           LookaheadCoverage;\r
-                                     /* array of lookahead coverage\r
-                                        tables                        */\r
-  HB_UShort               SubstCount; /* number of SubstLookupRecords  */\r
-  HB_SubstLookupRecord*  SubstLookupRecord;\r
-                                     /* array of substitution lookups */\r
-};\r
-\r
-typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;\r
-\r
-\r
-struct  HB_ChainContextSubst_\r
-{\r
-  HB_UShort  SubstFormat;             /* 1, 2, or 3 */\r
-\r
-  union\r
-  {\r
-    HB_ChainContextSubstFormat1  ccsf1;\r
-    HB_ChainContextSubstFormat2  ccsf2;\r
-    HB_ChainContextSubstFormat3  ccsf3;\r
-  } ccsf;\r
-};\r
-\r
-typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;\r
-\r
-\r
-#if 0\r
-/* LookupType 7 */\r
-struct HB_ExtensionSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */\r
-  HB_GSUB_SubTable *subtable;         /* referenced subtable */\r
-};\r
-\r
-typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;\r
-#endif\r
-\r
-\r
-/* LookupType 8 */\r
-struct HB_ReverseChainContextSubst_\r
-{\r
-  HB_UShort      SubstFormat;         /* always 1 */\r
-  HB_Coverage   Coverage;              /* coverage table for input glyphs */\r
-  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */\r
-  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage\r
-                                        tables                          */\r
-  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */\r
-  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage\r
-                                        tables                          */\r
-  HB_UShort      GlyphCount;          /* number of Glyph IDs             */\r
-  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */\r
-};\r
-\r
-typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;\r
-\r
-\r
-union  HB_GSUB_SubTable_\r
-{\r
-  HB_SingleSubst              single;\r
-  HB_MultipleSubst            multiple;\r
-  HB_AlternateSubst           alternate;\r
-  HB_LigatureSubst            ligature;\r
-  HB_ContextSubst             context;\r
-  HB_ChainContextSubst        chain;\r
-  HB_ReverseChainContextSubst reverse;\r
-};\r
-\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,\r
-                                 HB_Stream     stream,\r
-                                 HB_UShort     lookup_type );\r
-\r
-HB_INTERNAL void\r
-_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,\r
-                             HB_UShort     lookup_type );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_PRIVATE_H
+#define HARFBUZZ_GSUB_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include "harfbuzz-gsub.h"
+
+HB_BEGIN_HEADER
+
+
+typedef union HB_GSUB_SubTable_  HB_GSUB_SubTable;
+
+/* LookupType 1 */
+
+struct  HB_SingleSubstFormat1_
+{
+  HB_Short  DeltaGlyphID;             /* constant added to get
+                                        substitution glyph index */
+};
+
+typedef struct HB_SingleSubstFormat1_  HB_SingleSubstFormat1;
+
+
+struct  HB_SingleSubstFormat2_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in
+                                        Substitute array              */
+  HB_UShort*  Substitute;             /* array of substitute glyph IDs */
+};
+
+typedef struct HB_SingleSubstFormat2_  HB_SingleSubstFormat2;
+
+
+struct  HB_SingleSubst_
+{
+  HB_UShort     SubstFormat;          /* 1 or 2         */
+  HB_Coverage  Coverage;             /* Coverage table */
+
+  union
+  {
+    HB_SingleSubstFormat1  ssf1;
+    HB_SingleSubstFormat2  ssf2;
+  } ssf;
+};
+
+typedef struct HB_SingleSubst_  HB_SingleSubst;
+
+
+/* LookupType 2 */
+
+struct  HB_Sequence_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Substitute array           */
+  HB_UShort*  Substitute;             /* string of glyph IDs to
+                                        substitute                 */
+};
+
+typedef struct HB_Sequence_  HB_Sequence;
+
+
+struct  HB_MultipleSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1                  */
+  HB_Coverage   Coverage;            /* Coverage table            */
+  HB_UShort      SequenceCount;       /* number of Sequence tables */
+  HB_Sequence*  Sequence;            /* array of Sequence tables  */
+};
+
+typedef struct HB_MultipleSubst_  HB_MultipleSubst;
+
+
+/* LookupType 3 */
+
+struct  HB_AlternateSet_
+{
+  HB_UShort   GlyphCount;             /* number of glyph IDs in the
+                                        Alternate array              */
+  HB_UShort*  Alternate;              /* array of alternate glyph IDs */
+};
+
+typedef struct HB_AlternateSet_  HB_AlternateSet;
+
+
+struct  HB_AlternateSubst_
+{
+  HB_UShort          SubstFormat;     /* always 1                      */
+  HB_Coverage       Coverage;        /* Coverage table                */
+  HB_UShort          AlternateSetCount;
+                                     /* number of AlternateSet tables */
+  HB_AlternateSet*  AlternateSet;    /* array of AlternateSet tables  */
+};
+
+typedef struct HB_AlternateSubst_  HB_AlternateSubst;
+
+
+/* LookupType 4 */
+
+struct  HB_Ligature_
+{
+  HB_UShort   LigGlyph;               /* glyphID of ligature
+                                        to substitute                    */
+  HB_UShort   ComponentCount;         /* number of components in ligature */
+  HB_UShort*  Component;              /* array of component glyph IDs     */
+};
+
+typedef struct HB_Ligature_  HB_Ligature;
+
+
+struct  HB_LigatureSet_
+{
+  HB_UShort      LigatureCount;       /* number of Ligature tables */
+  HB_Ligature*  Ligature;            /* array of Ligature tables  */
+};
+
+typedef struct HB_LigatureSet_  HB_LigatureSet;
+
+
+struct  HB_LigatureSubst_
+{
+  HB_UShort         SubstFormat;      /* always 1                     */
+  HB_Coverage      Coverage;         /* Coverage table               */
+  HB_UShort         LigatureSetCount; /* number of LigatureSet tables */
+  HB_LigatureSet*  LigatureSet;      /* array of LigatureSet tables  */
+};
+
+typedef struct HB_LigatureSubst_  HB_LigatureSubst;
+
+
+/* needed by both lookup type 5 and 6 */
+
+struct  HB_SubstLookupRecord_
+{
+  HB_UShort  SequenceIndex;           /* index into current
+                                        glyph sequence               */
+  HB_UShort  LookupListIndex;         /* Lookup to apply to that pos. */
+};
+
+typedef struct HB_SubstLookupRecord_  HB_SubstLookupRecord;
+
+
+/* LookupType 5 */
+
+struct  HB_SubRule_
+{
+  HB_UShort               GlyphCount; /* total number of input glyphs */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                       */
+  HB_UShort*              Input;      /* array of input glyph IDs     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                       */
+};
+
+typedef struct HB_SubRule_  HB_SubRule;
+
+
+struct  HB_SubRuleSet_
+{
+  HB_UShort     SubRuleCount;         /* number of SubRule tables */
+  HB_SubRule*  SubRule;              /* array of SubRule tables  */
+};
+
+typedef struct HB_SubRuleSet_  HB_SubRuleSet;
+
+
+struct  HB_ContextSubstFormat1_
+{
+  HB_Coverage     Coverage;          /* Coverage table              */
+  HB_UShort        SubRuleSetCount;   /* number of SubRuleSet tables */
+  HB_SubRuleSet*  SubRuleSet;        /* array of SubRuleSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat1_  HB_ContextSubstFormat1;
+
+
+struct  HB_SubClassRule_
+{
+  HB_UShort               GlyphCount; /* total number of context classes */
+  HB_UShort               SubstCount; /* number of SubstLookupRecord
+                                        tables                          */
+  HB_UShort*              Class;      /* array of classes                */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecord
+                                        tables                          */
+};
+
+typedef struct HB_SubClassRule_  HB_SubClassRule;
+
+
+struct  HB_SubClassSet_
+{
+  HB_UShort          SubClassRuleCount;
+                                     /* number of SubClassRule tables */
+  HB_SubClassRule*  SubClassRule;    /* array of SubClassRule tables  */
+};
+
+typedef struct HB_SubClassSet_  HB_SubClassSet;
+
+
+/* The `MaxContextLength' field is not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the context rules.                    */
+
+struct  HB_ContextSubstFormat2_
+{
+  HB_UShort            MaxContextLength;
+                                     /* maximal context length       */
+  HB_Coverage         Coverage;      /* Coverage table               */
+  HB_ClassDefinition  ClassDef;      /* ClassDef table               */
+  HB_UShort            SubClassSetCount;
+                                     /* number of SubClassSet tables */
+  HB_SubClassSet*     SubClassSet;   /* array of SubClassSet tables  */
+};
+
+typedef struct HB_ContextSubstFormat2_  HB_ContextSubstFormat2;
+
+
+struct  HB_ContextSubstFormat3_
+{
+  HB_UShort               GlyphCount; /* number of input glyphs        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_Coverage*           Coverage;   /* array of Coverage tables      */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ContextSubstFormat3_  HB_ContextSubstFormat3;
+
+
+struct  HB_ContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ContextSubstFormat1  csf1;
+    HB_ContextSubstFormat2  csf2;
+    HB_ContextSubstFormat3  csf3;
+  } csf;
+};
+
+typedef struct HB_ContextSubst_  HB_ContextSubst;
+
+
+/* LookupType 6 */
+
+struct  HB_ChainSubRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack glyphs */
+  HB_UShort*              Backtrack;  /* array of backtrack glyph IDs     */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of input glyphs     */
+  HB_UShort*              Input;      /* array of input glyph IDs         */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead glyphs */
+  HB_UShort*              Lookahead;  /* array of lookahead glyph IDs     */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords     */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of SubstLookupRecords      */
+};
+
+typedef struct HB_ChainSubRule_  HB_ChainSubRule;
+
+
+struct  HB_ChainSubRuleSet_
+{
+  HB_UShort          ChainSubRuleCount;
+                                     /* number of ChainSubRule tables */
+  HB_ChainSubRule*  ChainSubRule;    /* array of ChainSubRule tables  */
+};
+
+typedef struct HB_ChainSubRuleSet_  HB_ChainSubRuleSet;
+
+
+struct  HB_ChainContextSubstFormat1_
+{
+  HB_Coverage          Coverage;     /* Coverage table                   */
+  HB_UShort             ChainSubRuleSetCount;
+                                     /* number of ChainSubRuleSet tables */
+  HB_ChainSubRuleSet*  ChainSubRuleSet;
+                                     /* array of ChainSubRuleSet tables  */
+};
+
+typedef struct HB_ChainContextSubstFormat1_  HB_ChainContextSubstFormat1;
+
+
+struct  HB_ChainSubClassRule_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* total number of backtrack
+                                        classes                         */
+  HB_UShort*              Backtrack;  /* array of backtrack classes      */
+  HB_UShort               InputGlyphCount;
+                                     /* total number of context classes */
+  HB_UShort*              Input;      /* array of context classes        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* total number of lookahead
+                                        classes                         */
+  HB_UShort*              Lookahead;  /* array of lookahead classes      */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords    */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups   */
+};
+
+typedef struct HB_ChainSubClassRule_  HB_ChainSubClassRule;
+
+
+struct  HB_ChainSubClassSet_
+{
+  HB_UShort               ChainSubClassRuleCount;
+                                     /* number of ChainSubClassRule
+                                        tables                      */
+  HB_ChainSubClassRule*  ChainSubClassRule;
+                                     /* array of ChainSubClassRule
+                                        tables                      */
+};
+
+typedef struct HB_ChainSubClassSet_  HB_ChainSubClassSet;
+
+
+/* The `MaxXXXLength' fields are not defined in the TTO specification
+   but simplifies the implementation of this format.  It holds the
+   maximal context length used in the specific context rules.         */
+
+struct  HB_ChainContextSubstFormat2_
+{
+  HB_Coverage           Coverage;    /* Coverage table             */
+
+  HB_UShort              MaxBacktrackLength;
+                                     /* maximal backtrack length   */
+  HB_ClassDefinition    BacktrackClassDef;
+                                     /* BacktrackClassDef table    */
+  HB_UShort              MaxInputLength;
+                                     /* maximal input length       */
+  HB_ClassDefinition    InputClassDef;
+                                     /* InputClassDef table        */
+  HB_UShort              MaxLookaheadLength;
+                                     /* maximal lookahead length   */
+  HB_ClassDefinition    LookaheadClassDef;
+                                     /* LookaheadClassDef table    */
+
+  HB_UShort              ChainSubClassSetCount;
+                                     /* number of ChainSubClassSet
+                                        tables                     */
+  HB_ChainSubClassSet*  ChainSubClassSet;
+                                     /* array of ChainSubClassSet
+                                        tables                     */
+};
+
+typedef struct HB_ChainContextSubstFormat2_  HB_ChainContextSubstFormat2;
+
+
+struct  HB_ChainContextSubstFormat3_
+{
+  HB_UShort               BacktrackGlyphCount;
+                                     /* number of backtrack glyphs    */
+  HB_Coverage*           BacktrackCoverage;
+                                     /* array of backtrack Coverage
+                                        tables                        */
+  HB_UShort               InputGlyphCount;
+                                     /* number of input glyphs        */
+  HB_Coverage*           InputCoverage;
+                                     /* array of input coverage
+                                        tables                        */
+  HB_UShort               LookaheadGlyphCount;
+                                     /* number of lookahead glyphs    */
+  HB_Coverage*           LookaheadCoverage;
+                                     /* array of lookahead coverage
+                                        tables                        */
+  HB_UShort               SubstCount; /* number of SubstLookupRecords  */
+  HB_SubstLookupRecord*  SubstLookupRecord;
+                                     /* array of substitution lookups */
+};
+
+typedef struct HB_ChainContextSubstFormat3_  HB_ChainContextSubstFormat3;
+
+
+struct  HB_ChainContextSubst_
+{
+  HB_UShort  SubstFormat;             /* 1, 2, or 3 */
+
+  union
+  {
+    HB_ChainContextSubstFormat1  ccsf1;
+    HB_ChainContextSubstFormat2  ccsf2;
+    HB_ChainContextSubstFormat3  ccsf3;
+  } ccsf;
+};
+
+typedef struct HB_ChainContextSubst_  HB_ChainContextSubst;
+
+
+#if 0
+/* LookupType 7 */
+struct HB_ExtensionSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_UShort      LookuptType;         /* lookup-type of referenced subtable */
+  HB_GSUB_SubTable *subtable;         /* referenced subtable */
+};
+
+typedef struct HB_ExtensionSubst_  HB_ExtensionSubst;
+#endif
+
+
+/* LookupType 8 */
+struct HB_ReverseChainContextSubst_
+{
+  HB_UShort      SubstFormat;         /* always 1 */
+  HB_Coverage   Coverage;              /* coverage table for input glyphs */
+  HB_UShort      BacktrackGlyphCount; /* number of backtrack glyphs      */
+  HB_Coverage*  BacktrackCoverage;   /* array of backtrack Coverage
+                                        tables                          */
+  HB_UShort      LookaheadGlyphCount; /* number of lookahead glyphs      */
+  HB_Coverage*  LookaheadCoverage;   /* array of lookahead Coverage
+                                        tables                          */
+  HB_UShort      GlyphCount;          /* number of Glyph IDs             */
+  HB_UShort*     Substitute;          /* array of substitute Glyph ID    */
+};
+
+typedef struct HB_ReverseChainContextSubst_  HB_ReverseChainContextSubst;
+
+
+union  HB_GSUB_SubTable_
+{
+  HB_SingleSubst              single;
+  HB_MultipleSubst            multiple;
+  HB_AlternateSubst           alternate;
+  HB_LigatureSubst            ligature;
+  HB_ContextSubst             context;
+  HB_ChainContextSubst        chain;
+  HB_ReverseChainContextSubst reverse;
+};
+
+
+
+
+HB_INTERNAL HB_Error
+_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+                                 HB_Stream     stream,
+                                 HB_UShort     lookup_type );
+
+HB_INTERNAL void
+_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
+                             HB_UShort     lookup_type );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_PRIVATE_H */
index 4471751..1ca3f0c 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_GSUB_H\r
-#define HARFBUZZ_GSUB_H\r
-\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-buffer.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-/* Lookup types for glyph substitution */\r
-\r
-#define HB_GSUB_LOOKUP_SINGLE        1\r
-#define HB_GSUB_LOOKUP_MULTIPLE      2\r
-#define HB_GSUB_LOOKUP_ALTERNATE     3\r
-#define HB_GSUB_LOOKUP_LIGATURE      4\r
-#define HB_GSUB_LOOKUP_CONTEXT       5\r
-#define HB_GSUB_LOOKUP_CHAIN         6\r
-#define HB_GSUB_LOOKUP_EXTENSION     7\r
-#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8\r
-\r
-\r
-/* A pointer to a function which selects the alternate glyph.  `pos' is\r
-   the position of the glyph with index `glyphID', `num_alternates'\r
-   gives the number of alternates in the `alternates' array.  `data'\r
-   points to the user-defined structure specified during a call to\r
-   HB_GSUB_Register_Alternate_Function().  The function must return an\r
-   index into the `alternates' array.                                   */\r
-\r
-typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,\r
-                                     HB_UShort   glyphID,\r
-                                     HB_UShort   num_alternates,\r
-                                     HB_UShort*  alternates,\r
-                                     void*       data );\r
-\r
-\r
-struct  HB_GSUBHeader_\r
-{\r
-  HB_UInt         offset;\r
-\r
-  HB_16Dot16         Version;\r
-\r
-  HB_ScriptList   ScriptList;\r
-  HB_FeatureList  FeatureList;\r
-  HB_LookupList   LookupList;\r
-\r
-  HB_GDEFHeader*  gdef;\r
-\r
-  /* the next two fields are used for an alternate substitution callback\r
-     function to select the proper alternate glyph.                      */\r
-\r
-  HB_AltFunction  altfunc;\r
-  void*            data;\r
-};\r
-\r
-typedef struct HB_GSUBHeader_   HB_GSUBHeader;\r
-typedef HB_GSUBHeader*  HB_GSUB;\r
-\r
-\r
-HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,\r
-                             HB_GSUBHeader** gsub,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream );\r
-\r
-\r
-HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index );\r
-\r
-HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index );\r
-\r
-HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index );\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,\r
-                                HB_UInt**       script_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list );\r
-\r
-HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list );\r
-\r
-\r
-HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property );\r
-\r
-HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );\r
-\r
-\r
-HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,\r
-                                              HB_AltFunction  altfunc,\r
-                                              void*            data );\r
-\r
-\r
-HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,\r
-                               HB_Buffer        buffer );\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_GSUB_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_GSUB_H
+#define HARFBUZZ_GSUB_H
+
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-buffer.h"
+
+HB_BEGIN_HEADER
+
+
+/* Lookup types for glyph substitution */
+
+#define HB_GSUB_LOOKUP_SINGLE        1
+#define HB_GSUB_LOOKUP_MULTIPLE      2
+#define HB_GSUB_LOOKUP_ALTERNATE     3
+#define HB_GSUB_LOOKUP_LIGATURE      4
+#define HB_GSUB_LOOKUP_CONTEXT       5
+#define HB_GSUB_LOOKUP_CHAIN         6
+#define HB_GSUB_LOOKUP_EXTENSION     7
+#define HB_GSUB_LOOKUP_REVERSE_CHAIN 8
+
+
+/* A pointer to a function which selects the alternate glyph.  `pos' is
+   the position of the glyph with index `glyphID', `num_alternates'
+   gives the number of alternates in the `alternates' array.  `data'
+   points to the user-defined structure specified during a call to
+   HB_GSUB_Register_Alternate_Function().  The function must return an
+   index into the `alternates' array.                                   */
+
+typedef HB_UShort  (*HB_AltFunction)(HB_UInt    pos,
+                                     HB_UShort   glyphID,
+                                     HB_UShort   num_alternates,
+                                     HB_UShort*  alternates,
+                                     void*       data );
+
+
+struct  HB_GSUBHeader_
+{
+  HB_UInt         offset;
+
+  HB_16Dot16         Version;
+
+  HB_ScriptList   ScriptList;
+  HB_FeatureList  FeatureList;
+  HB_LookupList   LookupList;
+
+  HB_GDEFHeader*  gdef;
+
+  /* the next two fields are used for an alternate substitution callback
+     function to select the proper alternate glyph.                      */
+
+  HB_AltFunction  altfunc;
+  void*            data;
+};
+
+typedef struct HB_GSUBHeader_   HB_GSUBHeader;
+typedef HB_GSUBHeader*  HB_GSUB;
+
+
+HB_Error  HB_Load_GSUB_Table( HB_Stream       stream,
+                             HB_GSUBHeader** gsub,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream );
+
+
+HB_Error  HB_Done_GSUB_Table( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index );
+
+HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index );
+
+HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index );
+
+
+HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,
+                                HB_UInt**       script_tag_list );
+
+HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list );
+
+HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list );
+
+
+HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,
+                              HB_UShort        feature_index,
+                              HB_UInt          property );
+
+HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub );
+
+
+HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,
+                                              HB_AltFunction  altfunc,
+                                              void*            data );
+
+
+HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,
+                               HB_Buffer        buffer );
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_GSUB_H */
index 358f587..2e86168 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_IMPL_H\r
-#define HARFBUZZ_IMPL_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-#include <stdlib.h>\r
-\r
-HB_BEGIN_HEADER\r
-\r
-#ifndef HB_INTERNAL\r
-# define HB_INTERNAL\r
-#endif\r
-\r
-#ifndef NULL\r
-# define NULL ((void *)0)\r
-#endif\r
-\r
-#ifndef FALSE\r
-# define FALSE 0\r
-#endif\r
-\r
-#ifndef TRUE\r
-# define TRUE 1\r
-#endif\r
-\r
-#ifndef TTAG_GDEF\r
-# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )\r
-#endif\r
-#ifndef TTAG_GPOS\r
-# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )\r
-#endif\r
-#ifndef TTAG_GSUB\r
-# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )\r
-#endif\r
-\r
-#ifndef HB_UNUSED\r
-# define HB_UNUSED(arg) ((arg) = (arg))\r
-#endif\r
-\r
-#define HB_LIKELY(cond) (cond)\r
-#define HB_UNLIKELY(cond) (cond)\r
-\r
-#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))\r
-\r
-\r
-\r
-#define HB_IsHighSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xd800)\r
-\r
-#define HB_IsLowSurrogate(ucs) \\r
-    (((ucs) & 0xfc00) == 0xdc00)\r
-\r
-#define HB_SurrogateToUcs4(high, low) \\r
-    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;\r
-\r
-\r
-\r
-\r
-\r
-#define  ALLOC(_ptr,_size,_type)   \\r
-           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )\r
-\r
-#define  REALLOC(_ptr,_newsz,_type)  \\r
-           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )\r
-\r
-#define  FREE(_ptr)                    \\r
-  do {                                 \\r
-    if ( (_ptr) )                      \\r
-    {                                  \\r
-      _hb_free( _ptr );     \\r
-      _ptr = NULL;                     \\r
-    }                                  \\r
-  } while (0)\r
-\r
-#define  ALLOC_ARRAY(_ptr,_count,_type)   \\r
-           ALLOC(_ptr,(_count)*sizeof(_type),_type*)\r
-\r
-#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \\r
-           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)\r
-\r
-#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )\r
-\r
-#define ERR_HB(err)   _hb_err (err)\r
-\r
-\r
-//HB_INTERNAL\r
-HB_Pointer\r
-_hb_alloc( size_t    size,\r
-          HB_Error *perror_ );\r
-\r
-//HB_INTERNAL\r
-       HB_Pointer\r
-_hb_realloc( HB_Pointer block,\r
-            size_t     new_size,\r
-            HB_Error  *perror_ );\r
-\r
-//HB_INTERNAL \r
-       void\r
-_hb_free( HB_Pointer block );\r
-\r
-\r
-/* helper func to set a breakpoint on */\r
-//HB_INTERNAL \r
-HB_Error\r
-_hb_err(HB_Error code);\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_IMPL_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_IMPL_H
+#define HARFBUZZ_IMPL_H
+
+#include "harfbuzz-global.h"
+
+#include <stdlib.h>
+
+HB_BEGIN_HEADER
+
+#ifndef HB_INTERNAL
+# define HB_INTERNAL
+#endif
+
+#ifndef NULL
+# define NULL ((void *)0)
+#endif
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+#ifndef TTAG_GDEF
+# define TTAG_GDEF  HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
+#endif
+#ifndef TTAG_GPOS
+# define TTAG_GPOS  HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
+#endif
+#ifndef TTAG_GSUB
+# define TTAG_GSUB  HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
+#endif
+
+#ifndef HB_UNUSED
+# define HB_UNUSED(arg) ((arg) = (arg))
+#endif
+
+#define HB_LIKELY(cond) (cond)
+#define HB_UNLIKELY(cond) (cond)
+
+#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
+
+
+
+#define HB_IsHighSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xd800)
+
+#define HB_IsLowSurrogate(ucs) \
+    (((ucs) & 0xfc00) == 0xdc00)
+
+#define HB_SurrogateToUcs4(high, low) \
+    (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00;
+
+
+
+
+
+#define  ALLOC(_ptr,_size,_type)   \
+           ( (_ptr) = (_type)_hb_alloc( _size, &error ), error != 0 )
+
+#define  REALLOC(_ptr,_newsz,_type)  \
+           ( (_ptr) = (_type)_hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
+
+#define  FREE(_ptr)                    \
+  do {                                 \
+    if ( (_ptr) )                      \
+    {                                  \
+      _hb_free( _ptr );     \
+      _ptr = NULL;                     \
+    }                                  \
+  } while (0)
+
+#define  ALLOC_ARRAY(_ptr,_count,_type)   \
+           ALLOC(_ptr,(_count)*sizeof(_type),_type*)
+
+#define  REALLOC_ARRAY(_ptr,_newcnt,_type) \
+           REALLOC(_ptr,(_newcnt)*sizeof(_type),_type*)
+
+#define  MEM_Copy(dest,source,count)   memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
+
+#define ERR_HB(err)   _hb_err (err)
+
+
+//HB_INTERNAL
+HB_Pointer
+_hb_alloc( size_t    size,
+          HB_Error *perror_ );
+
+//HB_INTERNAL
+       HB_Pointer
+_hb_realloc( HB_Pointer block,
+            size_t     new_size,
+            HB_Error  *perror_ );
+
+//HB_INTERNAL 
+       void
+_hb_free( HB_Pointer block );
+
+
+/* helper func to set a breakpoint on */
+//HB_INTERNAL 
+HB_Error
+_hb_err(HB_Error code);
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_IMPL_H */
index 02aae80..73dd383 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_PRIVATE_H\r
-#define HARFBUZZ_OPEN_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-gpos-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-\r
-struct  HB_SubTable_\r
-{\r
-  union\r
-  {\r
-    HB_GSUB_SubTable  gsub;\r
-    HB_GPOS_SubTable  gpos;\r
-  } st;\r
-};\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,\r
-                          HB_Stream     input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,\r
-                           HB_Stream         input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_LookupList( HB_LookupList*  ll,\r
-                          HB_Stream        input,\r
-                          HB_Type         type );\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Coverage( HB_Coverage* c,\r
-                        HB_Stream      input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,\r
-                               HB_UShort             limit,\r
-                               HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,\r
-                                              HB_UShort             limit,\r
-                                              HB_UInt              class_offset,\r
-                                              HB_UInt              base_offset,\r
-                                              HB_Stream             input );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Device( HB_Device* d,\r
-                      HB_Stream    input );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );\r
-HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );\r
-HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,\r
-                      HB_Type         type );\r
-\r
-HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );\r
-HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );\r
-HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );\r
-\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Coverage_Index( HB_Coverage* c,\r
-                         HB_UShort      glyphID,\r
-                         HB_UShort*     index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Class( HB_ClassDefinition* cd,\r
-                    HB_UShort             glyphID,\r
-                   HB_UShort*          klass,\r
-                    HB_UShort*            index );\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Device( HB_Device* d,\r
-                     HB_UShort    size,\r
-                     HB_Short*    value );\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_PRIVATE_H
+#define HARFBUZZ_OPEN_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-gpos-private.h"
+
+HB_BEGIN_HEADER
+
+
+struct  HB_SubTable_
+{
+  union
+  {
+    HB_GSUB_SubTable  gsub;
+    HB_GPOS_SubTable  gpos;
+  } st;
+};
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+                          HB_Stream     input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+                           HB_Stream         input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_LookupList( HB_LookupList*  ll,
+                          HB_Stream        input,
+                          HB_Type         type );
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Coverage( HB_Coverage* c,
+                        HB_Stream      input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+                               HB_UShort             limit,
+                               HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+                                              HB_UShort             limit,
+                                              HB_UInt              class_offset,
+                                              HB_UInt              base_offset,
+                                              HB_Stream             input );
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Device( HB_Device* d,
+                      HB_Stream    input );
+
+HB_INTERNAL void  _HB_OPEN_Free_ScriptList( HB_ScriptList*  sl );
+HB_INTERNAL void  _HB_OPEN_Free_FeatureList( HB_FeatureList*  fl );
+HB_INTERNAL void  _HB_OPEN_Free_LookupList( HB_LookupList*  ll,
+                      HB_Type         type );
+
+HB_INTERNAL void  _HB_OPEN_Free_Coverage( HB_Coverage*  c );
+HB_INTERNAL void  _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd );
+HB_INTERNAL void  _HB_OPEN_Free_Device( HB_Device*  d );
+
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Coverage_Index( HB_Coverage* c,
+                         HB_UShort      glyphID,
+                         HB_UShort*     index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+                    HB_UShort             glyphID,
+                   HB_UShort*          klass,
+                    HB_UShort*            index );
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Device( HB_Device* d,
+                     HB_UShort    size,
+                     HB_Short*    value );
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_PRIVATE_H */
index 8bc33dc..bdc6358 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_OPEN_H\r
-#define HARFBUZZ_OPEN_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-/* Use this if a feature applies to all glyphs */\r
-#define HB_ALL_GLYPHS                    0xFFFF\r
-\r
-#define HB_DEFAULT_LANGUAGE              0xFFFF\r
-\r
-#define HB_MAX_NESTING_LEVEL             100\r
-\r
-\r
-/* Script list related structures */\r
-\r
-struct  HB_LangSys_\r
-{\r
-  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */\r
-  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */\r
-  HB_UShort   FeatureCount;           /* number of Feature indices */\r
-  HB_UShort*  FeatureIndex;           /* array of Feature indices  */\r
-};\r
-\r
-typedef struct HB_LangSys_  HB_LangSys;\r
-\r
-\r
-struct  HB_LangSysRecord_\r
-{\r
-  HB_UInt     LangSysTag;            /* LangSysTag identifier */\r
-  HB_LangSys  LangSys;               /* LangSys table         */\r
-};\r
-\r
-typedef struct HB_LangSysRecord_  HB_LangSysRecord;\r
-\r
-\r
-struct  HB_ScriptTable_\r
-{\r
-  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */\r
-  HB_UShort           LangSysCount;   /* number of LangSysRecords */\r
-  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptTable_  HB_ScriptTable;\r
-\r
-\r
-struct  HB_ScriptRecord_\r
-{\r
-  HB_UInt        ScriptTag;              /* ScriptTag identifier */\r
-  HB_ScriptTable  Script;                 /* Script table         */\r
-};\r
-\r
-typedef struct HB_ScriptRecord_  HB_ScriptRecord;\r
-\r
-\r
-struct  HB_ScriptList_\r
-{\r
-  HB_UShort          ScriptCount;     /* number of ScriptRecords */\r
-  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */\r
-};\r
-\r
-typedef struct HB_ScriptList_  HB_ScriptList;\r
-\r
-\r
-/* Feature list related structures */\r
-\r
-struct HB_Feature_\r
-{\r
-  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */\r
-  HB_UShort   LookupListCount;        /* number of LookupList indices */\r
-  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */\r
-};\r
-\r
-typedef struct HB_Feature_  HB_Feature;\r
-\r
-\r
-struct  HB_FeatureRecord_\r
-{\r
-  HB_UInt     FeatureTag;            /* FeatureTag identifier */\r
-  HB_Feature  Feature;               /* Feature table         */\r
-};\r
-\r
-typedef struct HB_FeatureRecord_  HB_FeatureRecord;\r
-\r
-\r
-struct  HB_FeatureList_\r
-{\r
-  HB_UShort           FeatureCount;   /* number of FeatureRecords */\r
-  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */\r
-  HB_UShort*           ApplyOrder;     /* order to apply features */\r
-  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */\r
-};\r
-\r
-typedef struct HB_FeatureList_  HB_FeatureList;\r
-\r
-\r
-/* Lookup list related structures */\r
-\r
-typedef struct HB_SubTable_  HB_SubTable;\r
-\r
-\r
-struct  HB_Lookup_\r
-{\r
-  HB_UShort      LookupType;          /* Lookup type         */\r
-  HB_UShort      LookupFlag;          /* Lookup qualifiers   */\r
-  HB_UShort      SubTableCount;       /* number of SubTables */\r
-  HB_SubTable*  SubTable;            /* array of SubTables  */\r
-};\r
-\r
-typedef struct HB_Lookup_  HB_Lookup;\r
-\r
-\r
-/* The `Properties' field is not defined in the OpenType specification but\r
-   is needed for processing lookups.  If properties[n] is > 0, the\r
-   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will\r
-   process Lookup[n] for glyphs which have the specific bit not set in\r
-   the `properties' field of the input string object.                  */\r
-\r
-struct  HB_LookupList_\r
-{\r
-  HB_UShort    LookupCount;           /* number of Lookups       */\r
-  HB_Lookup*  Lookup;                /* array of Lookup records */\r
-  HB_UInt*     Properties;            /* array of flags          */\r
-};\r
-\r
-typedef struct HB_LookupList_  HB_LookupList;\r
-\r
-\r
-/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the\r
-   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in\r
-   OpenType 1.3 -- if set, the last glyph in a cursive attachment\r
-   sequence has to be positioned on the baseline -- regardless of the\r
-   writing direction.                                                    */\r
-\r
-#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001\r
-#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002\r
-#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004\r
-#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008\r
-#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00\r
-\r
-\r
-struct  HB_CoverageFormat1_\r
-{\r
-  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */\r
-  HB_UShort*  GlyphArray;             /* array of glyph IDs             */\r
-};\r
-\r
-typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;\r
-\r
-\r
-struct HB_RangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range */\r
-  HB_UShort  End;                     /* last glyph ID in the range  */\r
-  HB_UShort  StartCoverageIndex;      /* coverage index of first\r
-                                        glyph ID in the range       */\r
-};\r
-\r
-typedef struct HB_RangeRecord_  HB_RangeRecord;\r
-\r
-\r
-struct  HB_CoverageFormat2_\r
-{\r
-  HB_UShort         RangeCount;       /* number of RangeRecords */\r
-  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */\r
-};\r
-\r
-typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;\r
-\r
-\r
-struct  HB_Coverage_\r
-{\r
-  HB_UShort  CoverageFormat;          /* 1 or 2 */\r
-\r
-  union\r
-  {\r
-    HB_CoverageFormat1  cf1;\r
-    HB_CoverageFormat2  cf2;\r
-  } cf;\r
-};\r
-\r
-typedef struct HB_Coverage_  HB_Coverage;\r
-\r
-\r
-struct  HB_ClassDefFormat1_\r
-{\r
-  HB_UShort   StartGlyph;             /* first glyph ID of the\r
-                                        ClassValueArray             */\r
-  HB_UShort   GlyphCount;             /* size of the ClassValueArray */\r
-  HB_UShort*  ClassValueArray;        /* array of class values       */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;\r
-\r
-\r
-struct  HB_ClassRangeRecord_\r
-{\r
-  HB_UShort  Start;                   /* first glyph ID in the range    */\r
-  HB_UShort  End;                     /* last glyph ID in the range     */\r
-  HB_UShort  Class;                   /* applied to all glyphs in range */\r
-};\r
-\r
-typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;\r
-\r
-\r
-struct  HB_ClassDefFormat2_\r
-{\r
-  HB_UShort              ClassRangeCount;\r
-                                     /* number of ClassRangeRecords */\r
-  HB_ClassRangeRecord*  ClassRangeRecord;\r
-                                     /* array of ClassRangeRecords  */\r
-};\r
-\r
-typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;\r
-\r
-\r
-struct  HB_ClassDefinition_\r
-{\r
-  HB_Bool    loaded;\r
-\r
-  HB_UShort  ClassFormat;             /* 1 or 2                      */\r
-\r
-  union\r
-  {\r
-    HB_ClassDefFormat1  cd1;\r
-    HB_ClassDefFormat2  cd2;\r
-  } cd;\r
-};\r
-\r
-typedef struct HB_ClassDefinition_  HB_ClassDefinition;\r
-\r
-\r
-struct HB_Device_\r
-{\r
-  HB_UShort   StartSize;              /* smallest size to correct      */\r
-  HB_UShort   EndSize;                /* largest size to correct       */\r
-  HB_UShort   DeltaFormat;            /* DeltaValue array data format:\r
-                                        1, 2, or 3                    */\r
-  HB_UShort*  DeltaValue;             /* array of compressed data      */\r
-};\r
-\r
-typedef struct HB_Device_  HB_Device;\r
-\r
-\r
-enum  HB_Type_\r
-{\r
-  HB_Type_GSUB,\r
-  HB_Type_GPOS\r
-};\r
-\r
-typedef enum HB_Type_  HB_Type;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_OPEN_H
+#define HARFBUZZ_OPEN_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+/* Use this if a feature applies to all glyphs */
+#define HB_ALL_GLYPHS                    0xFFFF
+
+#define HB_DEFAULT_LANGUAGE              0xFFFF
+
+#define HB_MAX_NESTING_LEVEL             100
+
+
+/* Script list related structures */
+
+struct  HB_LangSys_
+{
+  HB_UShort   LookupOrderOffset;      /* always 0 for TT Open 1.0  */
+  HB_UShort   ReqFeatureIndex;        /* required FeatureIndex     */
+  HB_UShort   FeatureCount;           /* number of Feature indices */
+  HB_UShort*  FeatureIndex;           /* array of Feature indices  */
+};
+
+typedef struct HB_LangSys_  HB_LangSys;
+
+
+struct  HB_LangSysRecord_
+{
+  HB_UInt     LangSysTag;            /* LangSysTag identifier */
+  HB_LangSys  LangSys;               /* LangSys table         */
+};
+
+typedef struct HB_LangSysRecord_  HB_LangSysRecord;
+
+
+struct  HB_ScriptTable_
+{
+  HB_LangSys         DefaultLangSys; /* DefaultLangSys table     */
+  HB_UShort           LangSysCount;   /* number of LangSysRecords */
+  HB_LangSysRecord*  LangSysRecord;  /* array of LangSysRecords  */
+};
+
+typedef struct HB_ScriptTable_  HB_ScriptTable;
+
+
+struct  HB_ScriptRecord_
+{
+  HB_UInt        ScriptTag;              /* ScriptTag identifier */
+  HB_ScriptTable  Script;                 /* Script table         */
+};
+
+typedef struct HB_ScriptRecord_  HB_ScriptRecord;
+
+
+struct  HB_ScriptList_
+{
+  HB_UShort          ScriptCount;     /* number of ScriptRecords */
+  HB_ScriptRecord*  ScriptRecord;    /* array of ScriptRecords  */
+};
+
+typedef struct HB_ScriptList_  HB_ScriptList;
+
+
+/* Feature list related structures */
+
+struct HB_Feature_
+{
+  HB_UShort   FeatureParams;          /* always 0 for TT Open 1.0     */
+  HB_UShort   LookupListCount;        /* number of LookupList indices */
+  HB_UShort*  LookupListIndex;        /* array of LookupList indices  */
+};
+
+typedef struct HB_Feature_  HB_Feature;
+
+
+struct  HB_FeatureRecord_
+{
+  HB_UInt     FeatureTag;            /* FeatureTag identifier */
+  HB_Feature  Feature;               /* Feature table         */
+};
+
+typedef struct HB_FeatureRecord_  HB_FeatureRecord;
+
+
+struct  HB_FeatureList_
+{
+  HB_UShort           FeatureCount;   /* number of FeatureRecords */
+  HB_FeatureRecord*  FeatureRecord;  /* array of FeatureRecords  */
+  HB_UShort*           ApplyOrder;     /* order to apply features */
+  HB_UShort            ApplyCount;     /* number of elements in ApplyOrder */
+};
+
+typedef struct HB_FeatureList_  HB_FeatureList;
+
+
+/* Lookup list related structures */
+
+typedef struct HB_SubTable_  HB_SubTable;
+
+
+struct  HB_Lookup_
+{
+  HB_UShort      LookupType;          /* Lookup type         */
+  HB_UShort      LookupFlag;          /* Lookup qualifiers   */
+  HB_UShort      SubTableCount;       /* number of SubTables */
+  HB_SubTable*  SubTable;            /* array of SubTables  */
+};
+
+typedef struct HB_Lookup_  HB_Lookup;
+
+
+/* The `Properties' field is not defined in the OpenType specification but
+   is needed for processing lookups.  If properties[n] is > 0, the
+   functions HB_GSUB_Apply_String() resp. HB_GPOS_Apply_String() will
+   process Lookup[n] for glyphs which have the specific bit not set in
+   the `properties' field of the input string object.                  */
+
+struct  HB_LookupList_
+{
+  HB_UShort    LookupCount;           /* number of Lookups       */
+  HB_Lookup*  Lookup;                /* array of Lookup records */
+  HB_UInt*     Properties;            /* array of flags          */
+};
+
+typedef struct HB_LookupList_  HB_LookupList;
+
+
+/* Possible LookupFlag bit masks.  `HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS' comes from the
+   OpenType 1.2 specification; HB_LOOKUP_FLAG_RIGHT_TO_LEFT has been (re)introduced in
+   OpenType 1.3 -- if set, the last glyph in a cursive attachment
+   sequence has to be positioned on the baseline -- regardless of the
+   writing direction.                                                    */
+
+#define HB_LOOKUP_FLAG_RIGHT_TO_LEFT         0x0001
+#define HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS    0x0002
+#define HB_LOOKUP_FLAG_IGNORE_LIGATURES      0x0004
+#define HB_LOOKUP_FLAG_IGNORE_MARKS          0x0008
+#define HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  0xFF00
+
+
+struct  HB_CoverageFormat1_
+{
+  HB_UShort   GlyphCount;             /* number of glyphs in GlyphArray */
+  HB_UShort*  GlyphArray;             /* array of glyph IDs             */
+};
+
+typedef struct HB_CoverageFormat1_  HB_CoverageFormat1;
+
+
+struct HB_RangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range */
+  HB_UShort  End;                     /* last glyph ID in the range  */
+  HB_UShort  StartCoverageIndex;      /* coverage index of first
+                                        glyph ID in the range       */
+};
+
+typedef struct HB_RangeRecord_  HB_RangeRecord;
+
+
+struct  HB_CoverageFormat2_
+{
+  HB_UShort         RangeCount;       /* number of RangeRecords */
+  HB_RangeRecord*  RangeRecord;      /* array of RangeRecords  */
+};
+
+typedef struct HB_CoverageFormat2_  HB_CoverageFormat2;
+
+
+struct  HB_Coverage_
+{
+  HB_UShort  CoverageFormat;          /* 1 or 2 */
+
+  union
+  {
+    HB_CoverageFormat1  cf1;
+    HB_CoverageFormat2  cf2;
+  } cf;
+};
+
+typedef struct HB_Coverage_  HB_Coverage;
+
+
+struct  HB_ClassDefFormat1_
+{
+  HB_UShort   StartGlyph;             /* first glyph ID of the
+                                        ClassValueArray             */
+  HB_UShort   GlyphCount;             /* size of the ClassValueArray */
+  HB_UShort*  ClassValueArray;        /* array of class values       */
+};
+
+typedef struct HB_ClassDefFormat1_  HB_ClassDefFormat1;
+
+
+struct  HB_ClassRangeRecord_
+{
+  HB_UShort  Start;                   /* first glyph ID in the range    */
+  HB_UShort  End;                     /* last glyph ID in the range     */
+  HB_UShort  Class;                   /* applied to all glyphs in range */
+};
+
+typedef struct HB_ClassRangeRecord_  HB_ClassRangeRecord;
+
+
+struct  HB_ClassDefFormat2_
+{
+  HB_UShort              ClassRangeCount;
+                                     /* number of ClassRangeRecords */
+  HB_ClassRangeRecord*  ClassRangeRecord;
+                                     /* array of ClassRangeRecords  */
+};
+
+typedef struct HB_ClassDefFormat2_  HB_ClassDefFormat2;
+
+
+struct  HB_ClassDefinition_
+{
+  HB_Bool    loaded;
+
+  HB_UShort  ClassFormat;             /* 1 or 2                      */
+
+  union
+  {
+    HB_ClassDefFormat1  cd1;
+    HB_ClassDefFormat2  cd2;
+  } cd;
+};
+
+typedef struct HB_ClassDefinition_  HB_ClassDefinition;
+
+
+struct HB_Device_
+{
+  HB_UShort   StartSize;              /* smallest size to correct      */
+  HB_UShort   EndSize;                /* largest size to correct       */
+  HB_UShort   DeltaFormat;            /* DeltaValue array data format:
+                                        1, 2, or 3                    */
+  HB_UShort*  DeltaValue;             /* array of compressed data      */
+};
+
+typedef struct HB_Device_  HB_Device;
+
+
+enum  HB_Type_
+{
+  HB_Type_GSUB,
+  HB_Type_GPOS
+};
+
+typedef enum HB_Type_  HB_Type;
+
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_OPEN_H */
index 82c510a..e4b5f9a 100755 (executable)
-/*\r
- * Copyright (C) 2006  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor\r
- */\r
-\r
-#include <stdint.h>\r
-\r
-/* Base Types */\r
-\r
-typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */\r
-typedef char HB_Boolean;\r
-typedef hb_uint32 HB_Fixed; /* 26.6 */\r
-typedef hb_uint32 HB_Glyph;\r
-typedef hb_uint32 HB_Unichar;\r
-\r
-/* Metrics reported by the font backend for use of the shaper */\r
-typedef struct _HB_GlyphMetrics HB_GlyphMetrics;\r
-struct _HB_GlyphMetrics\r
-{\r
-    HB_Fixed advance;\r
-    \r
-    /* Do we need ink/logical extents for the glyph here? */\r
-};\r
-\r
-/*\r
- * HB_Font: Abstract font interface.\r
- *  First pass of this might just have FT_Face *getFace();\r
- */\r
-typedef struct _HB_Font HB_Font;\r
-typedef struct _HB_FontClass HB_FontClass;\r
-\r
-struct HB_FontClass {\r
-    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);\r
-    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);\r
-    HB_Boolean (*freeSFontTable)(void **cookie);\r
-};\r
-\r
-struct _HB_Font {\r
-    HB_FontClass *clazz;\r
-};\r
-\r
-/*\r
- * Language tags, of the form en-us; represented as interned, canonicalized\r
- * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")\r
- * both return the same (pointer-comparable) HB_Language).\r
- */\r
-typedef struct HB_Language_ *HB_Language;\r
-\r
-HB_Language hb_language_from_string(const char *str);\r
-const char *hb_language_to_string(HB_Language language);\r
-\r
-/* Special treatment for the edges of runs.\r
- */\r
-typedef enum {\r
-    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,\r
-    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,\r
-    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */\r
-} HB_RunEdge;\r
-\r
-/* Defines optional informaiton in HB_ShapeInput; this allows extension\r
- * of HB_ShapeInput while keeping binary compatibility\r
- */\r
-typedef enum {\r
-    HB_SHAPE_START_TYPE = 1 << 0,\r
-    HB_SHAPE_END_TYPE   = 1 << 1\r
-} HB_ShapeFlags;\r
-\r
-/* Attributes types are described by "interned strings"; this is a little\r
- * annoying if you want to write a switch statement, but keeps things\r
- * simple.\r
- */\r
-typedef struct _HB_AttributeType *HB_AttributeType;\r
-\r
-HB_AttributeType hb_attribute_type_from_string(const char *str);\r
-const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);\r
-\r
-struct HB_Attribute {\r
-    HB_AttributeType type;\r
-    int start; \r
-    int end;\r
-};\r
-\r
-\r
-/**\r
- * You could handle this like HB_Language, but an enum seems a little nicer;\r
- * another approach would be to use OpenType script tags.\r
- */\r
-typedef enum {\r
-    HB_SCRIPT_LATIN\r
-    /* ... */\r
-} HB_ShapeScript;\r
-\r
-/* This is just the subset of direction information needed by the shaper */\r
-typedef enum {\r
-    HB_DIRECTION_LTR,\r
-    HB_DIRECTION_RTL,\r
-    HB_DIRECTION_TTB\r
-} HB_Direction;\r
-\r
-typedef struct _HB_ShapeInput HB_ShapeInput;\r
-struct _HB_ShapeInput {\r
-    /* Defines what fields the caller has initialized - fields not in\r
-     * the enum are mandatory.\r
-     */\r
-    HB_ShapeFlags flags;\r
-    \r
-    HB_CodePoint *text;\r
-    int length;       /* total length of text to shape */\r
-    int shape_offset; /* start of section to shape */\r
-    int shape_length; /* number of code points to shape */\r
-\r
-    HB_Direction direction;\r
-    HB_ShapeScript script;\r
-    HB_Language language;\r
-\r
-    HB_AttributeType *attributes;\r
-    int n_attributes;\r
-\r
-    HB_RunEdge start_type;\r
-    HB_RunEdge end_type;\r
-};\r
-\r
-struct HB_GlyphItem {\r
-    HB_Glyph glyph;\r
-    \r
-    HB_Fixed x_offset;\r
-    HB_Fixed y_offset;\r
-    HB_Fixed advance;\r
-\r
-    /* Add kashida information, etc, here */\r
-};\r
-\r
-typedef enum {\r
-    HB_RESULT_SUCCESS,\r
-    HB_RESULT_NO_MEMORY,\r
-    HB_SHAPE_RESULT_FAILED\r
-} HB_Result;\r
-\r
-/*\r
- * Buffer for output \r
- */\r
-typedef struct _HB_GlyphBuffer HB_GlyphBuffer;\r
-struct _HB_GlyphBuffer {\r
-    int glyph_item_size;\r
-    int total_glyphs;\r
-    \r
-    int *log_clusters; /* Uniscribe style */\r
-    int cluster_space;\r
-  \r
-    int glyph_space;\r
-    void *glyph_buffer;\r
-};\r
-\r
-/* Making this self-allocating simplifies writing shapers and\r
- * also keeps things easier for caller. item_size passed in\r
- * must be at least sizeof(HB_GlyphItem) but can be bigger,\r
- * to accomodate application structures that extend HB_GlyphItem.\r
- * The allocated items will be zero-initialized.\r
- *\r
- * (Hack: Harfbuzz could choose to use even a *bigger* item size\r
- * and stick internal information before the public item structure.\r
- * This hack could possibly be used to unify this with HB_Buffer)\r
- */\r
-HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);\r
-void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);\r
-HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);\r
-HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);\r
-void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);\r
-\r
-\r
-/* Accessor for a particular glyph */\r
-#define HB_GLYPH_BUFFER_ITEM(buffer, index)\r
-\r
-/*\r
- * Main shaping function\r
- */\r
-HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);\r
+/*
+ * Copyright (C) 2006  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor
+ */
+
+#include <stdint.h>
+
+/* Base Types */
+
+typedef hb_uint16 HB_CodePoint; /* UTF-16 codepoint (not character ) */
+typedef char HB_Boolean;
+typedef hb_uint32 HB_Fixed; /* 26.6 */
+typedef hb_uint32 HB_Glyph;
+typedef hb_uint32 HB_Unichar;
+
+/* Metrics reported by the font backend for use of the shaper */
+typedef struct _HB_GlyphMetrics HB_GlyphMetrics;
+struct _HB_GlyphMetrics
+{
+    HB_Fixed advance;
+    
+    /* Do we need ink/logical extents for the glyph here? */
+};
+
+/*
+ * HB_Font: Abstract font interface.
+ *  First pass of this might just have FT_Face *getFace();
+ */
+typedef struct _HB_Font HB_Font;
+typedef struct _HB_FontClass HB_FontClass;
+
+struct HB_FontClass {
+    HB_Glyph   (*charToGlyph)(HB_Font *font, HB_Unichar chr);
+    void       (*getMetrics)(HB_Font *font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Boolean (*getSFontTable)(HB_Font *font, void **cookie, char **start, int *len);
+    HB_Boolean (*freeSFontTable)(void **cookie);
+};
+
+struct _HB_Font {
+    HB_FontClass *clazz;
+};
+
+/*
+ * Language tags, of the form en-us; represented as interned, canonicalized
+ * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")
+ * both return the same (pointer-comparable) HB_Language).
+ */
+typedef struct HB_Language_ *HB_Language;
+
+HB_Language hb_language_from_string(const char *str);
+const char *hb_language_to_string(HB_Language language);
+
+/* Special treatment for the edges of runs.
+ */
+typedef enum {
+    HB_RUN_EDGE_LINE_VISUAL_EDGE    = 1 << 0,
+    HB_RUN_EDGE_LINE_LOGICAL_EDGE   = 1 << 1,
+    HB_RUN_EDGE_LINE_ADD_HYPHEN     = 1 << 2  /* ???? */
+} HB_RunEdge;
+
+/* Defines optional informaiton in HB_ShapeInput; this allows extension
+ * of HB_ShapeInput while keeping binary compatibility
+ */
+typedef enum {
+    HB_SHAPE_START_TYPE = 1 << 0,
+    HB_SHAPE_END_TYPE   = 1 << 1
+} HB_ShapeFlags;
+
+/* Attributes types are described by "interned strings"; this is a little
+ * annoying if you want to write a switch statement, but keeps things
+ * simple.
+ */
+typedef struct _HB_AttributeType *HB_AttributeType;
+
+HB_AttributeType hb_attribute_type_from_string(const char *str);
+const char *hb_attribute_type_to_string(HB_AttributeType attribute_type);
+
+struct HB_Attribute {
+    HB_AttributeType type;
+    int start; 
+    int end;
+};
+
+
+/**
+ * You could handle this like HB_Language, but an enum seems a little nicer;
+ * another approach would be to use OpenType script tags.
+ */
+typedef enum {
+    HB_SCRIPT_LATIN
+    /* ... */
+} HB_ShapeScript;
+
+/* This is just the subset of direction information needed by the shaper */
+typedef enum {
+    HB_DIRECTION_LTR,
+    HB_DIRECTION_RTL,
+    HB_DIRECTION_TTB
+} HB_Direction;
+
+typedef struct _HB_ShapeInput HB_ShapeInput;
+struct _HB_ShapeInput {
+    /* Defines what fields the caller has initialized - fields not in
+     * the enum are mandatory.
+     */
+    HB_ShapeFlags flags;
+    
+    HB_CodePoint *text;
+    int length;       /* total length of text to shape */
+    int shape_offset; /* start of section to shape */
+    int shape_length; /* number of code points to shape */
+
+    HB_Direction direction;
+    HB_ShapeScript script;
+    HB_Language language;
+
+    HB_AttributeType *attributes;
+    int n_attributes;
+
+    HB_RunEdge start_type;
+    HB_RunEdge end_type;
+};
+
+struct HB_GlyphItem {
+    HB_Glyph glyph;
+    
+    HB_Fixed x_offset;
+    HB_Fixed y_offset;
+    HB_Fixed advance;
+
+    /* Add kashida information, etc, here */
+};
+
+typedef enum {
+    HB_RESULT_SUCCESS,
+    HB_RESULT_NO_MEMORY,
+    HB_SHAPE_RESULT_FAILED
+} HB_Result;
+
+/*
+ * Buffer for output 
+ */
+typedef struct _HB_GlyphBuffer HB_GlyphBuffer;
+struct _HB_GlyphBuffer {
+    int glyph_item_size;
+    int total_glyphs;
+    
+    int *log_clusters; /* Uniscribe style */
+    int cluster_space;
+  
+    int glyph_space;
+    void *glyph_buffer;
+};
+
+/* Making this self-allocating simplifies writing shapers and
+ * also keeps things easier for caller. item_size passed in
+ * must be at least sizeof(HB_GlyphItem) but can be bigger,
+ * to accomodate application structures that extend HB_GlyphItem.
+ * The allocated items will be zero-initialized.
+ *
+ * (Hack: Harfbuzz could choose to use even a *bigger* item size
+ * and stick internal information before the public item structure.
+ * This hack could possibly be used to unify this with HB_Buffer)
+ */
+HB_GlyphBuffer *hb_glyph_buffer_new             (size_t item_size);
+void            hb_glyph_buffer_clear           (HB_GlyphBuffer *buf);
+HB_Result       hb_glyph_buffer_extend_glyphs   (HB_GlyphBuffer *buf, int n_items);
+HB_Result       hb_glyph_buffer_extend_clusters (HB_GlyphBuffer *buf, int n_clusters);
+void            hb_glyph_buffer_free            (HB_GlyphBuffer *buf);
+
+
+/* Accessor for a particular glyph */
+#define HB_GLYPH_BUFFER_ITEM(buffer, index)
+
+/*
+ * Main shaping function
+ */
+HB_Result hb_shape(HB_ShapeInput *input, HB_GlyphBuffer *output);
index bb0ae9f..e4e7ebc 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_PRIVATE_H\r
-#define HARFBUZZ_SHAPER_PRIVATE_H\r
-\r
-HB_BEGIN_HEADER\r
-enum {\r
-    C_DOTTED_CIRCLE = 0x25CC\r
-};\r
-\r
-typedef enum \r
-{\r
-    HB_Combining_BelowLeftAttached       = 200,\r
-    HB_Combining_BelowAttached           = 202,\r
-    HB_Combining_BelowRightAttached      = 204,\r
-    HB_Combining_LeftAttached            = 208,\r
-    HB_Combining_RightAttached           = 210,\r
-    HB_Combining_AboveLeftAttached       = 212,\r
-    HB_Combining_AboveAttached           = 214,\r
-    HB_Combining_AboveRightAttached      = 216,\r
-\r
-    HB_Combining_BelowLeft               = 218,\r
-    HB_Combining_Below                   = 220,\r
-    HB_Combining_BelowRight              = 222,\r
-    HB_Combining_Left                    = 224,\r
-    HB_Combining_Right                   = 226,\r
-    HB_Combining_AboveLeft               = 228,\r
-    HB_Combining_Above                   = 230,\r
-    HB_Combining_AboveRight              = 232,\r
-\r
-    HB_Combining_DoubleBelow             = 233,\r
-    HB_Combining_DoubleAbove             = 234,\r
-    HB_Combining_IotaSubscript           = 240\r
-} HB_CombiningClass;\r
-\r
-typedef enum {\r
-    CcmpProperty = 0x1,\r
-    InitProperty = 0x2,\r
-    IsolProperty = 0x4,\r
-    FinaProperty = 0x8,\r
-    MediProperty = 0x10,\r
-    RligProperty = 0x20,\r
-    CaltProperty = 0x40,\r
-    LigaProperty = 0x80,\r
-    DligProperty = 0x100,\r
-    CswhProperty = 0x200,\r
-    MsetProperty = 0x400,\r
-\r
-    /* used by indic and myanmar shaper */\r
-    NuktaProperty = 0x4,\r
-    AkhantProperty = 0x8,\r
-    RephProperty = 0x10,\r
-    PreFormProperty = 0x20,\r
-    BelowFormProperty = 0x40,\r
-    AboveFormProperty = 0x80,\r
-    HalfFormProperty = 0x100,\r
-    PostFormProperty = 0x200,\r
-    VattuProperty = 0x400,\r
-    PreSubstProperty = 0x800,\r
-    BelowSubstProperty = 0x1000,\r
-    AboveSubstProperty = 0x2000,\r
-    PostSubstProperty = 0x4000,\r
-    HalantProperty = 0x8000,\r
-    CligProperty = 0x10000\r
-\r
-} HB_OpenTypeProperty;\r
-\r
-/* return true if ok. */\r
-typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);\r
-typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    HB_ShapeFunction shape;\r
-    HB_AttributeFunction charAttributes;\r
-} HB_ScriptEngine;\r
-\r
-extern const HB_ScriptEngine HB_ScriptEngines[];\r
-\r
-extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);\r
-extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);\r
-\r
-extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);\r
-\r
-typedef struct {\r
-    hb_uint32 tag;\r
-    hb_uint32 property;\r
-} HB_OpenTypeFeature;\r
-\r
-#define PositioningProperties 0x80000000\r
-\r
-HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);\r
-\r
-HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);\r
-HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);\r
-\r
-void HB_HeuristicPosition(HB_ShaperItem *item);\r
-void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);\r
-\r
-#define HB_IsControlChar(uc) \\r
-    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \\r
-     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \\r
-     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))\r
-\r
-HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);\r
-\r
-#define HB_GetGlyphAdvances(shaper_item) \\r
-    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \\r
-                                               shaper_item->glyphs, shaper_item->num_glyphs, \\r
-                                               shaper_item->advances, \\r
-                                               shaper_item->face->current_flags);\r
-\r
-#define HB_DECLARE_STACKARRAY(Type, Name) \\r
-    Type stack##Name[64]; \ \r
-    Type *Name = stack##Name;\r
-\r
-#define HB_INIT_STACKARRAY(Type, Name, Length) \\r
-    if ((Length) >= 64) \\r
-        Name = (Type *)malloc((Length) * sizeof(Type));\r
-\r
-#define HB_STACKARRAY(Type, Name, Length) \\r
-    HB_DECLARE_STACKARRAY(Type, Name) \\r
-    HB_INIT_STACKARRAY(Type, Name, Length)\r
-\r
-#define HB_FREE_STACKARRAY(Name) \\r
-    if (stack##Name != Name) \\r
-        free(Name);\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_PRIVATE_H
+#define HARFBUZZ_SHAPER_PRIVATE_H
+
+HB_BEGIN_HEADER
+enum {
+    C_DOTTED_CIRCLE = 0x25CC
+};
+
+typedef enum 
+{
+    HB_Combining_BelowLeftAttached       = 200,
+    HB_Combining_BelowAttached           = 202,
+    HB_Combining_BelowRightAttached      = 204,
+    HB_Combining_LeftAttached            = 208,
+    HB_Combining_RightAttached           = 210,
+    HB_Combining_AboveLeftAttached       = 212,
+    HB_Combining_AboveAttached           = 214,
+    HB_Combining_AboveRightAttached      = 216,
+
+    HB_Combining_BelowLeft               = 218,
+    HB_Combining_Below                   = 220,
+    HB_Combining_BelowRight              = 222,
+    HB_Combining_Left                    = 224,
+    HB_Combining_Right                   = 226,
+    HB_Combining_AboveLeft               = 228,
+    HB_Combining_Above                   = 230,
+    HB_Combining_AboveRight              = 232,
+
+    HB_Combining_DoubleBelow             = 233,
+    HB_Combining_DoubleAbove             = 234,
+    HB_Combining_IotaSubscript           = 240
+} HB_CombiningClass;
+
+typedef enum {
+    CcmpProperty = 0x1,
+    InitProperty = 0x2,
+    IsolProperty = 0x4,
+    FinaProperty = 0x8,
+    MediProperty = 0x10,
+    RligProperty = 0x20,
+    CaltProperty = 0x40,
+    LigaProperty = 0x80,
+    DligProperty = 0x100,
+    CswhProperty = 0x200,
+    MsetProperty = 0x400,
+
+    /* used by indic and myanmar shaper */
+    NuktaProperty = 0x4,
+    AkhantProperty = 0x8,
+    RephProperty = 0x10,
+    PreFormProperty = 0x20,
+    BelowFormProperty = 0x40,
+    AboveFormProperty = 0x80,
+    HalfFormProperty = 0x100,
+    PostFormProperty = 0x200,
+    VattuProperty = 0x400,
+    PreSubstProperty = 0x800,
+    BelowSubstProperty = 0x1000,
+    AboveSubstProperty = 0x2000,
+    PostSubstProperty = 0x4000,
+    HalantProperty = 0x8000,
+    CligProperty = 0x10000
+
+} HB_OpenTypeProperty;
+
+/* return true if ok. */
+typedef HB_Bool (*HB_ShapeFunction)(HB_ShaperItem *shaper_item);
+typedef void (*HB_AttributeFunction)(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    HB_ShapeFunction shape;
+    HB_AttributeFunction charAttributes;
+} HB_ScriptEngine;
+
+extern const HB_ScriptEngine HB_ScriptEngines[];
+
+extern HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_TibetanShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_ArabicShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_HangulShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_MyanmarShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_KhmerShape(HB_ShaperItem *shaper_item);
+extern HB_Bool HB_IndicShape(HB_ShaperItem *shaper_item);
+
+extern void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_IndicAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+extern void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *string, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes);
+
+typedef struct {
+    hb_uint32 tag;
+    hb_uint32 property;
+} HB_OpenTypeFeature;
+
+#define PositioningProperties 0x80000000
+
+HB_Bool HB_SelectScript(HB_ShaperItem *item, const HB_OpenTypeFeature *features);
+
+HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties);
+HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters);
+
+void HB_HeuristicPosition(HB_ShaperItem *item);
+void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item);
+
+#define HB_IsControlChar(uc) \
+    ((uc >= 0x200b && uc <= 0x200f /* ZW Space, ZWNJ, ZWJ, LRM and RLM */) \
+     || (uc >= 0x2028 && uc <= 0x202f /* LS, PS, LRE, RLE, PDF, LRO, RLO, NNBSP */) \
+     || (uc >= 0x206a && uc <= 0x206f /* ISS, ASS, IAFS, AFS, NADS, NODS */))
+
+HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item);
+
+#define HB_GetGlyphAdvances(shaper_item) \
+    shaper_item->font->klass->getGlyphAdvances(shaper_item->font, \
+                                               shaper_item->glyphs, shaper_item->num_glyphs, \
+                                               shaper_item->advances, \
+                                               shaper_item->face->current_flags);
+
+#define HB_DECLARE_STACKARRAY(Type, Name) \
+    Type stack##Name[64]; \ 
+    Type *Name = stack##Name;
+
+#define HB_INIT_STACKARRAY(Type, Name, Length) \
+    if ((Length) >= 64) \
+        Name = (Type *)malloc((Length) * sizeof(Type));
+
+#define HB_STACKARRAY(Type, Name, Length) \
+    HB_DECLARE_STACKARRAY(Type, Name) \
+    HB_INIT_STACKARRAY(Type, Name, Length)
+
+#define HB_FREE_STACKARRAY(Name) \
+    if (stack##Name != Name) \
+        free(Name);
+
+HB_END_HEADER
+
+#endif
index c74c664..9bdc8c6 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_SHAPER_H\r
-#define HARFBUZZ_SHAPER_H\r
-\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-external.h" \r
-#include "harfbuzz-stream-private.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef enum {\r
-        HB_Script_Common,\r
-        HB_Script_Greek,\r
-        HB_Script_Cyrillic,\r
-        HB_Script_Armenian,\r
-        HB_Script_Hebrew,\r
-        HB_Script_Arabic,\r
-        HB_Script_Syriac,\r
-        HB_Script_Thaana,\r
-        HB_Script_Devanagari,\r
-        HB_Script_Bengali,\r
-        HB_Script_Gurmukhi,\r
-        HB_Script_Gujarati,\r
-        HB_Script_Oriya,\r
-        HB_Script_Tamil,\r
-        HB_Script_Telugu,\r
-        HB_Script_Kannada,\r
-        HB_Script_Malayalam,\r
-        HB_Script_Sinhala,\r
-        HB_Script_Thai,\r
-        HB_Script_Lao,\r
-        HB_Script_Tibetan,\r
-        HB_Script_Myanmar,\r
-        HB_Script_Georgian,\r
-        HB_Script_Hangul,\r
-        HB_Script_Ogham,\r
-        HB_Script_Runic,\r
-        HB_Script_Khmer,\r
-        HB_Script_Nko,\r
-        HB_Script_Inherited,\r
-        HB_ScriptCount = HB_Script_Inherited\r
-        /*\r
-        HB_Script_Latin = Common,\r
-        HB_Script_Ethiopic = Common,\r
-        HB_Script_Cherokee = Common,\r
-        HB_Script_CanadianAboriginal = Common,\r
-        HB_Script_Mongolian = Common,\r
-        HB_Script_Hiragana = Common,\r
-        HB_Script_Katakana = Common,\r
-        HB_Script_Bopomofo = Common,\r
-        HB_Script_Han = Common,\r
-        HB_Script_Yi = Common,\r
-        HB_Script_OldItalic = Common,\r
-        HB_Script_Gothic = Common,\r
-        HB_Script_Deseret = Common,\r
-        HB_Script_Tagalog = Common,\r
-        HB_Script_Hanunoo = Common,\r
-        HB_Script_Buhid = Common,\r
-        HB_Script_Tagbanwa = Common,\r
-        HB_Script_Limbu = Common,\r
-        HB_Script_TaiLe = Common,\r
-        HB_Script_LinearB = Common,\r
-        HB_Script_Ugaritic = Common,\r
-        HB_Script_Shavian = Common,\r
-        HB_Script_Osmanya = Common,\r
-        HB_Script_Cypriot = Common,\r
-        HB_Script_Braille = Common,\r
-        HB_Script_Buginese = Common,\r
-        HB_Script_Coptic = Common,\r
-        HB_Script_NewTaiLue = Common,\r
-        HB_Script_Glagolitic = Common,\r
-        HB_Script_Tifinagh = Common,\r
-        HB_Script_SylotiNagri = Common,\r
-        HB_Script_OldPersian = Common,\r
-        HB_Script_Kharoshthi = Common,\r
-        HB_Script_Balinese = Common,\r
-        HB_Script_Cuneiform = Common,\r
-        HB_Script_Phoenician = Common,\r
-        HB_Script_PhagsPa = Common,\r
-        */\r
-} HB_Script;\r
-\r
-typedef struct\r
-{\r
-    hb_uint32 pos;\r
-    hb_uint32 length;\r
-    HB_Script script;\r
-    hb_uint8 bidiLevel;\r
-} HB_ScriptItem;\r
-\r
-typedef enum {\r
-    HB_NoBreak,\r
-    HB_SoftHyphen,\r
-    HB_Break,\r
-    HB_ForcedBreak\r
-} HB_LineBreakType;\r
-\r
-\r
-typedef struct {\r
-    /*HB_LineBreakType*/ unsigned lineBreakType  :2;\r
-    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */\r
-    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */\r
-    /*HB_Bool*/ unsigned wordBoundary            :1;\r
-    /*HB_Bool*/ unsigned sentenceBoundary        :1;\r
-    unsigned unused                  :2;\r
-} HB_CharAttributes;\r
-\r
-void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes);\r
-\r
-/* requires HB_GetCharAttributes to be called before */\r
-void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                              const HB_ScriptItem *items, hb_uint32 numItems,\r
-                              HB_CharAttributes *attributes);\r
-\r
-\r
-typedef enum {\r
-    HB_LeftToRight = 0,\r
-    HB_RightToLeft = 1\r
-} HB_StringToGlyphsFlags;\r
-\r
-typedef enum {\r
-    HB_ShaperFlag_Default = 0,\r
-    HB_ShaperFlag_NoKerning = 1,\r
-    HB_ShaperFlag_UseDesignMetrics = 2\r
-} HB_ShaperFlag;\r
-\r
-/* \r
-   highest value means highest priority for justification. Justification is done by first inserting kashidas\r
-   starting with the highest priority positions, then stretching spaces, afterwards extending inter char\r
-   spacing, and last spacing between arabic words.\r
-   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.\r
-*/\r
-typedef enum {\r
-    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */\r
-    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */\r
-    HB_Character      = 2,   /* Inter-character justification point follows this glyph */\r
-    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */\r
-    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */\r
-    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */\r
-    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */\r
-    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */\r
-    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */\r
-    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */\r
-    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */\r
-} HB_JustificationClass;\r
-\r
-/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep\r
- * it like that. If this is a problem please tell Trolltech :)\r
- */\r
-typedef struct {\r
-    unsigned justification   :4;  /* Justification class */\r
-    unsigned clusterStart    :1;  /* First glyph of representation of cluster */\r
-    unsigned mark            :1;  /* needs to be positioned around base char */\r
-    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */\r
-    unsigned dontPrint       :1;\r
-    unsigned combiningClass  :8;\r
-} HB_GlyphAttributes;\r
-\r
-typedef struct HB_FaceRec_ {\r
-    HB_Bool isSymbolFont;\r
-\r
-    HB_GDEF gdef;\r
-    HB_GSUB gsub;\r
-    HB_GPOS gpos;\r
-    HB_Bool supported_scripts[HB_ScriptCount];\r
-    HB_Buffer buffer;\r
-    HB_Script current_script;\r
-    int current_flags; /* HB_ShaperFlags */\r
-    HB_Bool has_opentype_kerning;\r
-    HB_Bool glyphs_substituted;\r
-    HB_GlyphAttributes *tmpAttributes;\r
-    unsigned int *tmpLogClusters;\r
-    int length;\r
-    int orig_nglyphs;\r
-} HB_FaceRec;\r
-\r
-typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);\r
-\r
-HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);\r
-void HB_FreeFace(HB_Face face);\r
-\r
-typedef struct {\r
-    HB_Fixed x, y;\r
-    HB_Fixed width, height;\r
-    HB_Fixed xOffset, yOffset;\r
-} HB_GlyphMetrics;\r
-\r
-typedef enum {\r
-    HB_FontAscent\r
-} HB_FontMetric;\r
-\r
-typedef struct {\r
-    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);\r
-    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);\r
-    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);\r
-    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */\r
-    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);\r
-    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);\r
-    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);\r
-} HB_FontClass;\r
-\r
-typedef struct HB_Font_ {\r
-    const HB_FontClass *klass;\r
-\r
-    /* Metrics */\r
-    HB_UShort x_ppem, y_ppem;\r
-    HB_16Dot16 x_scale, y_scale;\r
-\r
-    void *userData;\r
-} HB_FontRec;\r
-\r
-typedef struct HB_ShaperItem_ HB_ShaperItem;\r
-\r
-struct HB_ShaperItem_ {\r
-    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */\r
-    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */\r
-    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */\r
-    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */\r
-    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */\r
-    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */\r
-    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */\r
-    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */\r
-\r
-    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */\r
-                                            /* output: required capacity (may be larger than actual capacity) */\r
-\r
-    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */\r
-    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */\r
-    HB_Fixed *advances;                     /* output: <num_glyphs> advances */\r
-    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */\r
-    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */\r
-\r
-    /* internal */\r
-    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */\r
-};\r
-\r
-HB_Bool HB_ShapeItem(HB_ShaperItem *item);\r
-\r
-\r
-extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-//#ifdef __cplusplus\r
-//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;\r
-//#endif\r
-\r
-extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_SHAPER_H
+#define HARFBUZZ_SHAPER_H
+
+#include "harfbuzz-global.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-external.h" 
+#include "harfbuzz-stream-private.h"
+
+HB_BEGIN_HEADER
+
+typedef enum {
+        HB_Script_Common,
+        HB_Script_Greek,
+        HB_Script_Cyrillic,
+        HB_Script_Armenian,
+        HB_Script_Hebrew,
+        HB_Script_Arabic,
+        HB_Script_Syriac,
+        HB_Script_Thaana,
+        HB_Script_Devanagari,
+        HB_Script_Bengali,
+        HB_Script_Gurmukhi,
+        HB_Script_Gujarati,
+        HB_Script_Oriya,
+        HB_Script_Tamil,
+        HB_Script_Telugu,
+        HB_Script_Kannada,
+        HB_Script_Malayalam,
+        HB_Script_Sinhala,
+        HB_Script_Thai,
+        HB_Script_Lao,
+        HB_Script_Tibetan,
+        HB_Script_Myanmar,
+        HB_Script_Georgian,
+        HB_Script_Hangul,
+        HB_Script_Ogham,
+        HB_Script_Runic,
+        HB_Script_Khmer,
+        HB_Script_Nko,
+        HB_Script_Inherited,
+        HB_ScriptCount = HB_Script_Inherited
+        /*
+        HB_Script_Latin = Common,
+        HB_Script_Ethiopic = Common,
+        HB_Script_Cherokee = Common,
+        HB_Script_CanadianAboriginal = Common,
+        HB_Script_Mongolian = Common,
+        HB_Script_Hiragana = Common,
+        HB_Script_Katakana = Common,
+        HB_Script_Bopomofo = Common,
+        HB_Script_Han = Common,
+        HB_Script_Yi = Common,
+        HB_Script_OldItalic = Common,
+        HB_Script_Gothic = Common,
+        HB_Script_Deseret = Common,
+        HB_Script_Tagalog = Common,
+        HB_Script_Hanunoo = Common,
+        HB_Script_Buhid = Common,
+        HB_Script_Tagbanwa = Common,
+        HB_Script_Limbu = Common,
+        HB_Script_TaiLe = Common,
+        HB_Script_LinearB = Common,
+        HB_Script_Ugaritic = Common,
+        HB_Script_Shavian = Common,
+        HB_Script_Osmanya = Common,
+        HB_Script_Cypriot = Common,
+        HB_Script_Braille = Common,
+        HB_Script_Buginese = Common,
+        HB_Script_Coptic = Common,
+        HB_Script_NewTaiLue = Common,
+        HB_Script_Glagolitic = Common,
+        HB_Script_Tifinagh = Common,
+        HB_Script_SylotiNagri = Common,
+        HB_Script_OldPersian = Common,
+        HB_Script_Kharoshthi = Common,
+        HB_Script_Balinese = Common,
+        HB_Script_Cuneiform = Common,
+        HB_Script_Phoenician = Common,
+        HB_Script_PhagsPa = Common,
+        */
+} HB_Script;
+
+typedef struct
+{
+    hb_uint32 pos;
+    hb_uint32 length;
+    HB_Script script;
+    hb_uint8 bidiLevel;
+} HB_ScriptItem;
+
+typedef enum {
+    HB_NoBreak,
+    HB_SoftHyphen,
+    HB_Break,
+    HB_ForcedBreak
+} HB_LineBreakType;
+
+
+typedef struct {
+    /*HB_LineBreakType*/ unsigned lineBreakType  :2;
+    /*HB_Bool*/ unsigned whiteSpace              :1;     /* A unicode whitespace character, except NBSP, ZWNBSP */
+    /*HB_Bool*/ unsigned charStop                :1;     /* Valid cursor position (for left/right arrow) */
+    /*HB_Bool*/ unsigned wordBoundary            :1;
+    /*HB_Bool*/ unsigned sentenceBoundary        :1;
+    unsigned unused                  :2;
+} HB_CharAttributes;
+
+void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes);
+
+/* requires HB_GetCharAttributes to be called before */
+void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                              const HB_ScriptItem *items, hb_uint32 numItems,
+                              HB_CharAttributes *attributes);
+
+
+typedef enum {
+    HB_LeftToRight = 0,
+    HB_RightToLeft = 1
+} HB_StringToGlyphsFlags;
+
+typedef enum {
+    HB_ShaperFlag_Default = 0,
+    HB_ShaperFlag_NoKerning = 1,
+    HB_ShaperFlag_UseDesignMetrics = 2
+} HB_ShaperFlag;
+
+/* 
+   highest value means highest priority for justification. Justification is done by first inserting kashidas
+   starting with the highest priority positions, then stretching spaces, afterwards extending inter char
+   spacing, and last spacing between arabic words.
+   NoJustification is for example set for arabic where no Kashida can be inserted or for diacritics.
+*/
+typedef enum {
+    HB_NoJustification= 0,   /* Justification can't be applied after this glyph */
+    HB_Arabic_Space   = 1,   /* This glyph represents a space inside arabic text */
+    HB_Character      = 2,   /* Inter-character justification point follows this glyph */
+    HB_Space          = 4,   /* This glyph represents a blank outside an Arabic run */
+    HB_Arabic_Normal  = 7,   /* Normal Middle-Of-Word glyph that connects to the right (begin) */
+    HB_Arabic_Waw     = 8,   /* Next character is final form of Waw/Ain/Qaf/Fa */
+    HB_Arabic_BaRa    = 9,   /* Next two chars are Ba + Ra/Ya/AlefMaksura */
+    HB_Arabic_Alef    = 10,  /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
+    HB_Arabic_HaaDal  = 11,  /* Next character is final form of Haa/Dal/Taa Marbutah */
+    HB_Arabic_Seen    = 12,  /* Initial or Medial form Of Seen/Sad */
+    HB_Arabic_Kashida = 13   /* Kashida(U+640) in middle of word */
+} HB_JustificationClass;
+
+/* This structure is binary compatible with Uniscribe's SCRIPT_VISATTR. Would be nice to keep
+ * it like that. If this is a problem please tell Trolltech :)
+ */
+typedef struct {
+    unsigned justification   :4;  /* Justification class */
+    unsigned clusterStart    :1;  /* First glyph of representation of cluster */
+    unsigned mark            :1;  /* needs to be positioned around base char */
+    unsigned zeroWidth       :1;  /* ZWJ, ZWNJ etc, with no width */
+    unsigned dontPrint       :1;
+    unsigned combiningClass  :8;
+} HB_GlyphAttributes;
+
+typedef struct HB_FaceRec_ {
+    HB_Bool isSymbolFont;
+
+    HB_GDEF gdef;
+    HB_GSUB gsub;
+    HB_GPOS gpos;
+    HB_Bool supported_scripts[HB_ScriptCount];
+    HB_Buffer buffer;
+    HB_Script current_script;
+    int current_flags; /* HB_ShaperFlags */
+    HB_Bool has_opentype_kerning;
+    HB_Bool glyphs_substituted;
+    HB_GlyphAttributes *tmpAttributes;
+    unsigned int *tmpLogClusters;
+    int length;
+    int orig_nglyphs;
+} HB_FaceRec;
+
+typedef HB_Error (*HB_GetFontTableFunc)(void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length);
+
+HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc);
+void HB_FreeFace(HB_Face face);
+
+typedef struct {
+    HB_Fixed x, y;
+    HB_Fixed width, height;
+    HB_Fixed xOffset, yOffset;
+} HB_GlyphMetrics;
+
+typedef enum {
+    HB_FontAscent
+} HB_FontMetric;
+
+typedef struct {
+    HB_Bool  (*convertStringToGlyphIndices)(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft);
+    void     (*getGlyphAdvances)(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags /*HB_ShaperFlag*/);
+    HB_Bool  (*canRender)(HB_Font font, const HB_UChar16 *string, hb_uint32 length);
+    /* implementation needs to make sure to load a scaled glyph, so /no/ FT_LOAD_NO_SCALE */
+    HB_Error (*getPointInOutline)(HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
+    void     (*getGlyphMetrics)(HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics);
+    HB_Fixed (*getFontMetric)(HB_Font font, HB_FontMetric metric);
+} HB_FontClass;
+
+typedef struct HB_Font_ {
+    const HB_FontClass *klass;
+
+    /* Metrics */
+    HB_UShort x_ppem, y_ppem;
+    HB_16Dot16 x_scale, y_scale;
+
+    void *userData;
+} HB_FontRec;
+
+typedef struct HB_ShaperItem_ HB_ShaperItem;
+
+struct HB_ShaperItem_ {
+    const HB_UChar16 *string;               /* input: the Unicode UTF16 text to be shaped */
+    hb_uint32 stringLength;                 /* input: the length of the input in 16-bit words */
+    HB_ScriptItem item;                     /* input: the current run to be shaped: a run of text all in the same script that is a substring of <string> */
+    HB_Font font;                           /* input: the font: scale, units and function pointers supplying glyph indices and metrics */
+    HB_Face face;                           /* input: the shaper state; current script, access to the OpenType tables , etc. */
+    int shaperFlags;                        /* input (unused) should be set to 0; intended to support flags defined in HB_ShaperFlag */
+    HB_Bool glyphIndicesPresent;            /* input: true if the <glyphs> array contains glyph indices ready to be shaped */
+    hb_uint32 initialGlyphCount;            /* input: if glyphIndicesPresent is true, the number of glyph indices in the <glyphs> array */
+
+    hb_uint32 num_glyphs;                   /* input: capacity of output arrays <glyphs>, <attributes>, <advances>, <offsets>, and <log_clusters>; */
+                                            /* output: required capacity (may be larger than actual capacity) */
+
+    HB_Glyph *glyphs;                       /* output: <num_glyphs> indices of shaped glyphs */
+    HB_GlyphAttributes *attributes;         /* output: <num_glyphs> glyph attributes */
+    HB_Fixed *advances;                     /* output: <num_glyphs> advances */
+    HB_FixedPoint *offsets;                 /* output: <num_glyphs> offsets */
+    unsigned short *log_clusters;           /* output: for each output glyph, the index in the input of the start of its logical cluster */
+
+    /* internal */
+    HB_Bool kerning_applied;                /* output: true if kerning was applied by the shaper */
+};
+
+HB_Bool HB_ShapeItem(HB_ShaperItem *item);
+
+
+extern int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+extern int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+//#ifdef __cplusplus
+//extern "C"  //{ int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, bool *invalid) ;
+//#endif
+
+extern int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid) ;
+
+
+HB_END_HEADER
+
+#endif
index 322cf08..7dd41ad 100755 (executable)
@@ -1,81 +1,81 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_PRIVATE_H\r
-#define HARFBUZZ_STREAM_PRIVATE_H\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-HB_INTERNAL void\r
-_hb_close_stream( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Int\r
-_hb_stream_pos( HB_Stream stream );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_seek( HB_Stream stream,\r
-                 HB_UInt   pos );\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_frame_enter( HB_Stream stream,\r
-                        HB_UInt   size );\r
-\r
-HB_INTERNAL    void\r
-_hb_stream_frame_exit( HB_Stream stream );\r
-\r
-/* convenience macros */\r
-\r
-#define  SET_ERR(c)   ( (error = (c)) != 0 )\r
-\r
-#define  GOTO_Table(tag) (0)\r
-#define  FILE_Pos()      _hb_stream_pos( stream )\r
-#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )\r
-#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )\r
-#define  FORGET_Frame()      _hb_stream_frame_exit( stream )\r
-\r
-#define  GET_Byte()      (*stream->cursor++)\r
-#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \\r
-                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \\r
-                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \\r
-                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \\r
-                                *(((HB_Byte*)stream->cursor)-1) \\r
-                        ))\r
-\r
-\r
-#define  GET_Char()      ((HB_Char)GET_Byte())\r
-#define  GET_UShort()    ((HB_UShort)GET_Short())\r
-#define  GET_ULong()     ((HB_UInt)GET_Long())\r
-#define  GET_Tag4()      GET_ULong()\r
-\r
-HB_END_HEADER\r
-\r
-#endif /* HARFBUZZ_STREAM_PRIVATE_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_PRIVATE_H
+#define HARFBUZZ_STREAM_PRIVATE_H
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream.h"
+
+HB_BEGIN_HEADER
+
+HB_INTERNAL void
+_hb_close_stream( HB_Stream stream );
+
+HB_INTERNAL    HB_Int
+_hb_stream_pos( HB_Stream stream );
+
+HB_INTERNAL    HB_Error
+_hb_stream_seek( HB_Stream stream,
+                 HB_UInt   pos );
+
+HB_INTERNAL    HB_Error
+_hb_stream_frame_enter( HB_Stream stream,
+                        HB_UInt   size );
+
+HB_INTERNAL    void
+_hb_stream_frame_exit( HB_Stream stream );
+
+/* convenience macros */
+
+#define  SET_ERR(c)   ( (error = (c)) != 0 )
+
+#define  GOTO_Table(tag) (0)
+#define  FILE_Pos()      _hb_stream_pos( stream )
+#define  FILE_Seek(pos)  SET_ERR( _hb_stream_seek( stream, pos ) )
+#define  ACCESS_Frame(size)  SET_ERR( _hb_stream_frame_enter( stream, size ) )
+#define  FORGET_Frame()      _hb_stream_frame_exit( stream )
+
+#define  GET_Byte()      (*stream->cursor++)
+#define  GET_Short()     (stream->cursor += 2, (HB_Short)( \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+#define  GET_Long()      (stream->cursor += 4, (HB_Int)( \
+                               (*(((HB_Byte*)stream->cursor)-4) << 24) | \
+                               (*(((HB_Byte*)stream->cursor)-3) << 16) | \
+                               (*(((HB_Byte*)stream->cursor)-2) << 8) | \
+                                *(((HB_Byte*)stream->cursor)-1) \
+                        ))
+
+
+#define  GET_Char()      ((HB_Char)GET_Byte())
+#define  GET_UShort()    ((HB_UShort)GET_Short())
+#define  GET_ULong()     ((HB_UInt)GET_Long())
+#define  GET_Tag4()      GET_ULong()
+
+HB_END_HEADER
+
+#endif /* HARFBUZZ_STREAM_PRIVATE_H */
index e49c307..07578d5 100755 (executable)
@@ -1,42 +1,42 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_STREAM_H\r
-#define HARFBUZZ_STREAM_H\r
-\r
-#include "harfbuzz-global.h"\r
-\r
-HB_BEGIN_HEADER\r
-\r
-typedef struct HB_StreamRec_\r
-{\r
-    HB_Byte*       base;\r
-    HB_UInt        size;\r
-    HB_UInt        pos;\r
-    \r
-    HB_Byte*       cursor;\r
-} HB_StreamRec;\r
-\r
-\r
-HB_END_HEADER\r
-\r
-#endif\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_STREAM_H
+#define HARFBUZZ_STREAM_H
+
+#include "harfbuzz-global.h"
+
+HB_BEGIN_HEADER
+
+typedef struct HB_StreamRec_
+{
+    HB_Byte*       base;
+    HB_UInt        size;
+    HB_UInt        pos;
+    
+    HB_Byte*       cursor;
+} HB_StreamRec;
+
+
+HB_END_HEADER
+
+#endif
index d127458..8d86779 100755 (executable)
@@ -1,49 +1,49 @@
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef HARFBUZZ_H\r
-#define HARFBUZZ_H\r
-\r
-#include "harfbuzz-external.h"\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-global.h"\r
-#include "harfbuzz-buffer.h"\r
-#include "harfbuzz-gdef.h"\r
-#include "harfbuzz-gsub.h"\r
-#include "harfbuzz-gpos.h"\r
-#include "harfbuzz-open.h"\r
-#include "harfbuzz-shaper.h"\r
-\r
-#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */\r
-#define HB_ZWJ           0x200D   /** Zero Width Joiner */\r
-#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */\r
-\r
-#define HB_INITIAL_NO_OF_GLYPH 64\r
-\r
-extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;\r
-extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;\r
-extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;\r
-\r
-#endif /* HARFBUZZ_OPEN_H */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef HARFBUZZ_H
+#define HARFBUZZ_H
+
+#include "harfbuzz-external.h"
+#include "harfbuzz-impl.h"
+#include "harfbuzz-global.h"
+#include "harfbuzz-buffer.h"
+#include "harfbuzz-gdef.h"
+#include "harfbuzz-gsub.h"
+#include "harfbuzz-gpos.h"
+#include "harfbuzz-open.h"
+#include "harfbuzz-shaper.h"
+
+#define HB_DOTTED_CIRCLE       0x25CC   /** DottedCircle used with dependent Matras */
+#define HB_ZWJ           0x200D   /** Zero Width Joiner */
+#define HB_ZWNJ          0x200C   /** Zero Width Non-Joiner */
+
+#define HB_INITIAL_NO_OF_GLYPH 64
+
+extern HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID) ;
+extern HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen) ;
+extern int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID) ;
+
+#endif /* HARFBUZZ_OPEN_H */
index 20e40e6..0ff1a4e 100755 (executable)
-\r
-/*\r
- * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#ifndef __hb_unicode_tables_h__\r
-#define __hb_unicode_tables_h__\r
-\r
-#include "math.h"\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-typedef struct\r
-{\r
-       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable\r
-       HB_Script *pSubTable;\r
-\r
-}unicodeScriptTableStruct;\r
-\r
-HB_Script subTableThanaSyriac[] = \r
-{\r
-       HB_Script_Syriac,//0x00\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x08\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x10\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x18\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x20\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x28\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x30\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x38\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,//0x40\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-\r
-       HB_Script_Syriac,//0x48\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,\r
-       HB_Script_Syriac,//0x4f\r
-\r
-       HB_Script_Common,//0x50\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x58\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x60\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x68\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x70\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,//0x78\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-       HB_Script_Common,\r
-\r
-       HB_Script_Thaana,//0x80\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x88\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x90\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0x98\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xa8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb0\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,//0xb8\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,\r
-       HB_Script_Thaana,//0xbf\r
-};\r
-\r
-HB_Script subTableDevaBengali[] = \r
-{\r
-       HB_Script_Devanagari,//0x00\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x08\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x10\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x18\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x20\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x28\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x30\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x38\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x40\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x48\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x4f\r
-\r
-       HB_Script_Devanagari,//0x50\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x58\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x60\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x68\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-\r
-       HB_Script_Devanagari,//0x70\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,//0x78\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,\r
-       HB_Script_Devanagari,//0x7f\r
-\r
-\r
-       HB_Script_Bengali,//0x80\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x88\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0x90\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0x98\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xa8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xb0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xb8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xc0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xc8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xd8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xe0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-\r
-       HB_Script_Bengali,//0xe8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf0\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,//0xf8\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,\r
-       HB_Script_Bengali,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableGuruGuarati[]=\r
-{\r
-       HB_Script_Gurmukhi,//0x00\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x08\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x10\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x18\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x20\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x28\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x30\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x38\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x40\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x48\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x4f\r
-\r
-       HB_Script_Gurmukhi,//0x50\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x58\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x60\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x68\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-\r
-       HB_Script_Gurmukhi,//0x70\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,//0x78\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,\r
-       HB_Script_Gurmukhi,//0x7f\r
-\r
-\r
-       HB_Script_Gujarati,//0x80\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x88\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0x90\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0x98\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xa8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xb0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xb8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xc0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xc8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xd8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xe0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-\r
-       HB_Script_Gujarati,//0xe8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf0\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,//0xf8\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,\r
-       HB_Script_Gujarati,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOriyaTamil[]=\r
-{\r
-       HB_Script_Oriya,//0x00\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x08\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x10\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x18\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x20\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x28\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x30\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x38\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x40\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x48\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x4f\r
-\r
-       HB_Script_Oriya,//0x50\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x58\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x60\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x68\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-\r
-       HB_Script_Oriya,//0x70\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,//0x78\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,\r
-       HB_Script_Oriya,//0x7f\r
-\r
-\r
-       HB_Script_Tamil,//0x80\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x88\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0x90\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0x98\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xa8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xb0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xb8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xc0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xc8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xd8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xe0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-\r
-       HB_Script_Tamil,//0xe8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf0\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,//0xf8\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,\r
-       HB_Script_Tamil,//0xff\r
-\r
-};\r
-\r
-\r
-HB_Script subTableTelukannada[]=\r
-{\r
-       HB_Script_Telugu,//0x00\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x08\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x10\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x18\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x20\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x28\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x30\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x38\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x40\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x48\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x4f\r
-\r
-       HB_Script_Telugu,//0x50\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x58\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x60\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x68\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-\r
-       HB_Script_Telugu,//0x70\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,//0x78\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,\r
-       HB_Script_Telugu,//0x7f\r
-\r
-\r
-       HB_Script_Kannada,//0x80\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x88\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0x90\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0x98\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xa8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xb0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xb8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xc0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xc8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xd8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xe0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-\r
-       HB_Script_Kannada,//0xe8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf0\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,//0xf8\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,\r
-       HB_Script_Kannada,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMalSinhala[]=\r
-{\r
-       HB_Script_Malayalam,//0x00\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x08\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x10\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x18\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x20\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x28\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x30\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x38\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x40\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x48\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x4f\r
-\r
-       HB_Script_Malayalam,//0x50\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x58\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x60\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x68\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-\r
-       HB_Script_Malayalam,//0x70\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,//0x78\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,\r
-       HB_Script_Malayalam,//0x7f\r
-\r
-\r
-       HB_Script_Sinhala,//0x80\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x88\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0x90\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0x98\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xa8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xb0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xb8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xc0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xc8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xd8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xe0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-\r
-       HB_Script_Sinhala,//0xe8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf0\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,//0xf8\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,\r
-       HB_Script_Sinhala,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableThaiLao[]=\r
-{\r
-       HB_Script_Thai,//0x00\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x08\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x10\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x18\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x20\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x28\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x30\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x38\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x40\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x48\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x4f\r
-\r
-       HB_Script_Thai,//0x50\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x58\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x60\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x68\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-\r
-       HB_Script_Thai,//0x70\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,//0x78\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,\r
-       HB_Script_Thai,//0x7f\r
-\r
-\r
-       HB_Script_Lao,//0x80\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x88\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0x90\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0x98\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xa8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xb0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xb8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xc0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xc8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xd8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xe0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-\r
-       HB_Script_Lao,//0xe8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf0\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,//0xf8\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,\r
-       HB_Script_Lao,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableMyanGeorgian[] =\r
-{\r
-       HB_Script_Myanmar,//0x00\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x08\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x10\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x18\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x20\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x28\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x30\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x38\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x40\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x48\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x4f\r
-\r
-       HB_Script_Myanmar,//0x50\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x58\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x60\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x68\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x70\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x78\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,//0x7f\r
-\r
-\r
-       HB_Script_Myanmar,//0x80\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x88\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,//0x90\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-\r
-       HB_Script_Myanmar,//0x98\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-       HB_Script_Myanmar,\r
-\r
-       HB_Script_Georgian,//0xa0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xa8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xb0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xb8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xc0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xc8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xd8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xe0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-\r
-       HB_Script_Georgian,//0xe8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf0\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,//0xf8\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,\r
-       HB_Script_Georgian,//0xff\r
-\r
-};\r
-\r
-HB_Script subTableOghamRunic[] = \r
-{\r
-       HB_Script_Ogham,//0x00\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x08\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x10\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x18\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x20\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x28\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x30\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x38\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x40\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x48\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x4f\r
-\r
-       HB_Script_Ogham,//0x50\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x58\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x60\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x68\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x70\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x78\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,//0x7f\r
-\r
-\r
-       HB_Script_Ogham,//0x80\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x88\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,//0x90\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-\r
-       HB_Script_Ogham,//0x98\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-       HB_Script_Ogham,\r
-\r
-       HB_Script_Runic,//0xa0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xa8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xb0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xb8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xc0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xc8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xd8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xe0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-\r
-       HB_Script_Runic,//0xe8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf0\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,//0xf8\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,\r
-       HB_Script_Runic,//0xff\r
-\r
-};\r
-\r
-#define VFE_UNICODE_MAX_SCRIPT 256\r
-\r
-static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=\r
-{\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Greek, 0},\r
-\r
-       {HB_Script_Cyrillic, 0},//0x04\r
-       {HB_Script_Armenian, 0},\r
-       {HB_Script_Arabic, 0},\r
-       {0xc0, subTableThanaSyriac},\r
-\r
-       {HB_Script_Common, 0},//0x08\r
-       {0x100, subTableDevaBengali},\r
-       {0x100, subTableGuruGuarati},\r
-       {0x100, subTableOriyaTamil},\r
-       \r
-       {0x100, subTableTelukannada},//0x0c\r
-       {0x100, subTableMalSinhala},\r
-       {0x100, subTableThaiLao},\r
-       {HB_Script_Tibetan, 0},\r
-\r
-       {0x100, subTableMyanGeorgian},//0x10\r
-       {HB_Script_Hangul, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x14\r
-       {HB_Script_Common, 0},\r
-       {0x100, subTableOghamRunic},\r
-       {HB_Script_Khmer, 0},\r
-\r
-       {HB_Script_Common, 0},//0x18\r
-       {HB_Script_Khmer, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x1c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x20\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x24\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x28\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x2c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x30\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x34\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x38\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x3c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x44\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x48\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x4c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x50\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x54\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x58\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x5c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x60\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x64\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x68\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x6c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x70\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x74\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x78\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x7c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x80\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x84\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x88\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x8c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x40\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x94\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x98\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0x9c\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xa8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xac\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xb8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xbc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xc8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xcc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xd8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xdc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xe8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xec\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf0\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf4\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xf8\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-\r
-       {HB_Script_Common, 0},//0xfc\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},\r
-       {HB_Script_Common, 0},//ff\r
-};\r
-\r
-#endif /* __hb_unicode_tables_h__ */\r
-\r
+
+/*
+ * Copyright (C) 2010  Samsung India Software Operations Pvt. Ltd.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#ifndef __hb_unicode_tables_h__
+#define __hb_unicode_tables_h__
+
+#include "math.h"
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+typedef struct
+{
+       HB_UShort scriptID;//it can be sript id if subtable is null, else size of subtable
+       HB_Script *pSubTable;
+
+}unicodeScriptTableStruct;
+
+HB_Script subTableThanaSyriac[] = 
+{
+       HB_Script_Syriac,//0x00
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x08
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x10
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x18
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x20
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x28
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x30
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x38
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,//0x40
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+
+       HB_Script_Syriac,//0x48
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,
+       HB_Script_Syriac,//0x4f
+
+       HB_Script_Common,//0x50
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x58
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x60
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x68
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x70
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,//0x78
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+       HB_Script_Common,
+
+       HB_Script_Thaana,//0x80
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x88
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x90
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0x98
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xa8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb0
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,//0xb8
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,
+       HB_Script_Thaana,//0xbf
+};
+
+HB_Script subTableDevaBengali[] = 
+{
+       HB_Script_Devanagari,//0x00
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x08
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x10
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x18
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x20
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x28
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x30
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x38
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x40
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x48
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x4f
+
+       HB_Script_Devanagari,//0x50
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x58
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x60
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x68
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+
+       HB_Script_Devanagari,//0x70
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,//0x78
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,
+       HB_Script_Devanagari,//0x7f
+
+
+       HB_Script_Bengali,//0x80
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x88
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0x90
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0x98
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xa8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xb0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xb8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xc0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xc8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xd8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xe0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+
+       HB_Script_Bengali,//0xe8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf0
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,//0xf8
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,
+       HB_Script_Bengali,//0xff
+
+};
+
+
+HB_Script subTableGuruGuarati[]=
+{
+       HB_Script_Gurmukhi,//0x00
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x08
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x10
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x18
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x20
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x28
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x30
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x38
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x40
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x48
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x4f
+
+       HB_Script_Gurmukhi,//0x50
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x58
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x60
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x68
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+
+       HB_Script_Gurmukhi,//0x70
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,//0x78
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,
+       HB_Script_Gurmukhi,//0x7f
+
+
+       HB_Script_Gujarati,//0x80
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x88
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0x90
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0x98
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xa8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xb0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xb8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xc0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xc8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xd8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xe0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+
+       HB_Script_Gujarati,//0xe8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf0
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,//0xf8
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,
+       HB_Script_Gujarati,//0xff
+
+};
+
+HB_Script subTableOriyaTamil[]=
+{
+       HB_Script_Oriya,//0x00
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x08
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x10
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x18
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x20
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x28
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x30
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x38
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x40
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x48
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x4f
+
+       HB_Script_Oriya,//0x50
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x58
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x60
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x68
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+
+       HB_Script_Oriya,//0x70
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,//0x78
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,
+       HB_Script_Oriya,//0x7f
+
+
+       HB_Script_Tamil,//0x80
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x88
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0x90
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0x98
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xa8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xb0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xb8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xc0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xc8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xd8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xe0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+
+       HB_Script_Tamil,//0xe8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf0
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,//0xf8
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,
+       HB_Script_Tamil,//0xff
+
+};
+
+
+HB_Script subTableTelukannada[]=
+{
+       HB_Script_Telugu,//0x00
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x08
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x10
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x18
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x20
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x28
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x30
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x38
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x40
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x48
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x4f
+
+       HB_Script_Telugu,//0x50
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x58
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x60
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x68
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+
+       HB_Script_Telugu,//0x70
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,//0x78
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,
+       HB_Script_Telugu,//0x7f
+
+
+       HB_Script_Kannada,//0x80
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x88
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0x90
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0x98
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xa8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xb0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xb8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xc0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xc8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xd8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xe0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+
+       HB_Script_Kannada,//0xe8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf0
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,//0xf8
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,
+       HB_Script_Kannada,//0xff
+
+};
+
+HB_Script subTableMalSinhala[]=
+{
+       HB_Script_Malayalam,//0x00
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x08
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x10
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x18
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x20
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x28
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x30
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x38
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x40
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x48
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x4f
+
+       HB_Script_Malayalam,//0x50
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x58
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x60
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x68
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+
+       HB_Script_Malayalam,//0x70
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,//0x78
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,
+       HB_Script_Malayalam,//0x7f
+
+
+       HB_Script_Sinhala,//0x80
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x88
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0x90
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0x98
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xa8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xb0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xb8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xc0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xc8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xd8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xe0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+
+       HB_Script_Sinhala,//0xe8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf0
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,//0xf8
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,
+       HB_Script_Sinhala,//0xff
+
+};
+
+HB_Script subTableThaiLao[]=
+{
+       HB_Script_Thai,//0x00
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x08
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x10
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x18
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x20
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x28
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x30
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x38
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x40
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x48
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x4f
+
+       HB_Script_Thai,//0x50
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x58
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x60
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x68
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+
+       HB_Script_Thai,//0x70
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,//0x78
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,
+       HB_Script_Thai,//0x7f
+
+
+       HB_Script_Lao,//0x80
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x88
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0x90
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0x98
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xa8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xb0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xb8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xc0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xc8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xd8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xe0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+
+       HB_Script_Lao,//0xe8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf0
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,//0xf8
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,
+       HB_Script_Lao,//0xff
+
+};
+
+HB_Script subTableMyanGeorgian[] =
+{
+       HB_Script_Myanmar,//0x00
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x08
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x10
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x18
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x20
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x28
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x30
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x38
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x40
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x48
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x4f
+
+       HB_Script_Myanmar,//0x50
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x58
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x60
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x68
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x70
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x78
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,//0x7f
+
+
+       HB_Script_Myanmar,//0x80
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x88
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,//0x90
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+
+       HB_Script_Myanmar,//0x98
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+       HB_Script_Myanmar,
+
+       HB_Script_Georgian,//0xa0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xa8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xb0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xb8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xc0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xc8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xd8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xe0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+
+       HB_Script_Georgian,//0xe8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf0
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,//0xf8
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,
+       HB_Script_Georgian,//0xff
+
+};
+
+HB_Script subTableOghamRunic[] = 
+{
+       HB_Script_Ogham,//0x00
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x08
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x10
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x18
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x20
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x28
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x30
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x38
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x40
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x48
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x4f
+
+       HB_Script_Ogham,//0x50
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x58
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x60
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x68
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x70
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x78
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,//0x7f
+
+
+       HB_Script_Ogham,//0x80
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x88
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,//0x90
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+
+       HB_Script_Ogham,//0x98
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+       HB_Script_Ogham,
+
+       HB_Script_Runic,//0xa0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xa8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xb0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xb8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xc0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xc8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xd8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xe0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+
+       HB_Script_Runic,//0xe8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf0
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,//0xf8
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,
+       HB_Script_Runic,//0xff
+
+};
+
+#define VFE_UNICODE_MAX_SCRIPT 256
+
+static const unicodeScriptTableStruct scriptTableStruct[VFE_UNICODE_MAX_SCRIPT]=
+{
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Greek, 0},
+
+       {HB_Script_Cyrillic, 0},//0x04
+       {HB_Script_Armenian, 0},
+       {HB_Script_Arabic, 0},
+       {0xc0, subTableThanaSyriac},
+
+       {HB_Script_Common, 0},//0x08
+       {0x100, subTableDevaBengali},
+       {0x100, subTableGuruGuarati},
+       {0x100, subTableOriyaTamil},
+       
+       {0x100, subTableTelukannada},//0x0c
+       {0x100, subTableMalSinhala},
+       {0x100, subTableThaiLao},
+       {HB_Script_Tibetan, 0},
+
+       {0x100, subTableMyanGeorgian},//0x10
+       {HB_Script_Hangul, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x14
+       {HB_Script_Common, 0},
+       {0x100, subTableOghamRunic},
+       {HB_Script_Khmer, 0},
+
+       {HB_Script_Common, 0},//0x18
+       {HB_Script_Khmer, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x1c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x20
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x24
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x28
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x2c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x30
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x34
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x38
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x3c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x44
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x48
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x4c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x50
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x54
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x58
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x5c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x60
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x64
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x68
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x6c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x70
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x74
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x78
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x7c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x80
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x84
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x88
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x8c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x40
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x94
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x98
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0x9c
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xa8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xac
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xb8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xbc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xc8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xcc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xd8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xdc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xe8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xec
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf0
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf4
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xf8
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+
+       {HB_Script_Common, 0},//0xfc
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},
+       {HB_Script_Common, 0},//ff
+};
+
+#endif /* __hb_unicode_tables_h__ */
+
index 6f9e9ad..e7130c7 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-\r
-static const HB_UChar16 ReplacementCharacter = 0xfffd;\r
-\r
-typedef struct {\r
-    unsigned char shape;\r
-    unsigned char justification;\r
-} HB_ArabicProperties;\r
-\r
-typedef enum {\r
-    XIsolated,\r
-    XFinal,\r
-    XInitial,\r
-    XMedial,\r
-    /* intermediate state */\r
-    XCausing\r
-} ArabicShape;\r
-\r
-/*\r
-// these groups correspond to the groups defined in the Unicode standard.\r
-// Some of these groups are equal with regards to both joining and line breaking behaviour,\r
-// and thus have the same enum value\r
-//\r
-// I'm not sure the mapping of syriac to arabic enums is correct with regards to justification, but as\r
-// I couldn't find any better document I'll hope for the best.\r
-*/\r
-typedef enum {\r
-    /* NonJoining */\r
-    ArabicNone,\r
-    ArabicSpace,\r
-    /* Transparent */\r
-    Transparent,\r
-    /* Causing */\r
-    Center,\r
-    Kashida,\r
-\r
-    /* Arabic */\r
-    /* Dual */\r
-    Beh,\r
-    Noon,\r
-    Meem = Noon,\r
-    Heh = Noon,\r
-    KnottedHeh = Noon,\r
-    HehGoal = Noon,\r
-    SwashKaf = Noon,\r
-    Yeh,\r
-    Hah,\r
-    Seen,\r
-    Sad = Seen,\r
-    Tah,\r
-    Kaf = Tah,\r
-    Gaf = Tah,\r
-    Lam = Tah,\r
-    Ain,\r
-    Feh = Ain,\r
-    Qaf = Ain,\r
-    /* Right */\r
-    Alef,\r
-    Waw,\r
-    Dal,\r
-    TehMarbuta = Dal,\r
-    Reh,\r
-    HamzaOnHehGoal,\r
-    YehWithTail = HamzaOnHehGoal,\r
-    YehBarre = HamzaOnHehGoal,\r
-\r
-    /* Syriac */\r
-    /* Dual */\r
-    Beth = Beh,\r
-    Gamal = Ain,\r
-    Heth = Noon,\r
-    Teth = Hah,\r
-    Yudh = Noon,\r
-    Kaph = Noon,\r
-    Lamadh = Lam,\r
-    Mim = Noon,\r
-    Nun = Noon,\r
-    Semakh = Noon,\r
-    FinalSemakh = Noon,\r
-    SyriacE = Ain,\r
-    Pe = Ain,\r
-    ReversedPe = Hah,\r
-    Qaph = Noon,\r
-    Shin = Noon,\r
-    Fe = Ain,\r
-\r
-    /* Right */\r
-    Alaph = Alef,\r
-    Dalath = Dal,\r
-    He = Dal,\r
-    SyriacWaw = Waw,\r
-    Zain = Alef,\r
-    YudhHe = Waw,\r
-    Sadhe = HamzaOnHehGoal,\r
-    Taw = Dal,\r
-\r
-    /* Compiler bug? Otherwise ArabicGroupsEnd would be equal to Dal + 1. */\r
-    Dummy = HamzaOnHehGoal,\r
-    ArabicGroupsEnd\r
-} ArabicGroup;\r
-\r
-static const unsigned char arabic_group[0x150] = {\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-\r
-    ArabicNone, ArabicNone, Alef, Alef,\r
-    Waw, Alef, Yeh, Alef,\r
-    Beh, TehMarbuta, Beh, Beh,\r
-    Hah, Hah, Hah, Dal,\r
-\r
-    Dal, Reh, Reh, Seen,\r
-    Seen, Sad, Sad, Tah,\r
-    Tah, Ain, Ain, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-\r
-    /* 0x640 */\r
-    Kashida, Feh, Qaf, Kaf,\r
-    Lam, Meem, Noon, Heh,\r
-    Waw, Yeh, Yeh, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, Beh, Qaf,\r
-\r
-    Transparent, Alef, Alef, Alef,\r
-    ArabicNone, Alef, Waw, Waw,\r
-    Yeh, Beh, Beh, Beh,\r
-    Beh, Beh, Beh, Beh,\r
-\r
-    /* 0x680 */\r
-    Beh, Hah, Hah, Hah,\r
-    Hah, Hah, Hah, Hah,\r
-    Dal, Dal, Dal, Dal,\r
-    Dal, Dal, Dal, Dal,\r
-\r
-    Dal, Reh, Reh, Reh,\r
-    Reh, Reh, Reh, Reh,\r
-    Reh, Reh, Seen, Seen,\r
-    Seen, Sad, Sad, Tah,\r
-\r
-    Ain, Feh, Feh, Feh,\r
-    Feh, Feh, Feh, Qaf,\r
-    Qaf, Gaf, SwashKaf, Gaf,\r
-    Kaf, Kaf, Kaf, Gaf,\r
-\r
-    Gaf, Gaf, Gaf, Gaf,\r
-    Gaf, Lam, Lam, Lam,\r
-    Lam, Noon, Noon, Noon,\r
-    Noon, Noon, KnottedHeh, Hah,\r
-\r
-    /* 0x6c0 */\r
-    TehMarbuta, HehGoal, HamzaOnHehGoal, HamzaOnHehGoal,\r
-    Waw, Waw, Waw, Waw,\r
-    Waw, Waw, Waw, Waw,\r
-    Yeh, YehWithTail, Yeh, Waw,\r
-\r
-    Yeh, Yeh, YehBarre, YehBarre,\r
-    ArabicNone, TehMarbuta, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, ArabicNone, ArabicNone, Transparent,\r
-\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, ArabicNone, ArabicNone, Transparent,\r
-    Transparent, ArabicNone, Transparent, Transparent,\r
-    Transparent, Transparent, Dal, Reh,\r
-\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, Seen, Sad,\r
-    Ain, ArabicNone, ArabicNone, KnottedHeh,\r
-\r
-    /* 0x700 */\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-    ArabicNone, ArabicNone, ArabicNone, ArabicNone,\r
-\r
-    Alaph, Transparent, Beth, Gamal,\r
-    Gamal, Dalath, Dalath, He,\r
-    SyriacWaw, Zain, Heth, Teth,\r
-    Teth, Yudh, YudhHe, Kaph,\r
-\r
-    Lamadh, Mim, Nun, Semakh,\r
-    FinalSemakh, SyriacE, Pe, ReversedPe,\r
-    Sadhe, Qaph, Dalath, Shin,\r
-    Taw, Beth, Gamal, Dalath,\r
-\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, Transparent,\r
-    Transparent, Transparent, Transparent, ArabicNone,\r
-    ArabicNone, Zain, Kaph, Fe,\r
-};\r
-\r
-static ArabicGroup arabicGroup(unsigned short uc)\r
-{\r
-    if (uc >= 0x0600 && uc < 0x750)\r
-        return (ArabicGroup) arabic_group[uc-0x600];\r
-    else if (uc == 0x200d)\r
-        return Center;\r
-    else if (HB_GetUnicodeCharCategory(uc) == HB_Separator_Space)\r
-        return ArabicSpace;\r
-    else\r
-        return ArabicNone;\r
-}\r
-\r
-\r
-/*\r
-   Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on\r
-   arabic).\r
-\r
-   Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent).\r
-   transparent joining is not encoded in HB_UChar16::joining(), but applies to all combining marks and format marks.\r
-\r
-   Right join-causing: dual + center\r
-   Left join-causing: dual + right + center\r
-\r
-   Rules are as follows (for a string already in visual order, as we have it here):\r
-\r
-   R1 Transparent characters do not affect joining behaviour.\r
-   R2 A right joining character, that has a right join-causing char on the right will get form XRight\r
-   (R3 A left joining character, that has a left join-causing char on the left will get form XLeft)\r
-   Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode\r
-   R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on\r
-             the right will get form XMedial\r
-   R5  A dual joining character, that has a right join causing char on the right, and no left join causing char on the left\r
-         will get form XRight\r
-   R6 A dual joining character, that has a  left join causing char on the left, and no right join causing char on the right\r
-         will get form XLeft\r
-   R7 Otherwise the character will get form XIsolated\r
-\r
-   Additionally we have to do the minimal ligature support for lam-alef ligatures:\r
-\r
-   L1 Transparent characters do not affect ligature behaviour.\r
-   L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft)\r
-   L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated)\r
-\r
-   The state table below handles rules R1-R7.\r
-*/\r
-\r
-typedef enum {\r
-    JNone,\r
-    JCausing,\r
-    JDual,\r
-    JRight,\r
-    JTransparent\r
-} Joining;\r
-\r
-static const Joining joining_for_group[ArabicGroupsEnd] = {\r
-    /* NonJoining */\r
-    JNone, /* ArabicNone */\r
-    JNone, /* ArabicSpace */\r
-    /* Transparent */\r
-    JTransparent, /* Transparent */\r
-    /* Causing */\r
-    JCausing, /* Center */\r
-    JCausing, /* Kashida */\r
-    /* Dual */\r
-    JDual, /* Beh */\r
-    JDual, /* Noon */\r
-    JDual, /* Yeh */\r
-    JDual, /* Hah */\r
-    JDual, /* Seen */\r
-    JDual, /* Tah */\r
-    JDual, /* Ain */\r
-    /* Right */\r
-    JRight, /* Alef */\r
-    JRight, /* Waw */\r
-    JRight, /* Dal */\r
-    JRight, /* Reh */\r
-    JRight  /* HamzaOnHehGoal */\r
-};\r
-\r
-\r
-typedef struct {\r
-    ArabicShape form1;\r
-    ArabicShape form2;\r
-} JoiningPair;\r
-\r
-static const JoiningPair joining_table[5][4] =\r
-/* None, Causing, Dual, Right */\r
-{\r
-    { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XInitial }, { XIsolated, XIsolated } }, /* XIsolated */\r
-    { { XFinal, XIsolated }, { XFinal, XCausing }, { XFinal, XInitial }, { XFinal, XIsolated } }, /* XFinal */\r
-    { { XIsolated, XIsolated }, { XInitial, XCausing }, { XInitial, XMedial }, { XInitial, XFinal } }, /* XInitial */\r
-    { { XFinal, XIsolated }, { XMedial, XCausing }, { XMedial, XMedial }, { XMedial, XFinal } }, /* XMedial */\r
-    { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XMedial }, { XIsolated, XFinal } }, /* XCausing */\r
-};\r
-\r
-\r
-/*\r
-According to http://www.microsoft.com/middleeast/Arabicdev/IE6/KBase.asp\r
-\r
-1. Find the priority of the connecting opportunities in each word\r
-2. Add expansion at the highest priority connection opportunity\r
-3. If more than one connection opportunity have the same highest value,\r
-   use the opportunity closest to the end of the word.\r
-\r
-Following is a chart that provides the priority for connection\r
-opportunities and where expansion occurs. The character group names\r
-are those in table 6.6 of the UNICODE 2.0 book.\r
-\r
-\r
-PrioritY        Glyph                   Condition                                       Kashida Location\r
-\r
-Arabic_Kashida        User inserted Kashida   The user entered a Kashida in a position.       After the user\r
-                (Shift+j or Shift+[E with hat])    Thus, it is the highest priority to insert an   inserted kashida\r
-                                        automatic kashida.\r
-\r
-Arabic_Seen        Seen, Sad               Connecting to the next character.               After the character.\r
-                                        (Initial or medial form).\r
-\r
-Arabic_HaaDal        Teh Marbutah, Haa, Dal  Connecting to previous character.               Before the final form\r
-                                                                                        of these characters.\r
-\r
-Arabic_Alef     Alef, Tah, Lam,         Connecting to previous character.               Before the final form\r
-                Kaf and Gaf                                                             of these characters.\r
-\r
-Arabic_BaRa     Reh, Yeh                Connected to medial Beh                         Before preceding medial Baa\r
-\r
-Arabic_Waw        Waw, Ain, Qaf, Feh      Connecting to previous character.               Before the final form of\r
-                                                                                        these characters.\r
-\r
-Arabic_Normal   Other connecting        Connecting to previous character.               Before the final form\r
-                characters                                                              of these characters.\r
-\r
-\r
-\r
-This seems to imply that we have at most one kashida point per arabic word.\r
-\r
-*/\r
-\r
-static void getArabicProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties)\r
-{\r
-/*     qDebug("arabicSyriacOpenTypeShape: properties:"); */\r
-    int lastPos = 0;\r
-    int lastGroup = ArabicNone;\r
-    int i = 0;\r
-\r
-    ArabicGroup group = arabicGroup(chars[0]);\r
-    Joining j = joining_for_group[group];\r
-    ArabicShape shape = joining_table[XIsolated][j].form2;\r
-    properties[0].justification = HB_NoJustification;\r
-\r
-    for (i = 1; i < len; ++i) {\r
-        /* #### fix handling for spaces and punktuation */\r
-        properties[i].justification = HB_NoJustification;\r
-\r
-        group = arabicGroup(chars[i]);\r
-        j = joining_for_group[group];\r
-\r
-        if (j == JTransparent) {\r
-            properties[i].shape = XIsolated;\r
-            continue;\r
-        }\r
-\r
-        properties[lastPos].shape = joining_table[shape][j].form1;\r
-        shape = joining_table[shape][j].form2;\r
-\r
-        switch(lastGroup) {\r
-        case Seen:\r
-            if (properties[lastPos].shape == XInitial || properties[lastPos].shape == XMedial)\r
-                properties[i-1].justification = HB_Arabic_Seen;\r
-            break;\r
-        case Hah:\r
-            if (properties[lastPos].shape == XFinal)\r
-                properties[lastPos-1].justification = HB_Arabic_HaaDal;\r
-            break;\r
-        case Alef:\r
-            if (properties[lastPos].shape == XFinal)\r
-                properties[lastPos-1].justification = HB_Arabic_Alef;\r
-            break;\r
-        case Ain:\r
-            if (properties[lastPos].shape == XFinal)\r
-                properties[lastPos-1].justification = HB_Arabic_Waw;\r
-            break;\r
-        case Noon:\r
-            if (properties[lastPos].shape == XFinal)\r
-                properties[lastPos-1].justification = HB_Arabic_Normal;\r
-            break;\r
-        case ArabicNone:\r
-            break;\r
-\r
-        default:\r
-            assert(FALSE);\r
-        }\r
-\r
-        lastGroup = ArabicNone;\r
-\r
-        switch(group) {\r
-        case ArabicNone:\r
-        case Transparent:\r
-        /* ### Center should probably be treated as transparent when it comes to justification. */\r
-        case Center:\r
-            break;\r
-        case ArabicSpace:\r
-            properties[i].justification = HB_Arabic_Space;\r
-            break;\r
-        case Kashida:\r
-            properties[i].justification = HB_Arabic_Kashida;\r
-            break;\r
-        case Seen:\r
-            lastGroup = Seen;\r
-            break;\r
-\r
-        case Hah:\r
-        case Dal:\r
-            lastGroup = Hah;\r
-            break;\r
-\r
-        case Alef:\r
-        case Tah:\r
-            lastGroup = Alef;\r
-            break;\r
-\r
-        case Yeh:\r
-        case Reh:\r
-            if (properties[lastPos].shape == XMedial && arabicGroup(chars[lastPos]) == Beh)\r
-                properties[lastPos-1].justification = HB_Arabic_BaRa;\r
-            break;\r
-\r
-        case Ain:\r
-        case Waw:\r
-            lastGroup = Ain;\r
-            break;\r
-\r
-        case Noon:\r
-        case Beh:\r
-        case HamzaOnHehGoal:\r
-            lastGroup = Noon;\r
-            break;\r
-        case ArabicGroupsEnd:\r
-            assert(FALSE);\r
-        }\r
-\r
-        lastPos = i;\r
-    }\r
-    properties[lastPos].shape = joining_table[shape][JNone].form1;\r
-\r
-\r
-    /*\r
-     for (int i = 0; i < len; ++i)\r
-         qDebug("arabic properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);\r
-    */\r
-}\r
-\r
-static Joining getNkoJoining(unsigned short uc)\r
-{\r
-    if (uc < 0x7ca)\r
-        return JNone;\r
-    if (uc <= 0x7ea)\r
-        return JDual;\r
-    if (uc <= 0x7f3)\r
-        return JTransparent;\r
-    if (uc <= 0x7f9)\r
-        return JNone;\r
-    if (uc == 0x7fa)\r
-        return JCausing;\r
-    return JNone;\r
-}\r
-\r
-static void getNkoProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties)\r
-{\r
-    int lastPos = 0;\r
-    int i = 0;\r
-\r
-    Joining j = getNkoJoining(chars[0]);\r
-    ArabicShape shape = joining_table[XIsolated][j].form2;\r
-    properties[0].justification = HB_NoJustification;\r
-\r
-    for (i = 1; i < len; ++i) {\r
-        properties[i].justification = (HB_GetUnicodeCharCategory(chars[i]) == HB_Separator_Space) ?\r
-                                      ArabicSpace : ArabicNone;\r
-\r
-        j = getNkoJoining(chars[i]);\r
-\r
-        if (j == JTransparent) {\r
-            properties[i].shape = XIsolated;\r
-            continue;\r
-        }\r
-\r
-        properties[lastPos].shape = joining_table[shape][j].form1;\r
-        shape = joining_table[shape][j].form2;\r
-\r
-\r
-        lastPos = i;\r
-    }\r
-    properties[lastPos].shape = joining_table[shape][JNone].form1;\r
-\r
-\r
-    /*\r
-     for (int i = 0; i < len; ++i)\r
-         qDebug("nko properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);\r
-    */\r
-}\r
-\r
-/*\r
-// The unicode to unicode shaping codec.\r
-// does only presentation forms B at the moment, but that should be enough for\r
-// simple display\r
-*/\r
-static const hb_uint16 arabicUnicodeMapping[256][2] = {\r
-    /* base of shaped forms, and number-1 of them (0 for non shaping,\r
-       1 for right binding and 3 for dual binding */\r
-\r
-    /* These are just the glyphs available in Unicode,\r
-       some characters are in R class, but have no glyphs in Unicode. */\r
-\r
-    { 0x0600, 0 }, /* 0x0600 */\r
-    { 0x0601, 0 }, /* 0x0601 */\r
-    { 0x0602, 0 }, /* 0x0602 */\r
-    { 0x0603, 0 }, /* 0x0603 */\r
-    { 0x0604, 0 }, /* 0x0604 */\r
-    { 0x0605, 0 }, /* 0x0605 */\r
-    { 0x0606, 0 }, /* 0x0606 */\r
-    { 0x0607, 0 }, /* 0x0607 */\r
-    { 0x0608, 0 }, /* 0x0608 */\r
-    { 0x0609, 0 }, /* 0x0609 */\r
-    { 0x060A, 0 }, /* 0x060A */\r
-    { 0x060B, 0 }, /* 0x060B */\r
-    { 0x060C, 0 }, /* 0x060C */\r
-    { 0x060D, 0 }, /* 0x060D */\r
-    { 0x060E, 0 }, /* 0x060E */\r
-    { 0x060F, 0 }, /* 0x060F */\r
-\r
-    { 0x0610, 0 }, /* 0x0610 */\r
-    { 0x0611, 0 }, /* 0x0611 */\r
-    { 0x0612, 0 }, /* 0x0612 */\r
-    { 0x0613, 0 }, /* 0x0613 */\r
-    { 0x0614, 0 }, /* 0x0614 */\r
-    { 0x0615, 0 }, /* 0x0615 */\r
-    { 0x0616, 0 }, /* 0x0616 */\r
-    { 0x0617, 0 }, /* 0x0617 */\r
-    { 0x0618, 0 }, /* 0x0618 */\r
-    { 0x0619, 0 }, /* 0x0619 */\r
-    { 0x061A, 0 }, /* 0x061A */\r
-    { 0x061B, 0 }, /* 0x061B */\r
-    { 0x061C, 0 }, /* 0x061C */\r
-    { 0x061D, 0 }, /* 0x061D */\r
-    { 0x061E, 0 }, /* 0x061E */\r
-    { 0x061F, 0 }, /* 0x061F */\r
-\r
-    { 0x0620, 0 }, /* 0x0620 */\r
-    { 0xFE80, 0 }, /* 0x0621            HAMZA */\r
-    { 0xFE81, 1 }, /* 0x0622    R       ALEF WITH MADDA ABOVE */\r
-    { 0xFE83, 1 }, /* 0x0623    R       ALEF WITH HAMZA ABOVE */\r
-    { 0xFE85, 1 }, /* 0x0624    R       WAW WITH HAMZA ABOVE */\r
-    { 0xFE87, 1 }, /* 0x0625    R       ALEF WITH HAMZA BELOW */\r
-    { 0xFE89, 3 }, /* 0x0626    D       YEH WITH HAMZA ABOVE */\r
-    { 0xFE8D, 1 }, /* 0x0627    R       ALEF */\r
-    { 0xFE8F, 3 }, /* 0x0628    D       BEH */\r
-    { 0xFE93, 1 }, /* 0x0629    R       TEH MARBUTA */\r
-    { 0xFE95, 3 }, /* 0x062A    D       TEH */\r
-    { 0xFE99, 3 }, /* 0x062B    D       THEH */\r
-    { 0xFE9D, 3 }, /* 0x062C    D       JEEM */\r
-    { 0xFEA1, 3 }, /* 0x062D    D       HAH */\r
-    { 0xFEA5, 3 }, /* 0x062E    D       KHAH */\r
-    { 0xFEA9, 1 }, /* 0x062F    R       DAL */\r
-\r
-    { 0xFEAB, 1 }, /* 0x0630    R       THAL */\r
-    { 0xFEAD, 1 }, /* 0x0631    R       REH */\r
-    { 0xFEAF, 1 }, /* 0x0632    R       ZAIN */\r
-    { 0xFEB1, 3 }, /* 0x0633    D       SEEN */\r
-    { 0xFEB5, 3 }, /* 0x0634    D       SHEEN */\r
-    { 0xFEB9, 3 }, /* 0x0635    D       SAD */\r
-    { 0xFEBD, 3 }, /* 0x0636    D       DAD */\r
-    { 0xFEC1, 3 }, /* 0x0637    D       TAH */\r
-    { 0xFEC5, 3 }, /* 0x0638    D       ZAH */\r
-    { 0xFEC9, 3 }, /* 0x0639    D       AIN */\r
-    { 0xFECD, 3 }, /* 0x063A    D       GHAIN */\r
-    { 0x063B, 0 }, /* 0x063B */\r
-    { 0x063C, 0 }, /* 0x063C */\r
-    { 0x063D, 0 }, /* 0x063D */\r
-    { 0x063E, 0 }, /* 0x063E */\r
-    { 0x063F, 0 }, /* 0x063F */\r
-\r
-    { 0x0640, 0 }, /* 0x0640    C       TATWEEL // ### Join Causing, only one glyph */\r
-    { 0xFED1, 3 }, /* 0x0641    D       FEH */\r
-    { 0xFED5, 3 }, /* 0x0642    D       QAF */\r
-    { 0xFED9, 3 }, /* 0x0643    D       KAF */\r
-    { 0xFEDD, 3 }, /* 0x0644    D       LAM */\r
-    { 0xFEE1, 3 }, /* 0x0645    D       MEEM */\r
-    { 0xFEE5, 3 }, /* 0x0646    D       NOON */\r
-    { 0xFEE9, 3 }, /* 0x0647    D       HEH */\r
-    { 0xFEED, 1 }, /* 0x0648    R       WAW */\r
-    { 0x0649, 3 }, /* 0x0649            ALEF MAKSURA // ### Dual, glyphs not consecutive, handle in code. */\r
-    { 0xFEF1, 3 }, /* 0x064A    D       YEH */\r
-    { 0x064B, 0 }, /* 0x064B */\r
-    { 0x064C, 0 }, /* 0x064C */\r
-    { 0x064D, 0 }, /* 0x064D */\r
-    { 0x064E, 0 }, /* 0x064E */\r
-    { 0x064F, 0 }, /* 0x064F */\r
-\r
-    { 0x0650, 0 }, /* 0x0650 */\r
-    { 0x0651, 0 }, /* 0x0651 */\r
-    { 0x0652, 0 }, /* 0x0652 */\r
-    { 0x0653, 0 }, /* 0x0653 */\r
-    { 0x0654, 0 }, /* 0x0654 */\r
-    { 0x0655, 0 }, /* 0x0655 */\r
-    { 0x0656, 0 }, /* 0x0656 */\r
-    { 0x0657, 0 }, /* 0x0657 */\r
-    { 0x0658, 0 }, /* 0x0658 */\r
-    { 0x0659, 0 }, /* 0x0659 */\r
-    { 0x065A, 0 }, /* 0x065A */\r
-    { 0x065B, 0 }, /* 0x065B */\r
-    { 0x065C, 0 }, /* 0x065C */\r
-    { 0x065D, 0 }, /* 0x065D */\r
-    { 0x065E, 0 }, /* 0x065E */\r
-    { 0x065F, 0 }, /* 0x065F */\r
-\r
-    { 0x0660, 0 }, /* 0x0660 */\r
-    { 0x0661, 0 }, /* 0x0661 */\r
-    { 0x0662, 0 }, /* 0x0662 */\r
-    { 0x0663, 0 }, /* 0x0663 */\r
-    { 0x0664, 0 }, /* 0x0664 */\r
-    { 0x0665, 0 }, /* 0x0665 */\r
-    { 0x0666, 0 }, /* 0x0666 */\r
-    { 0x0667, 0 }, /* 0x0667 */\r
-    { 0x0668, 0 }, /* 0x0668 */\r
-    { 0x0669, 0 }, /* 0x0669 */\r
-    { 0x066A, 0 }, /* 0x066A */\r
-    { 0x066B, 0 }, /* 0x066B */\r
-    { 0x066C, 0 }, /* 0x066C */\r
-    { 0x066D, 0 }, /* 0x066D */\r
-    { 0x066E, 0 }, /* 0x066E */\r
-    { 0x066F, 0 }, /* 0x066F */\r
-\r
-    { 0x0670, 0 }, /* 0x0670 */\r
-    { 0xFB50, 1 }, /* 0x0671    R       ALEF WASLA */\r
-    { 0x0672, 0 }, /* 0x0672 */\r
-    { 0x0673, 0 }, /* 0x0673 */\r
-    { 0x0674, 0 }, /* 0x0674 */\r
-    { 0x0675, 0 }, /* 0x0675 */\r
-    { 0x0676, 0 }, /* 0x0676 */\r
-    { 0x0677, 0 }, /* 0x0677 */\r
-    { 0x0678, 0 }, /* 0x0678 */\r
-    { 0xFB66, 3 }, /* 0x0679    D       TTEH */\r
-    { 0xFB5E, 3 }, /* 0x067A    D       TTEHEH */\r
-    { 0xFB52, 3 }, /* 0x067B    D       BEEH */\r
-    { 0x067C, 0 }, /* 0x067C */\r
-    { 0x067D, 0 }, /* 0x067D */\r
-    { 0xFB56, 3 }, /* 0x067E    D       PEH */\r
-    { 0xFB62, 3 }, /* 0x067F    D       TEHEH */\r
-\r
-    { 0xFB5A, 3 }, /* 0x0680    D       BEHEH */\r
-    { 0x0681, 0 }, /* 0x0681 */\r
-    { 0x0682, 0 }, /* 0x0682 */\r
-    { 0xFB76, 3 }, /* 0x0683    D       NYEH */\r
-    { 0xFB72, 3 }, /* 0x0684    D       DYEH */\r
-    { 0x0685, 0 }, /* 0x0685 */\r
-    { 0xFB7A, 3 }, /* 0x0686    D       TCHEH */\r
-    { 0xFB7E, 3 }, /* 0x0687    D       TCHEHEH */\r
-    { 0xFB88, 1 }, /* 0x0688    R       DDAL */\r
-    { 0x0689, 0 }, /* 0x0689 */\r
-    { 0x068A, 0 }, /* 0x068A */\r
-    { 0x068B, 0 }, /* 0x068B */\r
-    { 0xFB84, 1 }, /* 0x068C    R       DAHAL */\r
-    { 0xFB82, 1 }, /* 0x068D    R       DDAHAL */\r
-    { 0xFB86, 1 }, /* 0x068E    R       DUL */\r
-    { 0x068F, 0 }, /* 0x068F */\r
-\r
-    { 0x0690, 0 }, /* 0x0690 */\r
-    { 0xFB8C, 1 }, /* 0x0691    R       RREH */\r
-    { 0x0692, 0 }, /* 0x0692 */\r
-    { 0x0693, 0 }, /* 0x0693 */\r
-    { 0x0694, 0 }, /* 0x0694 */\r
-    { 0x0695, 0 }, /* 0x0695 */\r
-    { 0x0696, 0 }, /* 0x0696 */\r
-    { 0x0697, 0 }, /* 0x0697 */\r
-    { 0xFB8A, 1 }, /* 0x0698    R       JEH */\r
-    { 0x0699, 0 }, /* 0x0699 */\r
-    { 0x069A, 0 }, /* 0x069A */\r
-    { 0x069B, 0 }, /* 0x069B */\r
-    { 0x069C, 0 }, /* 0x069C */\r
-    { 0x069D, 0 }, /* 0x069D */\r
-    { 0x069E, 0 }, /* 0x069E */\r
-    { 0x069F, 0 }, /* 0x069F */\r
-\r
-    { 0x06A0, 0 }, /* 0x06A0 */\r
-    { 0x06A1, 0 }, /* 0x06A1 */\r
-    { 0x06A2, 0 }, /* 0x06A2 */\r
-    { 0x06A3, 0 }, /* 0x06A3 */\r
-    { 0xFB6A, 3 }, /* 0x06A4    D       VEH */\r
-    { 0x06A5, 0 }, /* 0x06A5 */\r
-    { 0xFB6E, 3 }, /* 0x06A6    D       PEHEH */\r
-    { 0x06A7, 0 }, /* 0x06A7 */\r
-    { 0x06A8, 0 }, /* 0x06A8 */\r
-    { 0xFB8E, 3 }, /* 0x06A9    D       KEHEH */\r
-    { 0x06AA, 0 }, /* 0x06AA */\r
-    { 0x06AB, 0 }, /* 0x06AB */\r
-    { 0x06AC, 0 }, /* 0x06AC */\r
-    { 0xFBD3, 3 }, /* 0x06AD    D       NG */\r
-    { 0x06AE, 0 }, /* 0x06AE */\r
-    { 0xFB92, 3 }, /* 0x06AF    D       GAF */\r
-\r
-    { 0x06B0, 0 }, /* 0x06B0 */\r
-    { 0xFB9A, 3 }, /* 0x06B1    D       NGOEH */\r
-    { 0x06B2, 0 }, /* 0x06B2 */\r
-    { 0xFB96, 3 }, /* 0x06B3    D       GUEH */\r
-    { 0x06B4, 0 }, /* 0x06B4 */\r
-    { 0x06B5, 0 }, /* 0x06B5 */\r
-    { 0x06B6, 0 }, /* 0x06B6 */\r
-    { 0x06B7, 0 }, /* 0x06B7 */\r
-    { 0x06B8, 0 }, /* 0x06B8 */\r
-    { 0x06B9, 0 }, /* 0x06B9 */\r
-    { 0xFB9E, 1 }, /* 0x06BA    R       NOON GHUNNA */\r
-    { 0xFBA0, 3 }, /* 0x06BB    D       RNOON */\r
-    { 0x06BC, 0 }, /* 0x06BC */\r
-    { 0x06BD, 0 }, /* 0x06BD */\r
-    { 0xFBAA, 3 }, /* 0x06BE    D       HEH DOACHASHMEE */\r
-    { 0x06BF, 0 }, /* 0x06BF */\r
-\r
-    { 0xFBA4, 1 }, /* 0x06C0    R       HEH WITH YEH ABOVE */\r
-    { 0xFBA6, 3 }, /* 0x06C1    D       HEH GOAL */\r
-    { 0x06C2, 0 }, /* 0x06C2 */\r
-    { 0x06C3, 0 }, /* 0x06C3 */\r
-    { 0x06C4, 0 }, /* 0x06C4 */\r
-    { 0xFBE0, 1 }, /* 0x06C5    R       KIRGHIZ OE */\r
-    { 0xFBD9, 1 }, /* 0x06C6    R       OE */\r
-    { 0xFBD7, 1 }, /* 0x06C7    R       U */\r
-    { 0xFBDB, 1 }, /* 0x06C8    R       YU */\r
-    { 0xFBE2, 1 }, /* 0x06C9    R       KIRGHIZ YU */\r
-    { 0x06CA, 0 }, /* 0x06CA */\r
-    { 0xFBDE, 1 }, /* 0x06CB    R       VE */\r
-    { 0xFBFC, 3 }, /* 0x06CC    D       FARSI YEH */\r
-    { 0x06CD, 0 }, /* 0x06CD */\r
-    { 0x06CE, 0 }, /* 0x06CE */\r
-    { 0x06CF, 0 }, /* 0x06CF */\r
-\r
-    { 0xFBE4, 3 }, /* 0x06D0    D       E */\r
-    { 0x06D1, 0 }, /* 0x06D1 */\r
-    { 0xFBAE, 1 }, /* 0x06D2    R       YEH BARREE */\r
-    { 0xFBB0, 1 }, /* 0x06D3    R       YEH BARREE WITH HAMZA ABOVE */\r
-    { 0x06D4, 0 }, /* 0x06D4 */\r
-    { 0x06D5, 0 }, /* 0x06D5 */\r
-    { 0x06D6, 0 }, /* 0x06D6 */\r
-    { 0x06D7, 0 }, /* 0x06D7 */\r
-    { 0x06D8, 0 }, /* 0x06D8 */\r
-    { 0x06D9, 0 }, /* 0x06D9 */\r
-    { 0x06DA, 0 }, /* 0x06DA */\r
-    { 0x06DB, 0 }, /* 0x06DB */\r
-    { 0x06DC, 0 }, /* 0x06DC */\r
-    { 0x06DD, 0 }, /* 0x06DD */\r
-    { 0x06DE, 0 }, /* 0x06DE */\r
-    { 0x06DF, 0 }, /* 0x06DF */\r
-\r
-    { 0x06E0, 0 }, /* 0x06E0 */\r
-    { 0x06E1, 0 }, /* 0x06E1 */\r
-    { 0x06E2, 0 }, /* 0x06E2 */\r
-    { 0x06E3, 0 }, /* 0x06E3 */\r
-    { 0x06E4, 0 }, /* 0x06E4 */\r
-    { 0x06E5, 0 }, /* 0x06E5 */\r
-    { 0x06E6, 0 }, /* 0x06E6 */\r
-    { 0x06E7, 0 }, /* 0x06E7 */\r
-    { 0x06E8, 0 }, /* 0x06E8 */\r
-    { 0x06E9, 0 }, /* 0x06E9 */\r
-    { 0x06EA, 0 }, /* 0x06EA */\r
-    { 0x06EB, 0 }, /* 0x06EB */\r
-    { 0x06EC, 0 }, /* 0x06EC */\r
-    { 0x06ED, 0 }, /* 0x06ED */\r
-    { 0x06EE, 0 }, /* 0x06EE */\r
-    { 0x06EF, 0 }, /* 0x06EF */\r
-\r
-    { 0x06F0, 0 }, /* 0x06F0 */\r
-    { 0x06F1, 0 }, /* 0x06F1 */\r
-    { 0x06F2, 0 }, /* 0x06F2 */\r
-    { 0x06F3, 0 }, /* 0x06F3 */\r
-    { 0x06F4, 0 }, /* 0x06F4 */\r
-    { 0x06F5, 0 }, /* 0x06F5 */\r
-    { 0x06F6, 0 }, /* 0x06F6 */\r
-    { 0x06F7, 0 }, /* 0x06F7 */\r
-    { 0x06F8, 0 }, /* 0x06F8 */\r
-    { 0x06F9, 0 }, /* 0x06F9 */\r
-    { 0x06FA, 0 }, /* 0x06FA */\r
-    { 0x06FB, 0 }, /* 0x06FB */\r
-    { 0x06FC, 0 }, /* 0x06FC */\r
-    { 0x06FD, 0 }, /* 0x06FD */\r
-    { 0x06FE, 0 }, /* 0x06FE */\r
-    { 0x06FF, 0 }  /* 0x06FF */\r
-};\r
-\r
-/* the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, this table does */\r
-static const hb_uint16 alefMaksura[4] = {0xFEEF, 0xFEF0, 0xFBE8, 0xFBE9};\r
-\r
-/*\r
-// this is a bit tricky. Alef always binds to the right, so the second parameter descibing the shape\r
-// of the lam can be either initial of medial. So initial maps to the isolated form of the ligature,\r
-// medial to the final form\r
-*/\r
-static const hb_uint16 arabicUnicodeLamAlefMapping[6][4] = {\r
-    { 0xfffd, 0xfffd, 0xfef5, 0xfef6 }, /* 0x622        R       Alef with Madda above */\r
-    { 0xfffd, 0xfffd, 0xfef7, 0xfef8 }, /* 0x623        R       Alef with Hamza above */\r
-    { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, /* 0x624        // Just to fill the table ;-) */\r
-    { 0xfffd, 0xfffd, 0xfef9, 0xfefa }, /* 0x625        R       Alef with Hamza below */\r
-    { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, /* 0x626        // Just to fill the table ;-) */\r
-    { 0xfffd, 0xfffd, 0xfefb, 0xfefc }  /* 0x627        R       Alef */\r
-};\r
-\r
-static int getShape(hb_uint8 cell, int shape)\r
-{\r
-    /* the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, handle this here */\r
-    int ch = (cell != 0x49)\r
-              ? (shape ? arabicUnicodeMapping[cell][0] + shape : 0x600+cell)\r
-              : alefMaksura[shape] ;\r
-    return ch;\r
-}\r
-\r
-\r
-/*\r
-  Two small helper functions for arabic shaping.\r
-*/\r
-static HB_UChar16 prevChar(const HB_UChar16 *str, int pos)\r
-{\r
-    /*qDebug("leftChar: pos=%d", pos); */\r
-    const HB_UChar16 *ch = str + pos - 1;\r
-    pos--;\r
-    while(pos > -1) {\r
-        if(HB_GetUnicodeCharCategory(*ch) != HB_Mark_NonSpacing)\r
-            return *ch;\r
-        pos--;\r
-        ch--;\r
-    }\r
-    return ReplacementCharacter;\r
-}\r
-\r
-static HB_UChar16 nextChar(const HB_UChar16 *str, hb_uint32 len, hb_uint32 pos)\r
-{\r
-    const HB_UChar16 *ch = str + pos + 1;\r
-    pos++;\r
-    while(pos < len) {\r
-        /*qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); */\r
-        if(HB_GetUnicodeCharCategory(*ch) != HB_Mark_NonSpacing)\r
-            return *ch;\r
-        /* assume it's a transparent char, this might not be 100% correct */\r
-        pos++;\r
-        ch++;\r
-    }\r
-    return ReplacementCharacter;\r
-}\r
-\r
-static void shapedString(const HB_UChar16 *uc, hb_uint32 stringLength, hb_uint32 from, hb_uint32 len, HB_UChar16 *shapeBuffer, int *shapedLength,\r
-                         HB_Bool reverse, HB_GlyphAttributes *attributes, unsigned short *logClusters)\r
-{\r
-    HB_ArabicProperties *properties;\r
-    hb_int32 f = from;\r
-    hb_uint32 l = len;\r
-    const HB_UChar16 *ch;\r
-    HB_UChar16 *data;\r
-    int clusterStart;\r
-    hb_uint32 i;\r
-    HB_STACKARRAY(HB_ArabicProperties, props, len + 2);\r
-    properties = props;\r
-\r
-    assert(stringLength >= from + len);\r
-\r
-    if(len == 0) {\r
-        *shapedLength = 0;\r
-        return;\r
-    }\r
-\r
-    if (from > 0) {\r
-        --f;\r
-        ++l;\r
-        ++properties;\r
-    }\r
-    if (f + l < stringLength)\r
-        ++l;\r
-    getArabicProperties(uc+f, l, props);\r
-\r
-    ch = uc + from;\r
-    data = shapeBuffer;\r
-    clusterStart = 0;\r
-\r
-    for (i = 0; i < len; i++) {\r
-        hb_uint8 r = *ch >> 8;\r
-        int gpos = data - shapeBuffer;\r
-\r
-        if (r != 0x06) {\r
-            if (r == 0x20) {\r
-                if (*ch == 0x200c || *ch == 0x200d)\r
-                    /* remove ZWJ and ZWNJ */\r
-                    goto skip;\r
-            }\r
-            if (reverse)\r
-                *data = HB_GetMirroredChar(*ch);\r
-            else\r
-                *data = *ch;\r
-        } else {\r
-            hb_uint8 c = *ch & 0xff;\r
-            int pos = i + from;\r
-            int shape = properties[i].shape;\r
-/*            qDebug("mapping U+%x to shape %d glyph=0x%x", ch->unicode(), shape, getShape(c, shape)); */\r
-            /* take care of lam-alef ligatures (lam right of alef) */\r
-            hb_uint16 map;\r
-            switch (c) {\r
-                case 0x44: { /* lam */\r
-                    const HB_UChar16 pch = nextChar(uc, stringLength, pos);\r
-                    if ((pch >> 8) == 0x06) {\r
-                        switch (pch & 0xff) {\r
-                            case 0x22:\r
-                            case 0x23:\r
-                            case 0x25:\r
-                            case 0x27:\r
-/*                                 qDebug(" lam of lam-alef ligature"); */\r
-                                map = arabicUnicodeLamAlefMapping[(pch & 0xff) - 0x22][shape];\r
-                                goto next;\r
-                            default:\r
-                                break;\r
-                        }\r
-                    }\r
-                    break;\r
-                }\r
-                case 0x22: /* alef with madda */\r
-                case 0x23: /* alef with hamza above */\r
-                case 0x25: /* alef with hamza below */\r
-                case 0x27: /* alef */\r
-                    if (prevChar(uc, pos) == 0x0644) {\r
-                        /* have a lam alef ligature */\r
-                        /*qDebug(" alef of lam-alef ligature"); */\r
-                        goto skip;\r
-                    }\r
-                default:\r
-                    break;\r
-            }\r
-            map = getShape(c, shape);\r
-        next:\r
-            *data = map;\r
-        }\r
-        /* ##### Fixme */\r
-        /*glyphs[gpos].attributes.zeroWidth = zeroWidth; */\r
-        if (HB_GetUnicodeCharCategory(*ch) == HB_Mark_NonSpacing) {\r
-            attributes[gpos].mark = TRUE;\r
-/*             qDebug("glyph %d (char %d) is mark!", gpos, i); */\r
-        } else {\r
-            attributes[gpos].mark = FALSE;\r
-            clusterStart = data - shapeBuffer;\r
-        }\r
-        attributes[gpos].clusterStart = !attributes[gpos].mark;\r
-        attributes[gpos].combiningClass = HB_GetUnicodeCharCombiningClass(*ch);\r
-        attributes[gpos].justification = properties[i].justification;\r
-/*         qDebug("data[%d] = %x (from %x)", gpos, (uint)data->unicode(), ch->unicode());*/\r
-        data++;\r
-    skip:\r
-        ch++;\r
-        logClusters[i] = clusterStart;\r
-    }\r
-    *shapedLength = data - shapeBuffer;\r
-\r
-    HB_FREE_STACKARRAY(props);\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-\r
-static const HB_OpenTypeFeature arabic_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty },\r
-    { HB_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty },\r
-    { HB_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty },\r
-    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },\r
-    { HB_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty },\r
-    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },\r
-    { HB_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty },\r
-    { HB_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty },\r
-    { HB_MAKE_TAG('c', 's', 'w', 'h'), CswhProperty },\r
-    /* mset is used in old Win95 fonts that don't have a 'mark' positioning table. */\r
-    { HB_MAKE_TAG('m', 's', 'e', 't'), MsetProperty },\r
-    {0, 0}\r
-};\r
-\r
-static const HB_OpenTypeFeature syriac_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty },\r
-    { HB_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty },\r
-    { HB_MAKE_TAG('f', 'i', 'n', '2'), FinaProperty },\r
-    { HB_MAKE_TAG('f', 'i', 'n', '3'), FinaProperty },\r
-    { HB_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty },\r
-    { HB_MAKE_TAG('m', 'e', 'd', '2'), MediProperty },\r
-    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },\r
-    { HB_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty },\r
-    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },\r
-    { HB_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty },\r
-    { HB_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty },\r
-    {0, 0}\r
-};\r
-\r
-static HB_Bool arabicSyriacOpenTypeShape(HB_ShaperItem *item, HB_Bool *ot_ok)\r
-{\r
-    const HB_UChar16 *uc;\r
-    const int nglyphs = item->num_glyphs;\r
-    hb_int32 f;\r
-    hb_uint32 l;\r
-    HB_ArabicProperties *properties;\r
-    HB_DECLARE_STACKARRAY(HB_ArabicProperties, props)\r
-    HB_DECLARE_STACKARRAY(hb_uint32, apply)\r
-    HB_Bool shaped;\r
-    HB_Bool positioned;\r
-    int i = 0;\r
-\r
-    *ot_ok = TRUE;\r
-\r
-    if (!HB_ConvertStringToGlyphIndices(item))\r
-        return FALSE;\r
-    HB_HeuristicSetGlyphAttributes(item);\r
-\r
-    HB_INIT_STACKARRAY(HB_ArabicProperties, props, item->item.length + 2);\r
-    HB_INIT_STACKARRAY(hb_uint32, apply, item->num_glyphs);\r
-\r
-    uc = item->string + item->item.pos;\r
-\r
-    properties = props;\r
-    f = 0;\r
-    l = item->item.length;\r
-    if (item->item.pos > 0) {\r
-        --f;\r
-        ++l;\r
-        ++properties;\r
-    }\r
-    if (f + l + item->item.pos < item->stringLength) {\r
-        ++l;\r
-    }\r
-    if (item->item.script == HB_Script_Nko)\r
-        getNkoProperties(uc+f, l, props);\r
-    else\r
-        getArabicProperties(uc+f, l, props);\r
-\r
-    for (i = 0; i < (int)item->num_glyphs; i++) {\r
-        apply[i] = 0;\r
-\r
-        if (properties[i].shape == XIsolated)\r
-            apply[i] |= MediProperty|FinaProperty|InitProperty;\r
-        else if (properties[i].shape == XMedial)\r
-            apply[i] |= IsolProperty|FinaProperty|InitProperty;\r
-        else if (properties[i].shape == XFinal)\r
-            apply[i] |= IsolProperty|MediProperty|InitProperty;\r
-        else if (properties[i].shape == XInitial)\r
-            apply[i] |= IsolProperty|MediProperty|FinaProperty;\r
-\r
-        item->attributes[i].justification = properties[i].justification;\r
-    }\r
-\r
-    HB_FREE_STACKARRAY(props);\r
-\r
-    shaped = HB_OpenTypeShape(item, apply);\r
-\r
-    HB_FREE_STACKARRAY(apply);\r
-\r
-    if (!shaped) {\r
-        *ot_ok = FALSE;\r
-        return FALSE;\r
-    }\r
-\r
-    positioned = HB_OpenTypePosition(item, nglyphs, /*doLogClusters*/TRUE);\r
-\r
-   /* SAMSUNG bug fix for Arabic - Start */\r
-    if(TRUE == item->item.bidiLevel)\r
-    {\r
-         int j = item->num_glyphs/2;\r
-\r
-         for(i=0; i<j; i++)\r
-         {\r
-               HB_Glyph glyph   = item->glyphs[i];\r
-               HB_Fixed advance = item->advances[i];\r
-               HB_FixedPoint offset  = item->offsets[i];\r
-               int k = (item->num_glyphs-1)-i;\r
-\r
-               item->glyphs[i]   = item->glyphs[k];\r
-               item->advances[i] = item->advances[k];\r
-               item->offsets[i]  = item->offsets[k];\r
-\r
-               item->glyphs[k]   = glyph;\r
-               item->advances[k] = advance;\r
-               item->offsets[k]  = offset;\r
-         }\r
-    }\r
-\r
-       /* SAMSUNG bug fix for Arabic - End */\r
-\r
-    return positioned;\r
-}\r
-\r
-#endif\r
-\r
-/* #### stil missing: identify invalid character combinations */\r
-HB_Bool HB_ArabicShape(HB_ShaperItem *item)\r
-{\r
-    int slen;\r
-    HB_Bool haveGlyphs;\r
-    HB_STACKARRAY(HB_UChar16, shapedChars, item->item.length);\r
-\r
-    assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac\r
-           || item->item.script == HB_Script_Nko);\r
-\r
-#ifndef NO_OPENTYPE\r
-\r
-    if (HB_SelectScript(item, item->item.script == HB_Script_Arabic ? arabic_features : syriac_features)) {\r
-        HB_Bool ot_ok;\r
-        if (arabicSyriacOpenTypeShape(item, &ot_ok))\r
-            return TRUE;\r
-        if (ot_ok)\r
-            return FALSE;\r
-            /* fall through to the non OT code*/\r
-    }\r
-#endif\r
-\r
-    if (item->item.script != HB_Script_Arabic)\r
-        return HB_BasicShape(item);\r
-\r
-    shapedString(item->string, item->stringLength, item->item.pos, item->item.length, shapedChars, &slen,\r
-                  item->item.bidiLevel % 2,\r
-                  item->attributes, item->log_clusters);\r
-\r
-    haveGlyphs = item->font->klass\r
-        ->convertStringToGlyphIndices(item->font,\r
-                                      shapedChars, slen,\r
-                                      item->glyphs, &item->num_glyphs,\r
-                                      item->item.bidiLevel % 2);\r
-\r
-    HB_FREE_STACKARRAY(shapedChars);\r
-\r
-    if (!haveGlyphs)\r
-        return FALSE;\r
-\r
-    HB_HeuristicPosition(item);\r
-    return TRUE;\r
-}\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+
+static const HB_UChar16 ReplacementCharacter = 0xfffd;
+
+typedef struct {
+    unsigned char shape;
+    unsigned char justification;
+} HB_ArabicProperties;
+
+typedef enum {
+    XIsolated,
+    XFinal,
+    XInitial,
+    XMedial,
+    /* intermediate state */
+    XCausing
+} ArabicShape;
+
+/*
+// these groups correspond to the groups defined in the Unicode standard.
+// Some of these groups are equal with regards to both joining and line breaking behaviour,
+// and thus have the same enum value
+//
+// I'm not sure the mapping of syriac to arabic enums is correct with regards to justification, but as
+// I couldn't find any better document I'll hope for the best.
+*/
+typedef enum {
+    /* NonJoining */
+    ArabicNone,
+    ArabicSpace,
+    /* Transparent */
+    Transparent,
+    /* Causing */
+    Center,
+    Kashida,
+
+    /* Arabic */
+    /* Dual */
+    Beh,
+    Noon,
+    Meem = Noon,
+    Heh = Noon,
+    KnottedHeh = Noon,
+    HehGoal = Noon,
+    SwashKaf = Noon,
+    Yeh,
+    Hah,
+    Seen,
+    Sad = Seen,
+    Tah,
+    Kaf = Tah,
+    Gaf = Tah,
+    Lam = Tah,
+    Ain,
+    Feh = Ain,
+    Qaf = Ain,
+    /* Right */
+    Alef,
+    Waw,
+    Dal,
+    TehMarbuta = Dal,
+    Reh,
+    HamzaOnHehGoal,
+    YehWithTail = HamzaOnHehGoal,
+    YehBarre = HamzaOnHehGoal,
+
+    /* Syriac */
+    /* Dual */
+    Beth = Beh,
+    Gamal = Ain,
+    Heth = Noon,
+    Teth = Hah,
+    Yudh = Noon,
+    Kaph = Noon,
+    Lamadh = Lam,
+    Mim = Noon,
+    Nun = Noon,
+    Semakh = Noon,
+    FinalSemakh = Noon,
+    SyriacE = Ain,
+    Pe = Ain,
+    ReversedPe = Hah,
+    Qaph = Noon,
+    Shin = Noon,
+    Fe = Ain,
+
+    /* Right */
+    Alaph = Alef,
+    Dalath = Dal,
+    He = Dal,
+    SyriacWaw = Waw,
+    Zain = Alef,
+    YudhHe = Waw,
+    Sadhe = HamzaOnHehGoal,
+    Taw = Dal,
+
+    /* Compiler bug? Otherwise ArabicGroupsEnd would be equal to Dal + 1. */
+    Dummy = HamzaOnHehGoal,
+    ArabicGroupsEnd
+} ArabicGroup;
+
+static const unsigned char arabic_group[0x150] = {
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+
+    ArabicNone, ArabicNone, Alef, Alef,
+    Waw, Alef, Yeh, Alef,
+    Beh, TehMarbuta, Beh, Beh,
+    Hah, Hah, Hah, Dal,
+
+    Dal, Reh, Reh, Seen,
+    Seen, Sad, Sad, Tah,
+    Tah, Ain, Ain, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+
+    /* 0x640 */
+    Kashida, Feh, Qaf, Kaf,
+    Lam, Meem, Noon, Heh,
+    Waw, Yeh, Yeh, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, Beh, Qaf,
+
+    Transparent, Alef, Alef, Alef,
+    ArabicNone, Alef, Waw, Waw,
+    Yeh, Beh, Beh, Beh,
+    Beh, Beh, Beh, Beh,
+
+    /* 0x680 */
+    Beh, Hah, Hah, Hah,
+    Hah, Hah, Hah, Hah,
+    Dal, Dal, Dal, Dal,
+    Dal, Dal, Dal, Dal,
+
+    Dal, Reh, Reh, Reh,
+    Reh, Reh, Reh, Reh,
+    Reh, Reh, Seen, Seen,
+    Seen, Sad, Sad, Tah,
+
+    Ain, Feh, Feh, Feh,
+    Feh, Feh, Feh, Qaf,
+    Qaf, Gaf, SwashKaf, Gaf,
+    Kaf, Kaf, Kaf, Gaf,
+
+    Gaf, Gaf, Gaf, Gaf,
+    Gaf, Lam, Lam, Lam,
+    Lam, Noon, Noon, Noon,
+    Noon, Noon, KnottedHeh, Hah,
+
+    /* 0x6c0 */
+    TehMarbuta, HehGoal, HamzaOnHehGoal, HamzaOnHehGoal,
+    Waw, Waw, Waw, Waw,
+    Waw, Waw, Waw, Waw,
+    Yeh, YehWithTail, Yeh, Waw,
+
+    Yeh, Yeh, YehBarre, YehBarre,
+    ArabicNone, TehMarbuta, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, ArabicNone, ArabicNone, Transparent,
+
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, ArabicNone, ArabicNone, Transparent,
+    Transparent, ArabicNone, Transparent, Transparent,
+    Transparent, Transparent, Dal, Reh,
+
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, Seen, Sad,
+    Ain, ArabicNone, ArabicNone, KnottedHeh,
+
+    /* 0x700 */
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+    ArabicNone, ArabicNone, ArabicNone, ArabicNone,
+
+    Alaph, Transparent, Beth, Gamal,
+    Gamal, Dalath, Dalath, He,
+    SyriacWaw, Zain, Heth, Teth,
+    Teth, Yudh, YudhHe, Kaph,
+
+    Lamadh, Mim, Nun, Semakh,
+    FinalSemakh, SyriacE, Pe, ReversedPe,
+    Sadhe, Qaph, Dalath, Shin,
+    Taw, Beth, Gamal, Dalath,
+
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, Transparent,
+    Transparent, Transparent, Transparent, ArabicNone,
+    ArabicNone, Zain, Kaph, Fe,
+};
+
+static ArabicGroup arabicGroup(unsigned short uc)
+{
+    if (uc >= 0x0600 && uc < 0x750)
+        return (ArabicGroup) arabic_group[uc-0x600];
+    else if (uc == 0x200d)
+        return Center;
+    else if (HB_GetUnicodeCharCategory(uc) == HB_Separator_Space)
+        return ArabicSpace;
+    else
+        return ArabicNone;
+}
+
+
+/*
+   Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on
+   arabic).
+
+   Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent).
+   transparent joining is not encoded in HB_UChar16::joining(), but applies to all combining marks and format marks.
+
+   Right join-causing: dual + center
+   Left join-causing: dual + right + center
+
+   Rules are as follows (for a string already in visual order, as we have it here):
+
+   R1 Transparent characters do not affect joining behaviour.
+   R2 A right joining character, that has a right join-causing char on the right will get form XRight
+   (R3 A left joining character, that has a left join-causing char on the left will get form XLeft)
+   Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode
+   R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on
+             the right will get form XMedial
+   R5  A dual joining character, that has a right join causing char on the right, and no left join causing char on the left
+         will get form XRight
+   R6 A dual joining character, that has a  left join causing char on the left, and no right join causing char on the right
+         will get form XLeft
+   R7 Otherwise the character will get form XIsolated
+
+   Additionally we have to do the minimal ligature support for lam-alef ligatures:
+
+   L1 Transparent characters do not affect ligature behaviour.
+   L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft)
+   L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated)
+
+   The state table below handles rules R1-R7.
+*/
+
+typedef enum {
+    JNone,
+    JCausing,
+    JDual,
+    JRight,
+    JTransparent
+} Joining;
+
+static const Joining joining_for_group[ArabicGroupsEnd] = {
+    /* NonJoining */
+    JNone, /* ArabicNone */
+    JNone, /* ArabicSpace */
+    /* Transparent */
+    JTransparent, /* Transparent */
+    /* Causing */
+    JCausing, /* Center */
+    JCausing, /* Kashida */
+    /* Dual */
+    JDual, /* Beh */
+    JDual, /* Noon */
+    JDual, /* Yeh */
+    JDual, /* Hah */
+    JDual, /* Seen */
+    JDual, /* Tah */
+    JDual, /* Ain */
+    /* Right */
+    JRight, /* Alef */
+    JRight, /* Waw */
+    JRight, /* Dal */
+    JRight, /* Reh */
+    JRight  /* HamzaOnHehGoal */
+};
+
+
+typedef struct {
+    ArabicShape form1;
+    ArabicShape form2;
+} JoiningPair;
+
+static const JoiningPair joining_table[5][4] =
+/* None, Causing, Dual, Right */
+{
+    { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XInitial }, { XIsolated, XIsolated } }, /* XIsolated */
+    { { XFinal, XIsolated }, { XFinal, XCausing }, { XFinal, XInitial }, { XFinal, XIsolated } }, /* XFinal */
+    { { XIsolated, XIsolated }, { XInitial, XCausing }, { XInitial, XMedial }, { XInitial, XFinal } }, /* XInitial */
+    { { XFinal, XIsolated }, { XMedial, XCausing }, { XMedial, XMedial }, { XMedial, XFinal } }, /* XMedial */
+    { { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XMedial }, { XIsolated, XFinal } }, /* XCausing */
+};
+
+
+/*
+According to http://www.microsoft.com/middleeast/Arabicdev/IE6/KBase.asp
+
+1. Find the priority of the connecting opportunities in each word
+2. Add expansion at the highest priority connection opportunity
+3. If more than one connection opportunity have the same highest value,
+   use the opportunity closest to the end of the word.
+
+Following is a chart that provides the priority for connection
+opportunities and where expansion occurs. The character group names
+are those in table 6.6 of the UNICODE 2.0 book.
+
+
+PrioritY        Glyph                   Condition                                       Kashida Location
+
+Arabic_Kashida        User inserted Kashida   The user entered a Kashida in a position.       After the user
+                (Shift+j or Shift+[E with hat])    Thus, it is the highest priority to insert an   inserted kashida
+                                        automatic kashida.
+
+Arabic_Seen        Seen, Sad               Connecting to the next character.               After the character.
+                                        (Initial or medial form).
+
+Arabic_HaaDal        Teh Marbutah, Haa, Dal  Connecting to previous character.               Before the final form
+                                                                                        of these characters.
+
+Arabic_Alef     Alef, Tah, Lam,         Connecting to previous character.               Before the final form
+                Kaf and Gaf                                                             of these characters.
+
+Arabic_BaRa     Reh, Yeh                Connected to medial Beh                         Before preceding medial Baa
+
+Arabic_Waw        Waw, Ain, Qaf, Feh      Connecting to previous character.               Before the final form of
+                                                                                        these characters.
+
+Arabic_Normal   Other connecting        Connecting to previous character.               Before the final form
+                characters                                                              of these characters.
+
+
+
+This seems to imply that we have at most one kashida point per arabic word.
+
+*/
+
+static void getArabicProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties)
+{
+/*     qDebug("arabicSyriacOpenTypeShape: properties:"); */
+    int lastPos = 0;
+    int lastGroup = ArabicNone;
+    int i = 0;
+
+    ArabicGroup group = arabicGroup(chars[0]);
+    Joining j = joining_for_group[group];
+    ArabicShape shape = joining_table[XIsolated][j].form2;
+    properties[0].justification = HB_NoJustification;
+
+    for (i = 1; i < len; ++i) {
+        /* #### fix handling for spaces and punktuation */
+        properties[i].justification = HB_NoJustification;
+
+        group = arabicGroup(chars[i]);
+        j = joining_for_group[group];
+
+        if (j == JTransparent) {
+            properties[i].shape = XIsolated;
+            continue;
+        }
+
+        properties[lastPos].shape = joining_table[shape][j].form1;
+        shape = joining_table[shape][j].form2;
+
+        switch(lastGroup) {
+        case Seen:
+            if (properties[lastPos].shape == XInitial || properties[lastPos].shape == XMedial)
+                properties[i-1].justification = HB_Arabic_Seen;
+            break;
+        case Hah:
+            if (properties[lastPos].shape == XFinal)
+                properties[lastPos-1].justification = HB_Arabic_HaaDal;
+            break;
+        case Alef:
+            if (properties[lastPos].shape == XFinal)
+                properties[lastPos-1].justification = HB_Arabic_Alef;
+            break;
+        case Ain:
+            if (properties[lastPos].shape == XFinal)
+                properties[lastPos-1].justification = HB_Arabic_Waw;
+            break;
+        case Noon:
+            if (properties[lastPos].shape == XFinal)
+                properties[lastPos-1].justification = HB_Arabic_Normal;
+            break;
+        case ArabicNone:
+            break;
+
+        default:
+            assert(FALSE);
+        }
+
+        lastGroup = ArabicNone;
+
+        switch(group) {
+        case ArabicNone:
+        case Transparent:
+        /* ### Center should probably be treated as transparent when it comes to justification. */
+        case Center:
+            break;
+        case ArabicSpace:
+            properties[i].justification = HB_Arabic_Space;
+            break;
+        case Kashida:
+            properties[i].justification = HB_Arabic_Kashida;
+            break;
+        case Seen:
+            lastGroup = Seen;
+            break;
+
+        case Hah:
+        case Dal:
+            lastGroup = Hah;
+            break;
+
+        case Alef:
+        case Tah:
+            lastGroup = Alef;
+            break;
+
+        case Yeh:
+        case Reh:
+            if (properties[lastPos].shape == XMedial && arabicGroup(chars[lastPos]) == Beh)
+                properties[lastPos-1].justification = HB_Arabic_BaRa;
+            break;
+
+        case Ain:
+        case Waw:
+            lastGroup = Ain;
+            break;
+
+        case Noon:
+        case Beh:
+        case HamzaOnHehGoal:
+            lastGroup = Noon;
+            break;
+        case ArabicGroupsEnd:
+            assert(FALSE);
+        }
+
+        lastPos = i;
+    }
+    properties[lastPos].shape = joining_table[shape][JNone].form1;
+
+
+    /*
+     for (int i = 0; i < len; ++i)
+         qDebug("arabic properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);
+    */
+}
+
+static Joining getNkoJoining(unsigned short uc)
+{
+    if (uc < 0x7ca)
+        return JNone;
+    if (uc <= 0x7ea)
+        return JDual;
+    if (uc <= 0x7f3)
+        return JTransparent;
+    if (uc <= 0x7f9)
+        return JNone;
+    if (uc == 0x7fa)
+        return JCausing;
+    return JNone;
+}
+
+static void getNkoProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties)
+{
+    int lastPos = 0;
+    int i = 0;
+
+    Joining j = getNkoJoining(chars[0]);
+    ArabicShape shape = joining_table[XIsolated][j].form2;
+    properties[0].justification = HB_NoJustification;
+
+    for (i = 1; i < len; ++i) {
+        properties[i].justification = (HB_GetUnicodeCharCategory(chars[i]) == HB_Separator_Space) ?
+                                      ArabicSpace : ArabicNone;
+
+        j = getNkoJoining(chars[i]);
+
+        if (j == JTransparent) {
+            properties[i].shape = XIsolated;
+            continue;
+        }
+
+        properties[lastPos].shape = joining_table[shape][j].form1;
+        shape = joining_table[shape][j].form2;
+
+
+        lastPos = i;
+    }
+    properties[lastPos].shape = joining_table[shape][JNone].form1;
+
+
+    /*
+     for (int i = 0; i < len; ++i)
+         qDebug("nko properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);
+    */
+}
+
+/*
+// The unicode to unicode shaping codec.
+// does only presentation forms B at the moment, but that should be enough for
+// simple display
+*/
+static const hb_uint16 arabicUnicodeMapping[256][2] = {
+    /* base of shaped forms, and number-1 of them (0 for non shaping,
+       1 for right binding and 3 for dual binding */
+
+    /* These are just the glyphs available in Unicode,
+       some characters are in R class, but have no glyphs in Unicode. */
+
+    { 0x0600, 0 }, /* 0x0600 */
+    { 0x0601, 0 }, /* 0x0601 */
+    { 0x0602, 0 }, /* 0x0602 */
+    { 0x0603, 0 }, /* 0x0603 */
+    { 0x0604, 0 }, /* 0x0604 */
+    { 0x0605, 0 }, /* 0x0605 */
+    { 0x0606, 0 }, /* 0x0606 */
+    { 0x0607, 0 }, /* 0x0607 */
+    { 0x0608, 0 }, /* 0x0608 */
+    { 0x0609, 0 }, /* 0x0609 */
+    { 0x060A, 0 }, /* 0x060A */
+    { 0x060B, 0 }, /* 0x060B */
+    { 0x060C, 0 }, /* 0x060C */
+    { 0x060D, 0 }, /* 0x060D */
+    { 0x060E, 0 }, /* 0x060E */
+    { 0x060F, 0 }, /* 0x060F */
+
+    { 0x0610, 0 }, /* 0x0610 */
+    { 0x0611, 0 }, /* 0x0611 */
+    { 0x0612, 0 }, /* 0x0612 */
+    { 0x0613, 0 }, /* 0x0613 */
+    { 0x0614, 0 }, /* 0x0614 */
+    { 0x0615, 0 }, /* 0x0615 */
+    { 0x0616, 0 }, /* 0x0616 */
+    { 0x0617, 0 }, /* 0x0617 */
+    { 0x0618, 0 }, /* 0x0618 */
+    { 0x0619, 0 }, /* 0x0619 */
+    { 0x061A, 0 }, /* 0x061A */
+    { 0x061B, 0 }, /* 0x061B */
+    { 0x061C, 0 }, /* 0x061C */
+    { 0x061D, 0 }, /* 0x061D */
+    { 0x061E, 0 }, /* 0x061E */
+    { 0x061F, 0 }, /* 0x061F */
+
+    { 0x0620, 0 }, /* 0x0620 */
+    { 0xFE80, 0 }, /* 0x0621            HAMZA */
+    { 0xFE81, 1 }, /* 0x0622    R       ALEF WITH MADDA ABOVE */
+    { 0xFE83, 1 }, /* 0x0623    R       ALEF WITH HAMZA ABOVE */
+    { 0xFE85, 1 }, /* 0x0624    R       WAW WITH HAMZA ABOVE */
+    { 0xFE87, 1 }, /* 0x0625    R       ALEF WITH HAMZA BELOW */
+    { 0xFE89, 3 }, /* 0x0626    D       YEH WITH HAMZA ABOVE */
+    { 0xFE8D, 1 }, /* 0x0627    R       ALEF */
+    { 0xFE8F, 3 }, /* 0x0628    D       BEH */
+    { 0xFE93, 1 }, /* 0x0629    R       TEH MARBUTA */
+    { 0xFE95, 3 }, /* 0x062A    D       TEH */
+    { 0xFE99, 3 }, /* 0x062B    D       THEH */
+    { 0xFE9D, 3 }, /* 0x062C    D       JEEM */
+    { 0xFEA1, 3 }, /* 0x062D    D       HAH */
+    { 0xFEA5, 3 }, /* 0x062E    D       KHAH */
+    { 0xFEA9, 1 }, /* 0x062F    R       DAL */
+
+    { 0xFEAB, 1 }, /* 0x0630    R       THAL */
+    { 0xFEAD, 1 }, /* 0x0631    R       REH */
+    { 0xFEAF, 1 }, /* 0x0632    R       ZAIN */
+    { 0xFEB1, 3 }, /* 0x0633    D       SEEN */
+    { 0xFEB5, 3 }, /* 0x0634    D       SHEEN */
+    { 0xFEB9, 3 }, /* 0x0635    D       SAD */
+    { 0xFEBD, 3 }, /* 0x0636    D       DAD */
+    { 0xFEC1, 3 }, /* 0x0637    D       TAH */
+    { 0xFEC5, 3 }, /* 0x0638    D       ZAH */
+    { 0xFEC9, 3 }, /* 0x0639    D       AIN */
+    { 0xFECD, 3 }, /* 0x063A    D       GHAIN */
+    { 0x063B, 0 }, /* 0x063B */
+    { 0x063C, 0 }, /* 0x063C */
+    { 0x063D, 0 }, /* 0x063D */
+    { 0x063E, 0 }, /* 0x063E */
+    { 0x063F, 0 }, /* 0x063F */
+
+    { 0x0640, 0 }, /* 0x0640    C       TATWEEL // ### Join Causing, only one glyph */
+    { 0xFED1, 3 }, /* 0x0641    D       FEH */
+    { 0xFED5, 3 }, /* 0x0642    D       QAF */
+    { 0xFED9, 3 }, /* 0x0643    D       KAF */
+    { 0xFEDD, 3 }, /* 0x0644    D       LAM */
+    { 0xFEE1, 3 }, /* 0x0645    D       MEEM */
+    { 0xFEE5, 3 }, /* 0x0646    D       NOON */
+    { 0xFEE9, 3 }, /* 0x0647    D       HEH */
+    { 0xFEED, 1 }, /* 0x0648    R       WAW */
+    { 0x0649, 3 }, /* 0x0649            ALEF MAKSURA // ### Dual, glyphs not consecutive, handle in code. */
+    { 0xFEF1, 3 }, /* 0x064A    D       YEH */
+    { 0x064B, 0 }, /* 0x064B */
+    { 0x064C, 0 }, /* 0x064C */
+    { 0x064D, 0 }, /* 0x064D */
+    { 0x064E, 0 }, /* 0x064E */
+    { 0x064F, 0 }, /* 0x064F */
+
+    { 0x0650, 0 }, /* 0x0650 */
+    { 0x0651, 0 }, /* 0x0651 */
+    { 0x0652, 0 }, /* 0x0652 */
+    { 0x0653, 0 }, /* 0x0653 */
+    { 0x0654, 0 }, /* 0x0654 */
+    { 0x0655, 0 }, /* 0x0655 */
+    { 0x0656, 0 }, /* 0x0656 */
+    { 0x0657, 0 }, /* 0x0657 */
+    { 0x0658, 0 }, /* 0x0658 */
+    { 0x0659, 0 }, /* 0x0659 */
+    { 0x065A, 0 }, /* 0x065A */
+    { 0x065B, 0 }, /* 0x065B */
+    { 0x065C, 0 }, /* 0x065C */
+    { 0x065D, 0 }, /* 0x065D */
+    { 0x065E, 0 }, /* 0x065E */
+    { 0x065F, 0 }, /* 0x065F */
+
+    { 0x0660, 0 }, /* 0x0660 */
+    { 0x0661, 0 }, /* 0x0661 */
+    { 0x0662, 0 }, /* 0x0662 */
+    { 0x0663, 0 }, /* 0x0663 */
+    { 0x0664, 0 }, /* 0x0664 */
+    { 0x0665, 0 }, /* 0x0665 */
+    { 0x0666, 0 }, /* 0x0666 */
+    { 0x0667, 0 }, /* 0x0667 */
+    { 0x0668, 0 }, /* 0x0668 */
+    { 0x0669, 0 }, /* 0x0669 */
+    { 0x066A, 0 }, /* 0x066A */
+    { 0x066B, 0 }, /* 0x066B */
+    { 0x066C, 0 }, /* 0x066C */
+    { 0x066D, 0 }, /* 0x066D */
+    { 0x066E, 0 }, /* 0x066E */
+    { 0x066F, 0 }, /* 0x066F */
+
+    { 0x0670, 0 }, /* 0x0670 */
+    { 0xFB50, 1 }, /* 0x0671    R       ALEF WASLA */
+    { 0x0672, 0 }, /* 0x0672 */
+    { 0x0673, 0 }, /* 0x0673 */
+    { 0x0674, 0 }, /* 0x0674 */
+    { 0x0675, 0 }, /* 0x0675 */
+    { 0x0676, 0 }, /* 0x0676 */
+    { 0x0677, 0 }, /* 0x0677 */
+    { 0x0678, 0 }, /* 0x0678 */
+    { 0xFB66, 3 }, /* 0x0679    D       TTEH */
+    { 0xFB5E, 3 }, /* 0x067A    D       TTEHEH */
+    { 0xFB52, 3 }, /* 0x067B    D       BEEH */
+    { 0x067C, 0 }, /* 0x067C */
+    { 0x067D, 0 }, /* 0x067D */
+    { 0xFB56, 3 }, /* 0x067E    D       PEH */
+    { 0xFB62, 3 }, /* 0x067F    D       TEHEH */
+
+    { 0xFB5A, 3 }, /* 0x0680    D       BEHEH */
+    { 0x0681, 0 }, /* 0x0681 */
+    { 0x0682, 0 }, /* 0x0682 */
+    { 0xFB76, 3 }, /* 0x0683    D       NYEH */
+    { 0xFB72, 3 }, /* 0x0684    D       DYEH */
+    { 0x0685, 0 }, /* 0x0685 */
+    { 0xFB7A, 3 }, /* 0x0686    D       TCHEH */
+    { 0xFB7E, 3 }, /* 0x0687    D       TCHEHEH */
+    { 0xFB88, 1 }, /* 0x0688    R       DDAL */
+    { 0x0689, 0 }, /* 0x0689 */
+    { 0x068A, 0 }, /* 0x068A */
+    { 0x068B, 0 }, /* 0x068B */
+    { 0xFB84, 1 }, /* 0x068C    R       DAHAL */
+    { 0xFB82, 1 }, /* 0x068D    R       DDAHAL */
+    { 0xFB86, 1 }, /* 0x068E    R       DUL */
+    { 0x068F, 0 }, /* 0x068F */
+
+    { 0x0690, 0 }, /* 0x0690 */
+    { 0xFB8C, 1 }, /* 0x0691    R       RREH */
+    { 0x0692, 0 }, /* 0x0692 */
+    { 0x0693, 0 }, /* 0x0693 */
+    { 0x0694, 0 }, /* 0x0694 */
+    { 0x0695, 0 }, /* 0x0695 */
+    { 0x0696, 0 }, /* 0x0696 */
+    { 0x0697, 0 }, /* 0x0697 */
+    { 0xFB8A, 1 }, /* 0x0698    R       JEH */
+    { 0x0699, 0 }, /* 0x0699 */
+    { 0x069A, 0 }, /* 0x069A */
+    { 0x069B, 0 }, /* 0x069B */
+    { 0x069C, 0 }, /* 0x069C */
+    { 0x069D, 0 }, /* 0x069D */
+    { 0x069E, 0 }, /* 0x069E */
+    { 0x069F, 0 }, /* 0x069F */
+
+    { 0x06A0, 0 }, /* 0x06A0 */
+    { 0x06A1, 0 }, /* 0x06A1 */
+    { 0x06A2, 0 }, /* 0x06A2 */
+    { 0x06A3, 0 }, /* 0x06A3 */
+    { 0xFB6A, 3 }, /* 0x06A4    D       VEH */
+    { 0x06A5, 0 }, /* 0x06A5 */
+    { 0xFB6E, 3 }, /* 0x06A6    D       PEHEH */
+    { 0x06A7, 0 }, /* 0x06A7 */
+    { 0x06A8, 0 }, /* 0x06A8 */
+    { 0xFB8E, 3 }, /* 0x06A9    D       KEHEH */
+    { 0x06AA, 0 }, /* 0x06AA */
+    { 0x06AB, 0 }, /* 0x06AB */
+    { 0x06AC, 0 }, /* 0x06AC */
+    { 0xFBD3, 3 }, /* 0x06AD    D       NG */
+    { 0x06AE, 0 }, /* 0x06AE */
+    { 0xFB92, 3 }, /* 0x06AF    D       GAF */
+
+    { 0x06B0, 0 }, /* 0x06B0 */
+    { 0xFB9A, 3 }, /* 0x06B1    D       NGOEH */
+    { 0x06B2, 0 }, /* 0x06B2 */
+    { 0xFB96, 3 }, /* 0x06B3    D       GUEH */
+    { 0x06B4, 0 }, /* 0x06B4 */
+    { 0x06B5, 0 }, /* 0x06B5 */
+    { 0x06B6, 0 }, /* 0x06B6 */
+    { 0x06B7, 0 }, /* 0x06B7 */
+    { 0x06B8, 0 }, /* 0x06B8 */
+    { 0x06B9, 0 }, /* 0x06B9 */
+    { 0xFB9E, 1 }, /* 0x06BA    R       NOON GHUNNA */
+    { 0xFBA0, 3 }, /* 0x06BB    D       RNOON */
+    { 0x06BC, 0 }, /* 0x06BC */
+    { 0x06BD, 0 }, /* 0x06BD */
+    { 0xFBAA, 3 }, /* 0x06BE    D       HEH DOACHASHMEE */
+    { 0x06BF, 0 }, /* 0x06BF */
+
+    { 0xFBA4, 1 }, /* 0x06C0    R       HEH WITH YEH ABOVE */
+    { 0xFBA6, 3 }, /* 0x06C1    D       HEH GOAL */
+    { 0x06C2, 0 }, /* 0x06C2 */
+    { 0x06C3, 0 }, /* 0x06C3 */
+    { 0x06C4, 0 }, /* 0x06C4 */
+    { 0xFBE0, 1 }, /* 0x06C5    R       KIRGHIZ OE */
+    { 0xFBD9, 1 }, /* 0x06C6    R       OE */
+    { 0xFBD7, 1 }, /* 0x06C7    R       U */
+    { 0xFBDB, 1 }, /* 0x06C8    R       YU */
+    { 0xFBE2, 1 }, /* 0x06C9    R       KIRGHIZ YU */
+    { 0x06CA, 0 }, /* 0x06CA */
+    { 0xFBDE, 1 }, /* 0x06CB    R       VE */
+    { 0xFBFC, 3 }, /* 0x06CC    D       FARSI YEH */
+    { 0x06CD, 0 }, /* 0x06CD */
+    { 0x06CE, 0 }, /* 0x06CE */
+    { 0x06CF, 0 }, /* 0x06CF */
+
+    { 0xFBE4, 3 }, /* 0x06D0    D       E */
+    { 0x06D1, 0 }, /* 0x06D1 */
+    { 0xFBAE, 1 }, /* 0x06D2    R       YEH BARREE */
+    { 0xFBB0, 1 }, /* 0x06D3    R       YEH BARREE WITH HAMZA ABOVE */
+    { 0x06D4, 0 }, /* 0x06D4 */
+    { 0x06D5, 0 }, /* 0x06D5 */
+    { 0x06D6, 0 }, /* 0x06D6 */
+    { 0x06D7, 0 }, /* 0x06D7 */
+    { 0x06D8, 0 }, /* 0x06D8 */
+    { 0x06D9, 0 }, /* 0x06D9 */
+    { 0x06DA, 0 }, /* 0x06DA */
+    { 0x06DB, 0 }, /* 0x06DB */
+    { 0x06DC, 0 }, /* 0x06DC */
+    { 0x06DD, 0 }, /* 0x06DD */
+    { 0x06DE, 0 }, /* 0x06DE */
+    { 0x06DF, 0 }, /* 0x06DF */
+
+    { 0x06E0, 0 }, /* 0x06E0 */
+    { 0x06E1, 0 }, /* 0x06E1 */
+    { 0x06E2, 0 }, /* 0x06E2 */
+    { 0x06E3, 0 }, /* 0x06E3 */
+    { 0x06E4, 0 }, /* 0x06E4 */
+    { 0x06E5, 0 }, /* 0x06E5 */
+    { 0x06E6, 0 }, /* 0x06E6 */
+    { 0x06E7, 0 }, /* 0x06E7 */
+    { 0x06E8, 0 }, /* 0x06E8 */
+    { 0x06E9, 0 }, /* 0x06E9 */
+    { 0x06EA, 0 }, /* 0x06EA */
+    { 0x06EB, 0 }, /* 0x06EB */
+    { 0x06EC, 0 }, /* 0x06EC */
+    { 0x06ED, 0 }, /* 0x06ED */
+    { 0x06EE, 0 }, /* 0x06EE */
+    { 0x06EF, 0 }, /* 0x06EF */
+
+    { 0x06F0, 0 }, /* 0x06F0 */
+    { 0x06F1, 0 }, /* 0x06F1 */
+    { 0x06F2, 0 }, /* 0x06F2 */
+    { 0x06F3, 0 }, /* 0x06F3 */
+    { 0x06F4, 0 }, /* 0x06F4 */
+    { 0x06F5, 0 }, /* 0x06F5 */
+    { 0x06F6, 0 }, /* 0x06F6 */
+    { 0x06F7, 0 }, /* 0x06F7 */
+    { 0x06F8, 0 }, /* 0x06F8 */
+    { 0x06F9, 0 }, /* 0x06F9 */
+    { 0x06FA, 0 }, /* 0x06FA */
+    { 0x06FB, 0 }, /* 0x06FB */
+    { 0x06FC, 0 }, /* 0x06FC */
+    { 0x06FD, 0 }, /* 0x06FD */
+    { 0x06FE, 0 }, /* 0x06FE */
+    { 0x06FF, 0 }  /* 0x06FF */
+};
+
+/* the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, this table does */
+static const hb_uint16 alefMaksura[4] = {0xFEEF, 0xFEF0, 0xFBE8, 0xFBE9};
+
+/*
+// this is a bit tricky. Alef always binds to the right, so the second parameter descibing the shape
+// of the lam can be either initial of medial. So initial maps to the isolated form of the ligature,
+// medial to the final form
+*/
+static const hb_uint16 arabicUnicodeLamAlefMapping[6][4] = {
+    { 0xfffd, 0xfffd, 0xfef5, 0xfef6 }, /* 0x622        R       Alef with Madda above */
+    { 0xfffd, 0xfffd, 0xfef7, 0xfef8 }, /* 0x623        R       Alef with Hamza above */
+    { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, /* 0x624        // Just to fill the table ;-) */
+    { 0xfffd, 0xfffd, 0xfef9, 0xfefa }, /* 0x625        R       Alef with Hamza below */
+    { 0xfffd, 0xfffd, 0xfffd, 0xfffd }, /* 0x626        // Just to fill the table ;-) */
+    { 0xfffd, 0xfffd, 0xfefb, 0xfefc }  /* 0x627        R       Alef */
+};
+
+static int getShape(hb_uint8 cell, int shape)
+{
+    /* the arabicUnicodeMapping does not work for U+0649 ALEF MAKSURA, handle this here */
+    int ch = (cell != 0x49)
+              ? (shape ? arabicUnicodeMapping[cell][0] + shape : 0x600+cell)
+              : alefMaksura[shape] ;
+    return ch;
+}
+
+
+/*
+  Two small helper functions for arabic shaping.
+*/
+static HB_UChar16 prevChar(const HB_UChar16 *str, int pos)
+{
+    /*qDebug("leftChar: pos=%d", pos); */
+    const HB_UChar16 *ch = str + pos - 1;
+    pos--;
+    while(pos > -1) {
+        if(HB_GetUnicodeCharCategory(*ch) != HB_Mark_NonSpacing)
+            return *ch;
+        pos--;
+        ch--;
+    }
+    return ReplacementCharacter;
+}
+
+static HB_UChar16 nextChar(const HB_UChar16 *str, hb_uint32 len, hb_uint32 pos)
+{
+    const HB_UChar16 *ch = str + pos + 1;
+    pos++;
+    while(pos < len) {
+        /*qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); */
+        if(HB_GetUnicodeCharCategory(*ch) != HB_Mark_NonSpacing)
+            return *ch;
+        /* assume it's a transparent char, this might not be 100% correct */
+        pos++;
+        ch++;
+    }
+    return ReplacementCharacter;
+}
+
+static void shapedString(const HB_UChar16 *uc, hb_uint32 stringLength, hb_uint32 from, hb_uint32 len, HB_UChar16 *shapeBuffer, int *shapedLength,
+                         HB_Bool reverse, HB_GlyphAttributes *attributes, unsigned short *logClusters)
+{
+    HB_ArabicProperties *properties;
+    hb_int32 f = from;
+    hb_uint32 l = len;
+    const HB_UChar16 *ch;
+    HB_UChar16 *data;
+    int clusterStart;
+    hb_uint32 i;
+    HB_STACKARRAY(HB_ArabicProperties, props, len + 2);
+    properties = props;
+
+    assert(stringLength >= from + len);
+
+    if(len == 0) {
+        *shapedLength = 0;
+        return;
+    }
+
+    if (from > 0) {
+        --f;
+        ++l;
+        ++properties;
+    }
+    if (f + l < stringLength)
+        ++l;
+    getArabicProperties(uc+f, l, props);
+
+    ch = uc + from;
+    data = shapeBuffer;
+    clusterStart = 0;
+
+    for (i = 0; i < len; i++) {
+        hb_uint8 r = *ch >> 8;
+        int gpos = data - shapeBuffer;
+
+        if (r != 0x06) {
+            if (r == 0x20) {
+                if (*ch == 0x200c || *ch == 0x200d)
+                    /* remove ZWJ and ZWNJ */
+                    goto skip;
+            }
+            if (reverse)
+                *data = HB_GetMirroredChar(*ch);
+            else
+                *data = *ch;
+        } else {
+            hb_uint8 c = *ch & 0xff;
+            int pos = i + from;
+            int shape = properties[i].shape;
+/*            qDebug("mapping U+%x to shape %d glyph=0x%x", ch->unicode(), shape, getShape(c, shape)); */
+            /* take care of lam-alef ligatures (lam right of alef) */
+            hb_uint16 map;
+            switch (c) {
+                case 0x44: { /* lam */
+                    const HB_UChar16 pch = nextChar(uc, stringLength, pos);
+                    if ((pch >> 8) == 0x06) {
+                        switch (pch & 0xff) {
+                            case 0x22:
+                            case 0x23:
+                            case 0x25:
+                            case 0x27:
+/*                                 qDebug(" lam of lam-alef ligature"); */
+                                map = arabicUnicodeLamAlefMapping[(pch & 0xff) - 0x22][shape];
+                                goto next;
+                            default:
+                                break;
+                        }
+                    }
+                    break;
+                }
+                case 0x22: /* alef with madda */
+                case 0x23: /* alef with hamza above */
+                case 0x25: /* alef with hamza below */
+                case 0x27: /* alef */
+                    if (prevChar(uc, pos) == 0x0644) {
+                        /* have a lam alef ligature */
+                        /*qDebug(" alef of lam-alef ligature"); */
+                        goto skip;
+                    }
+                default:
+                    break;
+            }
+            map = getShape(c, shape);
+        next:
+            *data = map;
+        }
+        /* ##### Fixme */
+        /*glyphs[gpos].attributes.zeroWidth = zeroWidth; */
+        if (HB_GetUnicodeCharCategory(*ch) == HB_Mark_NonSpacing) {
+            attributes[gpos].mark = TRUE;
+/*             qDebug("glyph %d (char %d) is mark!", gpos, i); */
+        } else {
+            attributes[gpos].mark = FALSE;
+            clusterStart = data - shapeBuffer;
+        }
+        attributes[gpos].clusterStart = !attributes[gpos].mark;
+        attributes[gpos].combiningClass = HB_GetUnicodeCharCombiningClass(*ch);
+        attributes[gpos].justification = properties[i].justification;
+/*         qDebug("data[%d] = %x (from %x)", gpos, (uint)data->unicode(), ch->unicode());*/
+        data++;
+    skip:
+        ch++;
+        logClusters[i] = clusterStart;
+    }
+    *shapedLength = data - shapeBuffer;
+
+    HB_FREE_STACKARRAY(props);
+}
+
+#ifndef NO_OPENTYPE
+
+static const HB_OpenTypeFeature arabic_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty },
+    { HB_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty },
+    { HB_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty },
+    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
+    { HB_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty },
+    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },
+    { HB_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty },
+    { HB_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty },
+    { HB_MAKE_TAG('c', 's', 'w', 'h'), CswhProperty },
+    /* mset is used in old Win95 fonts that don't have a 'mark' positioning table. */
+    { HB_MAKE_TAG('m', 's', 'e', 't'), MsetProperty },
+    {0, 0}
+};
+
+static const HB_OpenTypeFeature syriac_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('i', 's', 'o', 'l'), IsolProperty },
+    { HB_MAKE_TAG('f', 'i', 'n', 'a'), FinaProperty },
+    { HB_MAKE_TAG('f', 'i', 'n', '2'), FinaProperty },
+    { HB_MAKE_TAG('f', 'i', 'n', '3'), FinaProperty },
+    { HB_MAKE_TAG('m', 'e', 'd', 'i'), MediProperty },
+    { HB_MAKE_TAG('m', 'e', 'd', '2'), MediProperty },
+    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
+    { HB_MAKE_TAG('r', 'l', 'i', 'g'), RligProperty },
+    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },
+    { HB_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty },
+    { HB_MAKE_TAG('d', 'l', 'i', 'g'), DligProperty },
+    {0, 0}
+};
+
+static HB_Bool arabicSyriacOpenTypeShape(HB_ShaperItem *item, HB_Bool *ot_ok)
+{
+    const HB_UChar16 *uc;
+    const int nglyphs = item->num_glyphs;
+    hb_int32 f;
+    hb_uint32 l;
+    HB_ArabicProperties *properties;
+    HB_DECLARE_STACKARRAY(HB_ArabicProperties, props)
+    HB_DECLARE_STACKARRAY(hb_uint32, apply)
+    HB_Bool shaped;
+    HB_Bool positioned;
+    int i = 0;
+
+    *ot_ok = TRUE;
+
+    if (!HB_ConvertStringToGlyphIndices(item))
+        return FALSE;
+    HB_HeuristicSetGlyphAttributes(item);
+
+    HB_INIT_STACKARRAY(HB_ArabicProperties, props, item->item.length + 2);
+    HB_INIT_STACKARRAY(hb_uint32, apply, item->num_glyphs);
+
+    uc = item->string + item->item.pos;
+
+    properties = props;
+    f = 0;
+    l = item->item.length;
+    if (item->item.pos > 0) {
+        --f;
+        ++l;
+        ++properties;
+    }
+    if (f + l + item->item.pos < item->stringLength) {
+        ++l;
+    }
+    if (item->item.script == HB_Script_Nko)
+        getNkoProperties(uc+f, l, props);
+    else
+        getArabicProperties(uc+f, l, props);
+
+    for (i = 0; i < (int)item->num_glyphs; i++) {
+        apply[i] = 0;
+
+        if (properties[i].shape == XIsolated)
+            apply[i] |= MediProperty|FinaProperty|InitProperty;
+        else if (properties[i].shape == XMedial)
+            apply[i] |= IsolProperty|FinaProperty|InitProperty;
+        else if (properties[i].shape == XFinal)
+            apply[i] |= IsolProperty|MediProperty|InitProperty;
+        else if (properties[i].shape == XInitial)
+            apply[i] |= IsolProperty|MediProperty|FinaProperty;
+
+        item->attributes[i].justification = properties[i].justification;
+    }
+
+    HB_FREE_STACKARRAY(props);
+
+    shaped = HB_OpenTypeShape(item, apply);
+
+    HB_FREE_STACKARRAY(apply);
+
+    if (!shaped) {
+        *ot_ok = FALSE;
+        return FALSE;
+    }
+
+    positioned = HB_OpenTypePosition(item, nglyphs, /*doLogClusters*/TRUE);
+
+   /* SAMSUNG bug fix for Arabic - Start */
+    if(TRUE == item->item.bidiLevel)
+    {
+         int j = item->num_glyphs/2;
+
+         for(i=0; i<j; i++)
+         {
+               HB_Glyph glyph   = item->glyphs[i];
+               HB_Fixed advance = item->advances[i];
+               HB_FixedPoint offset  = item->offsets[i];
+               int k = (item->num_glyphs-1)-i;
+
+               item->glyphs[i]   = item->glyphs[k];
+               item->advances[i] = item->advances[k];
+               item->offsets[i]  = item->offsets[k];
+
+               item->glyphs[k]   = glyph;
+               item->advances[k] = advance;
+               item->offsets[k]  = offset;
+         }
+    }
+
+       /* SAMSUNG bug fix for Arabic - End */
+
+    return positioned;
+}
+
+#endif
+
+/* #### stil missing: identify invalid character combinations */
+HB_Bool HB_ArabicShape(HB_ShaperItem *item)
+{
+    int slen;
+    HB_Bool haveGlyphs;
+    HB_STACKARRAY(HB_UChar16, shapedChars, item->item.length);
+
+    assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac
+           || item->item.script == HB_Script_Nko);
+
+#ifndef NO_OPENTYPE
+
+    if (HB_SelectScript(item, item->item.script == HB_Script_Arabic ? arabic_features : syriac_features)) {
+        HB_Bool ot_ok;
+        if (arabicSyriacOpenTypeShape(item, &ot_ok))
+            return TRUE;
+        if (ot_ok)
+            return FALSE;
+            /* fall through to the non OT code*/
+    }
+#endif
+
+    if (item->item.script != HB_Script_Arabic)
+        return HB_BasicShape(item);
+
+    shapedString(item->string, item->stringLength, item->item.pos, item->item.length, shapedChars, &slen,
+                  item->item.bidiLevel % 2,
+                  item->attributes, item->log_clusters);
+
+    haveGlyphs = item->font->klass
+        ->convertStringToGlyphIndices(item->font,
+                                      shapedChars, slen,
+                                      item->glyphs, &item->num_glyphs,
+                                      item->item.bidiLevel % 2);
+
+    HB_FREE_STACKARRAY(shapedChars);
+
+    if (!haveGlyphs)
+        return FALSE;
+
+    HB_HeuristicPosition(item);
+    return TRUE;
+}
+
+
index e2b2c5c..1b1b80f 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2004,2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-buffer-private.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-gpos-private.h"\r
-\r
-/* Here is how the buffer works internally:\r
- *\r
- * There are two string pointers: in_string and out_string.  They\r
- * always have same allocated size, but different length and positions.\r
- *\r
- * As an optimization, both in_string and out_string may point to the\r
- * same piece of memory, which is owned by in_string.  This remains the\r
- * case as long as:\r
- *\r
- *   - copy_glyph() is called\r
- *   - replace_glyph() is called with inplace=TRUE\r
- *   - add_output_glyph() and add_output_glyphs() are not called\r
- *\r
- * In that case swap(), and copy_glyph(), and replace_glyph() are all\r
- * mostly no-op.\r
- *\r
- * As soon an add_output_glyph[s]() or replace_glyph() with inplace=FALSE is\r
- * called, out_string is moved over to an alternate buffer (alt_string), and\r
- * its current contents (out_length entries) are copied to the alt buffer.\r
- * This should all remain transparent to the user.  swap() then switches\r
- * in_string and alt_string.  alt_string is not allocated until its needed,\r
- * but after that it's grown with in_string unconditionally.\r
- *\r
- * The buffer->separate_out boolean keeps status of whether out_string points\r
- * to in_string (FALSE) or alt_string (TRUE).\r
- */\r
-\r
-/* Internal API */\r
-\r
-static HB_Error\r
-hb_buffer_ensure( HB_Buffer buffer,\r
-                  HB_UInt   size )\r
-{\r
-  HB_UInt new_allocated = buffer->allocated;\r
-\r
-  if (size > new_allocated)\r
-    {\r
-      HB_Error error;\r
-\r
-      while (size > new_allocated)\r
-       new_allocated += (new_allocated >> 1) + 8;\r
-      \r
-      if ( buffer->positions )\r
-        {\r
-         if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) )\r
-           return error;\r
-       }\r
-\r
-      if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) )\r
-       return error;\r
-\r
-      if ( buffer->separate_out )\r
-        {\r
-         if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )\r
-           return error;\r
-\r
-         buffer->out_string = buffer->alt_string;\r
-       }\r
-      else\r
-        {\r
-         buffer->out_string = buffer->in_string;\r
-\r
-         if ( buffer->alt_string )\r
-           {\r
-             if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )\r
-               return error;\r
-           }\r
-       }\r
-\r
-      buffer->allocated = new_allocated;\r
-    }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-static HB_Error\r
-hb_buffer_duplicate_out_buffer( HB_Buffer buffer )\r
-{\r
-  if ( !buffer->alt_string )\r
-    {\r
-      HB_Error error;\r
-\r
-      if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )\r
-       return error;\r
-    }\r
-\r
-  buffer->out_string = buffer->alt_string;\r
-  memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) );\r
-  buffer->separate_out = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-/* Public API */\r
-\r
-HB_Error\r
-hb_buffer_new( HB_Buffer *pbuffer )\r
-{\r
-  HB_Buffer buffer;\r
-  HB_Error error;\r
-\r
-  if ( ALLOC( buffer, sizeof( HB_BufferRec ), HB_Buffer) )\r
-    return error;\r
-\r
-  buffer->allocated = 0;\r
-  buffer->in_string = NULL;\r
-  buffer->alt_string = NULL;\r
-  buffer->positions = NULL;\r
-\r
-  hb_buffer_clear( buffer );\r
-\r
-  *pbuffer = buffer;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-void\r
-hb_buffer_free( HB_Buffer buffer )\r
-{\r
-  FREE( buffer->in_string );\r
-  FREE( buffer->alt_string );\r
-  buffer->out_string = NULL;\r
-  FREE( buffer->positions );\r
-  FREE( buffer );\r
-}\r
-\r
-void\r
-hb_buffer_clear( HB_Buffer buffer )\r
-{\r
-  buffer->in_length = 0;\r
-  buffer->out_length = 0;\r
-  buffer->in_pos = 0;\r
-  buffer->out_pos = 0;\r
-  buffer->out_string = buffer->in_string;\r
-  buffer->separate_out = FALSE;\r
-  buffer->max_ligID = 0;\r
-}\r
-\r
-HB_Error\r
-hb_buffer_add_glyph( HB_Buffer buffer,\r
-                     HB_UInt   glyph_index,\r
-                     HB_UInt   properties,\r
-                     HB_UInt   cluster )\r
-{\r
-  HB_Error error;\r
-  HB_GlyphItem glyph;\r
-  \r
-  error = hb_buffer_ensure( buffer, buffer->in_length + 1 );\r
-  if ( error )\r
-    return error;\r
-\r
-  glyph = &buffer->in_string[buffer->in_length];\r
-  glyph->gindex = glyph_index;\r
-  glyph->properties = properties;\r
-  glyph->cluster = cluster;\r
-  glyph->component = 0;\r
-  glyph->ligID = 0;\r
-  glyph->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;\r
-  \r
-  buffer->in_length++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-/* HarfBuzz-Internal API */\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_clear_output( HB_Buffer buffer )\r
-{\r
-  buffer->out_length = 0;\r
-  buffer->out_pos = 0;\r
-  buffer->out_string = buffer->in_string;\r
-  buffer->separate_out = FALSE;\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_clear_positions( HB_Buffer buffer )\r
-{\r
-  if ( !buffer->positions )\r
-    {\r
-      HB_Error error;\r
-\r
-      if ( ALLOC_ARRAY( buffer->positions, buffer->allocated, HB_PositionRec ) )\r
-       return error;\r
-    }\r
-\r
-  memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL void\r
-_hb_buffer_swap( HB_Buffer buffer )\r
-{\r
-  HB_GlyphItem tmp_string;\r
-  int tmp_length;\r
-  int tmp_pos;\r
-\r
-  if ( buffer->separate_out )\r
-    {\r
-      tmp_string = buffer->in_string;\r
-      buffer->in_string = buffer->out_string;\r
-      buffer->out_string = tmp_string;\r
-      buffer->alt_string = buffer->out_string;\r
-    }\r
-\r
-  tmp_length = buffer->in_length;\r
-  buffer->in_length = buffer->out_length;\r
-  buffer->out_length = tmp_length;\r
-\r
-  tmp_pos = buffer->in_pos;\r
-  buffer->in_pos = buffer->out_pos;\r
-  buffer->out_pos = tmp_pos;\r
-}\r
-\r
-/* The following function copies `num_out' elements from `glyph_data'\r
-   to `buffer->out_string', advancing the in array pointer in the structure\r
-   by `num_in' elements, and the out array pointer by `num_out' elements.\r
-   Finally, it sets the `length' field of `out' equal to\r
-   `pos' of the `out' structure.\r
-\r
-   If `component' is 0xFFFF, the component value from buffer->in_pos\r
-   will copied `num_out' times, otherwise `component' itself will\r
-   be used to fill the `component' fields.\r
-\r
-   If `ligID' is 0xFFFF, the ligID value from buffer->in_pos\r
-   will copied `num_out' times, otherwise `ligID' itself will\r
-   be used to fill the `ligID' fields.\r
-\r
-   The properties for all replacement glyphs are taken\r
-   from the glyph at position `buffer->in_pos'.\r
-\r
-   The cluster value for the glyph at position buffer->in_pos is used\r
-   for all replacement glyphs */\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyphs( HB_Buffer  buffer,\r
-                             HB_UShort  num_in,\r
-                             HB_UShort  num_out,\r
-                             HB_UShort *glyph_data,\r
-                             HB_UShort  component,\r
-                             HB_UShort  ligID )\r
-{\r
-  HB_Error  error;\r
-  HB_UShort i;\r
-  HB_UInt properties;\r
-  HB_UInt cluster;\r
-\r
-  error = hb_buffer_ensure( buffer, buffer->out_pos + num_out );\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( !buffer->separate_out )\r
-    {\r
-      error = hb_buffer_duplicate_out_buffer( buffer );\r
-      if ( error )\r
-       return error;\r
-    }\r
-\r
-  properties = buffer->in_string[buffer->in_pos].properties;\r
-  cluster = buffer->in_string[buffer->in_pos].cluster;\r
-  if ( component == 0xFFFF )\r
-    component = buffer->in_string[buffer->in_pos].component;\r
-  if ( ligID == 0xFFFF )\r
-    ligID = buffer->in_string[buffer->in_pos].ligID;\r
-\r
-  for ( i = 0; i < num_out; i++ )\r
-  {\r
-    HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];\r
-\r
-    item->gindex = glyph_data[i];\r
-    item->properties = properties;\r
-    item->cluster = cluster;\r
-    item->component = component;\r
-    item->ligID = ligID;\r
-    item->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;\r
-  }\r
-\r
-  buffer->in_pos  += num_in;\r
-  buffer->out_pos += num_out;\r
-\r
-  buffer->out_length = buffer->out_pos;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_add_output_glyph( HB_Buffer buffer,\r
-                            HB_UInt   glyph_index,\r
-                            HB_UShort component,\r
-                            HB_UShort ligID )\r
-{\r
-  HB_UShort glyph_data =  glyph_index;\r
-\r
-  return _hb_buffer_add_output_glyphs ( buffer, 1, 1,\r
-                                       &glyph_data, component, ligID );\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_copy_output_glyph ( HB_Buffer buffer )\r
-{  \r
-  HB_Error  error;\r
-\r
-  error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );\r
-  if ( error )\r
-    return error;\r
-  \r
-  if ( buffer->separate_out )\r
-    {\r
-      buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];\r
-    }\r
-\r
-  buffer->in_pos++;\r
-  buffer->out_pos++;\r
-  buffer->out_length = buffer->out_pos;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_hb_buffer_replace_output_glyph( HB_Buffer buffer,\r
-                                HB_UInt   glyph_index,\r
-                                HB_Bool   inplace )\r
-{\r
-\r
-  HB_Error error;\r
-\r
-  if ( inplace )\r
-    {\r
-      error = _hb_buffer_copy_output_glyph ( buffer );\r
-      if ( error )\r
-       return error;\r
-\r
-      buffer->out_string[buffer->out_pos-1].gindex = glyph_index;\r
-    }\r
-  else\r
-    {\r
-      return _hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF );\r
-    }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL HB_UShort\r
-_hb_buffer_allocate_ligid( HB_Buffer buffer )\r
-{\r
-  buffer->max_ligID++;\r
-  if (HB_UNLIKELY (buffer->max_ligID == 0))\r
-    buffer->max_ligID++;\r
-\r
-  return buffer->max_ligID;\r
-}\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2004,2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-buffer-private.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-gpos-private.h"
+
+/* Here is how the buffer works internally:
+ *
+ * There are two string pointers: in_string and out_string.  They
+ * always have same allocated size, but different length and positions.
+ *
+ * As an optimization, both in_string and out_string may point to the
+ * same piece of memory, which is owned by in_string.  This remains the
+ * case as long as:
+ *
+ *   - copy_glyph() is called
+ *   - replace_glyph() is called with inplace=TRUE
+ *   - add_output_glyph() and add_output_glyphs() are not called
+ *
+ * In that case swap(), and copy_glyph(), and replace_glyph() are all
+ * mostly no-op.
+ *
+ * As soon an add_output_glyph[s]() or replace_glyph() with inplace=FALSE is
+ * called, out_string is moved over to an alternate buffer (alt_string), and
+ * its current contents (out_length entries) are copied to the alt buffer.
+ * This should all remain transparent to the user.  swap() then switches
+ * in_string and alt_string.  alt_string is not allocated until its needed,
+ * but after that it's grown with in_string unconditionally.
+ *
+ * The buffer->separate_out boolean keeps status of whether out_string points
+ * to in_string (FALSE) or alt_string (TRUE).
+ */
+
+/* Internal API */
+
+static HB_Error
+hb_buffer_ensure( HB_Buffer buffer,
+                  HB_UInt   size )
+{
+  HB_UInt new_allocated = buffer->allocated;
+
+  if (size > new_allocated)
+    {
+      HB_Error error;
+
+      while (size > new_allocated)
+       new_allocated += (new_allocated >> 1) + 8;
+      
+      if ( buffer->positions )
+        {
+         if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) )
+           return error;
+       }
+
+      if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) )
+       return error;
+
+      if ( buffer->separate_out )
+        {
+         if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )
+           return error;
+
+         buffer->out_string = buffer->alt_string;
+       }
+      else
+        {
+         buffer->out_string = buffer->in_string;
+
+         if ( buffer->alt_string )
+           {
+             if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )
+               return error;
+           }
+       }
+
+      buffer->allocated = new_allocated;
+    }
+
+  return HB_Err_Ok;
+}
+
+static HB_Error
+hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
+{
+  if ( !buffer->alt_string )
+    {
+      HB_Error error;
+
+      if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )
+       return error;
+    }
+
+  buffer->out_string = buffer->alt_string;
+  memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) );
+  buffer->separate_out = TRUE;
+
+  return HB_Err_Ok;
+}
+
+/* Public API */
+
+HB_Error
+hb_buffer_new( HB_Buffer *pbuffer )
+{
+  HB_Buffer buffer;
+  HB_Error error;
+
+  if ( ALLOC( buffer, sizeof( HB_BufferRec ), HB_Buffer) )
+    return error;
+
+  buffer->allocated = 0;
+  buffer->in_string = NULL;
+  buffer->alt_string = NULL;
+  buffer->positions = NULL;
+
+  hb_buffer_clear( buffer );
+
+  *pbuffer = buffer;
+
+  return HB_Err_Ok;
+}
+
+void
+hb_buffer_free( HB_Buffer buffer )
+{
+  FREE( buffer->in_string );
+  FREE( buffer->alt_string );
+  buffer->out_string = NULL;
+  FREE( buffer->positions );
+  FREE( buffer );
+}
+
+void
+hb_buffer_clear( HB_Buffer buffer )
+{
+  buffer->in_length = 0;
+  buffer->out_length = 0;
+  buffer->in_pos = 0;
+  buffer->out_pos = 0;
+  buffer->out_string = buffer->in_string;
+  buffer->separate_out = FALSE;
+  buffer->max_ligID = 0;
+}
+
+HB_Error
+hb_buffer_add_glyph( HB_Buffer buffer,
+                     HB_UInt   glyph_index,
+                     HB_UInt   properties,
+                     HB_UInt   cluster )
+{
+  HB_Error error;
+  HB_GlyphItem glyph;
+  
+  error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
+  if ( error )
+    return error;
+
+  glyph = &buffer->in_string[buffer->in_length];
+  glyph->gindex = glyph_index;
+  glyph->properties = properties;
+  glyph->cluster = cluster;
+  glyph->component = 0;
+  glyph->ligID = 0;
+  glyph->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;
+  
+  buffer->in_length++;
+
+  return HB_Err_Ok;
+}
+
+/* HarfBuzz-Internal API */
+
+HB_INTERNAL void
+_hb_buffer_clear_output( HB_Buffer buffer )
+{
+  buffer->out_length = 0;
+  buffer->out_pos = 0;
+  buffer->out_string = buffer->in_string;
+  buffer->separate_out = FALSE;
+}
+
+HB_INTERNAL HB_Error
+_hb_buffer_clear_positions( HB_Buffer buffer )
+{
+  if ( !buffer->positions )
+    {
+      HB_Error error;
+
+      if ( ALLOC_ARRAY( buffer->positions, buffer->allocated, HB_PositionRec ) )
+       return error;
+    }
+
+  memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL void
+_hb_buffer_swap( HB_Buffer buffer )
+{
+  HB_GlyphItem tmp_string;
+  int tmp_length;
+  int tmp_pos;
+
+  if ( buffer->separate_out )
+    {
+      tmp_string = buffer->in_string;
+      buffer->in_string = buffer->out_string;
+      buffer->out_string = tmp_string;
+      buffer->alt_string = buffer->out_string;
+    }
+
+  tmp_length = buffer->in_length;
+  buffer->in_length = buffer->out_length;
+  buffer->out_length = tmp_length;
+
+  tmp_pos = buffer->in_pos;
+  buffer->in_pos = buffer->out_pos;
+  buffer->out_pos = tmp_pos;
+}
+
+/* The following function copies `num_out' elements from `glyph_data'
+   to `buffer->out_string', advancing the in array pointer in the structure
+   by `num_in' elements, and the out array pointer by `num_out' elements.
+   Finally, it sets the `length' field of `out' equal to
+   `pos' of the `out' structure.
+
+   If `component' is 0xFFFF, the component value from buffer->in_pos
+   will copied `num_out' times, otherwise `component' itself will
+   be used to fill the `component' fields.
+
+   If `ligID' is 0xFFFF, the ligID value from buffer->in_pos
+   will copied `num_out' times, otherwise `ligID' itself will
+   be used to fill the `ligID' fields.
+
+   The properties for all replacement glyphs are taken
+   from the glyph at position `buffer->in_pos'.
+
+   The cluster value for the glyph at position buffer->in_pos is used
+   for all replacement glyphs */
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyphs( HB_Buffer  buffer,
+                             HB_UShort  num_in,
+                             HB_UShort  num_out,
+                             HB_UShort *glyph_data,
+                             HB_UShort  component,
+                             HB_UShort  ligID )
+{
+  HB_Error  error;
+  HB_UShort i;
+  HB_UInt properties;
+  HB_UInt cluster;
+
+  error = hb_buffer_ensure( buffer, buffer->out_pos + num_out );
+  if ( error )
+    return error;
+
+  if ( !buffer->separate_out )
+    {
+      error = hb_buffer_duplicate_out_buffer( buffer );
+      if ( error )
+       return error;
+    }
+
+  properties = buffer->in_string[buffer->in_pos].properties;
+  cluster = buffer->in_string[buffer->in_pos].cluster;
+  if ( component == 0xFFFF )
+    component = buffer->in_string[buffer->in_pos].component;
+  if ( ligID == 0xFFFF )
+    ligID = buffer->in_string[buffer->in_pos].ligID;
+
+  for ( i = 0; i < num_out; i++ )
+  {
+    HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
+
+    item->gindex = glyph_data[i];
+    item->properties = properties;
+    item->cluster = cluster;
+    item->component = component;
+    item->ligID = ligID;
+    item->gproperties = HB_GLYPH_PROPERTIES_UNKNOWN;
+  }
+
+  buffer->in_pos  += num_in;
+  buffer->out_pos += num_out;
+
+  buffer->out_length = buffer->out_pos;
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL HB_Error
+_hb_buffer_add_output_glyph( HB_Buffer buffer,
+                            HB_UInt   glyph_index,
+                            HB_UShort component,
+                            HB_UShort ligID )
+{
+  HB_UShort glyph_data =  glyph_index;
+
+  return _hb_buffer_add_output_glyphs ( buffer, 1, 1,
+                                       &glyph_data, component, ligID );
+}
+
+HB_INTERNAL HB_Error
+_hb_buffer_copy_output_glyph ( HB_Buffer buffer )
+{  
+  HB_Error  error;
+
+  error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
+  if ( error )
+    return error;
+  
+  if ( buffer->separate_out )
+    {
+      buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
+    }
+
+  buffer->in_pos++;
+  buffer->out_pos++;
+  buffer->out_length = buffer->out_pos;
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL HB_Error
+_hb_buffer_replace_output_glyph( HB_Buffer buffer,
+                                HB_UInt   glyph_index,
+                                HB_Bool   inplace )
+{
+
+  HB_Error error;
+
+  if ( inplace )
+    {
+      error = _hb_buffer_copy_output_glyph ( buffer );
+      if ( error )
+       return error;
+
+      buffer->out_string[buffer->out_pos-1].gindex = glyph_index;
+    }
+  else
+    {
+      return _hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF );
+    }
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL HB_UShort
+_hb_buffer_allocate_ligid( HB_Buffer buffer )
+{
+  buffer->max_ligID++;
+  if (HB_UNLIKELY (buffer->max_ligID == 0))
+    buffer->max_ligID++;
+
+  return buffer->max_ligID;
+}
index 7792bb6..8c81da1 100755 (executable)
-/*\r
- * Copyright (C) 2000, 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Owen Taylor, Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-dump.h"\r
-#include "harfbuzz-gdef-private.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-gpos-private.h"\r
-#include "harfbuzz-open-private.h"\r
-#include <stdarg.h>\r
-\r
-#define DUMP(format) dump (stream, indent, format)\r
-#define DUMP1(format, arg1) dump (stream, indent, format, arg1)\r
-#define DUMP2(format, arg1, arg2) dump (stream, indent, format, arg1, arg2)\r
-#define DUMP3(format, arg1, arg2, arg3) dump (stream, indent, format, arg1, arg2, arg3)\r
-\r
-#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)\r
-#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)\r
-#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)\r
-#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)\r
-#define DUMP_USHORT_ARRAY(strct,fld,cnt) Dump_UShort_Array ((strct)->fld, cnt, #fld, stream, indent);\r
-\r
-#define DEF_DUMP(type) static void Dump_ ## type (HB_ ## type *type, FILE *stream, int indent, HB_Type hb_type)\r
-#define RECURSE(name, type, val) do {  DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)\r
-#define RECURSE_NUM(name, i, type, val) do {  DUMP1 ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)\r
-#define DUMP_VALUE_RECORD(val, frmt) do {  DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, hb_type, frmt); DUMP ("</ValueRecord>\n"); } while (0)\r
-\r
-static void\r
-do_indent (FILE *stream, int indent)\r
-{\r
-  fprintf (stream, "%*s", indent * 3, "");\r
-}\r
-\r
-static void\r
-dump (FILE *stream, int indent, const char *format, ...)\r
-{\r
-  va_list list;\r
-\r
-  do_indent (stream, indent);\r
-\r
-  va_start (list, format);\r
-  vfprintf (stream, format, list);\r
-  va_end (list);\r
-}\r
-\r
-static void\r
-Dump_UShort_Array (HB_UShort *array, int count, const char *name, FILE *stream, int indent)\r
-{\r
-  int i;\r
-\r
-  do_indent (stream, indent);\r
-\r
-  fprintf (stream, "<%s>", name);\r
-  for (i = 0; i < count; i++)\r
-    fprintf (stream, "%d%s", array[i], i == 0 ? "" : " ");\r
-  fprintf (stream, "</%s>\n", name);\r
-}\r
-\r
-static void\r
-Print_Tag (HB_UInt tag, FILE *stream)\r
-{\r
-  fprintf (stream, "%c%c%c%c",\r
-          (unsigned char)(tag >> 24),\r
-          (unsigned char)((tag >> 16) & 0xff),\r
-          (unsigned char)((tag >> 8) & 0xff),\r
-          (unsigned char)(tag & 0xff));\r
-}\r
-\r
-DEF_DUMP (LangSys)\r
-{\r
-  int i;\r
-\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (LangSys, LookupOrderOffset);\r
-  DUMP_FUINT (LangSys, ReqFeatureIndex);\r
-  DUMP_FUINT (LangSys, FeatureCount);\r
-\r
-  for (i=0; i < LangSys->FeatureCount; i++)\r
-    DUMP1("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);\r
-}\r
-\r
-DEF_DUMP (ScriptTable)\r
-{\r
-  int i;\r
-\r
-  RECURSE (DefaultLangSys, LangSys, &ScriptTable->DefaultLangSys);\r
-\r
-  DUMP_FUINT (ScriptTable, LangSysCount);\r
-\r
-  for (i=0; i < ScriptTable->LangSysCount; i++)\r
-    {\r
-      do_indent (stream, indent);\r
-      fprintf (stream, "<LangSysTag>");\r
-      Print_Tag (ScriptTable->LangSysRecord[i].LangSysTag, stream);\r
-      fprintf (stream, "</LangSysTag>\n");\r
-      RECURSE_NUM (LangSys, i, LangSys, &ScriptTable->LangSysRecord[i].LangSys);\r
-    }\r
-}\r
-\r
-DEF_DUMP (ScriptList)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (ScriptList, ScriptCount);\r
-\r
-  for (i=0; i < ScriptList->ScriptCount; i++)\r
-    {\r
-      do_indent (stream, indent);\r
-      fprintf (stream, "<ScriptTag>");\r
-      Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream);\r
-      fprintf (stream, "</ScriptTag>\n");\r
-      RECURSE_NUM (Script, i, ScriptTable, &ScriptList->ScriptRecord[i].Script);\r
-    }\r
-}\r
-\r
-DEF_DUMP (Feature)\r
-{\r
-  int i;\r
-\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (Feature, FeatureParams);\r
-  DUMP_FUINT (Feature, LookupListCount);\r
-\r
-  for (i=0; i < Feature->LookupListCount; i++)\r
-    DUMP1("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);\r
-}\r
-\r
-DEF_DUMP (MarkRecord)\r
-{\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (MarkRecord, Class);\r
-  DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );\r
-}\r
-\r
-DEF_DUMP (MarkArray)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (MarkArray, MarkCount);\r
-\r
-  for (i=0; i < MarkArray->MarkCount; i++)\r
-    RECURSE_NUM (MarkRecord, i, MarkRecord, &MarkArray->MarkRecord[i]);\r
-}\r
-\r
-DEF_DUMP (FeatureList)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (FeatureList, FeatureCount);\r
-\r
-  for (i=0; i < FeatureList->FeatureCount; i++)\r
-    {\r
-      do_indent (stream, indent);\r
-      fprintf (stream, "<FeatureTag>");\r
-      Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream);\r
-      fprintf (stream, "</FeatureTag> <!-- %d -->\n", i);\r
-      RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature);\r
-    }\r
-}\r
-\r
-DEF_DUMP (Coverage)\r
-{\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (Coverage, CoverageFormat);\r
-\r
-  if (Coverage->CoverageFormat == 1)\r
-    {\r
-      int i;\r
-      DUMP_FUINT (&Coverage->cf.cf1, GlyphCount);\r
-\r
-      for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++)\r
-       DUMP2("<Glyph>%#06x</Glyph> <!-- %d -->\n",\r
-             Coverage->cf.cf1.GlyphArray[i], i);\r
-    }\r
-  else\r
-    {\r
-      int i;\r
-      DUMP_FUINT (&Coverage->cf.cf2, RangeCount);\r
-\r
-      for ( i = 0; i < Coverage->cf.cf2.RangeCount; i++ )\r
-         DUMP3("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n",\r
-               Coverage->cf.cf2.RangeRecord[i].Start,\r
-               Coverage->cf.cf2.RangeRecord[i].End, i);\r
-    }\r
-}\r
-\r
-DEF_DUMP (ClassRangeRecord)\r
-{\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FGLYPH (ClassRangeRecord, Start);\r
-  DUMP_FGLYPH (ClassRangeRecord, End);\r
-  DUMP_FUINT (ClassRangeRecord, Class);\r
-}\r
-\r
-DEF_DUMP (ClassDefinition)\r
-{\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT( ClassDefinition, ClassFormat);\r
-  DUMP_FUINT( ClassDefinition, loaded);\r
-\r
-  if (ClassDefinition->ClassFormat == 1)\r
-    {\r
-      int i;\r
-      HB_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;\r
-      DUMP("<ClassDefinition>\n");\r
-      DUMP_FUINT (ClassDefFormat1, StartGlyph );\r
-      DUMP_FUINT (ClassDefFormat1, GlyphCount );\r
-      for (i = 0; i < ClassDefFormat1->GlyphCount; i++)\r
-       DUMP2(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i],\r
-             ClassDefFormat1->StartGlyph+i );\r
-    }\r
-  else if (ClassDefinition->ClassFormat == 2)\r
-    {\r
-      int i;\r
-      HB_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;\r
-      DUMP_FUINT (ClassDefFormat2, ClassRangeCount);\r
-\r
-      for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++)\r
-       RECURSE_NUM (ClassRangeRecord, i, ClassRangeRecord, &ClassDefFormat2->ClassRangeRecord[i]);\r
-    }\r
-  else\r
-    fprintf(stderr, "invalid class def table!!!\n");\r
-}\r
-\r
-DEF_DUMP (SubstLookupRecord)\r
-{\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (SubstLookupRecord, SequenceIndex);\r
-  DUMP_FUINT (SubstLookupRecord, LookupListIndex);\r
-}\r
-\r
-DEF_DUMP (ChainSubClassRule)\r
-{\r
-  int i;\r
-\r
-  DUMP_USHORT_ARRAY (ChainSubClassRule, Backtrack, ChainSubClassRule->BacktrackGlyphCount);\r
-  DUMP_USHORT_ARRAY (ChainSubClassRule, Input, ChainSubClassRule->InputGlyphCount - 1);\r
-  DUMP_USHORT_ARRAY (ChainSubClassRule, Lookahead, ChainSubClassRule->LookaheadGlyphCount);\r
-\r
-  for (i = 0; i < ChainSubClassRule->SubstCount; i++)\r
-    RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainSubClassRule->SubstLookupRecord[i]);\r
-\r
-  indent--;\r
-}\r
-\r
-DEF_DUMP (ChainSubClassSet)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount );\r
-  for (i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++)\r
-    RECURSE_NUM (ChainSubClassRule, i, ChainSubClassRule, &ChainSubClassSet->ChainSubClassRule[i]);\r
-}\r
-\r
-static void\r
-Dump_GSUB_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  HB_SingleSubst *SingleSubst = &subtable->st.gsub.single;\r
-\r
-  DUMP_FUINT (SingleSubst, SubstFormat);\r
-  RECURSE (Coverage, Coverage, &SingleSubst->Coverage);\r
-\r
-  if (SingleSubst->SubstFormat == 1)\r
-    {\r
-      DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID);\r
-    }\r
-  else\r
-    {\r
-      int i;\r
-\r
-      DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount);\r
-      for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++)\r
-       DUMP2("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);\r
-    }\r
-}\r
-\r
-DEF_DUMP (Ligature)\r
-{\r
-  int i;\r
-\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FGLYPH (Ligature, LigGlyph);\r
-  DUMP_FUINT (Ligature, ComponentCount);\r
-\r
-  for (i=0; i < Ligature->ComponentCount - 1; i++)\r
-    DUMP1("<Component>%#06x</Component>\n", Ligature->Component[i]);\r
-}\r
-\r
-DEF_DUMP (LigatureSet)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (LigatureSet, LigatureCount);\r
-\r
-  for (i=0; i < LigatureSet->LigatureCount; i++)\r
-    RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]);\r
-}\r
-\r
-static void\r
-Dump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  int i;\r
-  HB_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;\r
-\r
-  DUMP_FUINT (LigatureSubst, SubstFormat);\r
-  RECURSE (Coverage, Coverage, &LigatureSubst->Coverage);\r
-\r
-  DUMP_FUINT (LigatureSubst, LigatureSetCount);\r
-\r
-  for (i=0; i < LigatureSubst->LigatureSetCount; i++)\r
-    RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]);\r
-}\r
-\r
-DEF_DUMP (ContextSubstFormat1)\r
-{\r
-  HB_UNUSED(hb_type);\r
-  HB_UNUSED(ContextSubstFormat1);\r
-\r
-\r
-  DUMP("<!-- Not implemented!!! -->\n");\r
-}\r
-\r
-DEF_DUMP (ContextSubstFormat2)\r
-{\r
-  DUMP_FUINT (ContextSubstFormat2, MaxContextLength);\r
-  RECURSE (Coverage, Coverage, &ContextSubstFormat2->Coverage);\r
-  RECURSE (ClassDefinition, ClassDefinition, &ContextSubstFormat2->ClassDef);\r
-}\r
-\r
-DEF_DUMP (ContextSubstFormat3)\r
-{\r
-  HB_UNUSED(hb_type);\r
-  HB_UNUSED(ContextSubstFormat3);\r
-\r
-  DUMP("<!-- Not implemented!!! -->\n");\r
-}\r
-\r
-static void\r
-Dump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  HB_ContextSubst *ContextSubst = &subtable->st.gsub.context;\r
-\r
-  DUMP_FUINT (ContextSubst, SubstFormat);\r
-  switch( ContextSubst->SubstFormat )\r
-    {\r
-    case 1:\r
-      Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, hb_type);\r
-      break;\r
-    case 2:\r
-      Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, hb_type);\r
-      break;\r
-    case 3:\r
-      Dump_ContextSubstFormat3 (&ContextSubst->csf.csf3, stream, indent+2, hb_type);\r
-      break;\r
-    default:\r
-      fprintf(stderr, "invalid subformat!!!!!\n");\r
-    }\r
-}\r
-\r
-DEF_DUMP (ChainContextSubstFormat1)\r
-{\r
-  HB_UNUSED(hb_type);\r
-  HB_UNUSED(ChainContextSubstFormat1);\r
-\r
-  DUMP("<!-- Not implemented!!! -->\n");\r
-}\r
-\r
-DEF_DUMP (ChainContextSubstFormat2)\r
-{\r
-  int i;\r
-\r
-  RECURSE (Coverage, Coverage, &ChainContextSubstFormat2->Coverage);\r
-  DUMP_FUINT (ChainContextSubstFormat2, MaxBacktrackLength);\r
-  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->BacktrackClassDef);\r
-  DUMP_FUINT (ChainContextSubstFormat2, MaxInputLength);\r
-  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->InputClassDef);\r
-  DUMP_FUINT (ChainContextSubstFormat2, MaxLookaheadLength);\r
-  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->LookaheadClassDef);\r
-\r
-  DUMP_FUINT (ChainContextSubstFormat2, ChainSubClassSetCount);\r
-  for (i = 0; i < ChainContextSubstFormat2->ChainSubClassSetCount; i++)\r
-    RECURSE (ChainSubClassSet, ChainSubClassSet, &ChainContextSubstFormat2->ChainSubClassSet[i]);\r
-}\r
-\r
-DEF_DUMP (ChainContextSubstFormat3)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (ChainContextSubstFormat3, BacktrackGlyphCount);\r
-  for (i = 0; i < ChainContextSubstFormat3->BacktrackGlyphCount; i++)\r
-    RECURSE (BacktrackCoverage, Coverage, &ChainContextSubstFormat3->BacktrackCoverage[i]);\r
-  DUMP_FUINT (ChainContextSubstFormat3, InputGlyphCount);\r
-  for (i = 0; i < ChainContextSubstFormat3->InputGlyphCount; i++)\r
-    RECURSE (InputCoverage, Coverage, &ChainContextSubstFormat3->InputCoverage[i]);\r
-  DUMP_FUINT (ChainContextSubstFormat3, LookaheadGlyphCount);\r
-  for (i = 0; i < ChainContextSubstFormat3->LookaheadGlyphCount; i++)\r
-    RECURSE (LookaheadCoverage, Coverage, &ChainContextSubstFormat3->LookaheadCoverage[i]);\r
-\r
-  for (i = 0; i < ChainContextSubstFormat3->SubstCount; i++)\r
-    RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainContextSubstFormat3->SubstLookupRecord[i]);\r
-\r
-}\r
-\r
-static void\r
-Dump_GSUB_Lookup_Chain (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  HB_ChainContextSubst *chain = &subtable->st.gsub.chain;\r
-\r
-  DUMP_FUINT (chain, SubstFormat);\r
-  switch (chain->SubstFormat)\r
-    {\r
-    case 1:\r
-      Dump_ChainContextSubstFormat1 (&chain->ccsf.ccsf1, stream, indent+2, hb_type);\r
-      break;\r
-    case 2:\r
-      Dump_ChainContextSubstFormat2 (&chain->ccsf.ccsf2, stream, indent+2, hb_type);\r
-      break;\r
-    case 3:\r
-      Dump_ChainContextSubstFormat3 (&chain->ccsf.ccsf3, stream, indent+2, hb_type);\r
-      break;\r
-    default:\r
-      fprintf(stderr, "invalid subformat!!!!!\n");\r
-    }\r
-}\r
-\r
-static void\r
-Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  int i;\r
-  int bits;\r
-  int n_per;\r
-  unsigned int mask;\r
-\r
-  HB_UNUSED(hb_type);\r
-\r
-  DUMP_FUINT (Device, StartSize);\r
-  DUMP_FUINT (Device, EndSize);\r
-  DUMP_FUINT (Device, DeltaFormat);\r
-  switch (Device->DeltaFormat)\r
-    {\r
-    case 1:\r
-      bits = 2;\r
-      break;\r
-    case 2:\r
-      bits = 4;\r
-      break;\r
-    case 3:\r
-      bits = 8;\r
-      break;\r
-    default:\r
-      bits = 0;\r
-      break;\r
-    }\r
-\r
-  DUMP ("<DeltaValue>");\r
-  if (!bits)\r
-    {\r
-\r
-      fprintf(stderr, "invalid DeltaFormat!!!!!\n");\r
-    }\r
-  else\r
-    {\r
-      n_per = 16 / bits;\r
-      mask = (1 << bits) - 1;\r
-      mask = mask << (16 - bits);\r
-\r
-      for (i = Device->StartSize; i <= Device->EndSize ; i++)\r
-       {\r
-         HB_UShort val = Device->DeltaValue[i / n_per];\r
-         HB_Short signed_val = ((val << ((i % n_per) * bits)) & mask);\r
-         dump (stream, indent, "%d", signed_val >> (16 - bits));\r
-         if (i != Device->EndSize)\r
-           DUMP (", ");\r
-       }\r
-    }\r
-  DUMP ("</DeltaValue>\n");\r
-}\r
-\r
-static void\r
-Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort value_format)\r
-{\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT)\r
-    DUMP_FINT (ValueRecord, XPlacement);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT)\r
-    DUMP_FINT (ValueRecord, YPlacement);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE)\r
-    DUMP_FINT (ValueRecord, XAdvance);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE)\r
-    DUMP_FINT (ValueRecord, XAdvance);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE)\r
-    RECURSE (Device, Device, &ValueRecord->XPlacementDevice);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE)\r
-    RECURSE (Device, Device, &ValueRecord->YPlacementDevice);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE)\r
-    RECURSE (Device, Device, &ValueRecord->XAdvanceDevice);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE)\r
-    RECURSE (Device, Device, &ValueRecord->YAdvanceDevice);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT)\r
-    DUMP_FUINT (ValueRecord, XIdPlacement);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT)\r
-    DUMP_FUINT (ValueRecord, YIdPlacement);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE)\r
-    DUMP_FUINT (ValueRecord, XIdAdvance);\r
-  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE)\r
-    DUMP_FUINT (ValueRecord, XIdAdvance);\r
-}\r
-\r
-static void\r
-Dump_GPOS_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  HB_SinglePos *SinglePos = &subtable->st.gpos.single;\r
-\r
-  DUMP_FUINT (SinglePos, PosFormat);\r
-  RECURSE (Coverage, Coverage, &SinglePos->Coverage);\r
-\r
-  DUMP_FUINT (SinglePos, ValueFormat);\r
-\r
-  if (SinglePos->PosFormat == 1)\r
-    {\r
-      DUMP_VALUE_RECORD (&SinglePos->spf.spf1.Value, SinglePos->ValueFormat);\r
-    }\r
-  else\r
-    {\r
-      int i;\r
-\r
-      DUMP_FUINT (&SinglePos->spf.spf2, ValueCount);\r
-      for (i = 0; i < SinglePos->spf.spf2.ValueCount; i++)\r
-       DUMP_VALUE_RECORD (&SinglePos->spf.spf2.Value[i], SinglePos->ValueFormat);\r
-    }\r
-}\r
-\r
-static void\r
-Dump_PairValueRecord (HB_PairValueRecord *PairValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)\r
-{\r
-  DUMP_FUINT (PairValueRecord, SecondGlyph);\r
-  DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1);\r
-  DUMP_VALUE_RECORD (&PairValueRecord->Value2, ValueFormat2);\r
-}\r
-\r
-static void\r
-Dump_PairSet (HB_PairSet *PairSet, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)\r
-{\r
-  int i;\r
-  DUMP_FUINT (PairSet, PairValueCount);\r
-\r
-  for (i = 0; i < PairSet->PairValueCount; i++)\r
-    {\r
-      DUMP ("<PairValueRecord>\n");\r
-      Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, hb_type, ValueFormat1, ValueFormat2);\r
-      DUMP ("</PairValueRecord>\n");\r
-    }\r
-}\r
-\r
-static void\r
-Dump_GPOS_Lookup_Pair (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  HB_PairPos *PairPos = &subtable->st.gpos.pair;\r
-\r
-  DUMP_FUINT (PairPos, PosFormat);\r
-  RECURSE (Coverage, Coverage, &PairPos->Coverage);\r
-\r
-  DUMP_FUINT (PairPos, ValueFormat1);\r
-  DUMP_FUINT (PairPos, ValueFormat2);\r
-\r
-  if (PairPos->PosFormat == 1)\r
-    {\r
-      int i;\r
-\r
-      DUMP_FUINT (&PairPos->ppf.ppf1, PairSetCount);\r
-      for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++)\r
-       {\r
-         DUMP ("<PairSet>\n");\r
-         Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, hb_type, PairPos->ValueFormat1, PairPos->ValueFormat2);\r
-         DUMP ("</PairSet>\n");\r
-       }\r
-    }\r
-  else\r
-    {\r
-    }\r
-}\r
-\r
-static void\r
-Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)\r
-{\r
-  int i;\r
-  HB_MarkBasePos *markbase = &subtable->st.gpos.markbase;\r
-\r
-  DUMP_FUINT (markbase, PosFormat);\r
-  RECURSE (Coverage, Coverage, &markbase->MarkCoverage);\r
-  RECURSE (Coverage, Coverage, &markbase->BaseCoverage);\r
-  DUMP_FUINT (markbase, ClassCount);\r
-  RECURSE (MarkArray, MarkArray, &markbase->MarkArray);\r
-\r
-  DUMP ("<BaseArray>\n");\r
-  indent++;\r
-\r
-  DUMP_FUINT (&markbase->BaseArray, BaseCount);\r
-  for (i = 0; i < markbase->BaseArray.BaseCount; i++)\r
-    {\r
-      int j;\r
-      HB_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];\r
-      DUMP1 ("<BaseRecord> <!-- %d -->\n",  i);\r
-      for (j = 0; j < markbase->ClassCount; j++)\r
-       DUMP1 ("  <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat);\r
-      DUMP ("<BaseRecord>\n");\r
-    }\r
-\r
-  indent--;\r
-  DUMP ("</BaseArray>\n");\r
-}\r
-\r
-DEF_DUMP (Lookup)\r
-{\r
-  int i;\r
-  const char *lookup_name;\r
-  void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;\r
-\r
-  if (hb_type == HB_Type_GSUB)\r
-    {\r
-      switch (Lookup->LookupType)\r
-       {\r
-       case  HB_GSUB_LOOKUP_SINGLE:\r
-         lookup_name = "SINGLE";\r
-         lookup_func = Dump_GSUB_Lookup_Single;\r
-         break;\r
-       case  HB_GSUB_LOOKUP_MULTIPLE:\r
-         lookup_name = "MULTIPLE";\r
-         break;\r
-       case  HB_GSUB_LOOKUP_ALTERNATE:\r
-         lookup_name = "ALTERNATE";\r
-         break;\r
-       case  HB_GSUB_LOOKUP_LIGATURE:\r
-         lookup_name = "LIGATURE";\r
-         lookup_func = Dump_GSUB_Lookup_Ligature;\r
-         break;\r
-       case  HB_GSUB_LOOKUP_CONTEXT:\r
-         lookup_name = "CONTEXT";\r
-         lookup_func = Dump_GSUB_Lookup_Context;\r
-         break;\r
-       case  HB_GSUB_LOOKUP_CHAIN:\r
-         lookup_name = "CHAIN";\r
-         lookup_func = Dump_GSUB_Lookup_Chain;\r
-         break;\r
-       default:\r
-         lookup_name = "(unknown)";\r
-         lookup_func = NULL;\r
-         break;\r
-       }\r
-    }\r
-  else\r
-    {\r
-      switch (Lookup->LookupType)\r
-       {\r
-       case HB_GPOS_LOOKUP_SINGLE:\r
-         lookup_name = "SINGLE";\r
-         lookup_func = Dump_GPOS_Lookup_Single;\r
-         break;\r
-       case HB_GPOS_LOOKUP_PAIR:\r
-         lookup_name = "PAIR";\r
-         lookup_func = Dump_GPOS_Lookup_Pair;\r
-         break;\r
-       case HB_GPOS_LOOKUP_CURSIVE:\r
-         lookup_name = "CURSIVE";\r
-         break;\r
-       case HB_GPOS_LOOKUP_MARKBASE:\r
-         lookup_name = "MARKBASE";\r
-         lookup_func = Dump_GPOS_Lookup_Markbase;\r
-         break;\r
-       case HB_GPOS_LOOKUP_MARKLIG:\r
-         lookup_name = "MARKLIG";\r
-         break;\r
-       case HB_GPOS_LOOKUP_MARKMARK:\r
-         lookup_name = "MARKMARK";\r
-         break;\r
-       case HB_GPOS_LOOKUP_CONTEXT:\r
-         lookup_name = "CONTEXT";\r
-         break;\r
-       case HB_GPOS_LOOKUP_CHAIN:\r
-         lookup_name = "CHAIN";\r
-         break;\r
-       default:\r
-         lookup_name = "(unknown)";\r
-         lookup_func = NULL;\r
-         break;\r
-       }\r
-    }\r
-\r
-  DUMP2("<LookupType>%s</LookupType> <!-- %d -->\n", lookup_name, Lookup->LookupType);\r
-  DUMP1("<LookupFlag>%#06x</LookupFlag>\n", Lookup->LookupFlag);\r
-\r
-  for (i=0; i < Lookup->SubTableCount; i++)\r
-    {\r
-      DUMP ("<Subtable>\n");\r
-      if (lookup_func)\r
-       (*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, hb_type);\r
-      DUMP ("</Subtable>\n");\r
-    }\r
-}\r
-\r
-DEF_DUMP (LookupList)\r
-{\r
-  int i;\r
-\r
-  DUMP_FUINT (LookupList, LookupCount);\r
-\r
-  for (i=0; i < LookupList->LookupCount; i++)\r
-    RECURSE_NUM (Lookup, i, Lookup, &LookupList->Lookup[i]);\r
-}\r
-\r
-void\r
-HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream)\r
-{\r
-  int indent = 1;\r
-  HB_Type hb_type = HB_Type_GSUB;\r
-\r
-  do_indent (stream, indent);\r
-  fprintf(stream, "<!-- GSUB -->\n");\r
-  RECURSE (ScriptList, ScriptList, &gsub->ScriptList);\r
-  RECURSE (FeatureList, FeatureList, &gsub->FeatureList);\r
-  RECURSE (LookupList, LookupList, &gsub->LookupList);\r
-}\r
-\r
-void\r
-HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream)\r
-{\r
-  int indent = 1;\r
-  HB_Type hb_type = HB_Type_GPOS;\r
-\r
-  do_indent (stream, indent);\r
-  fprintf(stream, "<!-- GPOS -->\n");\r
-  RECURSE (ScriptList, ScriptList, &gpos->ScriptList);\r
-  RECURSE (FeatureList, FeatureList, &gpos->FeatureList);\r
-  RECURSE (LookupList, LookupList, &gpos->LookupList);\r
-}\r
+/*
+ * Copyright (C) 2000, 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-dump.h"
+#include "harfbuzz-gdef-private.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-gpos-private.h"
+#include "harfbuzz-open-private.h"
+#include <stdarg.h>
+
+#define DUMP(format) dump (stream, indent, format)
+#define DUMP1(format, arg1) dump (stream, indent, format, arg1)
+#define DUMP2(format, arg1, arg2) dump (stream, indent, format, arg1, arg2)
+#define DUMP3(format, arg1, arg2, arg3) dump (stream, indent, format, arg1, arg2, arg3)
+
+#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d</" #fld ">\n", (strct)->fld)
+#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u</" #fld ">\n", (strct)->fld)
+#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
+#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#06x</" #fld ">\n", (strct)->fld)
+#define DUMP_USHORT_ARRAY(strct,fld,cnt) Dump_UShort_Array ((strct)->fld, cnt, #fld, stream, indent);
+
+#define DEF_DUMP(type) static void Dump_ ## type (HB_ ## type *type, FILE *stream, int indent, HB_Type hb_type)
+#define RECURSE(name, type, val) do {  DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
+#define RECURSE_NUM(name, i, type, val) do {  DUMP1 ("<" #name "> <!-- %d -->\n", i); Dump_ ## type (val, stream, indent + 1, hb_type); DUMP ("</" #name ">\n"); } while (0)
+#define DUMP_VALUE_RECORD(val, frmt) do {  DUMP ("<ValueRecord>\n"); Dump_ValueRecord (val, stream, indent + 1, hb_type, frmt); DUMP ("</ValueRecord>\n"); } while (0)
+
+static void
+do_indent (FILE *stream, int indent)
+{
+  fprintf (stream, "%*s", indent * 3, "");
+}
+
+static void
+dump (FILE *stream, int indent, const char *format, ...)
+{
+  va_list list;
+
+  do_indent (stream, indent);
+
+  va_start (list, format);
+  vfprintf (stream, format, list);
+  va_end (list);
+}
+
+static void
+Dump_UShort_Array (HB_UShort *array, int count, const char *name, FILE *stream, int indent)
+{
+  int i;
+
+  do_indent (stream, indent);
+
+  fprintf (stream, "<%s>", name);
+  for (i = 0; i < count; i++)
+    fprintf (stream, "%d%s", array[i], i == 0 ? "" : " ");
+  fprintf (stream, "</%s>\n", name);
+}
+
+static void
+Print_Tag (HB_UInt tag, FILE *stream)
+{
+  fprintf (stream, "%c%c%c%c",
+          (unsigned char)(tag >> 24),
+          (unsigned char)((tag >> 16) & 0xff),
+          (unsigned char)((tag >> 8) & 0xff),
+          (unsigned char)(tag & 0xff));
+}
+
+DEF_DUMP (LangSys)
+{
+  int i;
+
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (LangSys, LookupOrderOffset);
+  DUMP_FUINT (LangSys, ReqFeatureIndex);
+  DUMP_FUINT (LangSys, FeatureCount);
+
+  for (i=0; i < LangSys->FeatureCount; i++)
+    DUMP1("<FeatureIndex>%d</FeatureIndex>\n", LangSys->FeatureIndex[i]);
+}
+
+DEF_DUMP (ScriptTable)
+{
+  int i;
+
+  RECURSE (DefaultLangSys, LangSys, &ScriptTable->DefaultLangSys);
+
+  DUMP_FUINT (ScriptTable, LangSysCount);
+
+  for (i=0; i < ScriptTable->LangSysCount; i++)
+    {
+      do_indent (stream, indent);
+      fprintf (stream, "<LangSysTag>");
+      Print_Tag (ScriptTable->LangSysRecord[i].LangSysTag, stream);
+      fprintf (stream, "</LangSysTag>\n");
+      RECURSE_NUM (LangSys, i, LangSys, &ScriptTable->LangSysRecord[i].LangSys);
+    }
+}
+
+DEF_DUMP (ScriptList)
+{
+  int i;
+
+  DUMP_FUINT (ScriptList, ScriptCount);
+
+  for (i=0; i < ScriptList->ScriptCount; i++)
+    {
+      do_indent (stream, indent);
+      fprintf (stream, "<ScriptTag>");
+      Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream);
+      fprintf (stream, "</ScriptTag>\n");
+      RECURSE_NUM (Script, i, ScriptTable, &ScriptList->ScriptRecord[i].Script);
+    }
+}
+
+DEF_DUMP (Feature)
+{
+  int i;
+
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (Feature, FeatureParams);
+  DUMP_FUINT (Feature, LookupListCount);
+
+  for (i=0; i < Feature->LookupListCount; i++)
+    DUMP1("<LookupIndex>%d</LookupIndex>\n", Feature->LookupListIndex[i]);
+}
+
+DEF_DUMP (MarkRecord)
+{
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (MarkRecord, Class);
+  DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
+}
+
+DEF_DUMP (MarkArray)
+{
+  int i;
+
+  DUMP_FUINT (MarkArray, MarkCount);
+
+  for (i=0; i < MarkArray->MarkCount; i++)
+    RECURSE_NUM (MarkRecord, i, MarkRecord, &MarkArray->MarkRecord[i]);
+}
+
+DEF_DUMP (FeatureList)
+{
+  int i;
+
+  DUMP_FUINT (FeatureList, FeatureCount);
+
+  for (i=0; i < FeatureList->FeatureCount; i++)
+    {
+      do_indent (stream, indent);
+      fprintf (stream, "<FeatureTag>");
+      Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream);
+      fprintf (stream, "</FeatureTag> <!-- %d -->\n", i);
+      RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature);
+    }
+}
+
+DEF_DUMP (Coverage)
+{
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (Coverage, CoverageFormat);
+
+  if (Coverage->CoverageFormat == 1)
+    {
+      int i;
+      DUMP_FUINT (&Coverage->cf.cf1, GlyphCount);
+
+      for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++)
+       DUMP2("<Glyph>%#06x</Glyph> <!-- %d -->\n",
+             Coverage->cf.cf1.GlyphArray[i], i);
+    }
+  else
+    {
+      int i;
+      DUMP_FUINT (&Coverage->cf.cf2, RangeCount);
+
+      for ( i = 0; i < Coverage->cf.cf2.RangeCount; i++ )
+         DUMP3("<Glyph>%#06x - %#06x</Glyph> <!-- %d -->\n",
+               Coverage->cf.cf2.RangeRecord[i].Start,
+               Coverage->cf.cf2.RangeRecord[i].End, i);
+    }
+}
+
+DEF_DUMP (ClassRangeRecord)
+{
+  HB_UNUSED(hb_type);
+
+  DUMP_FGLYPH (ClassRangeRecord, Start);
+  DUMP_FGLYPH (ClassRangeRecord, End);
+  DUMP_FUINT (ClassRangeRecord, Class);
+}
+
+DEF_DUMP (ClassDefinition)
+{
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT( ClassDefinition, ClassFormat);
+  DUMP_FUINT( ClassDefinition, loaded);
+
+  if (ClassDefinition->ClassFormat == 1)
+    {
+      int i;
+      HB_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1;
+      DUMP("<ClassDefinition>\n");
+      DUMP_FUINT (ClassDefFormat1, StartGlyph );
+      DUMP_FUINT (ClassDefFormat1, GlyphCount );
+      for (i = 0; i < ClassDefFormat1->GlyphCount; i++)
+       DUMP2(" <Class>%d</Class> <!-- %#06x -->", ClassDefFormat1->ClassValueArray[i],
+             ClassDefFormat1->StartGlyph+i );
+    }
+  else if (ClassDefinition->ClassFormat == 2)
+    {
+      int i;
+      HB_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2;
+      DUMP_FUINT (ClassDefFormat2, ClassRangeCount);
+
+      for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++)
+       RECURSE_NUM (ClassRangeRecord, i, ClassRangeRecord, &ClassDefFormat2->ClassRangeRecord[i]);
+    }
+  else
+    fprintf(stderr, "invalid class def table!!!\n");
+}
+
+DEF_DUMP (SubstLookupRecord)
+{
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (SubstLookupRecord, SequenceIndex);
+  DUMP_FUINT (SubstLookupRecord, LookupListIndex);
+}
+
+DEF_DUMP (ChainSubClassRule)
+{
+  int i;
+
+  DUMP_USHORT_ARRAY (ChainSubClassRule, Backtrack, ChainSubClassRule->BacktrackGlyphCount);
+  DUMP_USHORT_ARRAY (ChainSubClassRule, Input, ChainSubClassRule->InputGlyphCount - 1);
+  DUMP_USHORT_ARRAY (ChainSubClassRule, Lookahead, ChainSubClassRule->LookaheadGlyphCount);
+
+  for (i = 0; i < ChainSubClassRule->SubstCount; i++)
+    RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainSubClassRule->SubstLookupRecord[i]);
+
+  indent--;
+}
+
+DEF_DUMP (ChainSubClassSet)
+{
+  int i;
+
+  DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount );
+  for (i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++)
+    RECURSE_NUM (ChainSubClassRule, i, ChainSubClassRule, &ChainSubClassSet->ChainSubClassRule[i]);
+}
+
+static void
+Dump_GSUB_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  HB_SingleSubst *SingleSubst = &subtable->st.gsub.single;
+
+  DUMP_FUINT (SingleSubst, SubstFormat);
+  RECURSE (Coverage, Coverage, &SingleSubst->Coverage);
+
+  if (SingleSubst->SubstFormat == 1)
+    {
+      DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID);
+    }
+  else
+    {
+      int i;
+
+      DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount);
+      for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++)
+       DUMP2("<Substitute>%#06x</Substitute> <!-- %d -->\n", SingleSubst->ssf.ssf2.Substitute[i], i);
+    }
+}
+
+DEF_DUMP (Ligature)
+{
+  int i;
+
+  HB_UNUSED(hb_type);
+
+  DUMP_FGLYPH (Ligature, LigGlyph);
+  DUMP_FUINT (Ligature, ComponentCount);
+
+  for (i=0; i < Ligature->ComponentCount - 1; i++)
+    DUMP1("<Component>%#06x</Component>\n", Ligature->Component[i]);
+}
+
+DEF_DUMP (LigatureSet)
+{
+  int i;
+
+  DUMP_FUINT (LigatureSet, LigatureCount);
+
+  for (i=0; i < LigatureSet->LigatureCount; i++)
+    RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]);
+}
+
+static void
+Dump_GSUB_Lookup_Ligature (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  int i;
+  HB_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature;
+
+  DUMP_FUINT (LigatureSubst, SubstFormat);
+  RECURSE (Coverage, Coverage, &LigatureSubst->Coverage);
+
+  DUMP_FUINT (LigatureSubst, LigatureSetCount);
+
+  for (i=0; i < LigatureSubst->LigatureSetCount; i++)
+    RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]);
+}
+
+DEF_DUMP (ContextSubstFormat1)
+{
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ContextSubstFormat1);
+
+
+  DUMP("<!-- Not implemented!!! -->\n");
+}
+
+DEF_DUMP (ContextSubstFormat2)
+{
+  DUMP_FUINT (ContextSubstFormat2, MaxContextLength);
+  RECURSE (Coverage, Coverage, &ContextSubstFormat2->Coverage);
+  RECURSE (ClassDefinition, ClassDefinition, &ContextSubstFormat2->ClassDef);
+}
+
+DEF_DUMP (ContextSubstFormat3)
+{
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ContextSubstFormat3);
+
+  DUMP("<!-- Not implemented!!! -->\n");
+}
+
+static void
+Dump_GSUB_Lookup_Context (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  HB_ContextSubst *ContextSubst = &subtable->st.gsub.context;
+
+  DUMP_FUINT (ContextSubst, SubstFormat);
+  switch( ContextSubst->SubstFormat )
+    {
+    case 1:
+      Dump_ContextSubstFormat1 (&ContextSubst->csf.csf1, stream, indent+2, hb_type);
+      break;
+    case 2:
+      Dump_ContextSubstFormat2 (&ContextSubst->csf.csf2, stream, indent+2, hb_type);
+      break;
+    case 3:
+      Dump_ContextSubstFormat3 (&ContextSubst->csf.csf3, stream, indent+2, hb_type);
+      break;
+    default:
+      fprintf(stderr, "invalid subformat!!!!!\n");
+    }
+}
+
+DEF_DUMP (ChainContextSubstFormat1)
+{
+  HB_UNUSED(hb_type);
+  HB_UNUSED(ChainContextSubstFormat1);
+
+  DUMP("<!-- Not implemented!!! -->\n");
+}
+
+DEF_DUMP (ChainContextSubstFormat2)
+{
+  int i;
+
+  RECURSE (Coverage, Coverage, &ChainContextSubstFormat2->Coverage);
+  DUMP_FUINT (ChainContextSubstFormat2, MaxBacktrackLength);
+  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->BacktrackClassDef);
+  DUMP_FUINT (ChainContextSubstFormat2, MaxInputLength);
+  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->InputClassDef);
+  DUMP_FUINT (ChainContextSubstFormat2, MaxLookaheadLength);
+  RECURSE (ClassDefinition, ClassDefinition, &ChainContextSubstFormat2->LookaheadClassDef);
+
+  DUMP_FUINT (ChainContextSubstFormat2, ChainSubClassSetCount);
+  for (i = 0; i < ChainContextSubstFormat2->ChainSubClassSetCount; i++)
+    RECURSE (ChainSubClassSet, ChainSubClassSet, &ChainContextSubstFormat2->ChainSubClassSet[i]);
+}
+
+DEF_DUMP (ChainContextSubstFormat3)
+{
+  int i;
+
+  DUMP_FUINT (ChainContextSubstFormat3, BacktrackGlyphCount);
+  for (i = 0; i < ChainContextSubstFormat3->BacktrackGlyphCount; i++)
+    RECURSE (BacktrackCoverage, Coverage, &ChainContextSubstFormat3->BacktrackCoverage[i]);
+  DUMP_FUINT (ChainContextSubstFormat3, InputGlyphCount);
+  for (i = 0; i < ChainContextSubstFormat3->InputGlyphCount; i++)
+    RECURSE (InputCoverage, Coverage, &ChainContextSubstFormat3->InputCoverage[i]);
+  DUMP_FUINT (ChainContextSubstFormat3, LookaheadGlyphCount);
+  for (i = 0; i < ChainContextSubstFormat3->LookaheadGlyphCount; i++)
+    RECURSE (LookaheadCoverage, Coverage, &ChainContextSubstFormat3->LookaheadCoverage[i]);
+
+  for (i = 0; i < ChainContextSubstFormat3->SubstCount; i++)
+    RECURSE_NUM (SubstLookupRecord, i, SubstLookupRecord, &ChainContextSubstFormat3->SubstLookupRecord[i]);
+
+}
+
+static void
+Dump_GSUB_Lookup_Chain (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  HB_ChainContextSubst *chain = &subtable->st.gsub.chain;
+
+  DUMP_FUINT (chain, SubstFormat);
+  switch (chain->SubstFormat)
+    {
+    case 1:
+      Dump_ChainContextSubstFormat1 (&chain->ccsf.ccsf1, stream, indent+2, hb_type);
+      break;
+    case 2:
+      Dump_ChainContextSubstFormat2 (&chain->ccsf.ccsf2, stream, indent+2, hb_type);
+      break;
+    case 3:
+      Dump_ChainContextSubstFormat3 (&chain->ccsf.ccsf3, stream, indent+2, hb_type);
+      break;
+    default:
+      fprintf(stderr, "invalid subformat!!!!!\n");
+    }
+}
+
+static void
+Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
+{
+  int i;
+  int bits;
+  int n_per;
+  unsigned int mask;
+
+  HB_UNUSED(hb_type);
+
+  DUMP_FUINT (Device, StartSize);
+  DUMP_FUINT (Device, EndSize);
+  DUMP_FUINT (Device, DeltaFormat);
+  switch (Device->DeltaFormat)
+    {
+    case 1:
+      bits = 2;
+      break;
+    case 2:
+      bits = 4;
+      break;
+    case 3:
+      bits = 8;
+      break;
+    default:
+      bits = 0;
+      break;
+    }
+
+  DUMP ("<DeltaValue>");
+  if (!bits)
+    {
+
+      fprintf(stderr, "invalid DeltaFormat!!!!!\n");
+    }
+  else
+    {
+      n_per = 16 / bits;
+      mask = (1 << bits) - 1;
+      mask = mask << (16 - bits);
+
+      for (i = Device->StartSize; i <= Device->EndSize ; i++)
+       {
+         HB_UShort val = Device->DeltaValue[i / n_per];
+         HB_Short signed_val = ((val << ((i % n_per) * bits)) & mask);
+         dump (stream, indent, "%d", signed_val >> (16 - bits));
+         if (i != Device->EndSize)
+           DUMP (", ");
+       }
+    }
+  DUMP ("</DeltaValue>\n");
+}
+
+static void
+Dump_ValueRecord (HB_ValueRecord *ValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort value_format)
+{
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT)
+    DUMP_FINT (ValueRecord, XPlacement);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT)
+    DUMP_FINT (ValueRecord, YPlacement);
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE)
+    DUMP_FINT (ValueRecord, XAdvance);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE)
+    DUMP_FINT (ValueRecord, XAdvance);
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE)
+    RECURSE (Device, Device, &ValueRecord->XPlacementDevice);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE)
+    RECURSE (Device, Device, &ValueRecord->YPlacementDevice);
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE)
+    RECURSE (Device, Device, &ValueRecord->XAdvanceDevice);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE)
+    RECURSE (Device, Device, &ValueRecord->YAdvanceDevice);
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT)
+    DUMP_FUINT (ValueRecord, XIdPlacement);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT)
+    DUMP_FUINT (ValueRecord, YIdPlacement);
+  if (value_format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE)
+    DUMP_FUINT (ValueRecord, XIdAdvance);
+  if (value_format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE)
+    DUMP_FUINT (ValueRecord, XIdAdvance);
+}
+
+static void
+Dump_GPOS_Lookup_Single (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  HB_SinglePos *SinglePos = &subtable->st.gpos.single;
+
+  DUMP_FUINT (SinglePos, PosFormat);
+  RECURSE (Coverage, Coverage, &SinglePos->Coverage);
+
+  DUMP_FUINT (SinglePos, ValueFormat);
+
+  if (SinglePos->PosFormat == 1)
+    {
+      DUMP_VALUE_RECORD (&SinglePos->spf.spf1.Value, SinglePos->ValueFormat);
+    }
+  else
+    {
+      int i;
+
+      DUMP_FUINT (&SinglePos->spf.spf2, ValueCount);
+      for (i = 0; i < SinglePos->spf.spf2.ValueCount; i++)
+       DUMP_VALUE_RECORD (&SinglePos->spf.spf2.Value[i], SinglePos->ValueFormat);
+    }
+}
+
+static void
+Dump_PairValueRecord (HB_PairValueRecord *PairValueRecord, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)
+{
+  DUMP_FUINT (PairValueRecord, SecondGlyph);
+  DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1);
+  DUMP_VALUE_RECORD (&PairValueRecord->Value2, ValueFormat2);
+}
+
+static void
+Dump_PairSet (HB_PairSet *PairSet, FILE *stream, int indent, HB_Type hb_type, HB_UShort ValueFormat1, HB_UShort ValueFormat2)
+{
+  int i;
+  DUMP_FUINT (PairSet, PairValueCount);
+
+  for (i = 0; i < PairSet->PairValueCount; i++)
+    {
+      DUMP ("<PairValueRecord>\n");
+      Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, hb_type, ValueFormat1, ValueFormat2);
+      DUMP ("</PairValueRecord>\n");
+    }
+}
+
+static void
+Dump_GPOS_Lookup_Pair (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  HB_PairPos *PairPos = &subtable->st.gpos.pair;
+
+  DUMP_FUINT (PairPos, PosFormat);
+  RECURSE (Coverage, Coverage, &PairPos->Coverage);
+
+  DUMP_FUINT (PairPos, ValueFormat1);
+  DUMP_FUINT (PairPos, ValueFormat2);
+
+  if (PairPos->PosFormat == 1)
+    {
+      int i;
+
+      DUMP_FUINT (&PairPos->ppf.ppf1, PairSetCount);
+      for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++)
+       {
+         DUMP ("<PairSet>\n");
+         Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, hb_type, PairPos->ValueFormat1, PairPos->ValueFormat2);
+         DUMP ("</PairSet>\n");
+       }
+    }
+  else
+    {
+    }
+}
+
+static void
+Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type)
+{
+  int i;
+  HB_MarkBasePos *markbase = &subtable->st.gpos.markbase;
+
+  DUMP_FUINT (markbase, PosFormat);
+  RECURSE (Coverage, Coverage, &markbase->MarkCoverage);
+  RECURSE (Coverage, Coverage, &markbase->BaseCoverage);
+  DUMP_FUINT (markbase, ClassCount);
+  RECURSE (MarkArray, MarkArray, &markbase->MarkArray);
+
+  DUMP ("<BaseArray>\n");
+  indent++;
+
+  DUMP_FUINT (&markbase->BaseArray, BaseCount);
+  for (i = 0; i < markbase->BaseArray.BaseCount; i++)
+    {
+      int j;
+      HB_BaseRecord *r = &markbase->BaseArray.BaseRecord[i];
+      DUMP1 ("<BaseRecord> <!-- %d -->\n",  i);
+      for (j = 0; j < markbase->ClassCount; j++)
+       DUMP1 ("  <Anchor>%d</Anchor>\n", r->BaseAnchor->PosFormat);
+      DUMP ("<BaseRecord>\n");
+    }
+
+  indent--;
+  DUMP ("</BaseArray>\n");
+}
+
+DEF_DUMP (Lookup)
+{
+  int i;
+  const char *lookup_name;
+  void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;
+
+  if (hb_type == HB_Type_GSUB)
+    {
+      switch (Lookup->LookupType)
+       {
+       case  HB_GSUB_LOOKUP_SINGLE:
+         lookup_name = "SINGLE";
+         lookup_func = Dump_GSUB_Lookup_Single;
+         break;
+       case  HB_GSUB_LOOKUP_MULTIPLE:
+         lookup_name = "MULTIPLE";
+         break;
+       case  HB_GSUB_LOOKUP_ALTERNATE:
+         lookup_name = "ALTERNATE";
+         break;
+       case  HB_GSUB_LOOKUP_LIGATURE:
+         lookup_name = "LIGATURE";
+         lookup_func = Dump_GSUB_Lookup_Ligature;
+         break;
+       case  HB_GSUB_LOOKUP_CONTEXT:
+         lookup_name = "CONTEXT";
+         lookup_func = Dump_GSUB_Lookup_Context;
+         break;
+       case  HB_GSUB_LOOKUP_CHAIN:
+         lookup_name = "CHAIN";
+         lookup_func = Dump_GSUB_Lookup_Chain;
+         break;
+       default:
+         lookup_name = "(unknown)";
+         lookup_func = NULL;
+         break;
+       }
+    }
+  else
+    {
+      switch (Lookup->LookupType)
+       {
+       case HB_GPOS_LOOKUP_SINGLE:
+         lookup_name = "SINGLE";
+         lookup_func = Dump_GPOS_Lookup_Single;
+         break;
+       case HB_GPOS_LOOKUP_PAIR:
+         lookup_name = "PAIR";
+         lookup_func = Dump_GPOS_Lookup_Pair;
+         break;
+       case HB_GPOS_LOOKUP_CURSIVE:
+         lookup_name = "CURSIVE";
+         break;
+       case HB_GPOS_LOOKUP_MARKBASE:
+         lookup_name = "MARKBASE";
+         lookup_func = Dump_GPOS_Lookup_Markbase;
+         break;
+       case HB_GPOS_LOOKUP_MARKLIG:
+         lookup_name = "MARKLIG";
+         break;
+       case HB_GPOS_LOOKUP_MARKMARK:
+         lookup_name = "MARKMARK";
+         break;
+       case HB_GPOS_LOOKUP_CONTEXT:
+         lookup_name = "CONTEXT";
+         break;
+       case HB_GPOS_LOOKUP_CHAIN:
+         lookup_name = "CHAIN";
+         break;
+       default:
+         lookup_name = "(unknown)";
+         lookup_func = NULL;
+         break;
+       }
+    }
+
+  DUMP2("<LookupType>%s</LookupType> <!-- %d -->\n", lookup_name, Lookup->LookupType);
+  DUMP1("<LookupFlag>%#06x</LookupFlag>\n", Lookup->LookupFlag);
+
+  for (i=0; i < Lookup->SubTableCount; i++)
+    {
+      DUMP ("<Subtable>\n");
+      if (lookup_func)
+       (*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, hb_type);
+      DUMP ("</Subtable>\n");
+    }
+}
+
+DEF_DUMP (LookupList)
+{
+  int i;
+
+  DUMP_FUINT (LookupList, LookupCount);
+
+  for (i=0; i < LookupList->LookupCount; i++)
+    RECURSE_NUM (Lookup, i, Lookup, &LookupList->Lookup[i]);
+}
+
+void
+HB_Dump_GSUB_Table (HB_GSUB gsub, FILE *stream)
+{
+  int indent = 1;
+  HB_Type hb_type = HB_Type_GSUB;
+
+  do_indent (stream, indent);
+  fprintf(stream, "<!-- GSUB -->\n");
+  RECURSE (ScriptList, ScriptList, &gsub->ScriptList);
+  RECURSE (FeatureList, FeatureList, &gsub->FeatureList);
+  RECURSE (LookupList, LookupList, &gsub->LookupList);
+}
+
+void
+HB_Dump_GPOS_Table (HB_GPOS gpos, FILE *stream)
+{
+  int indent = 1;
+  HB_Type hb_type = HB_Type_GPOS;
+
+  do_indent (stream, indent);
+  fprintf(stream, "<!-- GPOS -->\n");
+  RECURSE (ScriptList, ScriptList, &gpos->ScriptList);
+  RECURSE (FeatureList, FeatureList, &gpos->FeatureList);
+  RECURSE (LookupList, LookupList, &gpos->LookupList);
+}
index ed3aeca..9beeb3e 100755 (executable)
@@ -1,45 +1,45 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-\r
-#include "harfbuzz-external.h"\r
-\r
-\r
-HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch){return 0;}\r
-HB_WordClass HB_GetWordClass(HB_UChar32 ch){return 0;}\r
-HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch){return 0;}\r
-HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch){return 0;}\r
-\r
-void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak){}\r
-void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass){}\r
-HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch){return 0;}\r
-int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch){return 0;}\r
-HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch){return 0;}\r
-\r
-void *HB_Library_Resolve(const char *library, const char *symbol){}\r
-\r
-void *HB_TextCodecForMib(int mib){}\r
-char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength){return NULL;}\r
-void HB_TextCodec_FreeResult(char * text){}\r
-\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+
+#include "harfbuzz-external.h"
+
+
+HB_GraphemeClass HB_GetGraphemeClass(HB_UChar32 ch){return 0;}
+HB_WordClass HB_GetWordClass(HB_UChar32 ch){return 0;}
+HB_SentenceClass HB_GetSentenceClass(HB_UChar32 ch){return 0;}
+HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch){return 0;}
+
+void HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *grapheme, HB_LineBreakClass *lineBreak){}
+void HB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *category, int *combiningClass){}
+HB_CharCategory HB_GetUnicodeCharCategory(HB_UChar32 ch){return 0;}
+int HB_GetUnicodeCharCombiningClass(HB_UChar32 ch){return 0;}
+HB_UChar16 HB_GetMirroredChar(HB_UChar16 ch){return 0;}
+
+void *HB_Library_Resolve(const char *library, const char *symbol){}
+
+void *HB_TextCodecForMib(int mib){}
+char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength){return NULL;}
+void HB_TextCodec_FreeResult(char * text){}
+
+
+
index 0d8929d..9cebc9c 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-gdef-private.h"\r
-#include "harfbuzz-open-private.h"\r
-\r
-static HB_Error  Load_AttachList( HB_AttachList*  al,\r
-                                 HB_Stream        stream );\r
-static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,\r
-                                   HB_Stream          stream );\r
-\r
-static void  Free_AttachList( HB_AttachList*  al);\r
-static void  Free_LigCaretList( HB_LigCaretList*  lcl);\r
-\r
-static void  Free_NewGlyphClasses( HB_GDEFHeader*  gdef);\r
-\r
-\r
-\r
-/* GDEF glyph classes */\r
-\r
-#define UNCLASSIFIED_GLYPH  0\r
-#define SIMPLE_GLYPH        1\r
-#define LIGATURE_GLYPH      2\r
-#define MARK_GLYPH          3\r
-#define COMPONENT_GLYPH     4\r
-\r
-\r
-\r
-\r
-\r
-\r
-HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr )\r
-{\r
-  HB_Error         error;\r
-\r
-  HB_GDEFHeader*  gdef;\r
-\r
-  if ( !retptr )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( ALLOC( gdef, sizeof( *gdef ), HB_GDEFHeader* ) )\r
-    return error;\r
-\r
-  gdef->GlyphClassDef.loaded = FALSE;\r
-  gdef->AttachList.loaded = FALSE;\r
-  gdef->LigCaretList.loaded = FALSE;\r
-  gdef->MarkAttachClassDef_offset = 0;\r
-  gdef->MarkAttachClassDef.loaded = FALSE;\r
-\r
-  gdef->LastGlyph = 0;\r
-  gdef->NewGlyphClasses = NULL;\r
-\r
-  *retptr = gdef;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-HB_Error  HB_Load_GDEF_Table( HB_Stream stream, \r
-                             HB_GDEFHeader** retptr )\r
-{\r
-  HB_Error         error;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  if ( !retptr )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( GOTO_Table( TTAG_GDEF ) )\r
-    return error;\r
-\r
-  if (( error = HB_New_GDEF_Table ( &gdef ) ))\r
-    return error;\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  /* skip version */\r
-\r
-  if ( FILE_Seek( base_offset + 4L ) ||\r
-       ACCESS_Frame( 2L ) )\r
-    goto Fail0;\r
-\r
-  new_offset = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  /* all GDEF subtables are optional */\r
-\r
-  if ( new_offset )\r
-  {\r
-    new_offset += base_offset;\r
-\r
-    /* only classes 1-4 are allowed here */\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,\r
-                                        stream ) ) != HB_Err_Ok )\r
-      goto Fail0;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail1;\r
-\r
-  new_offset = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( new_offset )\r
-  {\r
-    new_offset += base_offset;\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_AttachList( &gdef->AttachList,\r
-                                   stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  new_offset = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( new_offset )\r
-  {\r
-    new_offset += base_offset;\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LigCaretList( &gdef->LigCaretList,\r
-                                     stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  /* OpenType 1.2 has introduced the `MarkAttachClassDef' field.  We\r
-     first have to scan the LookupFlag values to find out whether we\r
-     must load it or not.  Here we only store the offset of the table. */\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( new_offset )\r
-    gdef->MarkAttachClassDef_offset = new_offset + base_offset;\r
-  else\r
-    gdef->MarkAttachClassDef_offset = 0;\r
-\r
-  *retptr = gdef;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail3:\r
-  Free_LigCaretList( &gdef->LigCaretList );\r
-  \r
-Fail2:\r
-  Free_AttachList( &gdef->AttachList );\r
-\r
-Fail1:\r
-  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef );\r
-\r
-Fail0:\r
-  FREE( gdef );\r
-\r
-  return error;\r
-}\r
-\r
-\r
-HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef ) \r
-{  \r
-  Free_LigCaretList( &gdef->LigCaretList );\r
-  Free_AttachList( &gdef->AttachList );\r
-  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef );\r
-  _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef );\r
-  \r
-  Free_NewGlyphClasses( gdef );\r
-\r
-  FREE( gdef );\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-\r
-/*******************************\r
- * AttachList related functions\r
- *******************************/\r
-\r
-\r
-/* AttachPoint */\r
-\r
-static HB_Error  Load_AttachPoint( HB_AttachPoint*  ap,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort   n, count;\r
-  HB_UShort*  pi;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ap->PointCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ap->PointIndex = NULL;\r
-\r
-  if ( count )\r
-  {\r
-    if ( ALLOC_ARRAY( ap->PointIndex, count, HB_UShort ) )\r
-      return error;\r
-\r
-    pi = ap->PointIndex;\r
-\r
-    if ( ACCESS_Frame( count * 2L ) )\r
-    {\r
-      FREE( pi );\r
-      return error;\r
-    }\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      pi[n] = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_AttachPoint( HB_AttachPoint*  ap )\r
-{\r
-  FREE( ap->PointIndex );\r
-}\r
-\r
-\r
-/* AttachList */\r
-\r
-static HB_Error  Load_AttachList( HB_AttachList*  al,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort         n, m, count;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_AttachPoint*  ap;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &al->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = al->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  al->AttachPoint = NULL;\r
-\r
-  if ( ALLOC_ARRAY( al->AttachPoint, count, HB_AttachPoint ) )\r
-    goto Fail2;\r
-\r
-  ap = al->AttachPoint;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_AttachPoint( &ap[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  al->loaded = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_AttachPoint( &ap[m] );\r
-\r
-  FREE( ap );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &al->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_AttachList( HB_AttachList*  al)\r
-{\r
-  HB_UShort         n, count;\r
-\r
-  HB_AttachPoint*  ap;\r
-\r
-\r
-  if ( !al->loaded )\r
-    return;\r
-\r
-  if ( al->AttachPoint )\r
-  {\r
-    count = al->GlyphCount;\r
-    ap    = al->AttachPoint;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_AttachPoint( &ap[n] );\r
-\r
-    FREE( ap );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &al->Coverage );\r
-}\r
-\r
-\r
-\r
-/*********************************\r
- * LigCaretList related functions\r
- *********************************/\r
-\r
-\r
-/* CaretValueFormat1 */\r
-/* CaretValueFormat2 */\r
-/* CaretValueFormat3 */\r
-/* CaretValueFormat4 */\r
-\r
-static HB_Error  Load_CaretValue( HB_CaretValue*  cv,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UInt cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cv->CaretValueFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( cv->CaretValueFormat )\r
-  {\r
-  case 1:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    cv->cvf.cvf1.Coordinate = GET_Short();\r
-\r
-    FORGET_Frame();\r
-\r
-    break;\r
-\r
-  case 2:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    cv->cvf.cvf2.CaretValuePoint = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    break;\r
-\r
-  case 3:\r
-    if ( ACCESS_Frame( 4L ) )\r
-      return error;\r
-\r
-    cv->cvf.cvf3.Coordinate = GET_Short();\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Device( &cv->cvf.cvf3.Device,\r
-                               stream ) ) != HB_Err_Ok )\r
-      return error;\r
-    (void)FILE_Seek( cur_offset );\r
-\r
-    break;\r
-\r
-  case 4:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    cv->cvf.cvf4.IdCaretValue = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_CaretValue( HB_CaretValue*  cv)\r
-{\r
-  if ( cv->CaretValueFormat == 3 )\r
-    _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device );\r
-}\r
-\r
-\r
-/* LigGlyph */\r
-\r
-static HB_Error  Load_LigGlyph( HB_LigGlyph*  lg,\r
-                               HB_Stream      stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort        n, m, count;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_CaretValue*  cv;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = lg->CaretCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  lg->CaretValue = NULL;\r
-\r
-  if ( ALLOC_ARRAY( lg->CaretValue, count, HB_CaretValue ) )\r
-    return error;\r
-\r
-  cv = lg->CaretValue;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_CaretValue( &cv[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_CaretValue( &cv[m] );\r
-\r
-  FREE( cv );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigGlyph( HB_LigGlyph*  lg)\r
-{\r
-  HB_UShort        n, count;\r
-\r
-  HB_CaretValue*  cv;\r
-\r
-\r
-  if ( lg->CaretValue )\r
-  {\r
-    count = lg->CaretCount;\r
-    cv    = lg->CaretValue;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_CaretValue( &cv[n] );\r
-\r
-    FREE( cv );\r
-  }\r
-}\r
-\r
-\r
-/* LigCaretList */\r
-\r
-static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,\r
-                                   HB_Stream          stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort      m, n, count;\r
-  HB_UInt       cur_offset, new_offset, base_offset;\r
-\r
-  HB_LigGlyph*  lg;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &lcl->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = lcl->LigGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  lcl->LigGlyph = NULL;\r
-\r
-  if ( ALLOC_ARRAY( lcl->LigGlyph, count, HB_LigGlyph ) )\r
-    goto Fail2;\r
-\r
-  lg = lcl->LigGlyph;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LigGlyph( &lg[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  lcl->loaded = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_LigGlyph( &lg[m] );\r
-\r
-  FREE( lg );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &lcl->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigCaretList( HB_LigCaretList*  lcl )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_LigGlyph*  lg;\r
-\r
-\r
-  if ( !lcl->loaded )\r
-    return;\r
-\r
-  if ( lcl->LigGlyph )\r
-  {\r
-    count = lcl->LigGlyphCount;\r
-    lg    = lcl->LigGlyph;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_LigGlyph( &lg[n] );\r
-\r
-    FREE( lg );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &lcl->Coverage );\r
-}\r
-\r
-\r
-\r
-/***********\r
- * GDEF API\r
- ***********/\r
-\r
-\r
-static HB_UShort  Get_New_Class( HB_GDEFHeader*  gdef,\r
-                                HB_UShort        glyphID,\r
-                                HB_UShort        index )\r
-{\r
-  HB_UShort              glyph_index, array_index, count;\r
-  HB_UShort              byte, bits;\r
-  \r
-  HB_ClassRangeRecord*  gcrr;\r
-  HB_UShort**            ngc;\r
-\r
-\r
-  if ( glyphID >= gdef->LastGlyph )\r
-    return 0;\r
-\r
-  count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;\r
-  gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord;\r
-  ngc  = gdef->NewGlyphClasses;\r
-\r
-  if ( index < count && glyphID < gcrr[index].Start )\r
-  {\r
-    array_index = index;\r
-    if ( index == 0 )\r
-      glyph_index = glyphID;\r
-    else\r
-      glyph_index = glyphID - gcrr[index - 1].End - 1;\r
-  }\r
-  else\r
-  {\r
-    array_index = index + 1;\r
-    glyph_index = glyphID - gcrr[index].End - 1;\r
-  }\r
-\r
-  byte = ngc[array_index][glyph_index / 4];\r
-  bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 );\r
-\r
-  return bits & 0x000F;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,\r
-                                     HB_UShort        glyphID,\r
-                                     HB_UShort*       property )\r
-{\r
-  HB_UShort klass = 0, index = 0; /* shut compiler up */\r
-\r
-  HB_Error  error;\r
-\r
-\r
-  if ( !gdef || !property )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  /* first, we check for mark attach classes */\r
-\r
-  if ( gdef->MarkAttachClassDef.loaded )\r
-  {\r
-    error = _HB_OPEN_Get_Class( &gdef->MarkAttachClassDef, glyphID, &klass, &index );\r
-    if ( error && error != HB_Err_Not_Covered )\r
-      return error;\r
-    if ( !error )\r
-    {\r
-      *property = klass << 8;\r
-      return HB_Err_Ok;\r
-    }\r
-  }\r
-\r
-  error = _HB_OPEN_Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    return error;\r
-\r
-  /* if we have a constructed klass table, check whether additional\r
-     values have been assigned                                      */\r
-\r
-  if ( error == HB_Err_Not_Covered && gdef->NewGlyphClasses )\r
-    klass = Get_New_Class( gdef, glyphID, index );\r
-\r
-  switch ( klass )\r
-  {\r
-  default:\r
-  case UNCLASSIFIED_GLYPH:\r
-    *property = 0;\r
-    break;\r
-\r
-  case SIMPLE_GLYPH:\r
-    *property = HB_GDEF_BASE_GLYPH;\r
-    break;\r
-\r
-  case LIGATURE_GLYPH:\r
-    *property = HB_GDEF_LIGATURE;\r
-    break;\r
-\r
-  case MARK_GLYPH:\r
-    *property = HB_GDEF_MARK;\r
-    break;\r
-\r
-  case COMPONENT_GLYPH:\r
-    *property = HB_GDEF_COMPONENT;\r
-    break;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static HB_Error  Make_ClassRange( HB_ClassDefinition*  cd,\r
-                                 HB_UShort             start,\r
-                                 HB_UShort             end,\r
-                                 HB_UShort             klass )\r
-{\r
-  HB_Error               error;\r
-  HB_UShort              index;\r
-\r
-  HB_ClassDefFormat2*   cdf2;\r
-  HB_ClassRangeRecord*  crr;\r
-\r
-\r
-  cdf2 = &cd->cd.cd2;\r
-\r
-  if ( REALLOC_ARRAY( cdf2->ClassRangeRecord,\r
-                     cdf2->ClassRangeCount + 1 ,\r
-                     HB_ClassRangeRecord ) )\r
-    return error;\r
-\r
-  cdf2->ClassRangeCount++;\r
-\r
-  crr   = cdf2->ClassRangeRecord;\r
-  index = cdf2->ClassRangeCount - 1;\r
-\r
-  crr[index].Start = start;\r
-  crr[index].End   = end;\r
-  crr[index].Class = klass;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,\r
-                                        HB_UShort        num_glyphs,\r
-                                        HB_UShort        glyph_count,\r
-                                        HB_UShort*       glyph_array,\r
-                                        HB_UShort*       class_array )\r
-{\r
-  HB_UShort              start, curr_glyph, curr_class;\r
-  HB_UShort              n, m, count;\r
-  HB_Error               error;\r
-\r
-  HB_ClassDefinition*   gcd;\r
-  HB_ClassRangeRecord*  gcrr;\r
-  HB_UShort**            ngc;\r
-\r
-\r
-  if ( !gdef || !glyph_array || !class_array )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gcd = &gdef->GlyphClassDef;\r
-\r
-  /* We build a format 2 table */\r
-\r
-  gcd->ClassFormat = 2;\r
-\r
-  gcd->cd.cd2.ClassRangeCount  = 0;\r
-  gcd->cd.cd2.ClassRangeRecord = NULL;\r
-\r
-  start      = glyph_array[0];\r
-  curr_class = class_array[0];\r
-  curr_glyph = start;\r
-\r
-  if ( curr_class >= 5 )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_Argument);\r
-    goto Fail4;\r
-  }\r
-\r
-  glyph_count--;\r
-\r
-  for ( n = 0; n < glyph_count + 1; n++ )\r
-  {\r
-    if ( curr_glyph == glyph_array[n] && curr_class == class_array[n] )\r
-    {\r
-      if ( n == glyph_count )\r
-      {\r
-       if ( ( error = Make_ClassRange( gcd, start,\r
-                                       curr_glyph,\r
-                                       curr_class) ) != HB_Err_Ok )\r
-         goto Fail3;\r
-      }\r
-      else\r
-      {\r
-       if ( curr_glyph == 0xFFFF )\r
-       {\r
-         error = ERR_HB(HB_Err_Invalid_Argument);\r
-         goto Fail3;\r
-       }\r
-       else\r
-         curr_glyph++;\r
-      }\r
-    }\r
-    else\r
-    {\r
-      if ( ( error = Make_ClassRange( gcd, start,\r
-                                     curr_glyph - 1,\r
-                                     curr_class) ) != HB_Err_Ok )\r
-       goto Fail3;\r
-\r
-      if ( curr_glyph > glyph_array[n] )\r
-      {\r
-       error = ERR_HB(HB_Err_Invalid_Argument);\r
-       goto Fail3;\r
-      }\r
-\r
-      start      = glyph_array[n];\r
-      curr_class = class_array[n];\r
-      curr_glyph = start;\r
-\r
-      if ( curr_class >= 5 )\r
-      {\r
-       error = ERR_HB(HB_Err_Invalid_Argument);\r
-       goto Fail3;\r
-      }\r
-\r
-      if ( n == glyph_count )\r
-      {\r
-       if ( ( error = Make_ClassRange( gcd, start,\r
-                                       curr_glyph,\r
-                                       curr_class) ) != HB_Err_Ok )\r
-         goto Fail3;\r
-      }\r
-      else\r
-      {\r
-       if ( curr_glyph == 0xFFFF )\r
-       {\r
-         error = ERR_HB(HB_Err_Invalid_Argument);\r
-         goto Fail3;\r
-       }\r
-       else\r
-         curr_glyph++;\r
-      }\r
-    }\r
-  }\r
-\r
-  /* now prepare the arrays for klass values assigned during the lookup\r
-     process                                                            */\r
-\r
-  if ( ALLOC_ARRAY( gdef->NewGlyphClasses,\r
-                   gcd->cd.cd2.ClassRangeCount + 1, HB_UShort* ) )\r
-    goto Fail3;\r
-\r
-  count = gcd->cd.cd2.ClassRangeCount;\r
-  gcrr  = gcd->cd.cd2.ClassRangeRecord;\r
-  ngc   = gdef->NewGlyphClasses;\r
-\r
-  /* We allocate arrays for all glyphs not covered by the klass range\r
-     records.  Each element holds four klass values.                  */\r
-\r
-  if ( count > 0 )\r
-  {\r
-      if ( gcrr[0].Start )\r
-      {\r
-       if ( ALLOC_ARRAY( ngc[0], ( gcrr[0].Start + 3 ) / 4, HB_UShort ) )\r
-         goto Fail2;\r
-      }\r
-\r
-      for ( n = 1; n < count; n++ )\r
-      {\r
-       if ( gcrr[n].Start - gcrr[n - 1].End > 1 )\r
-         if ( ALLOC_ARRAY( ngc[n],\r
-                           ( gcrr[n].Start - gcrr[n - 1].End + 2 ) / 4,\r
-                           HB_UShort ) )\r
-           goto Fail1;\r
-      }\r
-\r
-      if ( gcrr[count - 1].End != num_glyphs - 1 )\r
-      {\r
-       if ( ALLOC_ARRAY( ngc[count],\r
-                         ( num_glyphs - gcrr[count - 1].End + 2 ) / 4,\r
-                         HB_UShort ) )\r
-           goto Fail1;\r
-      }\r
-  }\r
-  else if ( num_glyphs > 0 )\r
-  {\r
-      if ( ALLOC_ARRAY( ngc[count],\r
-                       ( num_glyphs + 3 ) / 4,\r
-                       HB_UShort ) )\r
-         goto Fail2;\r
-  }\r
-      \r
-  gdef->LastGlyph = num_glyphs - 1;\r
-\r
-  gdef->MarkAttachClassDef_offset = 0L;\r
-  gdef->MarkAttachClassDef.loaded = FALSE;\r
-\r
-  gcd->loaded = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    FREE( ngc[m] );\r
-\r
-Fail2:\r
-  FREE( gdef->NewGlyphClasses );\r
-\r
-Fail3:\r
-  FREE( gcd->cd.cd2.ClassRangeRecord );\r
-\r
-Fail4:\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_NewGlyphClasses( HB_GDEFHeader*  gdef )\r
-{\r
-  HB_UShort**  ngc;\r
-  HB_UShort    n, count;\r
-\r
-\r
-  if ( gdef->NewGlyphClasses )\r
-  {\r
-    count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount + 1;\r
-    ngc   = gdef->NewGlyphClasses;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      FREE( ngc[n] );\r
-\r
-    FREE( ngc );\r
-  }\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,\r
-                             HB_UShort        glyphID,\r
-                             HB_UShort        property )\r
-{\r
-  HB_Error               error;\r
-  HB_UShort              klass, new_class, index = 0; /* shut compiler up */\r
-  HB_UShort              byte, bits, mask;\r
-  HB_UShort              array_index, glyph_index, count;\r
-\r
-  HB_ClassRangeRecord*  gcrr;\r
-  HB_UShort**            ngc;\r
-\r
-\r
-  error = _HB_OPEN_Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    return error;\r
-\r
-  /* we don't accept glyphs covered in `GlyphClassDef' */\r
-\r
-  if ( !error )\r
-    return HB_Err_Not_Covered;\r
-\r
-  switch ( property )\r
-  {\r
-  case 0:\r
-    new_class = UNCLASSIFIED_GLYPH;\r
-    break;\r
-\r
-  case HB_GDEF_BASE_GLYPH:\r
-    new_class = SIMPLE_GLYPH;\r
-    break;\r
-\r
-  case HB_GDEF_LIGATURE:\r
-    new_class = LIGATURE_GLYPH;\r
-    break;\r
-\r
-  case HB_GDEF_MARK:\r
-    new_class = MARK_GLYPH;\r
-    break;\r
-\r
-  case HB_GDEF_COMPONENT:\r
-    new_class = COMPONENT_GLYPH;\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-  }\r
-\r
-  count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;\r
-  gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord;\r
-  ngc  = gdef->NewGlyphClasses;\r
-\r
-  if ( index < count && glyphID < gcrr[index].Start )\r
-  {\r
-    array_index = index;\r
-    if ( index == 0 )\r
-      glyph_index = glyphID;\r
-    else\r
-      glyph_index = glyphID - gcrr[index - 1].End - 1;\r
-  }\r
-  else\r
-  {\r
-    array_index = index + 1;\r
-    glyph_index = glyphID - gcrr[index].End - 1;\r
-  }\r
-\r
-  byte  = ngc[array_index][glyph_index / 4];\r
-  bits  = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 );\r
-  klass = bits & 0x000F;\r
-\r
-  /* we don't overwrite existing entries */\r
-\r
-  if ( !klass )\r
-  {\r
-    bits = new_class << ( 16 - ( glyph_index % 4 + 1 ) * 4 );\r
-    mask = ~( 0x000F << ( 16 - ( glyph_index % 4 + 1 ) * 4 ) );\r
-\r
-    ngc[array_index][glyph_index / 4] &= mask;\r
-    ngc[array_index][glyph_index / 4] |= bits;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,\r
-                         HB_GlyphItem    gitem,\r
-                         HB_UShort        flags,\r
-                         HB_UShort*       property )\r
-{\r
-  HB_Error  error;\r
-\r
-  if ( gdef )\r
-  {\r
-    HB_UShort basic_glyph_class;\r
-    HB_UShort desired_attachment_class;\r
-\r
-    if ( gitem->gproperties == HB_GLYPH_PROPERTIES_UNKNOWN )\r
-    {\r
-      error = HB_GDEF_Get_Glyph_Property( gdef, gitem->gindex, &gitem->gproperties );\r
-      if ( error )\r
-       return error;\r
-    }\r
-\r
-    *property = gitem->gproperties;\r
-\r
-    /* If the glyph was found in the MarkAttachmentClass table,\r
-     * then that klass value is the high byte of the result,\r
-     * otherwise the low byte contains the basic type of the glyph\r
-     * as defined by the GlyphClassDef table.\r
-     */\r
-    if ( *property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  )\r
-      basic_glyph_class = HB_GDEF_MARK;\r
-    else\r
-      basic_glyph_class = *property;\r
-\r
-    /* Return Not_Covered, if, for example, basic_glyph_class\r
-     * is HB_GDEF_LIGATURE and LookFlags includes HB_LOOKUP_FLAG_IGNORE_LIGATURES\r
-     */\r
-    if ( flags & basic_glyph_class )\r
-      return HB_Err_Not_Covered;\r
-    \r
-    /* The high byte of LookupFlags has the meaning\r
-     * "ignore marks of attachment type different than\r
-     * the attachment type specified."\r
-     */\r
-    desired_attachment_class = flags & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS;\r
-    if ( desired_attachment_class )\r
-    {\r
-      if ( basic_glyph_class == HB_GDEF_MARK &&\r
-          *property != desired_attachment_class )\r
-       return HB_Err_Not_Covered;\r
-    }\r
-  } else {\r
-      *property = 0;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,\r
-                                                 HB_Stream      stream,\r
-                                                 HB_Lookup*     lo,\r
-                                                 HB_UShort      num_lookups)\r
-{\r
-  HB_Error   error = HB_Err_Ok;\r
-  HB_UShort  i;\r
-\r
-  /* We now check the LookupFlags for values larger than 0xFF to find\r
-     out whether we need to load the `MarkAttachClassDef' field of the\r
-     GDEF table -- this hack is necessary for OpenType 1.2 tables since\r
-     the version field of the GDEF table hasn't been incremented.\r
-\r
-     For constructed GDEF tables, we only load it if\r
-     `MarkAttachClassDef_offset' is not zero (nevertheless, a build of\r
-     a constructed mark attach table is not supported currently).       */\r
-\r
-  if ( gdef &&\r
-       gdef->MarkAttachClassDef_offset && !gdef->MarkAttachClassDef.loaded )\r
-  {\r
-    for ( i = 0; i < num_lookups; i++ )\r
-    {\r
-\r
-      if ( lo[i].LookupFlag & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )\r
-      {\r
-       if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) ||\r
-            ( error = _HB_OPEN_Load_ClassDefinition( &gdef->MarkAttachClassDef,\r
-                                            256, stream ) ) != HB_Err_Ok )\r
-         goto Done;\r
-\r
-       break;\r
-      }\r
-    }\r
-  }\r
-\r
-Done:\r
-  return error;\r
-}\r
-\r
-/* END */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-gdef-private.h"
+#include "harfbuzz-open-private.h"
+
+static HB_Error  Load_AttachList( HB_AttachList*  al,
+                                 HB_Stream        stream );
+static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,
+                                   HB_Stream          stream );
+
+static void  Free_AttachList( HB_AttachList*  al);
+static void  Free_LigCaretList( HB_LigCaretList*  lcl);
+
+static void  Free_NewGlyphClasses( HB_GDEFHeader*  gdef);
+
+
+
+/* GDEF glyph classes */
+
+#define UNCLASSIFIED_GLYPH  0
+#define SIMPLE_GLYPH        1
+#define LIGATURE_GLYPH      2
+#define MARK_GLYPH          3
+#define COMPONENT_GLYPH     4
+
+
+
+
+
+
+HB_Error  HB_New_GDEF_Table( HB_GDEFHeader** retptr )
+{
+  HB_Error         error;
+
+  HB_GDEFHeader*  gdef;
+
+  if ( !retptr )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( ALLOC( gdef, sizeof( *gdef ), HB_GDEFHeader* ) )
+    return error;
+
+  gdef->GlyphClassDef.loaded = FALSE;
+  gdef->AttachList.loaded = FALSE;
+  gdef->LigCaretList.loaded = FALSE;
+  gdef->MarkAttachClassDef_offset = 0;
+  gdef->MarkAttachClassDef.loaded = FALSE;
+
+  gdef->LastGlyph = 0;
+  gdef->NewGlyphClasses = NULL;
+
+  *retptr = gdef;
+
+  return HB_Err_Ok;
+}
+
+
+HB_Error  HB_Load_GDEF_Table( HB_Stream stream, 
+                             HB_GDEFHeader** retptr )
+{
+  HB_Error         error;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_GDEFHeader*  gdef;
+
+
+  if ( !retptr )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( GOTO_Table( TTAG_GDEF ) )
+    return error;
+
+  if (( error = HB_New_GDEF_Table ( &gdef ) ))
+    return error;
+
+  base_offset = FILE_Pos();
+
+  /* skip version */
+
+  if ( FILE_Seek( base_offset + 4L ) ||
+       ACCESS_Frame( 2L ) )
+    goto Fail0;
+
+  new_offset = GET_UShort();
+
+  FORGET_Frame();
+
+  /* all GDEF subtables are optional */
+
+  if ( new_offset )
+  {
+    new_offset += base_offset;
+
+    /* only classes 1-4 are allowed here */
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,
+                                        stream ) ) != HB_Err_Ok )
+      goto Fail0;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail1;
+
+  new_offset = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( new_offset )
+  {
+    new_offset += base_offset;
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_AttachList( &gdef->AttachList,
+                                   stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  new_offset = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( new_offset )
+  {
+    new_offset += base_offset;
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LigCaretList( &gdef->LigCaretList,
+                                     stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  /* OpenType 1.2 has introduced the `MarkAttachClassDef' field.  We
+     first have to scan the LookupFlag values to find out whether we
+     must load it or not.  Here we only store the offset of the table. */
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( new_offset )
+    gdef->MarkAttachClassDef_offset = new_offset + base_offset;
+  else
+    gdef->MarkAttachClassDef_offset = 0;
+
+  *retptr = gdef;
+
+  return HB_Err_Ok;
+
+Fail3:
+  Free_LigCaretList( &gdef->LigCaretList );
+  
+Fail2:
+  Free_AttachList( &gdef->AttachList );
+
+Fail1:
+  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef );
+
+Fail0:
+  FREE( gdef );
+
+  return error;
+}
+
+
+HB_Error  HB_Done_GDEF_Table ( HB_GDEFHeader* gdef ) 
+{  
+  Free_LigCaretList( &gdef->LigCaretList );
+  Free_AttachList( &gdef->AttachList );
+  _HB_OPEN_Free_ClassDefinition( &gdef->GlyphClassDef );
+  _HB_OPEN_Free_ClassDefinition( &gdef->MarkAttachClassDef );
+  
+  Free_NewGlyphClasses( gdef );
+
+  FREE( gdef );
+
+  return HB_Err_Ok;
+}
+
+
+
+
+/*******************************
+ * AttachList related functions
+ *******************************/
+
+
+/* AttachPoint */
+
+static HB_Error  Load_AttachPoint( HB_AttachPoint*  ap,
+                                  HB_Stream         stream )
+{
+  HB_Error  error;
+
+  HB_UShort   n, count;
+  HB_UShort*  pi;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ap->PointCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ap->PointIndex = NULL;
+
+  if ( count )
+  {
+    if ( ALLOC_ARRAY( ap->PointIndex, count, HB_UShort ) )
+      return error;
+
+    pi = ap->PointIndex;
+
+    if ( ACCESS_Frame( count * 2L ) )
+    {
+      FREE( pi );
+      return error;
+    }
+
+    for ( n = 0; n < count; n++ )
+      pi[n] = GET_UShort();
+
+    FORGET_Frame();
+  }
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_AttachPoint( HB_AttachPoint*  ap )
+{
+  FREE( ap->PointIndex );
+}
+
+
+/* AttachList */
+
+static HB_Error  Load_AttachList( HB_AttachList*  al,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+
+  HB_UShort         n, m, count;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_AttachPoint*  ap;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &al->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = al->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  al->AttachPoint = NULL;
+
+  if ( ALLOC_ARRAY( al->AttachPoint, count, HB_AttachPoint ) )
+    goto Fail2;
+
+  ap = al->AttachPoint;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_AttachPoint( &ap[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  al->loaded = TRUE;
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_AttachPoint( &ap[m] );
+
+  FREE( ap );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &al->Coverage );
+  return error;
+}
+
+
+static void  Free_AttachList( HB_AttachList*  al)
+{
+  HB_UShort         n, count;
+
+  HB_AttachPoint*  ap;
+
+
+  if ( !al->loaded )
+    return;
+
+  if ( al->AttachPoint )
+  {
+    count = al->GlyphCount;
+    ap    = al->AttachPoint;
+
+    for ( n = 0; n < count; n++ )
+      Free_AttachPoint( &ap[n] );
+
+    FREE( ap );
+  }
+
+  _HB_OPEN_Free_Coverage( &al->Coverage );
+}
+
+
+
+/*********************************
+ * LigCaretList related functions
+ *********************************/
+
+
+/* CaretValueFormat1 */
+/* CaretValueFormat2 */
+/* CaretValueFormat3 */
+/* CaretValueFormat4 */
+
+static HB_Error  Load_CaretValue( HB_CaretValue*  cv,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+
+  HB_UInt cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cv->CaretValueFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( cv->CaretValueFormat )
+  {
+  case 1:
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    cv->cvf.cvf1.Coordinate = GET_Short();
+
+    FORGET_Frame();
+
+    break;
+
+  case 2:
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    cv->cvf.cvf2.CaretValuePoint = GET_UShort();
+
+    FORGET_Frame();
+
+    break;
+
+  case 3:
+    if ( ACCESS_Frame( 4L ) )
+      return error;
+
+    cv->cvf.cvf3.Coordinate = GET_Short();
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Device( &cv->cvf.cvf3.Device,
+                               stream ) ) != HB_Err_Ok )
+      return error;
+    (void)FILE_Seek( cur_offset );
+
+    break;
+
+  case 4:
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    cv->cvf.cvf4.IdCaretValue = GET_UShort();
+
+    FORGET_Frame();
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_CaretValue( HB_CaretValue*  cv)
+{
+  if ( cv->CaretValueFormat == 3 )
+    _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device );
+}
+
+
+/* LigGlyph */
+
+static HB_Error  Load_LigGlyph( HB_LigGlyph*  lg,
+                               HB_Stream      stream )
+{
+  HB_Error  error;
+
+  HB_UShort        n, m, count;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_CaretValue*  cv;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = lg->CaretCount = GET_UShort();
+
+  FORGET_Frame();
+
+  lg->CaretValue = NULL;
+
+  if ( ALLOC_ARRAY( lg->CaretValue, count, HB_CaretValue ) )
+    return error;
+
+  cv = lg->CaretValue;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_CaretValue( &cv[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_CaretValue( &cv[m] );
+
+  FREE( cv );
+  return error;
+}
+
+
+static void  Free_LigGlyph( HB_LigGlyph*  lg)
+{
+  HB_UShort        n, count;
+
+  HB_CaretValue*  cv;
+
+
+  if ( lg->CaretValue )
+  {
+    count = lg->CaretCount;
+    cv    = lg->CaretValue;
+
+    for ( n = 0; n < count; n++ )
+      Free_CaretValue( &cv[n] );
+
+    FREE( cv );
+  }
+}
+
+
+/* LigCaretList */
+
+static HB_Error  Load_LigCaretList( HB_LigCaretList*  lcl,
+                                   HB_Stream          stream )
+{
+  HB_Error  error;
+
+  HB_UShort      m, n, count;
+  HB_UInt       cur_offset, new_offset, base_offset;
+
+  HB_LigGlyph*  lg;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &lcl->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = lcl->LigGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  lcl->LigGlyph = NULL;
+
+  if ( ALLOC_ARRAY( lcl->LigGlyph, count, HB_LigGlyph ) )
+    goto Fail2;
+
+  lg = lcl->LigGlyph;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LigGlyph( &lg[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  lcl->loaded = TRUE;
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_LigGlyph( &lg[m] );
+
+  FREE( lg );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &lcl->Coverage );
+  return error;
+}
+
+
+static void  Free_LigCaretList( HB_LigCaretList*  lcl )
+{
+  HB_UShort      n, count;
+
+  HB_LigGlyph*  lg;
+
+
+  if ( !lcl->loaded )
+    return;
+
+  if ( lcl->LigGlyph )
+  {
+    count = lcl->LigGlyphCount;
+    lg    = lcl->LigGlyph;
+
+    for ( n = 0; n < count; n++ )
+      Free_LigGlyph( &lg[n] );
+
+    FREE( lg );
+  }
+
+  _HB_OPEN_Free_Coverage( &lcl->Coverage );
+}
+
+
+
+/***********
+ * GDEF API
+ ***********/
+
+
+static HB_UShort  Get_New_Class( HB_GDEFHeader*  gdef,
+                                HB_UShort        glyphID,
+                                HB_UShort        index )
+{
+  HB_UShort              glyph_index, array_index, count;
+  HB_UShort              byte, bits;
+  
+  HB_ClassRangeRecord*  gcrr;
+  HB_UShort**            ngc;
+
+
+  if ( glyphID >= gdef->LastGlyph )
+    return 0;
+
+  count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;
+  gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord;
+  ngc  = gdef->NewGlyphClasses;
+
+  if ( index < count && glyphID < gcrr[index].Start )
+  {
+    array_index = index;
+    if ( index == 0 )
+      glyph_index = glyphID;
+    else
+      glyph_index = glyphID - gcrr[index - 1].End - 1;
+  }
+  else
+  {
+    array_index = index + 1;
+    glyph_index = glyphID - gcrr[index].End - 1;
+  }
+
+  byte = ngc[array_index][glyph_index / 4];
+  bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 );
+
+  return bits & 0x000F;
+}
+
+
+
+HB_Error  HB_GDEF_Get_Glyph_Property( HB_GDEFHeader*  gdef,
+                                     HB_UShort        glyphID,
+                                     HB_UShort*       property )
+{
+  HB_UShort klass = 0, index = 0; /* shut compiler up */
+
+  HB_Error  error;
+
+
+  if ( !gdef || !property )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  /* first, we check for mark attach classes */
+
+  if ( gdef->MarkAttachClassDef.loaded )
+  {
+    error = _HB_OPEN_Get_Class( &gdef->MarkAttachClassDef, glyphID, &klass, &index );
+    if ( error && error != HB_Err_Not_Covered )
+      return error;
+    if ( !error )
+    {
+      *property = klass << 8;
+      return HB_Err_Ok;
+    }
+  }
+
+  error = _HB_OPEN_Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );
+  if ( error && error != HB_Err_Not_Covered )
+    return error;
+
+  /* if we have a constructed klass table, check whether additional
+     values have been assigned                                      */
+
+  if ( error == HB_Err_Not_Covered && gdef->NewGlyphClasses )
+    klass = Get_New_Class( gdef, glyphID, index );
+
+  switch ( klass )
+  {
+  default:
+  case UNCLASSIFIED_GLYPH:
+    *property = 0;
+    break;
+
+  case SIMPLE_GLYPH:
+    *property = HB_GDEF_BASE_GLYPH;
+    break;
+
+  case LIGATURE_GLYPH:
+    *property = HB_GDEF_LIGATURE;
+    break;
+
+  case MARK_GLYPH:
+    *property = HB_GDEF_MARK;
+    break;
+
+  case COMPONENT_GLYPH:
+    *property = HB_GDEF_COMPONENT;
+    break;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+static HB_Error  Make_ClassRange( HB_ClassDefinition*  cd,
+                                 HB_UShort             start,
+                                 HB_UShort             end,
+                                 HB_UShort             klass )
+{
+  HB_Error               error;
+  HB_UShort              index;
+
+  HB_ClassDefFormat2*   cdf2;
+  HB_ClassRangeRecord*  crr;
+
+
+  cdf2 = &cd->cd.cd2;
+
+  if ( REALLOC_ARRAY( cdf2->ClassRangeRecord,
+                     cdf2->ClassRangeCount + 1 ,
+                     HB_ClassRangeRecord ) )
+    return error;
+
+  cdf2->ClassRangeCount++;
+
+  crr   = cdf2->ClassRangeRecord;
+  index = cdf2->ClassRangeCount - 1;
+
+  crr[index].Start = start;
+  crr[index].End   = end;
+  crr[index].Class = klass;
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GDEF_Build_ClassDefinition( HB_GDEFHeader*  gdef,
+                                        HB_UShort        num_glyphs,
+                                        HB_UShort        glyph_count,
+                                        HB_UShort*       glyph_array,
+                                        HB_UShort*       class_array )
+{
+  HB_UShort              start, curr_glyph, curr_class;
+  HB_UShort              n, m, count;
+  HB_Error               error;
+
+  HB_ClassDefinition*   gcd;
+  HB_ClassRangeRecord*  gcrr;
+  HB_UShort**            ngc;
+
+
+  if ( !gdef || !glyph_array || !class_array )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gcd = &gdef->GlyphClassDef;
+
+  /* We build a format 2 table */
+
+  gcd->ClassFormat = 2;
+
+  gcd->cd.cd2.ClassRangeCount  = 0;
+  gcd->cd.cd2.ClassRangeRecord = NULL;
+
+  start      = glyph_array[0];
+  curr_class = class_array[0];
+  curr_glyph = start;
+
+  if ( curr_class >= 5 )
+  {
+    error = ERR_HB(HB_Err_Invalid_Argument);
+    goto Fail4;
+  }
+
+  glyph_count--;
+
+  for ( n = 0; n < glyph_count + 1; n++ )
+  {
+    if ( curr_glyph == glyph_array[n] && curr_class == class_array[n] )
+    {
+      if ( n == glyph_count )
+      {
+       if ( ( error = Make_ClassRange( gcd, start,
+                                       curr_glyph,
+                                       curr_class) ) != HB_Err_Ok )
+         goto Fail3;
+      }
+      else
+      {
+       if ( curr_glyph == 0xFFFF )
+       {
+         error = ERR_HB(HB_Err_Invalid_Argument);
+         goto Fail3;
+       }
+       else
+         curr_glyph++;
+      }
+    }
+    else
+    {
+      if ( ( error = Make_ClassRange( gcd, start,
+                                     curr_glyph - 1,
+                                     curr_class) ) != HB_Err_Ok )
+       goto Fail3;
+
+      if ( curr_glyph > glyph_array[n] )
+      {
+       error = ERR_HB(HB_Err_Invalid_Argument);
+       goto Fail3;
+      }
+
+      start      = glyph_array[n];
+      curr_class = class_array[n];
+      curr_glyph = start;
+
+      if ( curr_class >= 5 )
+      {
+       error = ERR_HB(HB_Err_Invalid_Argument);
+       goto Fail3;
+      }
+
+      if ( n == glyph_count )
+      {
+       if ( ( error = Make_ClassRange( gcd, start,
+                                       curr_glyph,
+                                       curr_class) ) != HB_Err_Ok )
+         goto Fail3;
+      }
+      else
+      {
+       if ( curr_glyph == 0xFFFF )
+       {
+         error = ERR_HB(HB_Err_Invalid_Argument);
+         goto Fail3;
+       }
+       else
+         curr_glyph++;
+      }
+    }
+  }
+
+  /* now prepare the arrays for klass values assigned during the lookup
+     process                                                            */
+
+  if ( ALLOC_ARRAY( gdef->NewGlyphClasses,
+                   gcd->cd.cd2.ClassRangeCount + 1, HB_UShort* ) )
+    goto Fail3;
+
+  count = gcd->cd.cd2.ClassRangeCount;
+  gcrr  = gcd->cd.cd2.ClassRangeRecord;
+  ngc   = gdef->NewGlyphClasses;
+
+  /* We allocate arrays for all glyphs not covered by the klass range
+     records.  Each element holds four klass values.                  */
+
+  if ( count > 0 )
+  {
+      if ( gcrr[0].Start )
+      {
+       if ( ALLOC_ARRAY( ngc[0], ( gcrr[0].Start + 3 ) / 4, HB_UShort ) )
+         goto Fail2;
+      }
+
+      for ( n = 1; n < count; n++ )
+      {
+       if ( gcrr[n].Start - gcrr[n - 1].End > 1 )
+         if ( ALLOC_ARRAY( ngc[n],
+                           ( gcrr[n].Start - gcrr[n - 1].End + 2 ) / 4,
+                           HB_UShort ) )
+           goto Fail1;
+      }
+
+      if ( gcrr[count - 1].End != num_glyphs - 1 )
+      {
+       if ( ALLOC_ARRAY( ngc[count],
+                         ( num_glyphs - gcrr[count - 1].End + 2 ) / 4,
+                         HB_UShort ) )
+           goto Fail1;
+      }
+  }
+  else if ( num_glyphs > 0 )
+  {
+      if ( ALLOC_ARRAY( ngc[count],
+                       ( num_glyphs + 3 ) / 4,
+                       HB_UShort ) )
+         goto Fail2;
+  }
+      
+  gdef->LastGlyph = num_glyphs - 1;
+
+  gdef->MarkAttachClassDef_offset = 0L;
+  gdef->MarkAttachClassDef.loaded = FALSE;
+
+  gcd->loaded = TRUE;
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    FREE( ngc[m] );
+
+Fail2:
+  FREE( gdef->NewGlyphClasses );
+
+Fail3:
+  FREE( gcd->cd.cd2.ClassRangeRecord );
+
+Fail4:
+  return error;
+}
+
+
+static void  Free_NewGlyphClasses( HB_GDEFHeader*  gdef )
+{
+  HB_UShort**  ngc;
+  HB_UShort    n, count;
+
+
+  if ( gdef->NewGlyphClasses )
+  {
+    count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount + 1;
+    ngc   = gdef->NewGlyphClasses;
+
+    for ( n = 0; n < count; n++ )
+      FREE( ngc[n] );
+
+    FREE( ngc );
+  }
+}
+
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+                             HB_UShort        glyphID,
+                             HB_UShort        property )
+{
+  HB_Error               error;
+  HB_UShort              klass, new_class, index = 0; /* shut compiler up */
+  HB_UShort              byte, bits, mask;
+  HB_UShort              array_index, glyph_index, count;
+
+  HB_ClassRangeRecord*  gcrr;
+  HB_UShort**            ngc;
+
+
+  error = _HB_OPEN_Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );
+  if ( error && error != HB_Err_Not_Covered )
+    return error;
+
+  /* we don't accept glyphs covered in `GlyphClassDef' */
+
+  if ( !error )
+    return HB_Err_Not_Covered;
+
+  switch ( property )
+  {
+  case 0:
+    new_class = UNCLASSIFIED_GLYPH;
+    break;
+
+  case HB_GDEF_BASE_GLYPH:
+    new_class = SIMPLE_GLYPH;
+    break;
+
+  case HB_GDEF_LIGATURE:
+    new_class = LIGATURE_GLYPH;
+    break;
+
+  case HB_GDEF_MARK:
+    new_class = MARK_GLYPH;
+    break;
+
+  case HB_GDEF_COMPONENT:
+    new_class = COMPONENT_GLYPH;
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_Argument);
+  }
+
+  count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;
+  gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord;
+  ngc  = gdef->NewGlyphClasses;
+
+  if ( index < count && glyphID < gcrr[index].Start )
+  {
+    array_index = index;
+    if ( index == 0 )
+      glyph_index = glyphID;
+    else
+      glyph_index = glyphID - gcrr[index - 1].End - 1;
+  }
+  else
+  {
+    array_index = index + 1;
+    glyph_index = glyphID - gcrr[index].End - 1;
+  }
+
+  byte  = ngc[array_index][glyph_index / 4];
+  bits  = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 );
+  klass = bits & 0x000F;
+
+  /* we don't overwrite existing entries */
+
+  if ( !klass )
+  {
+    bits = new_class << ( 16 - ( glyph_index % 4 + 1 ) * 4 );
+    mask = ~( 0x000F << ( 16 - ( glyph_index % 4 + 1 ) * 4 ) );
+
+    ngc[array_index][glyph_index / 4] &= mask;
+    ngc[array_index][glyph_index / 4] |= bits;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+HB_INTERNAL HB_Error
+_HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+                         HB_GlyphItem    gitem,
+                         HB_UShort        flags,
+                         HB_UShort*       property )
+{
+  HB_Error  error;
+
+  if ( gdef )
+  {
+    HB_UShort basic_glyph_class;
+    HB_UShort desired_attachment_class;
+
+    if ( gitem->gproperties == HB_GLYPH_PROPERTIES_UNKNOWN )
+    {
+      error = HB_GDEF_Get_Glyph_Property( gdef, gitem->gindex, &gitem->gproperties );
+      if ( error )
+       return error;
+    }
+
+    *property = gitem->gproperties;
+
+    /* If the glyph was found in the MarkAttachmentClass table,
+     * then that klass value is the high byte of the result,
+     * otherwise the low byte contains the basic type of the glyph
+     * as defined by the GlyphClassDef table.
+     */
+    if ( *property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS  )
+      basic_glyph_class = HB_GDEF_MARK;
+    else
+      basic_glyph_class = *property;
+
+    /* Return Not_Covered, if, for example, basic_glyph_class
+     * is HB_GDEF_LIGATURE and LookFlags includes HB_LOOKUP_FLAG_IGNORE_LIGATURES
+     */
+    if ( flags & basic_glyph_class )
+      return HB_Err_Not_Covered;
+    
+    /* The high byte of LookupFlags has the meaning
+     * "ignore marks of attachment type different than
+     * the attachment type specified."
+     */
+    desired_attachment_class = flags & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS;
+    if ( desired_attachment_class )
+    {
+      if ( basic_glyph_class == HB_GDEF_MARK &&
+          *property != desired_attachment_class )
+       return HB_Err_Not_Covered;
+    }
+  } else {
+      *property = 0;
+  }
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL HB_Error
+_HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( HB_GDEFHeader* gdef,
+                                                 HB_Stream      stream,
+                                                 HB_Lookup*     lo,
+                                                 HB_UShort      num_lookups)
+{
+  HB_Error   error = HB_Err_Ok;
+  HB_UShort  i;
+
+  /* We now check the LookupFlags for values larger than 0xFF to find
+     out whether we need to load the `MarkAttachClassDef' field of the
+     GDEF table -- this hack is necessary for OpenType 1.2 tables since
+     the version field of the GDEF table hasn't been incremented.
+
+     For constructed GDEF tables, we only load it if
+     `MarkAttachClassDef_offset' is not zero (nevertheless, a build of
+     a constructed mark attach table is not supported currently).       */
+
+  if ( gdef &&
+       gdef->MarkAttachClassDef_offset && !gdef->MarkAttachClassDef.loaded )
+  {
+    for ( i = 0; i < num_lookups; i++ )
+    {
+
+      if ( lo[i].LookupFlag & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )
+      {
+       if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) ||
+            ( error = _HB_OPEN_Load_ClassDefinition( &gdef->MarkAttachClassDef,
+                                            256, stream ) ) != HB_Err_Ok )
+         goto Done;
+
+       break;
+      }
+    }
+  }
+
+Done:
+  return error;
+}
+
+/* END */
index 08718ba..0eb963f 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- * Copyright (C) 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-gpos-private.h"\r
-#include "harfbuzz-open-private.h"\r
-#include "harfbuzz-gdef-private.h"\r
-#include "harfbuzz-shaper.h"\r
-\r
-struct  GPOS_Instance_\r
-{\r
-  HB_GPOSHeader*  gpos;\r
-  HB_Font          font;\r
-  HB_Bool          dvi;\r
-  HB_UShort        load_flags;  /* how the glyph should be loaded */\r
-  HB_Bool          r2l;\r
-\r
-  HB_UShort        last;        /* the last valid glyph -- used\r
-                                  with cursive positioning     */\r
-  HB_Fixed           anchor_x;    /* the coordinates of the anchor point */\r
-  HB_Fixed           anchor_y;    /* of the last valid glyph             */\r
-};\r
-\r
-typedef struct GPOS_Instance_  GPOS_Instance;\r
-\r
-\r
-static HB_Error  GPOS_Do_Glyph_Lookup( GPOS_Instance*    gpi,\r
-                                      HB_UShort         lookup_index,\r
-                                      HB_Buffer        buffer,\r
-                                      HB_UShort         context_length,\r
-                                      int               nesting_level );\r
-\r
-\r
-\r
-/* the client application must replace this with something more\r
-   meaningful if multiple master fonts are to be supported.     */\r
-\r
-static HB_Error  default_mmfunc( HB_Font      font,\r
-                                HB_UShort    metric_id,\r
-                                HB_Fixed*      metric_value,\r
-                                void*        data )\r
-{\r
-  HB_UNUSED(font);\r
-  HB_UNUSED(metric_id);\r
-  HB_UNUSED(metric_value);\r
-  HB_UNUSED(data);\r
-  return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_Load_GPOS_Table( HB_Stream stream, \r
-                             HB_GPOSHeader** retptr,\r
-                             HB_GDEFHeader*  gdef,\r
-                             HB_Stream       gdefStream )\r
-{\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_GPOSHeader*  gpos;\r
-\r
-  HB_Error   error;\r
-\r
-\r
-  if ( !retptr )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( GOTO_Table( TTAG_GPOS ) )\r
-    return error;\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ALLOC ( gpos, sizeof( *gpos ), HB_GPOSHeader* ) )\r
-    return error;\r
-\r
-  gpos->mmfunc = default_mmfunc;\r
-\r
-  /* skip version */\r
-\r
-  if ( FILE_Seek( base_offset + 4L ) ||\r
-       ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_ScriptList( &gpos->ScriptList,\r
-                                 stream ) ) != HB_Err_Ok )\r
-    goto Fail4;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_FeatureList( &gpos->FeatureList,\r
-                                  stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_LookupList( &gpos->LookupList,\r
-                                 stream, HB_Type_GPOS ) ) != HB_Err_Ok )\r
-    goto Fail2;\r
-\r
-  gpos->gdef = gdef;      /* can be NULL */\r
-\r
-  if ( ( error =  _HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( gdef, gdefStream,\r
-                                                                    gpos->LookupList.Lookup,\r
-                                                                    gpos->LookupList.LookupCount ) ) )\r
-    goto Fail1;\r
-\r
-  *retptr = gpos;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_FeatureList( &gpos->FeatureList );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_ScriptList( &gpos->ScriptList );\r
-\r
-Fail4:\r
-  FREE( gpos );\r
-\r
-  return error;\r
-}\r
-\r
-\r
-HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos )\r
-{\r
-  _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS );\r
-  _HB_OPEN_Free_FeatureList( &gpos->FeatureList );\r
-  _HB_OPEN_Free_ScriptList( &gpos->ScriptList );\r
-\r
-  FREE( gpos );\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/*****************************\r
- * SubTable related functions\r
- *****************************/\r
-\r
-/* shared tables */\r
-\r
-/* ValueRecord */\r
-\r
-/* There is a subtle difference in the specs between a `table' and a\r
-   `record' -- offsets for device tables in ValueRecords are taken from\r
-   the parent table and not the parent record.                          */\r
-\r
-static HB_Error  Load_ValueRecord( HB_ValueRecord*  vr,\r
-                                  HB_UShort         format,\r
-                                  HB_UInt          base_offset,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UInt cur_offset, new_offset;\r
-\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    vr->XPlacement = GET_Short();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->XPlacement = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    vr->YPlacement = GET_Short();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->YPlacement = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    vr->XAdvance = GET_Short();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->XAdvance = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    vr->YAdvance = GET_Short();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->YAdvance = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &vr->XPlacementDevice,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       return error;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      goto empty1;\r
-  }\r
-  else\r
-  {\r
-  empty1:\r
-    vr->XPlacementDevice.StartSize  = 0;\r
-    vr->XPlacementDevice.EndSize    = 0;\r
-    vr->XPlacementDevice.DeltaValue = NULL;\r
-  }\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail3;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &vr->YPlacementDevice,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       goto Fail3;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      goto empty2;\r
-  }\r
-  else\r
-  {\r
-  empty2:\r
-    vr->YPlacementDevice.StartSize  = 0;\r
-    vr->YPlacementDevice.EndSize    = 0;\r
-    vr->YPlacementDevice.DeltaValue = NULL;\r
-  }\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &vr->XAdvanceDevice,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       goto Fail2;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      goto empty3;\r
-  }\r
-  else\r
-  {\r
-  empty3:\r
-    vr->XAdvanceDevice.StartSize  = 0;\r
-    vr->XAdvanceDevice.EndSize    = 0;\r
-    vr->XAdvanceDevice.DeltaValue = NULL;\r
-  }\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &vr->YAdvanceDevice,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      goto empty4;\r
-  }\r
-  else\r
-  {\r
-  empty4:\r
-    vr->YAdvanceDevice.StartSize  = 0;\r
-    vr->YAdvanceDevice.EndSize    = 0;\r
-    vr->YAdvanceDevice.DeltaValue = NULL;\r
-  }\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    vr->XIdPlacement = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->XIdPlacement = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    vr->YIdPlacement = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->YIdPlacement = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    vr->XIdAdvance = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->XIdAdvance = 0;\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    vr->YIdAdvance = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-  else\r
-    vr->YIdAdvance = 0;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  _HB_OPEN_Free_Device( &vr->YAdvanceDevice );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Device( &vr->XAdvanceDevice );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Device( &vr->YPlacementDevice );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ValueRecord( HB_ValueRecord*  vr,\r
-                              HB_UShort         format )\r
-{\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )\r
-    _HB_OPEN_Free_Device( &vr->YAdvanceDevice );\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )\r
-    _HB_OPEN_Free_Device( &vr->XAdvanceDevice );\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )\r
-    _HB_OPEN_Free_Device( &vr->YPlacementDevice );\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )\r
-    _HB_OPEN_Free_Device( &vr->XPlacementDevice );\r
-}\r
-\r
-\r
-static HB_Error  Get_ValueRecord( GPOS_Instance*    gpi,\r
-                                 HB_ValueRecord*  vr,\r
-                                 HB_UShort         format,\r
-                                 HB_Position      gd )\r
-{\r
-  HB_Fixed           value;\r
-  HB_Short         pixel_value;\r
-  HB_Error         error = HB_Err_Ok;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-\r
-  HB_UShort  x_ppem, y_ppem;\r
-  HB_16Dot16   x_scale, y_scale;\r
-\r
-\r
-  if ( !format )\r
-    return HB_Err_Ok;\r
-\r
-  x_ppem  = gpi->font->x_ppem;\r
-  y_ppem  = gpi->font->y_ppem;\r
-  x_scale = gpi->font->x_scale;\r
-  y_scale = gpi->font->y_scale;\r
-\r
-  /* design units -> fractional pixel */\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT )\r
-    gd->x_pos += x_scale * vr->XPlacement / 0x10000;\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT )\r
-    gd->y_pos += y_scale * vr->YPlacement / 0x10000;\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE )\r
-    gd->x_advance += x_scale * vr->XAdvance / 0x10000;\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE )\r
-    gd->y_advance += y_scale * vr->YAdvance / 0x10000;\r
-\r
-  if ( !gpi->dvi )\r
-  {\r
-    /* pixel -> fractional pixel */\r
-\r
-    if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )\r
-    {\r
-      _HB_OPEN_Get_Device( &vr->XPlacementDevice, x_ppem, &pixel_value );\r
-      gd->x_pos += pixel_value << 6;\r
-    }\r
-    if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )\r
-    {\r
-      _HB_OPEN_Get_Device( &vr->YPlacementDevice, y_ppem, &pixel_value );\r
-      gd->y_pos += pixel_value << 6;\r
-    }\r
-    if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )\r
-    {\r
-      _HB_OPEN_Get_Device( &vr->XAdvanceDevice, x_ppem, &pixel_value );\r
-      gd->x_advance += pixel_value << 6;\r
-    }\r
-    if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )\r
-    {\r
-      _HB_OPEN_Get_Device( &vr->YAdvanceDevice, y_ppem, &pixel_value );\r
-      gd->y_advance += pixel_value << 6;\r
-    }\r
-  }\r
-\r
-  /* values returned from mmfunc() are already in fractional pixels */\r
-\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT )\r
-  {\r
-    error = (gpos->mmfunc)( gpi->font, vr->XIdPlacement,\r
-                           &value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-    gd->x_pos += value;\r
-  }\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT )\r
-  {\r
-    error = (gpos->mmfunc)( gpi->font, vr->YIdPlacement,\r
-                           &value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-    gd->y_pos += value;\r
-  }\r
-  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE )\r
-  {\r
-    error = (gpos->mmfunc)( gpi->font, vr->XIdAdvance,\r
-                           &value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-    gd->x_advance += value;\r
-  }\r
-  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE )\r
-  {\r
-    error = (gpos->mmfunc)( gpi->font, vr->YIdAdvance,\r
-                           &value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-    gd->y_advance += value;\r
-  }\r
-\r
-  return error;\r
-}\r
-\r
-\r
-/* AnchorFormat1 */\r
-/* AnchorFormat2 */\r
-/* AnchorFormat3 */\r
-/* AnchorFormat4 */\r
-\r
-static HB_Error  Load_Anchor( HB_Anchor*  an,\r
-                             HB_Stream    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UInt cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  an->PosFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( an->PosFormat )\r
-  {\r
-  case 1:\r
-    if ( ACCESS_Frame( 4L ) )\r
-      return error;\r
-\r
-    an->af.af1.XCoordinate = GET_Short();\r
-    an->af.af1.YCoordinate = GET_Short();\r
-\r
-    FORGET_Frame();\r
-    break;\r
-\r
-  case 2:\r
-    if ( ACCESS_Frame( 6L ) )\r
-      return error;\r
-\r
-    an->af.af2.XCoordinate = GET_Short();\r
-    an->af.af2.YCoordinate = GET_Short();\r
-    an->af.af2.AnchorPoint = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-    break;\r
-\r
-  case 3:\r
-    if ( ACCESS_Frame( 6L ) )\r
-      return error;\r
-\r
-    an->af.af3.XCoordinate = GET_Short();\r
-    an->af.af3.YCoordinate = GET_Short();\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &an->af.af3.XDeviceTable,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       return error;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      an->af.af3.XDeviceTable.StartSize  = 0;\r
-      an->af.af3.XDeviceTable.EndSize    = 0;\r
-      an->af.af3.XDeviceTable.DeltaValue = NULL;\r
-    }\r
-\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = _HB_OPEN_Load_Device( &an->af.af3.YDeviceTable,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       goto Fail;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      an->af.af3.YDeviceTable.StartSize  = 0;\r
-      an->af.af3.YDeviceTable.EndSize    = 0;\r
-      an->af.af3.YDeviceTable.DeltaValue = NULL;\r
-    }\r
-    break;\r
-\r
-  case 4:\r
-    if ( ACCESS_Frame( 4L ) )\r
-      return error;\r
-\r
-    an->af.af4.XIdAnchor = GET_UShort();\r
-    an->af.af4.YIdAnchor = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_Anchor( HB_Anchor*  an)\r
-{\r
-  if ( an->PosFormat == 3 )\r
-  {\r
-    _HB_OPEN_Free_Device( &an->af.af3.YDeviceTable );\r
-    _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Get_Anchor( GPOS_Instance*   gpi,\r
-                            HB_Anchor*      an,\r
-                            HB_UShort        glyph_index,\r
-                            HB_Fixed*          x_value,\r
-                            HB_Fixed*          y_value )\r
-{\r
-  HB_Error  error = HB_Err_Ok;\r
-\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_UShort        ap;\r
-\r
-  HB_Short         pixel_value;\r
-\r
-  HB_UShort        x_ppem, y_ppem;\r
-  HB_16Dot16         x_scale, y_scale;\r
-\r
-\r
-  x_ppem  = gpi->font->x_ppem;\r
-  y_ppem  = gpi->font->y_ppem;\r
-  x_scale = gpi->font->x_scale;\r
-  y_scale = gpi->font->y_scale;\r
-\r
-  switch ( an->PosFormat )\r
-  {\r
-  case 0:\r
-    /* The special case of an empty AnchorTable */\r
-  default:\r
-\r
-    return HB_Err_Not_Covered;\r
-\r
-  case 1:\r
-    *x_value = x_scale * an->af.af1.XCoordinate / 0x10000;\r
-    *y_value = y_scale * an->af.af1.YCoordinate / 0x10000;\r
-    break;\r
-\r
-  case 2:\r
-    if ( !gpi->dvi )\r
-    {\r
-      hb_uint32 n_points = 0;\r
-      ap = an->af.af2.AnchorPoint;\r
-      if (!gpi->font->klass->getPointInOutline)\r
-          goto no_contour_point;\r
-      error = gpi->font->klass->getPointInOutline(gpi->font, glyph_index, gpi->load_flags, ap, x_value, y_value, &n_points);\r
-      if (error)\r
-          return error;\r
-      /* if n_points is set to zero, we use the design coordinate value pair.\r
-       * This can happen e.g. for sbit glyphs. */\r
-      if (!n_points)\r
-          goto no_contour_point;\r
-    }\r
-    else\r
-    {\r
-    no_contour_point:\r
-      *x_value = x_scale * an->af.af3.XCoordinate / 0x10000;\r
-      *y_value = y_scale * an->af.af3.YCoordinate / 0x10000;\r
-    }\r
-    break;\r
-\r
-  case 3:\r
-    if ( !gpi->dvi )\r
-    {\r
-      _HB_OPEN_Get_Device( &an->af.af3.XDeviceTable, x_ppem, &pixel_value );\r
-      *x_value = pixel_value << 6;\r
-      _HB_OPEN_Get_Device( &an->af.af3.YDeviceTable, y_ppem, &pixel_value );\r
-      *y_value = pixel_value << 6;\r
-    }\r
-    else\r
-      *x_value = *y_value = 0;\r
-\r
-    *x_value += x_scale * an->af.af3.XCoordinate / 0x10000;\r
-    *y_value += y_scale * an->af.af3.YCoordinate / 0x10000;\r
-    break;\r
-\r
-  case 4:\r
-    error = (gpos->mmfunc)( gpi->font, an->af.af4.XIdAnchor,\r
-                           x_value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-\r
-    error = (gpos->mmfunc)( gpi->font, an->af.af4.YIdAnchor,\r
-                           y_value, gpos->data );\r
-    if ( error )\r
-      return error;\r
-    break;\r
-  }\r
-\r
-  return error;\r
-}\r
-\r
-\r
-/* MarkArray */\r
-\r
-static HB_Error  Load_MarkArray ( HB_MarkArray*  ma,\r
-                                 HB_Stream       stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort        n, m, count;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_MarkRecord*  mr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ma->MarkCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ma->MarkRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ma->MarkRecord, count, HB_MarkRecord ) )\r
-    return error;\r
-\r
-  mr = ma->MarkRecord;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 4L ) )\r
-      goto Fail;\r
-\r
-    mr[n].Class = GET_UShort();\r
-    new_offset  = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_Anchor( &mr[n].MarkAnchor, stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_Anchor( &mr[m].MarkAnchor );\r
-\r
-  FREE( mr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_MarkArray( HB_MarkArray*  ma )\r
-{\r
-  HB_UShort        n, count;\r
-\r
-  HB_MarkRecord*  mr;\r
-\r
-\r
-  if ( ma->MarkRecord )\r
-  {\r
-    count = ma->MarkCount;\r
-    mr    = ma->MarkRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Anchor( &mr[n].MarkAnchor );\r
-\r
-    FREE( mr );\r
-  }\r
-}\r
-\r
-\r
-/* LookupType 1 */\r
-\r
-/* SinglePosFormat1 */\r
-/* SinglePosFormat2 */\r
-\r
-static HB_Error  Load_SinglePos( HB_GPOS_SubTable* st,\r
-                                HB_Stream       stream )\r
-{\r
-  HB_Error  error;\r
-  HB_SinglePos*   sp = &st->single;\r
-\r
-  HB_UShort         n, m, count, format;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_ValueRecord*  vr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 6L ) )\r
-    return error;\r
-\r
-  sp->PosFormat = GET_UShort();\r
-  new_offset    = GET_UShort() + base_offset;\r
-\r
-  format = sp->ValueFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( !format )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &sp->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  switch ( sp->PosFormat )\r
-  {\r
-  case 1:\r
-    error = Load_ValueRecord( &sp->spf.spf1.Value, format,\r
-                             base_offset, stream );\r
-    if ( error )\r
-      goto Fail2;\r
-    break;\r
-\r
-  case 2:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    count = sp->spf.spf2.ValueCount = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    sp->spf.spf2.Value = NULL;\r
-\r
-    if ( ALLOC_ARRAY( sp->spf.spf2.Value, count, HB_ValueRecord ) )\r
-      goto Fail2;\r
-\r
-    vr = sp->spf.spf2.Value;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-    {\r
-      error = Load_ValueRecord( &vr[n], format, base_offset, stream );\r
-      if ( error )\r
-       goto Fail1;\r
-    }\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ValueRecord( &vr[m], format );\r
-\r
-  FREE( vr );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &sp->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SinglePos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_UShort         n, count, format;\r
-  HB_SinglePos*   sp = &st->single;\r
-\r
-  HB_ValueRecord*  v;\r
-\r
-\r
-  format = sp->ValueFormat;\r
-\r
-  switch ( sp->PosFormat )\r
-  {\r
-  case 1:\r
-    Free_ValueRecord( &sp->spf.spf1.Value, format );\r
-    break;\r
-\r
-  case 2:\r
-    if ( sp->spf.spf2.Value )\r
-    {\r
-      count = sp->spf.spf2.ValueCount;\r
-      v     = sp->spf.spf2.Value;\r
-\r
-      for ( n = 0; n < count; n++ )\r
-       Free_ValueRecord( &v[n], format );\r
-\r
-      FREE( v );\r
-    }\r
-    break;\r
-  default:\r
-    break;\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &sp->Coverage );\r
-}\r
-\r
-static HB_Error  Lookup_SinglePos( GPOS_Instance*    gpi,\r
-                                  HB_GPOS_SubTable* st,\r
-                                  HB_Buffer        buffer,\r
-                                  HB_UShort         flags,\r
-                                  HB_UShort         context_length,\r
-                                  int               nesting_level )\r
-{\r
-  HB_UShort        index, property;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_SinglePos*   sp = &st->single;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &sp->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  switch ( sp->PosFormat )\r
-  {\r
-  case 1:\r
-    error = Get_ValueRecord( gpi, &sp->spf.spf1.Value,\r
-                            sp->ValueFormat, POSITION( buffer->in_pos ) );\r
-    if ( error )\r
-      return error;\r
-    break;\r
-\r
-  case 2:\r
-    if ( index >= sp->spf.spf2.ValueCount )\r
-      return ERR_HB(HB_Err_Invalid_SubTable);\r
-    error = Get_ValueRecord( gpi, &sp->spf.spf2.Value[index],\r
-                            sp->ValueFormat, POSITION( buffer->in_pos ) );\r
-    if ( error )\r
-      return error;\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-  }\r
-\r
-  (buffer->in_pos)++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-/* PairSet */\r
-\r
-static HB_Error  Load_PairSet ( HB_PairSet*  ps,\r
-                               HB_UShort     format1,\r
-                               HB_UShort     format2,\r
-                               HB_Stream     stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, m, count;\r
-  HB_UInt              base_offset;\r
-\r
-  HB_PairValueRecord*  pvr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ps->PairValueCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ps->PairValueRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ps->PairValueRecord, count, HB_PairValueRecord ) )\r
-    return error;\r
-\r
-  pvr = ps->PairValueRecord;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    pvr[n].SecondGlyph = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( format1 )\r
-    {\r
-      error = Load_ValueRecord( &pvr[n].Value1, format1,\r
-                               base_offset, stream );\r
-      if ( error )\r
-       goto Fail;\r
-    }\r
-    if ( format2 )\r
-    {\r
-      error = Load_ValueRecord( &pvr[n].Value2, format2,\r
-                               base_offset, stream );\r
-      if ( error )\r
-      {\r
-       if ( format1 )\r
-         Free_ValueRecord( &pvr[n].Value1, format1 );\r
-       goto Fail;\r
-      }\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-  {\r
-    if ( format1 )\r
-      Free_ValueRecord( &pvr[m].Value1, format1 );\r
-    if ( format2 )\r
-      Free_ValueRecord( &pvr[m].Value2, format2 );\r
-  }\r
-\r
-  FREE( pvr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PairSet( HB_PairSet*  ps,\r
-                          HB_UShort     format1,\r
-                          HB_UShort     format2 )\r
-{\r
-  HB_UShort             n, count;\r
-\r
-  HB_PairValueRecord*  pvr;\r
-\r
-\r
-  if ( ps->PairValueRecord )\r
-  {\r
-    count = ps->PairValueCount;\r
-    pvr   = ps->PairValueRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-    {\r
-      if ( format1 )\r
-       Free_ValueRecord( &pvr[n].Value1, format1 );\r
-      if ( format2 )\r
-       Free_ValueRecord( &pvr[n].Value2, format2 );\r
-    }\r
-\r
-    FREE( pvr );\r
-  }\r
-}\r
-\r
-\r
-/* PairPosFormat1 */\r
-\r
-static HB_Error  Load_PairPos1( HB_PairPosFormat1*  ppf1,\r
-                               HB_UShort            format1,\r
-                               HB_UShort            format2,\r
-                               HB_Stream            stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort     n, m, count;\r
-  HB_UInt      cur_offset, new_offset, base_offset;\r
-\r
-  HB_PairSet*  ps;\r
-\r
-\r
-  base_offset = FILE_Pos() - 8L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ppf1->PairSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ppf1->PairSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ppf1->PairSet, count, HB_PairSet ) )\r
-    return error;\r
-\r
-  ps = ppf1->PairSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_PairSet( &ps[n], format1,\r
-                                format2, stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_PairSet( &ps[m], format1, format2 );\r
-\r
-  FREE( ps );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PairPos1( HB_PairPosFormat1*  ppf1,\r
-                           HB_UShort            format1,\r
-                           HB_UShort            format2 )\r
-{\r
-  HB_UShort     n, count;\r
-\r
-  HB_PairSet*  ps;\r
-\r
-\r
-  if ( ppf1->PairSet )\r
-  {\r
-    count = ppf1->PairSetCount;\r
-    ps    = ppf1->PairSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_PairSet( &ps[n], format1, format2 );\r
-\r
-    FREE( ps );\r
-  }\r
-}\r
-\r
-\r
-/* PairPosFormat2 */\r
-\r
-static HB_Error  Load_PairPos2( HB_PairPosFormat2*  ppf2,\r
-                               HB_UShort            format1,\r
-                               HB_UShort            format2,\r
-                               HB_Stream            stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort          m, n, k, count1, count2;\r
-  HB_UInt           cur_offset, new_offset1, new_offset2, base_offset;\r
-\r
-  HB_Class1Record*  c1r;\r
-  HB_Class2Record*  c2r;\r
-\r
-\r
-  base_offset = FILE_Pos() - 8L;\r
-\r
-  if ( ACCESS_Frame( 8L ) )\r
-    return error;\r
-\r
-  new_offset1 = GET_UShort() + base_offset;\r
-  new_offset2 = GET_UShort() + base_offset;\r
-\r
-  /* `Class1Count' and `Class2Count' are the upper limits for klass\r
-     values, thus we read it now to make additional safety checks.  */\r
-\r
-  count1 = ppf2->Class1Count = GET_UShort();\r
-  count2 = ppf2->Class2Count = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset1 ) ||\r
-       ( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef1, count1,\r
-                                      stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  if ( FILE_Seek( new_offset2 ) ||\r
-       ( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef2, count2,\r
-                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  ppf2->Class1Record = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ppf2->Class1Record, count1, HB_Class1Record ) )\r
-    goto Fail2;\r
-\r
-  c1r = ppf2->Class1Record;\r
-\r
-  for ( m = 0; m < count1; m++ )\r
-  {\r
-    c1r[m].Class2Record = NULL;\r
-\r
-    if ( ALLOC_ARRAY( c1r[m].Class2Record, count2, HB_Class2Record ) )\r
-      goto Fail1;\r
-\r
-    c2r = c1r[m].Class2Record;\r
-\r
-    for ( n = 0; n < count2; n++ )\r
-    {\r
-      if ( format1 )\r
-      {\r
-       error = Load_ValueRecord( &c2r[n].Value1, format1,\r
-                                 base_offset, stream );\r
-       if ( error )\r
-         goto Fail0;\r
-      }\r
-      if ( format2 )\r
-      {\r
-       error = Load_ValueRecord( &c2r[n].Value2, format2,\r
-                                 base_offset, stream );\r
-       if ( error )\r
-       {\r
-         if ( format1 )\r
-           Free_ValueRecord( &c2r[n].Value1, format1 );\r
-         goto Fail0;\r
-       }\r
-      }\r
-    }\r
-\r
-    continue;\r
-\r
-  Fail0:\r
-    for ( k = 0; k < n; k++ )\r
-    {\r
-      if ( format1 )\r
-       Free_ValueRecord( &c2r[k].Value1, format1 );\r
-      if ( format2 )\r
-       Free_ValueRecord( &c2r[k].Value2, format2 );\r
-    }\r
-    goto Fail1;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( k = 0; k < m; k++ )\r
-  {\r
-    c2r = c1r[k].Class2Record;\r
-\r
-    for ( n = 0; n < count2; n++ )\r
-    {\r
-      if ( format1 )\r
-       Free_ValueRecord( &c2r[n].Value1, format1 );\r
-      if ( format2 )\r
-       Free_ValueRecord( &c2r[n].Value2, format2 );\r
-    }\r
-\r
-    FREE( c2r );\r
-  }\r
-\r
-  FREE( c1r );\r
-Fail2:\r
-\r
-  _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PairPos2( HB_PairPosFormat2*  ppf2,\r
-                           HB_UShort            format1,\r
-                           HB_UShort            format2)\r
-{\r
-  HB_UShort          m, n, count1, count2;\r
-\r
-  HB_Class1Record*  c1r;\r
-  HB_Class2Record*  c2r;\r
-\r
-\r
-  if ( ppf2->Class1Record )\r
-  {\r
-    c1r    = ppf2->Class1Record;\r
-    count1 = ppf2->Class1Count;\r
-    count2 = ppf2->Class2Count;\r
-\r
-    for ( m = 0; m < count1; m++ )\r
-    {\r
-      c2r = c1r[m].Class2Record;\r
-\r
-      for ( n = 0; n < count2; n++ )\r
-      {\r
-       if ( format1 )\r
-         Free_ValueRecord( &c2r[n].Value1, format1 );\r
-       if ( format2 )\r
-         Free_ValueRecord( &c2r[n].Value2, format2 );\r
-      }\r
-\r
-      FREE( c2r );\r
-    }\r
-\r
-    FREE( c1r );\r
-\r
-    _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 );\r
-    _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 );\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Load_PairPos( HB_GPOS_SubTable* st,\r
-                              HB_Stream     stream )\r
-{\r
-  HB_Error  error;\r
-  HB_PairPos*     pp = &st->pair;\r
-\r
-  HB_UShort         format1, format2;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 8L ) )\r
-    return error;\r
-\r
-  pp->PosFormat = GET_UShort();\r
-  new_offset    = GET_UShort() + base_offset;\r
-\r
-  format1 = pp->ValueFormat1 = GET_UShort();\r
-  format2 = pp->ValueFormat2 = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &pp->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  switch ( pp->PosFormat )\r
-  {\r
-  case 1:\r
-    error = Load_PairPos1( &pp->ppf.ppf1, format1, format2, stream );\r
-    if ( error )\r
-      goto Fail;\r
-    break;\r
-\r
-  case 2:\r
-    error = Load_PairPos2( &pp->ppf.ppf2, format1, format2, stream );\r
-    if ( error )\r
-      goto Fail;\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  _HB_OPEN_Free_Coverage( &pp->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PairPos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_UShort  format1, format2;\r
-  HB_PairPos*     pp = &st->pair;\r
-\r
-\r
-  format1 = pp->ValueFormat1;\r
-  format2 = pp->ValueFormat2;\r
-\r
-  switch ( pp->PosFormat )\r
-  {\r
-  case 1:\r
-    Free_PairPos1( &pp->ppf.ppf1, format1, format2 );\r
-    break;\r
-\r
-  case 2:\r
-    Free_PairPos2( &pp->ppf.ppf2, format1, format2 );\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &pp->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_PairPos1( GPOS_Instance*       gpi,\r
-                                 HB_PairPosFormat1*  ppf1,\r
-                                 HB_Buffer           buffer,\r
-                                 HB_UInt              first_pos,\r
-                                 HB_UShort            index,\r
-                                 HB_UShort            format1,\r
-                                 HB_UShort            format2 )\r
-{\r
-  HB_Error              error;\r
-  HB_UShort             numpvr, glyph2;\r
-\r
-  HB_PairValueRecord*  pvr;\r
-\r
-\r
-  if ( index >= ppf1->PairSetCount )\r
-     return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  pvr = ppf1->PairSet[index].PairValueRecord;\r
-  if ( !pvr )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  glyph2 = IN_CURGLYPH();\r
-\r
-  for ( numpvr = ppf1->PairSet[index].PairValueCount;\r
-       numpvr;\r
-       numpvr--, pvr++ )\r
-  {\r
-    if ( glyph2 == pvr->SecondGlyph )\r
-    {\r
-      error = Get_ValueRecord( gpi, &pvr->Value1, format1,\r
-                              POSITION( first_pos ) );\r
-      if ( error )\r
-       return error;\r
-      return Get_ValueRecord( gpi, &pvr->Value2, format2,\r
-                             POSITION( buffer->in_pos ) );\r
-    }\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_PairPos2( GPOS_Instance*       gpi,\r
-                                 HB_PairPosFormat2*  ppf2,\r
-                                 HB_Buffer           buffer,\r
-                                 HB_UInt              first_pos,\r
-                                 HB_UShort            format1,\r
-                                 HB_UShort            format2 )\r
-{\r
-  HB_Error           error;\r
-  HB_UShort          cl1 = 0, cl2 = 0; /* shut compiler up */\r
-\r
-  HB_Class1Record*  c1r;\r
-  HB_Class2Record*  c2r;\r
-\r
-\r
-  error = _HB_OPEN_Get_Class( &ppf2->ClassDef1, IN_GLYPH( first_pos ),\r
-                    &cl1, NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    return error;\r
-  error = _HB_OPEN_Get_Class( &ppf2->ClassDef2, IN_CURGLYPH(),\r
-                    &cl2, NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    return error;\r
-\r
-  c1r = &ppf2->Class1Record[cl1];\r
-  if ( !c1r )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-  c2r = &c1r->Class2Record[cl2];\r
-\r
-  error = Get_ValueRecord( gpi, &c2r->Value1, format1, POSITION( first_pos ) );\r
-  if ( error )\r
-    return error;\r
-  return Get_ValueRecord( gpi, &c2r->Value2, format2, POSITION( buffer->in_pos ) );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_PairPos( GPOS_Instance*    gpi,\r
-                                HB_GPOS_SubTable* st,\r
-                                HB_Buffer        buffer,\r
-                                HB_UShort         flags,\r
-                                HB_UShort         context_length,\r
-                                int               nesting_level )\r
-{\r
-  HB_Error         error;\r
-  HB_UShort        index, property;\r
-  HB_UInt          first_pos;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_PairPos*     pp = &st->pair;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( buffer->in_pos >= buffer->in_length - 1 )\r
-    return HB_Err_Not_Covered;           /* Not enough glyphs in stream */\r
-\r
-  if ( context_length != 0xFFFF && context_length < 2 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &pp->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* second glyph */\r
-\r
-  first_pos = buffer->in_pos;\r
-  (buffer->in_pos)++;\r
-\r
-  while ( CHECK_Property( gpos->gdef, IN_CURITEM(),\r
-                         flags, &property ) )\r
-  {\r
-    if ( error && error != HB_Err_Not_Covered )\r
-      return error;\r
-\r
-    if ( buffer->in_pos == buffer->in_length )\r
-      {\r
-       buffer->in_pos = first_pos;\r
-        return HB_Err_Not_Covered;\r
-      }\r
-    (buffer->in_pos)++;\r
-\r
-  }\r
-\r
-  switch ( pp->PosFormat )\r
-  {\r
-  case 1:\r
-    error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, buffer,\r
-                            first_pos, index,\r
-                            pp->ValueFormat1, pp->ValueFormat2 );\r
-    break;\r
-\r
-  case 2:\r
-    error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, buffer, first_pos,\r
-                            pp->ValueFormat1, pp->ValueFormat2 );\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  /* if we don't have coverage for the second glyph don't skip it for\r
-     further lookups but reset in_pos back to the first_glyph and let\r
-     the caller in Do_String_Lookup increment in_pos */\r
-  if ( error == HB_Err_Not_Covered )\r
-      buffer->in_pos = first_pos;\r
-\r
-  /* adjusting the `next' glyph */\r
-\r
-  if ( pp->ValueFormat2 )\r
-    (buffer->in_pos)++;\r
-\r
-  return error;\r
-}\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-/* CursivePosFormat1 */\r
-\r
-static HB_Error  Load_CursivePos( HB_GPOS_SubTable* st,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-  HB_CursivePos*  cp = &st->cursive;\r
-\r
-  HB_UShort             n, m, count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_EntryExitRecord*  eer;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  cp->PosFormat = GET_UShort();\r
-  new_offset    = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &cp->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = cp->EntryExitCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cp->EntryExitRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cp->EntryExitRecord, count, HB_EntryExitRecord ) )\r
-    goto Fail2;\r
-\r
-  eer = cp->EntryExitRecord;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    HB_UInt entry_offset;\r
-\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    entry_offset = new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_Anchor( &eer[n].EntryAnchor,\r
-                                 stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      eer[n].EntryAnchor.PosFormat   = 0;\r
-\r
-    if ( ACCESS_Frame( 2L ) )\r
-      return error;\r
-\r
-    new_offset = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset )\r
-    {\r
-      new_offset += base_offset;\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_Anchor( &eer[n].ExitAnchor,\r
-                                 stream ) ) != HB_Err_Ok )\r
-      {\r
-       if ( entry_offset )\r
-         Free_Anchor( &eer[n].EntryAnchor );\r
-       goto Fail1;\r
-      }\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-      eer[n].ExitAnchor.PosFormat   = 0;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-  {\r
-    Free_Anchor( &eer[m].EntryAnchor );\r
-    Free_Anchor( &eer[m].ExitAnchor );\r
-  }\r
-\r
-  FREE( eer );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &cp->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_CursivePos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_UShort             n, count;\r
-  HB_CursivePos*  cp = &st->cursive;\r
-\r
-  HB_EntryExitRecord*  eer;\r
-\r
-\r
-  if ( cp->EntryExitRecord )\r
-  {\r
-    count = cp->EntryExitCount;\r
-    eer   = cp->EntryExitRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-    {\r
-      Free_Anchor( &eer[n].EntryAnchor );\r
-      Free_Anchor( &eer[n].ExitAnchor );\r
-    }\r
-\r
-    FREE( eer );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &cp->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_CursivePos( GPOS_Instance*    gpi,\r
-                                   HB_GPOS_SubTable* st,\r
-                                   HB_Buffer        buffer,\r
-                                   HB_UShort         flags,\r
-                                   HB_UShort         context_length,\r
-                                   int               nesting_level )\r
-{\r
-  HB_UShort        index, property;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_CursivePos*  cp = &st->cursive;\r
-\r
-  HB_EntryExitRecord*  eer;\r
-  HB_Fixed                entry_x, entry_y;\r
-  HB_Fixed                exit_x, exit_y;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-  {\r
-    gpi->last = 0xFFFF;\r
-    return HB_Err_Not_Covered;\r
-  }\r
-\r
-  /* Glyphs not having the right GDEF properties will be ignored, i.e.,\r
-     gpi->last won't be reset (contrary to user defined properties). */\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  /* We don't handle mark glyphs here.  According to Andrei, this isn't\r
-     possible, but who knows...                                         */\r
-\r
-  if ( property == HB_GDEF_MARK )\r
-  {\r
-    gpi->last = 0xFFFF;\r
-    return HB_Err_Not_Covered;\r
-  }\r
-\r
-  error = _HB_OPEN_Coverage_Index( &cp->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-  {\r
-    gpi->last = 0xFFFF;\r
-    return error;\r
-  }\r
-\r
-  if ( index >= cp->EntryExitCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  eer = &cp->EntryExitRecord[index];\r
-\r
-  /* Now comes the messiest part of the whole OpenType\r
-     specification.  At first glance, cursive connections seem easy\r
-     to understand, but there are pitfalls!  The reason is that\r
-     the specs don't mention how to compute the advance values\r
-     resp. glyph offsets.  I was told it would be an omission, to\r
-     be fixed in the next OpenType version...  Again many thanks to\r
-     Andrei Burago <andreib@microsoft.com> for clarifications.\r
-\r
-     Consider the following example:\r
-\r
-                     |  xadv1    |\r
-                      +---------+\r
-                      |         |\r
-                +-----+--+ 1    |\r
-                |     | .|      |\r
-                |    0+--+------+\r
-                |   2    |\r
-                |        |\r
-               0+--------+\r
-               |  xadv2   |\r
-\r
-       glyph1: advance width = 12\r
-              anchor point = (3,1)\r
-\r
-       glyph2: advance width = 11\r
-              anchor point = (9,4)\r
-\r
-       LSB is 1 for both glyphs (so the boxes drawn above are glyph\r
-       bboxes).  Writing direction is R2L; `0' denotes the glyph's\r
-       coordinate origin.\r
-\r
-     Now the surprising part: The advance width of the *left* glyph\r
-     (resp. of the *bottom* glyph) will be modified, no matter\r
-     whether the writing direction is L2R or R2L (resp. T2B or\r
-     B2T)!  This assymetry is caused by the fact that the glyph's\r
-     coordinate origin is always the lower left corner for all\r
-     writing directions.\r
-\r
-     Continuing the above example, we can compute the new\r
-     (horizontal) advance width of glyph2 as\r
-\r
-       9 - 3 = 6  ,\r
-\r
-     and the new vertical offset of glyph2 as\r
-\r
-       1 - 4 = -3  .\r
-\r
-\r
-     Vertical writing direction is far more complicated:\r
-\r
-     a) Assuming that we recompute the advance height of the lower glyph:\r
-\r
-                                 --\r
-                      +---------+\r
-             --       |         |\r
-                +-----+--+ 1    | yadv1\r
-                |     | .|      |\r
-          yadv2 |    0+--+------+        -- BSB1  --\r
-                |   2    |       --      --        y_offset\r
-                |        |\r
-   BSB2 --      0+--------+                        --\r
-       --    --\r
-\r
-       glyph1: advance height = 6\r
-              anchor point = (3,1)\r
-\r
-       glyph2: advance height = 7\r
-              anchor point = (9,4)\r
-\r
-       TSB is 1 for both glyphs; writing direction is T2B.\r
-\r
-\r
-        BSB1     = yadv1 - (TSB1 + ymax1)\r
-        BSB2     = yadv2 - (TSB2 + ymax2)\r
-        y_offset = y2 - y1\r
-\r
-       vertical advance width of glyph2\r
-        = y_offset + BSB2 - BSB1\r
-        = (y2 - y1) + (yadv2 - (TSB2 + ymax2)) - (yadv1 - (TSB1 + ymax1))\r
-        = y2 - y1 + yadv2 - TSB2 - ymax2 - (yadv1 - TSB1 - ymax1)\r
-        = y2 - y1 + yadv2 - TSB2 - ymax2 - yadv1 + TSB1 + ymax1\r
-\r
-\r
-     b) Assuming that we recompute the advance height of the upper glyph:\r
-\r
-                                 --      --\r
-                      +---------+        -- TSB1\r
-       --    --       |         |\r
-   TSB2 --       +-----+--+ 1    | yadv1   ymax1\r
-                |     | .|      |\r
-          yadv2 |    0+--+------+        --       --\r
-    ymax2        |   2    |       --                y_offset\r
-                |        |\r
-       --      0+--------+                        --\r
-             --\r
-\r
-       glyph1: advance height = 6\r
-              anchor point = (3,1)\r
-\r
-       glyph2: advance height = 7\r
-              anchor point = (9,4)\r
-\r
-       TSB is 1 for both glyphs; writing direction is T2B.\r
-\r
-       y_offset = y2 - y1\r
-\r
-       vertical advance width of glyph2\r
-        = TSB1 + ymax1 + y_offset - (TSB2 + ymax2)\r
-        = TSB1 + ymax1 + y2 - y1 - TSB2 - ymax2\r
-\r
-\r
-     Comparing a) with b) shows that b) is easier to compute.  I'll wait\r
-     for a reply from Andrei to see what should really be implemented...\r
-\r
-     Since horizontal advance widths or vertical advance heights\r
-     can be used alone but not together, no ambiguity occurs.        */\r
-\r
-  if ( gpi->last == 0xFFFF )\r
-    goto end;\r
-\r
-  /* Get_Anchor() returns HB_Err_Not_Covered if there is no anchor\r
-     table.                                                         */\r
-\r
-  error = Get_Anchor( gpi, &eer->EntryAnchor, IN_CURGLYPH(),\r
-                     &entry_x, &entry_y );\r
-  if ( error == HB_Err_Not_Covered )\r
-    goto end;\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( gpi->r2l )\r
-  {\r
-    POSITION( buffer->in_pos )->x_advance   = entry_x - gpi->anchor_x;\r
-    POSITION( buffer->in_pos )->new_advance = TRUE;\r
-  }\r
-  else\r
-  {\r
-    POSITION( gpi->last )->x_advance   = gpi->anchor_x - entry_x;\r
-    POSITION( gpi->last )->new_advance = TRUE;\r
-  }\r
-\r
-  if ( flags & HB_LOOKUP_FLAG_RIGHT_TO_LEFT )\r
-  {\r
-    POSITION( gpi->last )->cursive_chain = gpi->last - buffer->in_pos;\r
-    POSITION( gpi->last )->y_pos = entry_y - gpi->anchor_y;\r
-  }\r
-  else\r
-  {\r
-    POSITION( buffer->in_pos )->cursive_chain = buffer->in_pos - gpi->last;\r
-    POSITION( buffer->in_pos )->y_pos = gpi->anchor_y - entry_y;\r
-  }\r
-\r
-end:\r
-  error = Get_Anchor( gpi, &eer->ExitAnchor, IN_CURGLYPH(),\r
-                     &exit_x, &exit_y );\r
-  if ( error == HB_Err_Not_Covered )\r
-    gpi->last = 0xFFFF;\r
-  else\r
-  {\r
-    gpi->last     = buffer->in_pos;\r
-    gpi->anchor_x = exit_x;\r
-    gpi->anchor_y = exit_y;\r
-  }\r
-  if ( error )\r
-    return error;\r
-\r
-  (buffer->in_pos)++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-/* BaseArray */\r
-\r
-static HB_Error  Load_BaseArray( HB_BaseArray*  ba,\r
-                                HB_UShort       num_classes,\r
-                                HB_Stream       stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort       m, n, count;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_BaseRecord  *br;\r
-  HB_Anchor      *ban, *bans;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ba->BaseCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ba->BaseRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ba->BaseRecord, count, HB_BaseRecord ) )\r
-    return error;\r
-\r
-  br = ba->BaseRecord;\r
-\r
-  bans = NULL;\r
-\r
-  if ( ALLOC_ARRAY( bans, count * num_classes, HB_Anchor ) )\r
-    goto Fail;\r
-\r
-  for ( m = 0; m < count; m++ )\r
-  {\r
-    br[m].BaseAnchor = NULL;\r
-\r
-    ban = br[m].BaseAnchor = bans + m * num_classes;\r
-\r
-    for ( n = 0; n < num_classes; n++ )\r
-    {\r
-      if ( ACCESS_Frame( 2L ) )\r
-       goto Fail;\r
-\r
-      new_offset = GET_UShort() + base_offset;\r
-\r
-      FORGET_Frame();\r
-\r
-      if (new_offset == base_offset) {\r
-       /* XXX\r
-        * Doulos SIL Regular is buggy and has zero offsets here.\r
-        * Skip it\r
-        */\r
-       ban[n].PosFormat = 0;\r
-       continue;\r
-      }\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_Anchor( &ban[n], stream ) ) != HB_Err_Ok )\r
-       goto Fail;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  FREE( bans );\r
-  FREE( br );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_BaseArray( HB_BaseArray*  ba,\r
-                            HB_UShort       num_classes )\r
-{\r
-  HB_BaseRecord  *br;\r
-  HB_Anchor      *bans;\r
-\r
-  if ( ba->BaseRecord )\r
-  {\r
-    br    = ba->BaseRecord;\r
-\r
-    if ( ba->BaseCount )\r
-    {\r
-      HB_UShort i, count;\r
-      count = num_classes * ba->BaseCount;\r
-      bans = br[0].BaseAnchor;\r
-      for (i = 0; i < count; i++)\r
-        Free_Anchor (&bans[i]);\r
-      FREE( bans );\r
-    }\r
-\r
-    FREE( br );\r
-  }\r
-}\r
-\r
-\r
-/* MarkBasePosFormat1 */\r
-\r
-static HB_Error  Load_MarkBasePos( HB_GPOS_SubTable* st,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error  error;\r
-  HB_MarkBasePos* mbp = &st->markbase;\r
-\r
-  HB_UInt  cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  mbp->PosFormat = GET_UShort();\r
-  new_offset     = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  if (mbp->PosFormat != 1)\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mbp->MarkCoverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mbp->BaseCoverage, stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    goto Fail2;\r
-\r
-  mbp->ClassCount = GET_UShort();\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_MarkArray( &mbp->MarkArray, stream ) ) != HB_Err_Ok )\r
-    goto Fail2;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail1;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_BaseArray( &mbp->BaseArray, mbp->ClassCount,\r
-                                stream ) ) != HB_Err_Ok )\r
-    goto Fail1;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  Free_MarkArray( &mbp->MarkArray );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &mbp->BaseCoverage );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Coverage( &mbp->MarkCoverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_MarkBasePos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_MarkBasePos* mbp = &st->markbase;\r
-\r
-  Free_BaseArray( &mbp->BaseArray, mbp->ClassCount );\r
-  Free_MarkArray( &mbp->MarkArray );\r
-  _HB_OPEN_Free_Coverage( &mbp->BaseCoverage );\r
-  _HB_OPEN_Free_Coverage( &mbp->MarkCoverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_MarkBasePos( GPOS_Instance*    gpi,\r
-                                    HB_GPOS_SubTable* st,\r
-                                    HB_Buffer        buffer,\r
-                                    HB_UShort         flags,\r
-                                    HB_UShort         context_length,\r
-                                    int               nesting_level )\r
-{\r
-  HB_UShort        i, j, mark_index, base_index, property, klass;\r
-  HB_Fixed           x_mark_value, y_mark_value, x_base_value, y_base_value;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_MarkBasePos* mbp = &st->markbase;\r
-\r
-  HB_MarkArray*   ma;\r
-  HB_BaseArray*   ba;\r
-  HB_BaseRecord*  br;\r
-  HB_Anchor*      mark_anchor;\r
-  HB_Anchor*      base_anchor;\r
-\r
-  HB_Position     o;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( flags & HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(),\r
-                      flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mbp->MarkCoverage, IN_CURGLYPH(),\r
-                         &mark_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* now we search backwards for a non-mark glyph */\r
-\r
-  i = 1;\r
-  j = buffer->in_pos - 1;\r
-\r
-  while ( i <= buffer->in_pos )\r
-  {\r
-    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),\r
-                                       &property );\r
-    if ( error )\r
-      return error;\r
-\r
-    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )\r
-      break;\r
-\r
-    i++;\r
-    j--;\r
-  }\r
-\r
-  /* The following assertion is too strong -- at least for mangal.ttf. */\r
-#if 0\r
-  if ( property != HB_GDEF_BASE_GLYPH )\r
-    return HB_Err_Not_Covered;\r
-#endif\r
-\r
-  if ( i > buffer->in_pos )\r
-    return HB_Err_Not_Covered;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mbp->BaseCoverage, IN_GLYPH( j ),\r
-                         &base_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  ma = &mbp->MarkArray;\r
-\r
-  if ( mark_index >= ma->MarkCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  klass       = ma->MarkRecord[mark_index].Class;\r
-  mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;\r
-\r
-  if ( klass >= mbp->ClassCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  ba = &mbp->BaseArray;\r
-\r
-  if ( base_index >= ba->BaseCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  br          = &ba->BaseRecord[base_index];\r
-  base_anchor = &br->BaseAnchor[klass];\r
-\r
-  error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(),\r
-                     &x_mark_value, &y_mark_value );\r
-  if ( error )\r
-    return error;\r
-\r
-  error = Get_Anchor( gpi, base_anchor, IN_GLYPH( j ),\r
-                     &x_base_value, &y_base_value );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* anchor points are not cumulative */\r
-\r
-  o = POSITION( buffer->in_pos );\r
-\r
-  o->x_pos     = x_base_value - x_mark_value;\r
-  o->y_pos     = y_base_value - y_mark_value;\r
-  o->x_advance = 0;\r
-  o->y_advance = 0;\r
-  o->back      = i;\r
-\r
-  (buffer->in_pos)++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-/* LigatureAttach */\r
-\r
-static HB_Error  Load_LigatureAttach( HB_LigatureAttach*  lat,\r
-                                     HB_UShort            num_classes,\r
-                                     HB_Stream            stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             m, n, k, count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_ComponentRecord*  cr;\r
-  HB_Anchor*           lan;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = lat->ComponentCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  lat->ComponentRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( lat->ComponentRecord, count, HB_ComponentRecord ) )\r
-    return error;\r
-\r
-  cr = lat->ComponentRecord;\r
-\r
-  for ( m = 0; m < count; m++ )\r
-  {\r
-    cr[m].LigatureAnchor = NULL;\r
-\r
-    if ( ALLOC_ARRAY( cr[m].LigatureAnchor, num_classes, HB_Anchor ) )\r
-      goto Fail;\r
-\r
-    lan = cr[m].LigatureAnchor;\r
-\r
-    for ( n = 0; n < num_classes; n++ )\r
-    {\r
-      if ( ACCESS_Frame( 2L ) )\r
-       goto Fail0;\r
-\r
-      new_offset = GET_UShort();\r
-\r
-      FORGET_Frame();\r
-\r
-      if ( new_offset )\r
-      {\r
-       new_offset += base_offset;\r
-\r
-       cur_offset = FILE_Pos();\r
-       if ( FILE_Seek( new_offset ) ||\r
-            ( error = Load_Anchor( &lan[n], stream ) ) != HB_Err_Ok )\r
-         goto Fail0;\r
-       (void)FILE_Seek( cur_offset );\r
-      }\r
-      else\r
-       lan[n].PosFormat = 0;\r
-    }\r
-\r
-    continue;\r
-  Fail0:\r
-    for ( k = 0; k < n; k++ )\r
-      Free_Anchor( &lan[k] );\r
-    goto Fail;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( k = 0; k < m; k++ )\r
-  {\r
-    lan = cr[k].LigatureAnchor;\r
-\r
-    for ( n = 0; n < num_classes; n++ )\r
-      Free_Anchor( &lan[n] );\r
-\r
-    FREE( lan );\r
-  }\r
-\r
-  FREE( cr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigatureAttach( HB_LigatureAttach*  lat,\r
-                                 HB_UShort            num_classes )\r
-{\r
-  HB_UShort        m, n, count;\r
-\r
-  HB_ComponentRecord*  cr;\r
-  HB_Anchor*           lan;\r
-\r
-\r
-  if ( lat->ComponentRecord )\r
-  {\r
-    count = lat->ComponentCount;\r
-    cr    = lat->ComponentRecord;\r
-\r
-    for ( m = 0; m < count; m++ )\r
-    {\r
-      lan = cr[m].LigatureAnchor;\r
-\r
-      for ( n = 0; n < num_classes; n++ )\r
-       Free_Anchor( &lan[n] );\r
-\r
-      FREE( lan );\r
-    }\r
-\r
-    FREE( cr );\r
-  }\r
-}\r
-\r
-\r
-/* LigatureArray */\r
-\r
-static HB_Error  Load_LigatureArray( HB_LigatureArray*  la,\r
-                                    HB_UShort           num_classes,\r
-                                    HB_Stream           stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort            n, m, count;\r
-  HB_UInt             cur_offset, new_offset, base_offset;\r
-\r
-  HB_LigatureAttach*  lat;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = la->LigatureCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  la->LigatureAttach = NULL;\r
-\r
-  if ( ALLOC_ARRAY( la->LigatureAttach, count, HB_LigatureAttach ) )\r
-    return error;\r
-\r
-  lat = la->LigatureAttach;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LigatureAttach( &lat[n], num_classes,\r
-                                       stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_LigatureAttach( &lat[m], num_classes );\r
-\r
-  FREE( lat );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigatureArray( HB_LigatureArray*  la,\r
-                                HB_UShort           num_classes )\r
-{\r
-  HB_UShort            n, count;\r
-\r
-  HB_LigatureAttach*  lat;\r
-\r
-\r
-  if ( la->LigatureAttach )\r
-  {\r
-    count = la->LigatureCount;\r
-    lat   = la->LigatureAttach;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_LigatureAttach( &lat[n], num_classes );\r
-\r
-    FREE( lat );\r
-  }\r
-}\r
-\r
-\r
-/* MarkLigPosFormat1 */\r
-\r
-static HB_Error  Load_MarkLigPos( HB_GPOS_SubTable* st,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-  HB_MarkLigPos*  mlp = &st->marklig;\r
-\r
-  HB_UInt  cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  mlp->PosFormat = GET_UShort();\r
-  new_offset     = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mlp->MarkCoverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mlp->LigatureCoverage,\r
-                               stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    goto Fail2;\r
-\r
-  mlp->ClassCount = GET_UShort();\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_MarkArray( &mlp->MarkArray, stream ) ) != HB_Err_Ok )\r
-    goto Fail2;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail1;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_LigatureArray( &mlp->LigatureArray, mlp->ClassCount,\r
-                                    stream ) ) != HB_Err_Ok )\r
-    goto Fail1;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  Free_MarkArray( &mlp->MarkArray );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Coverage( &mlp->MarkCoverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_MarkLigPos( HB_GPOS_SubTable* st)\r
-{\r
-  HB_MarkLigPos*  mlp = &st->marklig;\r
-\r
-  Free_LigatureArray( &mlp->LigatureArray, mlp->ClassCount );\r
-  Free_MarkArray( &mlp->MarkArray );\r
-  _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage );\r
-  _HB_OPEN_Free_Coverage( &mlp->MarkCoverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_MarkLigPos( GPOS_Instance*    gpi,\r
-                                   HB_GPOS_SubTable* st,\r
-                                   HB_Buffer        buffer,\r
-                                   HB_UShort         flags,\r
-                                   HB_UShort         context_length,\r
-                                   int               nesting_level )\r
-{\r
-  HB_UShort        i, j, mark_index, lig_index, property, klass;\r
-  HB_UShort        mark_glyph;\r
-  HB_Fixed           x_mark_value, y_mark_value, x_lig_value, y_lig_value;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_MarkLigPos*  mlp = &st->marklig;\r
-\r
-  HB_MarkArray*        ma;\r
-  HB_LigatureArray*    la;\r
-  HB_LigatureAttach*   lat;\r
-  HB_ComponentRecord*  cr;\r
-  HB_UShort             comp_index;\r
-  HB_Anchor*           mark_anchor;\r
-  HB_Anchor*           lig_anchor;\r
-\r
-  HB_Position    o;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( flags & HB_LOOKUP_FLAG_IGNORE_LIGATURES )\r
-    return HB_Err_Not_Covered;\r
-\r
-  mark_glyph = IN_CURGLYPH();\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* now we search backwards for a non-mark glyph */\r
-\r
-  i = 1;\r
-  j = buffer->in_pos - 1;\r
-\r
-  while ( i <= buffer->in_pos )\r
-  {\r
-    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),\r
-                                       &property );\r
-    if ( error )\r
-      return error;\r
-\r
-    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )\r
-      break;\r
-\r
-    i++;\r
-    j--;\r
-  }\r
-\r
-  /* Similar to Lookup_MarkBasePos(), I suspect that this assertion is\r
-     too strong, thus it is commented out.                             */\r
-#if 0\r
-  if ( property != HB_GDEF_LIGATURE )\r
-    return HB_Err_Not_Covered;\r
-#endif\r
-\r
-  if ( i > buffer->in_pos )\r
-    return HB_Err_Not_Covered;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mlp->LigatureCoverage, IN_GLYPH( j ),\r
-                         &lig_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  ma = &mlp->MarkArray;\r
-\r
-  if ( mark_index >= ma->MarkCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  klass       = ma->MarkRecord[mark_index].Class;\r
-  mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;\r
-\r
-  if ( klass >= mlp->ClassCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  la = &mlp->LigatureArray;\r
-\r
-  if ( lig_index >= la->LigatureCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  lat = &la->LigatureAttach[lig_index];\r
-\r
-  /* We must now check whether the ligature ID of the current mark glyph\r
-     is identical to the ligature ID of the found ligature.  If yes, we\r
-     can directly use the component index.  If not, we attach the mark\r
-     glyph to the last component of the ligature.                        */\r
-\r
-  if ( IN_LIGID( j ) == IN_LIGID( buffer->in_pos) )\r
-  {\r
-    comp_index = IN_COMPONENT( buffer->in_pos );\r
-    if ( comp_index >= lat->ComponentCount )\r
-      return HB_Err_Not_Covered;\r
-  }\r
-  else\r
-    comp_index = lat->ComponentCount - 1;\r
-\r
-  cr         = &lat->ComponentRecord[comp_index];\r
-  lig_anchor = &cr->LigatureAnchor[klass];\r
-\r
-  error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(),\r
-                     &x_mark_value, &y_mark_value );\r
-  if ( error )\r
-    return error;\r
-  error = Get_Anchor( gpi, lig_anchor, IN_GLYPH( j ),\r
-                     &x_lig_value, &y_lig_value );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* anchor points are not cumulative */\r
-\r
-  o = POSITION( buffer->in_pos );\r
-\r
-  o->x_pos     = x_lig_value - x_mark_value;\r
-  o->y_pos     = y_lig_value - y_mark_value;\r
-  o->x_advance = 0;\r
-  o->y_advance = 0;\r
-  o->back      = i;\r
-\r
-  (buffer->in_pos)++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-/* Mark2Array */\r
-\r
-static HB_Error  Load_Mark2Array( HB_Mark2Array*  m2a,\r
-                                 HB_UShort        num_classes,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort        m, n, count;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_Mark2Record  *m2r;\r
-  HB_Anchor       *m2an, *m2ans;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = m2a->Mark2Count = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  m2a->Mark2Record = NULL;\r
-\r
-  if ( ALLOC_ARRAY( m2a->Mark2Record, count, HB_Mark2Record ) )\r
-    return error;\r
-\r
-  m2r = m2a->Mark2Record;\r
-\r
-  m2ans = NULL;\r
-\r
-  if ( ALLOC_ARRAY( m2ans, count * num_classes, HB_Anchor ) )\r
-    goto Fail;\r
-\r
-  for ( m = 0; m < count; m++ )\r
-  {\r
-    m2an = m2r[m].Mark2Anchor = m2ans + m * num_classes;\r
-\r
-    for ( n = 0; n < num_classes; n++ )\r
-    {\r
-      if ( ACCESS_Frame( 2L ) )\r
-       goto Fail;\r
-\r
-      new_offset = GET_UShort() + base_offset;\r
-\r
-      FORGET_Frame();\r
-\r
-      if (new_offset == base_offset) {\r
-        /* Anchor table not provided.  Skip loading.\r
-        * Some versions of FreeSans hit this. */\r
-        m2an[n].PosFormat = 0;\r
-       continue;\r
-      }\r
-\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_Anchor( &m2an[n], stream ) ) != HB_Err_Ok )\r
-       goto Fail;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  FREE( m2ans );\r
-  FREE( m2r );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_Mark2Array( HB_Mark2Array*  m2a,\r
-                             HB_UShort        num_classes )\r
-{\r
-  HB_Mark2Record  *m2r;\r
-  HB_Anchor       *m2ans;\r
-\r
-  HB_UNUSED(num_classes);\r
-\r
-  if ( m2a->Mark2Record )\r
-  {\r
-    m2r   = m2a->Mark2Record;\r
-\r
-    if ( m2a->Mark2Count )\r
-    {\r
-      m2ans = m2r[0].Mark2Anchor;\r
-      FREE( m2ans );\r
-    }\r
-\r
-    FREE( m2r );\r
-  }\r
-}\r
-\r
-\r
-/* MarkMarkPosFormat1 */\r
-\r
-static HB_Error  Load_MarkMarkPos( HB_GPOS_SubTable* st,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error  error;\r
-  HB_MarkMarkPos* mmp = &st->markmark;\r
-\r
-  HB_UInt  cur_offset, new_offset, base_offset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  mmp->PosFormat = GET_UShort();\r
-  new_offset     = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mmp->Mark1Coverage,\r
-                               stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &mmp->Mark2Coverage,\r
-                               stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    goto Fail2;\r
-\r
-  mmp->ClassCount = GET_UShort();\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_MarkArray( &mmp->Mark1Array, stream ) ) != HB_Err_Ok )\r
-    goto Fail2;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail1;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = Load_Mark2Array( &mmp->Mark2Array, mmp->ClassCount,\r
-                                 stream ) ) != HB_Err_Ok )\r
-    goto Fail1;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  Free_MarkArray( &mmp->Mark1Array );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_MarkMarkPos( HB_GPOS_SubTable* st)\r
-{\r
-  HB_MarkMarkPos* mmp = &st->markmark;\r
-\r
-  Free_Mark2Array( &mmp->Mark2Array, mmp->ClassCount );\r
-  Free_MarkArray( &mmp->Mark1Array );\r
-  _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage );\r
-  _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_MarkMarkPos( GPOS_Instance*    gpi,\r
-                                    HB_GPOS_SubTable* st,\r
-                                    HB_Buffer        buffer,\r
-                                    HB_UShort         flags,\r
-                                    HB_UShort         context_length,\r
-                                    int               nesting_level )\r
-{\r
-  HB_UShort        i, j, mark1_index, mark2_index, property, klass;\r
-  HB_Fixed           x_mark1_value, y_mark1_value,\r
-                  x_mark2_value, y_mark2_value;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-  HB_MarkMarkPos* mmp = &st->markmark;\r
-\r
-  HB_MarkArray*    ma1;\r
-  HB_Mark2Array*   ma2;\r
-  HB_Mark2Record*  m2r;\r
-  HB_Anchor*       mark1_anchor;\r
-  HB_Anchor*       mark2_anchor;\r
-\r
-  HB_Position    o;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( flags & HB_LOOKUP_FLAG_IGNORE_MARKS )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gpos->gdef, IN_CURITEM(),\r
-                      flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mmp->Mark1Coverage, IN_CURGLYPH(),\r
-                         &mark1_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* now we search backwards for a suitable mark glyph until a non-mark\r
-     glyph                                                */\r
-\r
-  if ( buffer->in_pos == 0 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  i = 1;\r
-  j = buffer->in_pos - 1;\r
-  while ( i <= buffer->in_pos )\r
-  {\r
-    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),\r
-                                       &property );\r
-    if ( error )\r
-      return error;\r
-\r
-    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )\r
-      return HB_Err_Not_Covered;\r
-\r
-    if ( flags & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )\r
-    {\r
-      if ( property == (flags & 0xFF00) )\r
-        break;\r
-    }\r
-    else\r
-      break;\r
-\r
-    i++;\r
-    j--;\r
-  }\r
-\r
-  error = _HB_OPEN_Coverage_Index( &mmp->Mark2Coverage, IN_GLYPH( j ),\r
-                         &mark2_index );\r
-  if ( error )\r
-    return error;\r
-\r
-  ma1 = &mmp->Mark1Array;\r
-\r
-  if ( mark1_index >= ma1->MarkCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  klass        = ma1->MarkRecord[mark1_index].Class;\r
-  mark1_anchor = &ma1->MarkRecord[mark1_index].MarkAnchor;\r
-\r
-  if ( klass >= mmp->ClassCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  ma2 = &mmp->Mark2Array;\r
-\r
-  if ( mark2_index >= ma2->Mark2Count )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  m2r          = &ma2->Mark2Record[mark2_index];\r
-  mark2_anchor = &m2r->Mark2Anchor[klass];\r
-\r
-  error = Get_Anchor( gpi, mark1_anchor, IN_CURGLYPH(),\r
-                     &x_mark1_value, &y_mark1_value );\r
-  if ( error )\r
-    return error;\r
-  error = Get_Anchor( gpi, mark2_anchor, IN_GLYPH( j ),\r
-                     &x_mark2_value, &y_mark2_value );\r
-  if ( error )\r
-    return error;\r
-\r
-  /* anchor points are not cumulative */\r
-\r
-  o = POSITION( buffer->in_pos );\r
-\r
-  o->x_pos     = x_mark2_value - x_mark1_value;\r
-  o->y_pos     = y_mark2_value - y_mark1_value;\r
-  o->x_advance = 0;\r
-  o->y_advance = 0;\r
-  o->back      = 1;\r
-\r
-  (buffer->in_pos)++;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* Do the actual positioning for a context positioning (either format\r
-   7 or 8).  This is only called after we've determined that the stream\r
-   matches the subrule.                                                 */\r
-\r
-static HB_Error  Do_ContextPos( GPOS_Instance*        gpi,\r
-                               HB_UShort             GlyphCount,\r
-                               HB_UShort             PosCount,\r
-                               HB_PosLookupRecord*  pos,\r
-                               HB_Buffer            buffer,\r
-                               int                   nesting_level )\r
-{\r
-  HB_Error  error;\r
-  HB_UInt   i, old_pos;\r
-\r
-\r
-  i = 0;\r
-\r
-  while ( i < GlyphCount )\r
-  {\r
-    if ( PosCount && i == pos->SequenceIndex )\r
-    {\r
-      old_pos = buffer->in_pos;\r
-\r
-      /* Do a positioning */\r
-\r
-      error = GPOS_Do_Glyph_Lookup( gpi, pos->LookupListIndex, buffer,\r
-                                   GlyphCount, nesting_level );\r
-\r
-      if ( error )\r
-       return error;\r
-\r
-      pos++;\r
-      PosCount--;\r
-      i += buffer->in_pos - old_pos;\r
-    }\r
-    else\r
-    {\r
-      i++;\r
-      (buffer->in_pos)++;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 7 */\r
-\r
-/* PosRule */\r
-\r
-static HB_Error  Load_PosRule( HB_PosRule*  pr,\r
-                              HB_Stream     stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, count;\r
-  HB_UShort*            i;\r
-\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  pr->GlyphCount = GET_UShort();\r
-  pr->PosCount   = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  pr->Input = NULL;\r
-\r
-  count = pr->GlyphCount - 1;         /* only GlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( pr->Input, count, HB_UShort ) )\r
-    return error;\r
-\r
-  i = pr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  pr->PosLookupRecord = NULL;\r
-\r
-  count = pr->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( pr->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = pr->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  FREE( i );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PosRule( HB_PosRule*  pr )\r
-{\r
-  FREE( pr->PosLookupRecord );\r
-  FREE( pr->Input );\r
-}\r
-\r
-\r
-/* PosRuleSet */\r
-\r
-static HB_Error  Load_PosRuleSet( HB_PosRuleSet*  prs,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort     n, m, count;\r
-  HB_UInt      cur_offset, new_offset, base_offset;\r
-\r
-  HB_PosRule*  pr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = prs->PosRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  prs->PosRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( prs->PosRule, count, HB_PosRule ) )\r
-    return error;\r
-\r
-  pr = prs->PosRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_PosRule( &pr[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_PosRule( &pr[m] );\r
-\r
-  FREE( pr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PosRuleSet( HB_PosRuleSet*  prs )\r
-{\r
-  HB_UShort     n, count;\r
-\r
-  HB_PosRule*  pr;\r
-\r
-\r
-  if ( prs->PosRule )\r
-  {\r
-    count = prs->PosRuleCount;\r
-    pr    = prs->PosRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_PosRule( &pr[n] );\r
-\r
-    FREE( pr );\r
-  }\r
-}\r
-\r
-\r
-/* ContextPosFormat1 */\r
-\r
-static HB_Error  Load_ContextPos1( HB_ContextPosFormat1*  cpf1,\r
-                                  HB_Stream               stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort        n, m, count;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_PosRuleSet*  prs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &cpf1->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = cpf1->PosRuleSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpf1->PosRuleSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cpf1->PosRuleSet, count, HB_PosRuleSet ) )\r
-    goto Fail2;\r
-\r
-  prs = cpf1->PosRuleSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_PosRuleSet( &prs[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_PosRuleSet( &prs[m] );\r
-\r
-  FREE( prs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &cpf1->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextPos1( HB_ContextPosFormat1*  cpf1 )\r
-{\r
-  HB_UShort        n, count;\r
-\r
-  HB_PosRuleSet*  prs;\r
-\r
-\r
-  if ( cpf1->PosRuleSet )\r
-  {\r
-    count = cpf1->PosRuleSetCount;\r
-    prs   = cpf1->PosRuleSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_PosRuleSet( &prs[n] );\r
-\r
-    FREE( prs );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &cpf1->Coverage );\r
-}\r
-\r
-\r
-/* PosClassRule */\r
-\r
-static HB_Error  Load_PosClassRule( HB_ContextPosFormat2*  cpf2,\r
-                                   HB_PosClassRule*       pcr,\r
-                                   HB_Stream               stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, count;\r
-\r
-  HB_UShort*            c;\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  pcr->GlyphCount = GET_UShort();\r
-  pcr->PosCount   = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( pcr->GlyphCount > cpf2->MaxContextLength )\r
-    cpf2->MaxContextLength = pcr->GlyphCount;\r
-\r
-  pcr->Class = NULL;\r
-\r
-  count = pcr->GlyphCount - 1;        /* only GlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( pcr->Class, count, HB_UShort ) )\r
-    return error;\r
-\r
-  c = pcr->Class;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    c[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  pcr->PosLookupRecord = NULL;\r
-\r
-  count = pcr->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( pcr->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = pcr->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  FREE( c );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PosClassRule( HB_PosClassRule*  pcr )\r
-{\r
-  FREE( pcr->PosLookupRecord );\r
-  FREE( pcr->Class );\r
-}\r
-\r
-\r
-/* PosClassSet */\r
-\r
-static HB_Error  Load_PosClassSet( HB_ContextPosFormat2*  cpf2,\r
-                                  HB_PosClassSet*        pcs,\r
-                                  HB_Stream               stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort          n, m, count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_PosClassRule*  pcr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = pcs->PosClassRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  pcs->PosClassRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( pcs->PosClassRule, count, HB_PosClassRule ) )\r
-    return error;\r
-\r
-  pcr = pcs->PosClassRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_PosClassRule( cpf2, &pcr[n],\r
-                                     stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_PosClassRule( &pcr[m] );\r
-\r
-  FREE( pcr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_PosClassSet( HB_PosClassSet*  pcs )\r
-{\r
-  HB_UShort          n, count;\r
-\r
-  HB_PosClassRule*  pcr;\r
-\r
-\r
-  if ( pcs->PosClassRule )\r
-  {\r
-    count = pcs->PosClassRuleCount;\r
-    pcr   = pcs->PosClassRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_PosClassRule( &pcr[n] );\r
-\r
-    FREE( pcr );\r
-  }\r
-}\r
-\r
-\r
-/* ContextPosFormat2 */\r
-\r
-static HB_Error  Load_ContextPos2( HB_ContextPosFormat2*  cpf2,\r
-                                  HB_Stream               stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort         n, m, count;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_PosClassSet*  pcs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &cpf2->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  /* `PosClassSetCount' is the upper limit for klass values, thus we\r
-     read it now to make an additional safety check.                 */\r
-\r
-  count = cpf2->PosClassSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_ClassDefinition( &cpf2->ClassDef, count,\r
-                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  cpf2->PosClassSet      = NULL;\r
-  cpf2->MaxContextLength = 0;\r
-\r
-  if ( ALLOC_ARRAY( cpf2->PosClassSet, count, HB_PosClassSet ) )\r
-    goto Fail2;\r
-\r
-  pcs = cpf2->PosClassSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset != base_offset )      /* not a NULL offset */\r
-    {\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_PosClassSet( cpf2, &pcs[n],\r
-                                      stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      /* we create a PosClassSet table with no entries */\r
-\r
-      cpf2->PosClassSet[n].PosClassRuleCount = 0;\r
-      cpf2->PosClassSet[n].PosClassRule      = NULL;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; n++ )\r
-    Free_PosClassSet( &pcs[m] );\r
-\r
-  FREE( pcs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Coverage( &cpf2->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextPos2( HB_ContextPosFormat2*  cpf2 )\r
-{\r
-  HB_UShort         n, count;\r
-\r
-  HB_PosClassSet*  pcs;\r
-\r
-\r
-  if ( cpf2->PosClassSet )\r
-  {\r
-    count = cpf2->PosClassSetCount;\r
-    pcs   = cpf2->PosClassSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_PosClassSet( &pcs[n] );\r
-\r
-    FREE( pcs );\r
-  }\r
-\r
-  _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef );\r
-  _HB_OPEN_Free_Coverage( &cpf2->Coverage );\r
-}\r
-\r
-\r
-/* ContextPosFormat3 */\r
-\r
-static HB_Error  Load_ContextPos3( HB_ContextPosFormat3*  cpf3,\r
-                                  HB_Stream               stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_Coverage*         c;\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  cpf3->GlyphCount = GET_UShort();\r
-  cpf3->PosCount   = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpf3->Coverage = NULL;\r
-\r
-  count = cpf3->GlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cpf3->Coverage, count, HB_Coverage ) )\r
-    return error;\r
-\r
-  c = cpf3->Coverage;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  cpf3->PosLookupRecord = NULL;\r
-\r
-  count = cpf3->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( cpf3->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = cpf3->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  for ( n = 0; n < count; n++ )\r
-    _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-  FREE( c );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextPos3( HB_ContextPosFormat3*  cpf3 )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_Coverage*  c;\r
-\r
-\r
-  FREE( cpf3->PosLookupRecord );\r
-\r
-  if ( cpf3->Coverage )\r
-  {\r
-    count = cpf3->GlyphCount;\r
-    c     = cpf3->Coverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-}\r
-\r
-\r
-/* ContextPos */\r
-\r
-static HB_Error  Load_ContextPos( HB_GPOS_SubTable* st,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error  error;\r
-  HB_ContextPos*   cp = &st->context;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cp->PosFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( cp->PosFormat )\r
-  {\r
-  case 1:\r
-    return Load_ContextPos1( &cp->cpf.cpf1, stream );\r
-\r
-  case 2:\r
-    return Load_ContextPos2( &cp->cpf.cpf2, stream );\r
-\r
-  case 3:\r
-    return Load_ContextPos3( &cp->cpf.cpf3, stream );\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-static void  Free_ContextPos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_ContextPos*   cp = &st->context;\r
-\r
-  switch ( cp->PosFormat )\r
-  {\r
-  case 1:  Free_ContextPos1( &cp->cpf.cpf1 ); break;\r
-  case 2:  Free_ContextPos2( &cp->cpf.cpf2 ); break;\r
-  case 3:  Free_ContextPos3( &cp->cpf.cpf3 ); break;\r
-  default:                                           break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextPos1( GPOS_Instance*          gpi,\r
-                                    HB_ContextPosFormat1*  cpf1,\r
-                                    HB_Buffer              buffer,\r
-                                    HB_UShort               flags,\r
-                                    HB_UShort               context_length,\r
-                                    int                     nesting_level )\r
-{\r
-  HB_UShort        index, property;\r
-  HB_UShort        i, j, k, numpr;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-\r
-  HB_PosRule*     pr;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &cpf1->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  pr    = cpf1->PosRuleSet[index].PosRule;\r
-  numpr = cpf1->PosRuleSet[index].PosRuleCount;\r
-\r
-  for ( k = 0; k < numpr; k++ )\r
-  {\r
-    if ( context_length != 0xFFFF && context_length < pr[k].GlyphCount )\r
-      goto next_posrule;\r
-\r
-    if ( buffer->in_pos + pr[k].GlyphCount > buffer->in_length )\r
-      goto next_posrule;                       /* context is too long */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < pr[k].GlyphCount; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + pr[k].GlyphCount - i == (HB_Int)buffer->in_length )\r
-         goto next_posrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != pr[k].Input[i - 1] )\r
-       goto next_posrule;\r
-    }\r
-\r
-    return Do_ContextPos( gpi, pr[k].GlyphCount,\r
-                         pr[k].PosCount, pr[k].PosLookupRecord,\r
-                         buffer,\r
-                         nesting_level );\r
-\r
-    next_posrule:\r
-      ;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextPos2( GPOS_Instance*          gpi,\r
-                                    HB_ContextPosFormat2*  cpf2,\r
-                                    HB_Buffer              buffer,\r
-                                    HB_UShort               flags,\r
-                                    HB_UShort               context_length,\r
-                                    int                     nesting_level )\r
-{\r
-  HB_UShort          index, property;\r
-  HB_Error           error;\r
-  HB_UShort          i, j, k, known_classes;\r
-\r
-  HB_UShort*         classes;\r
-  HB_UShort*         cl;\r
-  HB_GPOSHeader*    gpos = gpi->gpos;\r
-\r
-  HB_PosClassSet*   pcs;\r
-  HB_PosClassRule*  pr;\r
-  HB_GDEFHeader*    gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  /* Note: The coverage table in format 2 doesn't give an index into\r
-          anything.  It just lets us know whether or not we need to\r
-          do any lookup at all.                                     */\r
-\r
-  error = _HB_OPEN_Coverage_Index( &cpf2->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if (cpf2->MaxContextLength < 1)\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( ALLOC_ARRAY( classes, cpf2->MaxContextLength, HB_UShort ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Get_Class( &cpf2->ClassDef, IN_CURGLYPH(),\r
-                    &classes[0], NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    goto End;\r
-  known_classes = 0;\r
-\r
-  pcs = &cpf2->PosClassSet[classes[0]];\r
-  if ( !pcs )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_SubTable);\r
-    goto End;\r
-  }\r
-\r
-  for ( k = 0; k < pcs->PosClassRuleCount; k++ )\r
-  {\r
-    pr = &pcs->PosClassRule[k];\r
-\r
-    if ( context_length != 0xFFFF && context_length < pr->GlyphCount )\r
-      goto next_posclassrule;\r
-\r
-    if ( buffer->in_pos + pr->GlyphCount > buffer->in_length )\r
-      goto next_posclassrule;                /* context is too long */\r
-\r
-    cl   = pr->Class;\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < pr->GlyphCount; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End;\r
-\r
-       if ( j + pr->GlyphCount - i == (HB_Int)buffer->in_length )\r
-         goto next_posclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i > known_classes )\r
-      {\r
-       /* Keeps us from having to do this for each rule */\r
-\r
-       error = _HB_OPEN_Get_Class( &cpf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End;\r
-       known_classes = i;\r
-      }\r
-\r
-      if ( cl[i - 1] != classes[i] )\r
-       goto next_posclassrule;\r
-    }\r
-\r
-    error = Do_ContextPos( gpi, pr->GlyphCount,\r
-                          pr->PosCount, pr->PosLookupRecord,\r
-                          buffer,\r
-                          nesting_level );\r
-    goto End;\r
-\r
-  next_posclassrule:\r
-    ;\r
-  }\r
-\r
-  error = HB_Err_Not_Covered;\r
-\r
-End:\r
-  FREE( classes );\r
-  return error;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextPos3( GPOS_Instance*          gpi,\r
-                                    HB_ContextPosFormat3*  cpf3,\r
-                                    HB_Buffer              buffer,\r
-                                    HB_UShort               flags,\r
-                                    HB_UShort               context_length,\r
-                                    int                     nesting_level )\r
-{\r
-  HB_Error         error;\r
-  HB_UShort        index, i, j, property;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-\r
-  HB_Coverage*    c;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  if ( context_length != 0xFFFF && context_length < cpf3->GlyphCount )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( buffer->in_pos + cpf3->GlyphCount > buffer->in_length )\r
-    return HB_Err_Not_Covered;         /* context is too long */\r
-\r
-  c    = cpf3->Coverage;\r
-\r
-  for ( i = 1, j = 1; i < cpf3->GlyphCount; i++, j++ )\r
-  {\r
-    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + cpf3->GlyphCount - i == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &c[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  return Do_ContextPos( gpi, cpf3->GlyphCount,\r
-                       cpf3->PosCount, cpf3->PosLookupRecord,\r
-                       buffer,\r
-                       nesting_level );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextPos( GPOS_Instance*    gpi,\r
-                                   HB_GPOS_SubTable* st,\r
-                                   HB_Buffer        buffer,\r
-                                   HB_UShort         flags,\r
-                                   HB_UShort         context_length,\r
-                                   int               nesting_level )\r
-{\r
-  HB_ContextPos*   cp = &st->context;\r
-\r
-  switch ( cp->PosFormat )\r
-  {\r
-  case 1:\r
-    return Lookup_ContextPos1( gpi, &cp->cpf.cpf1, buffer,\r
-                              flags, context_length, nesting_level );\r
-\r
-  case 2:\r
-    return Lookup_ContextPos2( gpi, &cp->cpf.cpf2, buffer,\r
-                              flags, context_length, nesting_level );\r
-\r
-  case 3:\r
-    return Lookup_ContextPos3( gpi, &cp->cpf.cpf3, buffer,\r
-                              flags, context_length, nesting_level );\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-/* LookupType 8 */\r
-\r
-/* ChainPosRule */\r
-\r
-static HB_Error  Load_ChainPosRule( HB_ChainPosRule*  cpr,\r
-                                   HB_Stream          stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, count;\r
-  HB_UShort*            b;\r
-  HB_UShort*            i;\r
-  HB_UShort*            l;\r
-\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cpr->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpr->Backtrack = NULL;\r
-\r
-  count = cpr->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cpr->Backtrack, count, HB_UShort ) )\r
-    return error;\r
-\r
-  b = cpr->Backtrack;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail4;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    b[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  cpr->InputGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpr->Input = NULL;\r
-\r
-  count = cpr->InputGlyphCount - 1;  /* only InputGlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( cpr->Input, count, HB_UShort ) )\r
-    goto Fail4;\r
-\r
-  i = cpr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail3;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  cpr->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpr->Lookahead = NULL;\r
-\r
-  count = cpr->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cpr->Lookahead, count, HB_UShort ) )\r
-    goto Fail3;\r
-\r
-  l = cpr->Lookahead;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    l[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  cpr->PosCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpr->PosLookupRecord = NULL;\r
-\r
-  count = cpr->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( cpr->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = cpr->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  FREE( l );\r
-\r
-Fail3:\r
-  FREE( i );\r
-\r
-Fail4:\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainPosRule( HB_ChainPosRule*  cpr )\r
-{\r
-  FREE( cpr->PosLookupRecord );\r
-  FREE( cpr->Lookahead );\r
-  FREE( cpr->Input );\r
-  FREE( cpr->Backtrack );\r
-}\r
-\r
-\r
-/* ChainPosRuleSet */\r
-\r
-static HB_Error  Load_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs,\r
-                                      HB_Stream             stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort          n, m, count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainPosRule*  cpr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = cprs->ChainPosRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cprs->ChainPosRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cprs->ChainPosRule, count, HB_ChainPosRule ) )\r
-    return error;\r
-\r
-  cpr = cprs->ChainPosRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainPosRule( &cpr[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainPosRule( &cpr[m] );\r
-\r
-  FREE( cpr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs )\r
-{\r
-  HB_UShort          n, count;\r
-\r
-  HB_ChainPosRule*  cpr;\r
-\r
-\r
-  if ( cprs->ChainPosRule )\r
-  {\r
-    count = cprs->ChainPosRuleCount;\r
-    cpr   = cprs->ChainPosRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainPosRule( &cpr[n] );\r
-\r
-    FREE( cpr );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextPosFormat1 */\r
-\r
-static HB_Error  Load_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1,\r
-                                       HB_Stream                    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, m, count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainPosRuleSet*  cprs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ccpf1->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = ccpf1->ChainPosRuleSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccpf1->ChainPosRuleSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ccpf1->ChainPosRuleSet, count, HB_ChainPosRuleSet ) )\r
-    goto Fail2;\r
-\r
-  cprs = ccpf1->ChainPosRuleSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainPosRuleSet( &cprs[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainPosRuleSet( &cprs[m] );\r
-\r
-  FREE( cprs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &ccpf1->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1 )\r
-{\r
-  HB_UShort             n, count;\r
-\r
-  HB_ChainPosRuleSet*  cprs;\r
-\r
-\r
-  if ( ccpf1->ChainPosRuleSet )\r
-  {\r
-    count = ccpf1->ChainPosRuleSetCount;\r
-    cprs  = ccpf1->ChainPosRuleSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainPosRuleSet( &cprs[n] );\r
-\r
-    FREE( cprs );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &ccpf1->Coverage );\r
-}\r
-\r
-\r
-/* ChainPosClassRule */\r
-\r
-static HB_Error  Load_ChainPosClassRule(\r
-                  HB_ChainContextPosFormat2*  ccpf2,\r
-                  HB_ChainPosClassRule*       cpcr,\r
-                  HB_Stream                    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, count;\r
-\r
-  HB_UShort*            b;\r
-  HB_UShort*            i;\r
-  HB_UShort*            l;\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cpcr->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( cpcr->BacktrackGlyphCount > ccpf2->MaxBacktrackLength )\r
-    ccpf2->MaxBacktrackLength = cpcr->BacktrackGlyphCount;\r
-\r
-  cpcr->Backtrack = NULL;\r
-\r
-  count = cpcr->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cpcr->Backtrack, count, HB_UShort ) )\r
-    return error;\r
-\r
-  b = cpcr->Backtrack;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail4;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    b[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  cpcr->InputGlyphCount = GET_UShort();\r
-\r
-  if ( cpcr->InputGlyphCount > ccpf2->MaxInputLength )\r
-    ccpf2->MaxInputLength = cpcr->InputGlyphCount;\r
-\r
-  FORGET_Frame();\r
-\r
-  cpcr->Input = NULL;\r
-\r
-  count = cpcr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( cpcr->Input, count, HB_UShort ) )\r
-    goto Fail4;\r
-\r
-  i = cpcr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail3;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  cpcr->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( cpcr->LookaheadGlyphCount > ccpf2->MaxLookaheadLength )\r
-    ccpf2->MaxLookaheadLength = cpcr->LookaheadGlyphCount;\r
-\r
-  cpcr->Lookahead = NULL;\r
-\r
-  count = cpcr->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cpcr->Lookahead, count, HB_UShort ) )\r
-    goto Fail3;\r
-\r
-  l = cpcr->Lookahead;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    l[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  cpcr->PosCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpcr->PosLookupRecord = NULL;\r
-\r
-  count = cpcr->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( cpcr->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = cpcr->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  FREE( l );\r
-\r
-Fail3:\r
-  FREE( i );\r
-\r
-Fail4:\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainPosClassRule( HB_ChainPosClassRule*  cpcr )\r
-{\r
-  FREE( cpcr->PosLookupRecord );\r
-  FREE( cpcr->Lookahead );\r
-  FREE( cpcr->Input );\r
-  FREE( cpcr->Backtrack );\r
-}\r
-\r
-\r
-/* PosClassSet */\r
-\r
-static HB_Error  Load_ChainPosClassSet(\r
-                  HB_ChainContextPosFormat2*  ccpf2,\r
-                  HB_ChainPosClassSet*        cpcs,\r
-                  HB_Stream                    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort               n, m, count;\r
-  HB_UInt                cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainPosClassRule*  cpcr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = cpcs->ChainPosClassRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cpcs->ChainPosClassRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cpcs->ChainPosClassRule, count,\r
-                   HB_ChainPosClassRule ) )\r
-    return error;\r
-\r
-  cpcr = cpcs->ChainPosClassRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainPosClassRule( ccpf2, &cpcr[n],\r
-                                          stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainPosClassRule( &cpcr[m] );\r
-\r
-  FREE( cpcr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainPosClassSet( HB_ChainPosClassSet*  cpcs )\r
-{\r
-  HB_UShort               n, count;\r
-\r
-  HB_ChainPosClassRule*  cpcr;\r
-\r
-\r
-  if ( cpcs->ChainPosClassRule )\r
-  {\r
-    count = cpcs->ChainPosClassRuleCount;\r
-    cpcr  = cpcs->ChainPosClassRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainPosClassRule( &cpcr[n] );\r
-\r
-    FREE( cpcr );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextPosFormat2 */\r
-\r
-static HB_Error  Load_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2,\r
-                                       HB_Stream                    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort              n, m, count;\r
-  HB_UInt               cur_offset, new_offset, base_offset;\r
-  HB_UInt               backtrack_offset, input_offset, lookahead_offset;\r
-\r
-  HB_ChainPosClassSet*  cpcs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ccpf2->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 8L ) )\r
-    goto Fail5;\r
-\r
-  backtrack_offset = GET_UShort();\r
-  input_offset     = GET_UShort();\r
-  lookahead_offset = GET_UShort();\r
-\r
-  /* `ChainPosClassSetCount' is the upper limit for input klass values,\r
-     thus we read it now to make an additional safety check. No limit\r
-     is known or needed for the other two klass definitions          */\r
-\r
-  count = ccpf2->ChainPosClassSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535,\r
-                                                      backtrack_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail5;\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count,\r
-                                                      input_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail4;\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535,\r
-                                                      lookahead_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-\r
-  ccpf2->ChainPosClassSet   = NULL;\r
-  ccpf2->MaxBacktrackLength = 0;\r
-  ccpf2->MaxInputLength     = 0;\r
-  ccpf2->MaxLookaheadLength = 0;\r
-\r
-  if ( ALLOC_ARRAY( ccpf2->ChainPosClassSet, count, HB_ChainPosClassSet ) )\r
-    goto Fail2;\r
-\r
-  cpcs = ccpf2->ChainPosClassSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset != base_offset )      /* not a NULL offset */\r
-    {\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_ChainPosClassSet( ccpf2, &cpcs[n],\r
-                                           stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      /* we create a ChainPosClassSet table with no entries */\r
-\r
-      ccpf2->ChainPosClassSet[n].ChainPosClassRuleCount = 0;\r
-      ccpf2->ChainPosClassSet[n].ChainPosClassRule      = NULL;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainPosClassSet( &cpcs[m] );\r
-\r
-  FREE( cpcs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef );\r
-\r
-Fail4:\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef );\r
-\r
-Fail5:\r
-  _HB_OPEN_Free_Coverage( &ccpf2->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2 )\r
-{\r
-  HB_UShort              n, count;\r
-\r
-  HB_ChainPosClassSet*  cpcs;\r
-\r
-\r
-  if ( ccpf2->ChainPosClassSet )\r
-  {\r
-    count = ccpf2->ChainPosClassSetCount;\r
-    cpcs  = ccpf2->ChainPosClassSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainPosClassSet( &cpcs[n] );\r
-\r
-    FREE( cpcs );\r
-  }\r
-\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef );\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef );\r
-  _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef );\r
-\r
-  _HB_OPEN_Free_Coverage( &ccpf2->Coverage );\r
-}\r
-\r
-\r
-/* ChainContextPosFormat3 */\r
-\r
-static HB_Error  Load_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3,\r
-                                       HB_Stream                    stream )\r
-{\r
-  HB_Error  error;\r
-\r
-  HB_UShort             n, nb, ni, nl, m, count;\r
-  HB_UShort             backtrack_count, input_count, lookahead_count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_Coverage*         b;\r
-  HB_Coverage*         i;\r
-  HB_Coverage*         l;\r
-  HB_PosLookupRecord*  plr;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  ccpf3->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccpf3->BacktrackCoverage = NULL;\r
-\r
-  backtrack_count = ccpf3->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccpf3->BacktrackCoverage, backtrack_count,\r
-                   HB_Coverage ) )\r
-    return error;\r
-\r
-  b = ccpf3->BacktrackCoverage;\r
-\r
-  for ( nb = 0; nb < backtrack_count; nb++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail4;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )\r
-      goto Fail4;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  ccpf3->InputGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccpf3->InputCoverage = NULL;\r
-\r
-  input_count = ccpf3->InputGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccpf3->InputCoverage, input_count, HB_Coverage ) )\r
-    goto Fail4;\r
-\r
-  i = ccpf3->InputCoverage;\r
-\r
-  for ( ni = 0; ni < input_count; ni++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail3;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )\r
-      goto Fail3;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  ccpf3->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccpf3->LookaheadCoverage = NULL;\r
-\r
-  lookahead_count = ccpf3->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccpf3->LookaheadCoverage, lookahead_count,\r
-                   HB_Coverage ) )\r
-    goto Fail3;\r
-\r
-  l = ccpf3->LookaheadCoverage;\r
-\r
-  for ( nl = 0; nl < lookahead_count; nl++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  ccpf3->PosCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccpf3->PosLookupRecord = NULL;\r
-\r
-  count = ccpf3->PosCount;\r
-\r
-  if ( ALLOC_ARRAY( ccpf3->PosLookupRecord, count, HB_PosLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  plr = ccpf3->PosLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    plr[n].SequenceIndex   = GET_UShort();\r
-    plr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( plr );\r
-\r
-Fail2:\r
-  for ( m = 0; m < nl; m++ )\r
-    _HB_OPEN_Free_Coverage( &l[m] );\r
-\r
-  FREE( l );\r
-\r
-Fail3:\r
-  for ( m = 0; m < ni; m++ )\r
-    _HB_OPEN_Free_Coverage( &i[m] );\r
-\r
-  FREE( i );\r
-\r
-Fail4:\r
-  for ( m = 0; m < nb; m++ )\r
-    _HB_OPEN_Free_Coverage( &b[m] );\r
-\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3 )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_Coverage*  c;\r
-\r
-\r
-  FREE( ccpf3->PosLookupRecord );\r
-\r
-  if ( ccpf3->LookaheadCoverage )\r
-  {\r
-    count = ccpf3->LookaheadGlyphCount;\r
-    c     = ccpf3->LookaheadCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  if ( ccpf3->InputCoverage )\r
-  {\r
-    count = ccpf3->InputGlyphCount;\r
-    c     = ccpf3->InputCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  if ( ccpf3->BacktrackCoverage )\r
-  {\r
-    count = ccpf3->BacktrackGlyphCount;\r
-    c     = ccpf3->BacktrackCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextPos */\r
-\r
-static HB_Error  Load_ChainContextPos( HB_GPOS_SubTable* st,\r
-                                      HB_Stream             stream )\r
-{\r
-  HB_Error  error;\r
-  HB_ChainContextPos*  ccp = &st->chain;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  ccp->PosFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( ccp->PosFormat )\r
-  {\r
-  case 1:\r
-    return Load_ChainContextPos1( &ccp->ccpf.ccpf1, stream );\r
-\r
-  case 2:\r
-    return Load_ChainContextPos2( &ccp->ccpf.ccpf2, stream );\r
-\r
-  case 3:\r
-    return Load_ChainContextPos3( &ccp->ccpf.ccpf3, stream );\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-static void  Free_ChainContextPos( HB_GPOS_SubTable* st )\r
-{\r
-  HB_ChainContextPos*  ccp = &st->chain;\r
-\r
-  switch ( ccp->PosFormat )\r
-  {\r
-  case 1:  Free_ChainContextPos1( &ccp->ccpf.ccpf1 ); break;\r
-  case 2:  Free_ChainContextPos2( &ccp->ccpf.ccpf2 ); break;\r
-  case 3:  Free_ChainContextPos3( &ccp->ccpf.ccpf3 ); break;\r
-  default:                                                   break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextPos1(\r
-                  GPOS_Instance*               gpi,\r
-                  HB_ChainContextPosFormat1*  ccpf1,\r
-                  HB_Buffer                   buffer,\r
-                  HB_UShort                    flags,\r
-                  HB_UShort                    context_length,\r
-                  int                          nesting_level )\r
-{\r
-  HB_UShort          index, property;\r
-  HB_UShort          i, j, k, num_cpr;\r
-  HB_UShort          bgc, igc, lgc;\r
-  HB_Error           error;\r
-  HB_GPOSHeader*    gpos = gpi->gpos;\r
-\r
-  HB_ChainPosRule*  cpr;\r
-  HB_ChainPosRule   curr_cpr;\r
-  HB_GDEFHeader*    gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ccpf1->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  cpr     = ccpf1->ChainPosRuleSet[index].ChainPosRule;\r
-  num_cpr = ccpf1->ChainPosRuleSet[index].ChainPosRuleCount;\r
-\r
-  for ( k = 0; k < num_cpr; k++ )\r
-  {\r
-    curr_cpr = cpr[k];\r
-    bgc      = curr_cpr.BacktrackGlyphCount;\r
-    igc      = curr_cpr.InputGlyphCount;\r
-    lgc      = curr_cpr.LookaheadGlyphCount;\r
-\r
-    if ( context_length != 0xFFFF && context_length < igc )\r
-      goto next_chainposrule;\r
-\r
-    /* check whether context is too long; it is a first guess only */\r
-\r
-    if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-      goto next_chainposrule;\r
-\r
-    if ( bgc )\r
-    {\r
-      /* Since we don't know in advance the number of glyphs to inspect,\r
-        we search backwards for matches in the backtrack glyph array    */\r
-\r
-      for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )\r
-      {\r
-       while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-       {\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           return error;\r
-\r
-         if ( j + 1 == bgc - i )\r
-           goto next_chainposrule;\r
-         j--;\r
-       }\r
-\r
-       /* In OpenType 1.3, it is undefined whether the offsets of\r
-          backtrack glyphs is in logical order or not.  Version 1.4\r
-          will clarify this:\r
-\r
-            Logical order -      a  b  c  d  e  f  g  h  i  j\r
-                                             i\r
-            Input offsets -                  0  1\r
-            Backtrack offsets -  3  2  1  0\r
-            Lookahead offsets -                    0  1  2  3           */\r
-\r
-       if ( IN_GLYPH( j ) != curr_cpr.Backtrack[i] )\r
-         goto next_chainposrule;\r
-      }\r
-    }\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-         goto next_chainposrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != curr_cpr.Input[i - 1] )\r
-       goto next_chainposrule;\r
-    }\r
-\r
-    /* we are starting to check for lookahead glyphs right after the\r
-       last context glyph                                            */\r
-\r
-    for ( i = 0; i < lgc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-         goto next_chainposrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != curr_cpr.Lookahead[i] )\r
-       goto next_chainposrule;\r
-    }\r
-\r
-    return Do_ContextPos( gpi, igc,\r
-                         curr_cpr.PosCount,\r
-                         curr_cpr.PosLookupRecord,\r
-                         buffer,\r
-                         nesting_level );\r
-\r
-  next_chainposrule:\r
-    ;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextPos2(\r
-                  GPOS_Instance*               gpi,\r
-                  HB_ChainContextPosFormat2*  ccpf2,\r
-                  HB_Buffer                   buffer,\r
-                  HB_UShort                    flags,\r
-                  HB_UShort                    context_length,\r
-                  int                          nesting_level )\r
-{\r
-  HB_UShort              index, property;\r
-  HB_Error               error;\r
-  HB_UShort              i, j, k;\r
-  HB_UShort              bgc, igc, lgc;\r
-  HB_UShort              known_backtrack_classes,\r
-                        known_input_classes,\r
-                        known_lookahead_classes;\r
-\r
-  HB_UShort*             backtrack_classes;\r
-  HB_UShort*             input_classes;\r
-  HB_UShort*             lookahead_classes;\r
-\r
-  HB_UShort*             bc;\r
-  HB_UShort*             ic;\r
-  HB_UShort*             lc;\r
-  HB_GPOSHeader*        gpos = gpi->gpos;\r
-\r
-  HB_ChainPosClassSet*  cpcs;\r
-  HB_ChainPosClassRule  cpcr;\r
-  HB_GDEFHeader*        gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  /* Note: The coverage table in format 2 doesn't give an index into\r
-          anything.  It just lets us know whether or not we need to\r
-          do any lookup at all.                                     */\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ccpf2->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( ALLOC_ARRAY( backtrack_classes, ccpf2->MaxBacktrackLength, HB_UShort ) )\r
-    return error;\r
-  known_backtrack_classes = 0;\r
-\r
-  if (ccpf2->MaxInputLength < 1)\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( ALLOC_ARRAY( input_classes, ccpf2->MaxInputLength, HB_UShort ) )\r
-    goto End3;\r
-  known_input_classes = 1;\r
-\r
-  if ( ALLOC_ARRAY( lookahead_classes, ccpf2->MaxLookaheadLength, HB_UShort ) )\r
-    goto End2;\r
-  known_lookahead_classes = 0;\r
-\r
-  error = _HB_OPEN_Get_Class( &ccpf2->InputClassDef, IN_CURGLYPH(),\r
-                    &input_classes[0], NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    goto End1;\r
-\r
-  cpcs = &ccpf2->ChainPosClassSet[input_classes[0]];\r
-  if ( !cpcs )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_SubTable);\r
-    goto End1;\r
-  }\r
-\r
-  for ( k = 0; k < cpcs->ChainPosClassRuleCount; k++ )\r
-  {\r
-    cpcr = cpcs->ChainPosClassRule[k];\r
-    bgc  = cpcr.BacktrackGlyphCount;\r
-    igc  = cpcr.InputGlyphCount;\r
-    lgc  = cpcr.LookaheadGlyphCount;\r
-\r
-    if ( context_length != 0xFFFF && context_length < igc )\r
-      goto next_chainposclassrule;\r
-\r
-    /* check whether context is too long; it is a first guess only */\r
-\r
-    if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-      goto next_chainposclassrule;\r
-\r
-    if ( bgc )\r
-    {\r
-      /* Since we don't know in advance the number of glyphs to inspect,\r
-        we search backwards for matches in the backtrack glyph array.\r
-        Note that `known_backtrack_classes' starts at index 0.         */\r
-\r
-      bc       = cpcr.Backtrack;\r
-\r
-      for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )\r
-      {\r
-       while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-       {\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           goto End1;\r
-\r
-         if ( j + 1 == bgc - i )\r
-           goto next_chainposclassrule;\r
-         j++;\r
-       }\r
-\r
-       if ( i >= known_backtrack_classes )\r
-       {\r
-         /* Keeps us from having to do this for each rule */\r
-\r
-         error = _HB_OPEN_Get_Class( &ccpf2->BacktrackClassDef, IN_GLYPH( j ),\r
-                            &backtrack_classes[i], NULL );\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           goto End1;\r
-         known_backtrack_classes = i;\r
-       }\r
-\r
-       if ( bc[i] != backtrack_classes[i] )\r
-         goto next_chainposclassrule;\r
-      }\r
-    }\r
-\r
-    ic       = cpcr.Input;\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-\r
-       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-         goto next_chainposclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i >= known_input_classes )\r
-      {\r
-       error = _HB_OPEN_Get_Class( &ccpf2->InputClassDef, IN_GLYPH( j ),\r
-                          &input_classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-       known_input_classes = i;\r
-      }\r
-\r
-      if ( ic[i - 1] != input_classes[i] )\r
-       goto next_chainposclassrule;\r
-    }\r
-\r
-    /* we are starting to check for lookahead glyphs right after the\r
-       last context glyph                                            */\r
-\r
-    lc       = cpcr.Lookahead;\r
-\r
-    for ( i = 0; i < lgc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-\r
-       if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-         goto next_chainposclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i >= known_lookahead_classes )\r
-      {\r
-       error = _HB_OPEN_Get_Class( &ccpf2->LookaheadClassDef, IN_GLYPH( j ),\r
-                          &lookahead_classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-       known_lookahead_classes = i;\r
-      }\r
-\r
-      if ( lc[i] != lookahead_classes[i] )\r
-       goto next_chainposclassrule;\r
-    }\r
-\r
-    error = Do_ContextPos( gpi, igc,\r
-                          cpcr.PosCount,\r
-                          cpcr.PosLookupRecord,\r
-                          buffer,\r
-                          nesting_level );\r
-    goto End1;\r
-\r
-  next_chainposclassrule:\r
-    ;\r
-  }\r
-\r
-  error = HB_Err_Not_Covered;\r
-\r
-End1:\r
-  FREE( lookahead_classes );\r
-\r
-End2:\r
-  FREE( input_classes );\r
-\r
-End3:\r
-  FREE( backtrack_classes );\r
-  return error;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextPos3(\r
-                  GPOS_Instance*               gpi,\r
-                  HB_ChainContextPosFormat3*  ccpf3,\r
-                  HB_Buffer                   buffer,\r
-                  HB_UShort                    flags,\r
-                  HB_UShort                    context_length,\r
-                  int                          nesting_level )\r
-{\r
-  HB_UShort        index, i, j, property;\r
-  HB_UShort        bgc, igc, lgc;\r
-  HB_Error         error;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-\r
-  HB_Coverage*    bc;\r
-  HB_Coverage*    ic;\r
-  HB_Coverage*    lc;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gpos->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  bgc = ccpf3->BacktrackGlyphCount;\r
-  igc = ccpf3->InputGlyphCount;\r
-  lgc = ccpf3->LookaheadGlyphCount;\r
-\r
-  if ( context_length != 0xFFFF && context_length < igc )\r
-    return HB_Err_Not_Covered;\r
-\r
-  /* check whether context is too long; it is a first guess only */\r
-\r
-  if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( bgc )\r
-  {\r
-    /* Since we don't know in advance the number of glyphs to inspect,\r
-       we search backwards for matches in the backtrack glyph array    */\r
-\r
-    bc       = ccpf3->BacktrackCoverage;\r
-\r
-    for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + 1 == bgc - i )\r
-         return HB_Err_Not_Covered;\r
-       j--;\r
-      }\r
-\r
-      error = _HB_OPEN_Coverage_Index( &bc[i], IN_GLYPH( j ), &index );\r
-      if ( error )\r
-       return error;\r
-    }\r
-  }\r
-\r
-  ic       = ccpf3->InputCoverage;\r
-\r
-  for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )\r
-  {\r
-    /* We already called CHECK_Property for IN_GLYPH ( buffer->in_pos ) */\r
-    while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &ic[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  /* we are starting to check for lookahead glyphs right after the\r
-     last context glyph                                            */\r
-\r
-  lc       = ccpf3->LookaheadCoverage;\r
-\r
-  for ( i = 0; i < lgc; i++, j++ )\r
-  {\r
-    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  return Do_ContextPos( gpi, igc,\r
-                       ccpf3->PosCount,\r
-                       ccpf3->PosLookupRecord,\r
-                       buffer,\r
-                       nesting_level );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextPos(\r
-                  GPOS_Instance*        gpi,\r
-                  HB_GPOS_SubTable* st,\r
-                  HB_Buffer            buffer,\r
-                  HB_UShort             flags,\r
-                  HB_UShort             context_length,\r
-                  int                   nesting_level )\r
-{\r
-  HB_ChainContextPos*  ccp = &st->chain;\r
-\r
-  switch ( ccp->PosFormat )\r
-  {\r
-  case 1:\r
-    return Lookup_ChainContextPos1( gpi, &ccp->ccpf.ccpf1, buffer,\r
-                                   flags, context_length,\r
-                                   nesting_level );\r
-\r
-  case 2:\r
-    return Lookup_ChainContextPos2( gpi, &ccp->ccpf.ccpf2, buffer,\r
-                                   flags, context_length,\r
-                                   nesting_level );\r
-\r
-  case 3:\r
-    return Lookup_ChainContextPos3( gpi, &ccp->ccpf.ccpf3, buffer,\r
-                                   flags, context_length,\r
-                                   nesting_level );\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-\r
-/***********\r
- * GPOS API\r
- ***********/\r
-\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index )\r
-{\r
-  HB_UShort          n;\r
-\r
-  HB_ScriptList*    sl;\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  if ( !gpos || !script_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  for ( n = 0; n < sl->ScriptCount; n++ )\r
-    if ( script_tag == sr[n].ScriptTag )\r
-    {\r
-      *script_index = n;\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index )\r
-{\r
-  HB_UShort           n;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*         s;\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  if ( !gpos || !language_index || !req_feature_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  for ( n = 0; n < s->LangSysCount; n++ )\r
-    if ( language_tag == lsr[n].LangSysTag )\r
-    {\r
-      *language_index = n;\r
-      *req_feature_index = lsr[n].LangSys.ReqFeatureIndex;\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-/* selecting 0xFFFF for language_index asks for the values of the\r
-   default language (DefaultLangSys)                              */\r
-\r
-\r
-HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index )\r
-{\r
-  HB_UShort           n;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*         s;\r
-  HB_LangSysRecord*  lsr;\r
-  HB_LangSys*        ls;\r
-  HB_UShort*          fi;\r
-\r
-  HB_FeatureList*    fl;\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  if ( !gpos || !feature_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  fl = &gpos->FeatureList;\r
-  fr = fl->FeatureRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( language_index == 0xFFFF )\r
-    ls = &s->DefaultLangSys;\r
-  else\r
-  {\r
-    if ( language_index >= s->LangSysCount )\r
-      return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-    ls = &lsr[language_index].LangSys;\r
-  }\r
-\r
-  fi = ls->FeatureIndex;\r
-\r
-  for ( n = 0; n < ls->FeatureCount; n++ )\r
-  {\r
-    if ( fi[n] >= fl->FeatureCount )\r
-      return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-\r
-    if ( feature_tag == fr[fi[n]].FeatureTag )\r
-    {\r
-      *feature_index = fi[n];\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-/* The next three functions return a null-terminated list */\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,\r
-                                HB_UInt**       script_tag_list )\r
-{\r
-  HB_Error           error;\r
-  HB_UShort          n;\r
-  HB_UInt*          stl;\r
-\r
-  HB_ScriptList*    sl;\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  if ( !gpos || !script_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < sl->ScriptCount; n++ )\r
-    stl[n] = sr[n].ScriptTag;\r
-  stl[n] = 0;\r
-\r
-  *script_tag_list = stl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list )\r
-{\r
-  HB_Error            error;\r
-  HB_UShort           n;\r
-  HB_UInt*           ltl;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  if ( !gpos || !language_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < s->LangSysCount; n++ )\r
-    ltl[n] = lsr[n].LangSysTag;\r
-  ltl[n] = 0;\r
-\r
-  *language_tag_list = ltl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* selecting 0xFFFF for language_index asks for the values of the\r
-   default language (DefaultLangSys)                              */\r
-\r
-\r
-HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list )\r
-{\r
-  HB_UShort           n;\r
-  HB_Error            error;\r
-  HB_UInt*           ftl;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-  HB_LangSys*        ls;\r
-  HB_UShort*          fi;\r
-\r
-  HB_FeatureList*    fl;\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  if ( !gpos || !feature_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gpos->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  fl = &gpos->FeatureList;\r
-  fr = fl->FeatureRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( language_index == 0xFFFF )\r
-    ls = &s->DefaultLangSys;\r
-  else\r
-  {\r
-    if ( language_index >= s->LangSysCount )\r
-      return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-    ls = &lsr[language_index].LangSys;\r
-  }\r
-\r
-  fi = ls->FeatureIndex;\r
-\r
-  if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < ls->FeatureCount; n++ )\r
-  {\r
-    if ( fi[n] >= fl->FeatureCount )\r
-    {\r
-      FREE( ftl );\r
-      return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-    }\r
-    ftl[n] = fr[fi[n]].FeatureTag;\r
-  }\r
-  ftl[n] = 0;\r
-\r
-  *feature_tag_list = ftl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* Do an individual subtable lookup.  Returns HB_Err_Ok if positioning\r
-   has been done, or HB_Err_Not_Covered if not.                        */\r
-static HB_Error  GPOS_Do_Glyph_Lookup( GPOS_Instance*    gpi,\r
-                                      HB_UShort         lookup_index,\r
-                                      HB_Buffer        buffer,\r
-                                      HB_UShort         context_length,\r
-                                      int               nesting_level )\r
-{\r
-  HB_Error             error = HB_Err_Not_Covered;\r
-  HB_UShort            i, flags, lookup_count;\r
-  HB_GPOSHeader*       gpos = gpi->gpos;\r
-  HB_Lookup*           lo;\r
-  int                 lookup_type;\r
-\r
-\r
-  nesting_level++;\r
-\r
-  if ( nesting_level > HB_MAX_NESTING_LEVEL )\r
-    return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */\r
-\r
-  lookup_count = gpos->LookupList.LookupCount;\r
-  if (lookup_index >= lookup_count)\r
-    return error;\r
-\r
-  lo    = &gpos->LookupList.Lookup[lookup_index];\r
-  flags = lo->LookupFlag;\r
-  lookup_type = lo->LookupType;\r
-\r
-  for ( i = 0; i < lo->SubTableCount; i++ )\r
-  {\r
-    HB_GPOS_SubTable *st = &lo->SubTable[i].st.gpos;\r
-\r
-    switch (lookup_type) {\r
-      case HB_GPOS_LOOKUP_SINGLE:\r
-        error = Lookup_SinglePos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_PAIR:\r
-       error = Lookup_PairPos          ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_CURSIVE:\r
-       error = Lookup_CursivePos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_MARKBASE:\r
-       error = Lookup_MarkBasePos      ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_MARKLIG:\r
-       error = Lookup_MarkLigPos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_MARKMARK:\r
-       error = Lookup_MarkMarkPos      ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_CONTEXT:\r
-       error = Lookup_ContextPos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GPOS_LOOKUP_CHAIN:\r
-       error = Lookup_ChainContextPos  ( gpi, st, buffer, flags, context_length, nesting_level ); break;\r
-    /*case HB_GPOS_LOOKUP_EXTENSION:\r
-       error = Lookup_ExtensionPos     ( gpi, st, buffer, flags, context_length, nesting_level ); break;*/\r
-      default:\r
-       error = HB_Err_Not_Covered;\r
-    }\r
-\r
-    /* Check whether we have a successful positioning or an error other\r
-       than HB_Err_Not_Covered                                         */\r
-    if ( error != HB_Err_Not_Covered )\r
-      return error;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,\r
-                       HB_Stream         stream,\r
-                       HB_UShort         lookup_type )\r
-{\r
-  switch ( lookup_type ) {\r
-    case HB_GPOS_LOOKUP_SINGLE:                return Load_SinglePos           ( st, stream );\r
-    case HB_GPOS_LOOKUP_PAIR:          return Load_PairPos             ( st, stream );\r
-    case HB_GPOS_LOOKUP_CURSIVE:       return Load_CursivePos          ( st, stream );\r
-    case HB_GPOS_LOOKUP_MARKBASE:      return Load_MarkBasePos         ( st, stream );\r
-    case HB_GPOS_LOOKUP_MARKLIG:       return Load_MarkLigPos          ( st, stream );\r
-    case HB_GPOS_LOOKUP_MARKMARK:      return Load_MarkMarkPos         ( st, stream );\r
-    case HB_GPOS_LOOKUP_CONTEXT:       return Load_ContextPos          ( st, stream );\r
-    case HB_GPOS_LOOKUP_CHAIN:         return Load_ChainContextPos     ( st, stream );\r
-  /*case HB_GPOS_LOOKUP_EXTENSION:     return Load_ExtensionPos        ( st, stream );*/\r
-    default:                           return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,\r
-                       HB_UShort         lookup_type )\r
-{\r
-  switch ( lookup_type ) {\r
-    case HB_GPOS_LOOKUP_SINGLE:                Free_SinglePos          ( st ); return;\r
-    case HB_GPOS_LOOKUP_PAIR:          Free_PairPos            ( st ); return;\r
-    case HB_GPOS_LOOKUP_CURSIVE:       Free_CursivePos         ( st ); return;\r
-    case HB_GPOS_LOOKUP_MARKBASE:      Free_MarkBasePos        ( st ); return;\r
-    case HB_GPOS_LOOKUP_MARKLIG:       Free_MarkLigPos         ( st ); return;\r
-    case HB_GPOS_LOOKUP_MARKMARK:      Free_MarkMarkPos        ( st ); return;\r
-    case HB_GPOS_LOOKUP_CONTEXT:       Free_ContextPos         ( st ); return;\r
-    case HB_GPOS_LOOKUP_CHAIN:         Free_ChainContextPos    ( st ); return;\r
-  /*case HB_GPOS_LOOKUP_EXTENSION:     Free_ExtensionPos       ( st ); return;*/\r
-    default:                                                                   return;\r
-  }\r
-}\r
-\r
-\r
-/* apply one lookup to the input string object */\r
-\r
-static HB_Error  GPOS_Do_String_Lookup( GPOS_Instance*    gpi,\r
-                                  HB_UShort         lookup_index,\r
-                                  HB_Buffer        buffer )\r
-{\r
-  HB_Error         error, retError = HB_Err_Not_Covered;\r
-  HB_GPOSHeader*  gpos = gpi->gpos;\r
-\r
-  HB_UInt*  properties = gpos->LookupList.Properties;\r
-\r
-  const int       nesting_level = 0;\r
-  /* 0xFFFF indicates that we don't have a context length yet */\r
-  const HB_UShort context_length = 0xFFFF;\r
-\r
-\r
-  gpi->last  = 0xFFFF;     /* no last valid glyph for cursive pos. */\r
-\r
-  buffer->in_pos = 0;\r
-  while ( buffer->in_pos < buffer->in_length )\r
-  {\r
-    if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )\r
-    {\r
-      /* Note that the connection between mark and base glyphs hold\r
-        exactly one (string) lookup.  For example, it would be possible\r
-        that in the first lookup, mark glyph X is attached to base\r
-        glyph A, and in the next lookup it is attached to base glyph B.\r
-        It is up to the font designer to provide meaningful lookups and\r
-        lookup order.                                                   */\r
-\r
-      error = GPOS_Do_Glyph_Lookup( gpi, lookup_index, buffer, context_length, nesting_level );\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-    }\r
-    else\r
-    {\r
-      /* Contrary to properties defined in GDEF, user-defined properties\r
-        will always stop a possible cursive positioning.                */\r
-      gpi->last = 0xFFFF;\r
-\r
-      error = HB_Err_Not_Covered;\r
-    }\r
-\r
-    if ( error == HB_Err_Not_Covered )\r
-      (buffer->in_pos)++;\r
-    else\r
-      retError = error;\r
-  }\r
-\r
-  return retError;\r
-}\r
-\r
-\r
-static HB_Error  Position_CursiveChain ( HB_Buffer     buffer )\r
-{\r
-  HB_UInt   i, j;\r
-  HB_Position positions = buffer->positions;\r
-\r
-  /* First handle all left-to-right connections */\r
-  for (j = 0; j < buffer->in_length; j++)\r
-  {\r
-    if (positions[j].cursive_chain > 0)\r
-      positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;\r
-  }\r
-\r
-  /* Then handle all right-to-left connections */\r
-  for (i = buffer->in_length; i > 0; i--)\r
-  {\r
-    j = i - 1;\r
-\r
-    if (positions[j].cursive_chain < 0)\r
-      positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property )\r
-{\r
-  HB_UShort    i;\r
-\r
-  HB_Feature  feature;\r
-  HB_UInt*     properties;\r
-  HB_UShort*   index;\r
-  HB_UShort    lookup_count;\r
-\r
-  /* Each feature can only be added once */\r
-\r
-  if ( !gpos ||\r
-       feature_index >= gpos->FeatureList.FeatureCount ||\r
-       gpos->FeatureList.ApplyCount == gpos->FeatureList.FeatureCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gpos->FeatureList.ApplyOrder[gpos->FeatureList.ApplyCount++] = feature_index;\r
-\r
-  properties = gpos->LookupList.Properties;\r
-\r
-  feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;\r
-  index   = feature.LookupListIndex;\r
-  lookup_count = gpos->LookupList.LookupCount;\r
-\r
-  for ( i = 0; i < feature.LookupListCount; i++ )\r
-  {\r
-    HB_UShort lookup_index = index[i];\r
-    if (lookup_index < lookup_count)\r
-      properties[lookup_index] |= property;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos )\r
-{\r
-  HB_UShort i;\r
-\r
-  HB_UInt*  properties;\r
-\r
-\r
-  if ( !gpos )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gpos->FeatureList.ApplyCount = 0;\r
-\r
-  properties = gpos->LookupList.Properties;\r
-\r
-  for ( i = 0; i < gpos->LookupList.LookupCount; i++ )\r
-    properties[i] = 0;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,\r
-                                       HB_MMFunction   mmfunc,\r
-                                       void*            data )\r
-{\r
-  if ( !gpos )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gpos->mmfunc = mmfunc;\r
-  gpos->data   = data;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-/* If `dvi' is TRUE, glyph contour points for anchor points and device\r
-   tables are ignored -- you will get device independent values.         */\r
-\r
-\r
-HB_Error  HB_GPOS_Apply_String( HB_Font            font,\r
-                               HB_GPOSHeader*    gpos,\r
-                               HB_UShort          load_flags,\r
-                               HB_Buffer         buffer,\r
-                               HB_Bool            dvi,\r
-                               HB_Bool            r2l )\r
-{\r
-  HB_Error       error, retError = HB_Err_Not_Covered;\r
-  GPOS_Instance  gpi;\r
-  int            i, j, lookup_count, num_features;\r
-\r
-  if ( !font || !gpos || !buffer )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( buffer->in_length == 0 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  gpi.font       = font;\r
-  gpi.gpos       = gpos;\r
-  gpi.load_flags = load_flags;\r
-  gpi.r2l        = r2l;\r
-  gpi.dvi        = dvi;\r
-\r
-  lookup_count = gpos->LookupList.LookupCount;\r
-  num_features = gpos->FeatureList.ApplyCount;\r
-\r
-  if ( num_features )\r
-    {\r
-      error = _hb_buffer_clear_positions( buffer );\r
-      if ( error )\r
-       return error;\r
-    }\r
-\r
-  for ( i = 0; i < num_features; i++ )\r
-  {\r
-    HB_UShort  feature_index = gpos->FeatureList.ApplyOrder[i];\r
-    HB_Feature feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;\r
-\r
-    for ( j = 0; j < feature.LookupListCount; j++ )\r
-    {\r
-      HB_UShort lookup_index = feature.LookupListIndex[j];\r
-\r
-      /* Skip nonexistant lookups */\r
-      if (lookup_index >= lookup_count)\r
-       continue;\r
-\r
-      error = GPOS_Do_String_Lookup( &gpi, lookup_index, buffer );\r
-      if ( error )\r
-      {\r
-       if ( error != HB_Err_Not_Covered )\r
-         return error;\r
-      }\r
-      else\r
-       retError = error;\r
-    }\r
-  }\r
-\r
-  if ( num_features )\r
-    {\r
-  error = Position_CursiveChain ( buffer );\r
-  if ( error )\r
-    return error;\r
-    }\r
-\r
-  return retError;\r
-}\r
-\r
-/* END */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ * Copyright (C) 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-gpos-private.h"
+#include "harfbuzz-open-private.h"
+#include "harfbuzz-gdef-private.h"
+#include "harfbuzz-shaper.h"
+
+struct  GPOS_Instance_
+{
+  HB_GPOSHeader*  gpos;
+  HB_Font          font;
+  HB_Bool          dvi;
+  HB_UShort        load_flags;  /* how the glyph should be loaded */
+  HB_Bool          r2l;
+
+  HB_UShort        last;        /* the last valid glyph -- used
+                                  with cursive positioning     */
+  HB_Fixed           anchor_x;    /* the coordinates of the anchor point */
+  HB_Fixed           anchor_y;    /* of the last valid glyph             */
+};
+
+typedef struct GPOS_Instance_  GPOS_Instance;
+
+
+static HB_Error  GPOS_Do_Glyph_Lookup( GPOS_Instance*    gpi,
+                                      HB_UShort         lookup_index,
+                                      HB_Buffer        buffer,
+                                      HB_UShort         context_length,
+                                      int               nesting_level );
+
+
+
+/* the client application must replace this with something more
+   meaningful if multiple master fonts are to be supported.     */
+
+static HB_Error  default_mmfunc( HB_Font      font,
+                                HB_UShort    metric_id,
+                                HB_Fixed*      metric_value,
+                                void*        data )
+{
+  HB_UNUSED(font);
+  HB_UNUSED(metric_id);
+  HB_UNUSED(metric_value);
+  HB_UNUSED(data);
+  return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */
+}
+
+
+
+HB_Error  HB_Load_GPOS_Table( HB_Stream stream, 
+                             HB_GPOSHeader** retptr,
+                             HB_GDEFHeader*  gdef,
+                             HB_Stream       gdefStream )
+{
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_GPOSHeader*  gpos;
+
+  HB_Error   error;
+
+
+  if ( !retptr )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( GOTO_Table( TTAG_GPOS ) )
+    return error;
+
+  base_offset = FILE_Pos();
+
+  if ( ALLOC ( gpos, sizeof( *gpos ), HB_GPOSHeader* ) )
+    return error;
+
+  gpos->mmfunc = default_mmfunc;
+
+  /* skip version */
+
+  if ( FILE_Seek( base_offset + 4L ) ||
+       ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_ScriptList( &gpos->ScriptList,
+                                 stream ) ) != HB_Err_Ok )
+    goto Fail4;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_FeatureList( &gpos->FeatureList,
+                                  stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_LookupList( &gpos->LookupList,
+                                 stream, HB_Type_GPOS ) ) != HB_Err_Ok )
+    goto Fail2;
+
+  gpos->gdef = gdef;      /* can be NULL */
+
+  if ( ( error =  _HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( gdef, gdefStream,
+                                                                    gpos->LookupList.Lookup,
+                                                                    gpos->LookupList.LookupCount ) ) )
+    goto Fail1;
+
+  *retptr = gpos;
+
+  return HB_Err_Ok;
+
+Fail1:
+  _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS );
+
+Fail2:
+  _HB_OPEN_Free_FeatureList( &gpos->FeatureList );
+
+Fail3:
+  _HB_OPEN_Free_ScriptList( &gpos->ScriptList );
+
+Fail4:
+  FREE( gpos );
+
+  return error;
+}
+
+
+HB_Error  HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
+{
+  _HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS );
+  _HB_OPEN_Free_FeatureList( &gpos->FeatureList );
+  _HB_OPEN_Free_ScriptList( &gpos->ScriptList );
+
+  FREE( gpos );
+
+  return HB_Err_Ok;
+}
+
+
+/*****************************
+ * SubTable related functions
+ *****************************/
+
+/* shared tables */
+
+/* ValueRecord */
+
+/* There is a subtle difference in the specs between a `table' and a
+   `record' -- offsets for device tables in ValueRecords are taken from
+   the parent table and not the parent record.                          */
+
+static HB_Error  Load_ValueRecord( HB_ValueRecord*  vr,
+                                  HB_UShort         format,
+                                  HB_UInt          base_offset,
+                                  HB_Stream         stream )
+{
+  HB_Error  error;
+
+  HB_UInt cur_offset, new_offset;
+
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    vr->XPlacement = GET_Short();
+
+    FORGET_Frame();
+  }
+  else
+    vr->XPlacement = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    vr->YPlacement = GET_Short();
+
+    FORGET_Frame();
+  }
+  else
+    vr->YPlacement = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    vr->XAdvance = GET_Short();
+
+    FORGET_Frame();
+  }
+  else
+    vr->XAdvance = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    vr->YAdvance = GET_Short();
+
+    FORGET_Frame();
+  }
+  else
+    vr->YAdvance = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &vr->XPlacementDevice,
+                                 stream ) ) != HB_Err_Ok )
+       return error;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      goto empty1;
+  }
+  else
+  {
+  empty1:
+    vr->XPlacementDevice.StartSize  = 0;
+    vr->XPlacementDevice.EndSize    = 0;
+    vr->XPlacementDevice.DeltaValue = NULL;
+  }
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail3;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &vr->YPlacementDevice,
+                                 stream ) ) != HB_Err_Ok )
+       goto Fail3;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      goto empty2;
+  }
+  else
+  {
+  empty2:
+    vr->YPlacementDevice.StartSize  = 0;
+    vr->YPlacementDevice.EndSize    = 0;
+    vr->YPlacementDevice.DeltaValue = NULL;
+  }
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &vr->XAdvanceDevice,
+                                 stream ) ) != HB_Err_Ok )
+       goto Fail2;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      goto empty3;
+  }
+  else
+  {
+  empty3:
+    vr->XAdvanceDevice.StartSize  = 0;
+    vr->XAdvanceDevice.EndSize    = 0;
+    vr->XAdvanceDevice.DeltaValue = NULL;
+  }
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &vr->YAdvanceDevice,
+                                 stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      goto empty4;
+  }
+  else
+  {
+  empty4:
+    vr->YAdvanceDevice.StartSize  = 0;
+    vr->YAdvanceDevice.EndSize    = 0;
+    vr->YAdvanceDevice.DeltaValue = NULL;
+  }
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    vr->XIdPlacement = GET_UShort();
+
+    FORGET_Frame();
+  }
+  else
+    vr->XIdPlacement = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    vr->YIdPlacement = GET_UShort();
+
+    FORGET_Frame();
+  }
+  else
+    vr->YIdPlacement = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    vr->XIdAdvance = GET_UShort();
+
+    FORGET_Frame();
+  }
+  else
+    vr->XIdAdvance = 0;
+
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    vr->YIdAdvance = GET_UShort();
+
+    FORGET_Frame();
+  }
+  else
+    vr->YIdAdvance = 0;
+
+  return HB_Err_Ok;
+
+Fail1:
+  _HB_OPEN_Free_Device( &vr->YAdvanceDevice );
+
+Fail2:
+  _HB_OPEN_Free_Device( &vr->XAdvanceDevice );
+
+Fail3:
+  _HB_OPEN_Free_Device( &vr->YPlacementDevice );
+  return error;
+}
+
+
+static void  Free_ValueRecord( HB_ValueRecord*  vr,
+                              HB_UShort         format )
+{
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )
+    _HB_OPEN_Free_Device( &vr->YAdvanceDevice );
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )
+    _HB_OPEN_Free_Device( &vr->XAdvanceDevice );
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )
+    _HB_OPEN_Free_Device( &vr->YPlacementDevice );
+  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )
+    _HB_OPEN_Free_Device( &vr->XPlacementDevice );
+}
+
+
+static HB_Error  Get_ValueRecord( GPOS_Instance*    gpi,
+                                 HB_ValueRecord*  vr,
+                                 HB_UShort         format,
+                                 HB_Position      gd )
+{
+  HB_Fixed           value;
+  HB_Short         pixel_value;
+  HB_Error         error = HB_Err_Ok;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+
+  HB_UShort  x_ppem, y_ppem;
+  HB_16Dot16   x_scale, y_scale;
+
+
+  if ( !format )
+    return HB_Err_Ok;
+
+  x_ppem  = gpi->font->x_ppem;
+  y_ppem  = gpi->font->y_ppem;
+  x_scale = gpi->font->x_scale;
+  y_scale = gpi->font->y_scale;
+
+  /* design units -> fractional pixel */
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT )
+    gd->x_pos += x_scale * vr->XPlacement / 0x10000;
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT )
+    gd->y_pos += y_scale * vr->YPlacement / 0x10000;
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE )
+    gd->x_advance += x_scale * vr->XAdvance / 0x10000;
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE )
+    gd->y_advance += y_scale * vr->YAdvance / 0x10000;
+
+  if ( !gpi->dvi )
+  {
+    /* pixel -> fractional pixel */
+
+    if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )
+    {
+      _HB_OPEN_Get_Device( &vr->XPlacementDevice, x_ppem, &pixel_value );
+      gd->x_pos += pixel_value << 6;
+    }
+    if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )
+    {
+      _HB_OPEN_Get_Device( &vr->YPlacementDevice, y_ppem, &pixel_value );
+      gd->y_pos += pixel_value << 6;
+    }
+    if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )
+    {
+      _HB_OPEN_Get_Device( &vr->XAdvanceDevice, x_ppem, &pixel_value );
+      gd->x_advance += pixel_value << 6;
+    }
+    if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )
+    {
+      _HB_OPEN_Get_Device( &vr->YAdvanceDevice, y_ppem, &pixel_value );
+      gd->y_advance += pixel_value << 6;
+    }
+  }
+
+  /* values returned from mmfunc() are already in fractional pixels */
+
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT )
+  {
+    error = (gpos->mmfunc)( gpi->font, vr->XIdPlacement,
+                           &value, gpos->data );
+    if ( error )
+      return error;
+    gd->x_pos += value;
+  }
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT )
+  {
+    error = (gpos->mmfunc)( gpi->font, vr->YIdPlacement,
+                           &value, gpos->data );
+    if ( error )
+      return error;
+    gd->y_pos += value;
+  }
+  if ( format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE )
+  {
+    error = (gpos->mmfunc)( gpi->font, vr->XIdAdvance,
+                           &value, gpos->data );
+    if ( error )
+      return error;
+    gd->x_advance += value;
+  }
+  if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE )
+  {
+    error = (gpos->mmfunc)( gpi->font, vr->YIdAdvance,
+                           &value, gpos->data );
+    if ( error )
+      return error;
+    gd->y_advance += value;
+  }
+
+  return error;
+}
+
+
+/* AnchorFormat1 */
+/* AnchorFormat2 */
+/* AnchorFormat3 */
+/* AnchorFormat4 */
+
+static HB_Error  Load_Anchor( HB_Anchor*  an,
+                             HB_Stream    stream )
+{
+  HB_Error  error;
+
+  HB_UInt cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  an->PosFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( an->PosFormat )
+  {
+  case 1:
+    if ( ACCESS_Frame( 4L ) )
+      return error;
+
+    an->af.af1.XCoordinate = GET_Short();
+    an->af.af1.YCoordinate = GET_Short();
+
+    FORGET_Frame();
+    break;
+
+  case 2:
+    if ( ACCESS_Frame( 6L ) )
+      return error;
+
+    an->af.af2.XCoordinate = GET_Short();
+    an->af.af2.YCoordinate = GET_Short();
+    an->af.af2.AnchorPoint = GET_UShort();
+
+    FORGET_Frame();
+    break;
+
+  case 3:
+    if ( ACCESS_Frame( 6L ) )
+      return error;
+
+    an->af.af3.XCoordinate = GET_Short();
+    an->af.af3.YCoordinate = GET_Short();
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &an->af.af3.XDeviceTable,
+                                 stream ) ) != HB_Err_Ok )
+       return error;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      an->af.af3.XDeviceTable.StartSize  = 0;
+      an->af.af3.XDeviceTable.EndSize    = 0;
+      an->af.af3.XDeviceTable.DeltaValue = NULL;
+    }
+
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = _HB_OPEN_Load_Device( &an->af.af3.YDeviceTable,
+                                 stream ) ) != HB_Err_Ok )
+       goto Fail;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      an->af.af3.YDeviceTable.StartSize  = 0;
+      an->af.af3.YDeviceTable.EndSize    = 0;
+      an->af.af3.YDeviceTable.DeltaValue = NULL;
+    }
+    break;
+
+  case 4:
+    if ( ACCESS_Frame( 4L ) )
+      return error;
+
+    an->af.af4.XIdAnchor = GET_UShort();
+    an->af.af4.YIdAnchor = GET_UShort();
+
+    FORGET_Frame();
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );
+  return error;
+}
+
+
+static void  Free_Anchor( HB_Anchor*  an)
+{
+  if ( an->PosFormat == 3 )
+  {
+    _HB_OPEN_Free_Device( &an->af.af3.YDeviceTable );
+    _HB_OPEN_Free_Device( &an->af.af3.XDeviceTable );
+  }
+}
+
+
+static HB_Error  Get_Anchor( GPOS_Instance*   gpi,
+                            HB_Anchor*      an,
+                            HB_UShort        glyph_index,
+                            HB_Fixed*          x_value,
+                            HB_Fixed*          y_value )
+{
+  HB_Error  error = HB_Err_Ok;
+
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_UShort        ap;
+
+  HB_Short         pixel_value;
+
+  HB_UShort        x_ppem, y_ppem;
+  HB_16Dot16         x_scale, y_scale;
+
+
+  x_ppem  = gpi->font->x_ppem;
+  y_ppem  = gpi->font->y_ppem;
+  x_scale = gpi->font->x_scale;
+  y_scale = gpi->font->y_scale;
+
+  switch ( an->PosFormat )
+  {
+  case 0:
+    /* The special case of an empty AnchorTable */
+  default:
+
+    return HB_Err_Not_Covered;
+
+  case 1:
+    *x_value = x_scale * an->af.af1.XCoordinate / 0x10000;
+    *y_value = y_scale * an->af.af1.YCoordinate / 0x10000;
+    break;
+
+  case 2:
+    if ( !gpi->dvi )
+    {
+      hb_uint32 n_points = 0;
+      ap = an->af.af2.AnchorPoint;
+      if (!gpi->font->klass->getPointInOutline)
+          goto no_contour_point;
+      error = gpi->font->klass->getPointInOutline(gpi->font, glyph_index, gpi->load_flags, ap, x_value, y_value, &n_points);
+      if (error)
+          return error;
+      /* if n_points is set to zero, we use the design coordinate value pair.
+       * This can happen e.g. for sbit glyphs. */
+      if (!n_points)
+          goto no_contour_point;
+    }
+    else
+    {
+    no_contour_point:
+      *x_value = x_scale * an->af.af3.XCoordinate / 0x10000;
+      *y_value = y_scale * an->af.af3.YCoordinate / 0x10000;
+    }
+    break;
+
+  case 3:
+    if ( !gpi->dvi )
+    {
+      _HB_OPEN_Get_Device( &an->af.af3.XDeviceTable, x_ppem, &pixel_value );
+      *x_value = pixel_value << 6;
+      _HB_OPEN_Get_Device( &an->af.af3.YDeviceTable, y_ppem, &pixel_value );
+      *y_value = pixel_value << 6;
+    }
+    else
+      *x_value = *y_value = 0;
+
+    *x_value += x_scale * an->af.af3.XCoordinate / 0x10000;
+    *y_value += y_scale * an->af.af3.YCoordinate / 0x10000;
+    break;
+
+  case 4:
+    error = (gpos->mmfunc)( gpi->font, an->af.af4.XIdAnchor,
+                           x_value, gpos->data );
+    if ( error )
+      return error;
+
+    error = (gpos->mmfunc)( gpi->font, an->af.af4.YIdAnchor,
+                           y_value, gpos->data );
+    if ( error )
+      return error;
+    break;
+  }
+
+  return error;
+}
+
+
+/* MarkArray */
+
+static HB_Error  Load_MarkArray ( HB_MarkArray*  ma,
+                                 HB_Stream       stream )
+{
+  HB_Error  error;
+
+  HB_UShort        n, m, count;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_MarkRecord*  mr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ma->MarkCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ma->MarkRecord = NULL;
+
+  if ( ALLOC_ARRAY( ma->MarkRecord, count, HB_MarkRecord ) )
+    return error;
+
+  mr = ma->MarkRecord;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 4L ) )
+      goto Fail;
+
+    mr[n].Class = GET_UShort();
+    new_offset  = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_Anchor( &mr[n].MarkAnchor, stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_Anchor( &mr[m].MarkAnchor );
+
+  FREE( mr );
+  return error;
+}
+
+
+static void  Free_MarkArray( HB_MarkArray*  ma )
+{
+  HB_UShort        n, count;
+
+  HB_MarkRecord*  mr;
+
+
+  if ( ma->MarkRecord )
+  {
+    count = ma->MarkCount;
+    mr    = ma->MarkRecord;
+
+    for ( n = 0; n < count; n++ )
+      Free_Anchor( &mr[n].MarkAnchor );
+
+    FREE( mr );
+  }
+}
+
+
+/* LookupType 1 */
+
+/* SinglePosFormat1 */
+/* SinglePosFormat2 */
+
+static HB_Error  Load_SinglePos( HB_GPOS_SubTable* st,
+                                HB_Stream       stream )
+{
+  HB_Error  error;
+  HB_SinglePos*   sp = &st->single;
+
+  HB_UShort         n, m, count, format;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_ValueRecord*  vr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 6L ) )
+    return error;
+
+  sp->PosFormat = GET_UShort();
+  new_offset    = GET_UShort() + base_offset;
+
+  format = sp->ValueFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( !format )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &sp->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  switch ( sp->PosFormat )
+  {
+  case 1:
+    error = Load_ValueRecord( &sp->spf.spf1.Value, format,
+                             base_offset, stream );
+    if ( error )
+      goto Fail2;
+    break;
+
+  case 2:
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    count = sp->spf.spf2.ValueCount = GET_UShort();
+
+    FORGET_Frame();
+
+    sp->spf.spf2.Value = NULL;
+
+    if ( ALLOC_ARRAY( sp->spf.spf2.Value, count, HB_ValueRecord ) )
+      goto Fail2;
+
+    vr = sp->spf.spf2.Value;
+
+    for ( n = 0; n < count; n++ )
+    {
+      error = Load_ValueRecord( &vr[n], format, base_offset, stream );
+      if ( error )
+       goto Fail1;
+    }
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_ValueRecord( &vr[m], format );
+
+  FREE( vr );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &sp->Coverage );
+  return error;
+}
+
+
+static void  Free_SinglePos( HB_GPOS_SubTable* st )
+{
+  HB_UShort         n, count, format;
+  HB_SinglePos*   sp = &st->single;
+
+  HB_ValueRecord*  v;
+
+
+  format = sp->ValueFormat;
+
+  switch ( sp->PosFormat )
+  {
+  case 1:
+    Free_ValueRecord( &sp->spf.spf1.Value, format );
+    break;
+
+  case 2:
+    if ( sp->spf.spf2.Value )
+    {
+      count = sp->spf.spf2.ValueCount;
+      v     = sp->spf.spf2.Value;
+
+      for ( n = 0; n < count; n++ )
+       Free_ValueRecord( &v[n], format );
+
+      FREE( v );
+    }
+    break;
+  default:
+    break;
+  }
+
+  _HB_OPEN_Free_Coverage( &sp->Coverage );
+}
+
+static HB_Error  Lookup_SinglePos( GPOS_Instance*    gpi,
+                                  HB_GPOS_SubTable* st,
+                                  HB_Buffer        buffer,
+                                  HB_UShort         flags,
+                                  HB_UShort         context_length,
+                                  int               nesting_level )
+{
+  HB_UShort        index, property;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_SinglePos*   sp = &st->single;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &sp->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  switch ( sp->PosFormat )
+  {
+  case 1:
+    error = Get_ValueRecord( gpi, &sp->spf.spf1.Value,
+                            sp->ValueFormat, POSITION( buffer->in_pos ) );
+    if ( error )
+      return error;
+    break;
+
+  case 2:
+    if ( index >= sp->spf.spf2.ValueCount )
+      return ERR_HB(HB_Err_Invalid_SubTable);
+    error = Get_ValueRecord( gpi, &sp->spf.spf2.Value[index],
+                            sp->ValueFormat, POSITION( buffer->in_pos ) );
+    if ( error )
+      return error;
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable);
+  }
+
+  (buffer->in_pos)++;
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 2 */
+
+/* PairSet */
+
+static HB_Error  Load_PairSet ( HB_PairSet*  ps,
+                               HB_UShort     format1,
+                               HB_UShort     format2,
+                               HB_Stream     stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, m, count;
+  HB_UInt              base_offset;
+
+  HB_PairValueRecord*  pvr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ps->PairValueCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ps->PairValueRecord = NULL;
+
+  if ( ALLOC_ARRAY( ps->PairValueRecord, count, HB_PairValueRecord ) )
+    return error;
+
+  pvr = ps->PairValueRecord;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    pvr[n].SecondGlyph = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( format1 )
+    {
+      error = Load_ValueRecord( &pvr[n].Value1, format1,
+                               base_offset, stream );
+      if ( error )
+       goto Fail;
+    }
+    if ( format2 )
+    {
+      error = Load_ValueRecord( &pvr[n].Value2, format2,
+                               base_offset, stream );
+      if ( error )
+      {
+       if ( format1 )
+         Free_ValueRecord( &pvr[n].Value1, format1 );
+       goto Fail;
+      }
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+  {
+    if ( format1 )
+      Free_ValueRecord( &pvr[m].Value1, format1 );
+    if ( format2 )
+      Free_ValueRecord( &pvr[m].Value2, format2 );
+  }
+
+  FREE( pvr );
+  return error;
+}
+
+
+static void  Free_PairSet( HB_PairSet*  ps,
+                          HB_UShort     format1,
+                          HB_UShort     format2 )
+{
+  HB_UShort             n, count;
+
+  HB_PairValueRecord*  pvr;
+
+
+  if ( ps->PairValueRecord )
+  {
+    count = ps->PairValueCount;
+    pvr   = ps->PairValueRecord;
+
+    for ( n = 0; n < count; n++ )
+    {
+      if ( format1 )
+       Free_ValueRecord( &pvr[n].Value1, format1 );
+      if ( format2 )
+       Free_ValueRecord( &pvr[n].Value2, format2 );
+    }
+
+    FREE( pvr );
+  }
+}
+
+
+/* PairPosFormat1 */
+
+static HB_Error  Load_PairPos1( HB_PairPosFormat1*  ppf1,
+                               HB_UShort            format1,
+                               HB_UShort            format2,
+                               HB_Stream            stream )
+{
+  HB_Error  error;
+
+  HB_UShort     n, m, count;
+  HB_UInt      cur_offset, new_offset, base_offset;
+
+  HB_PairSet*  ps;
+
+
+  base_offset = FILE_Pos() - 8L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ppf1->PairSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ppf1->PairSet = NULL;
+
+  if ( ALLOC_ARRAY( ppf1->PairSet, count, HB_PairSet ) )
+    return error;
+
+  ps = ppf1->PairSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_PairSet( &ps[n], format1,
+                                format2, stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_PairSet( &ps[m], format1, format2 );
+
+  FREE( ps );
+  return error;
+}
+
+
+static void  Free_PairPos1( HB_PairPosFormat1*  ppf1,
+                           HB_UShort            format1,
+                           HB_UShort            format2 )
+{
+  HB_UShort     n, count;
+
+  HB_PairSet*  ps;
+
+
+  if ( ppf1->PairSet )
+  {
+    count = ppf1->PairSetCount;
+    ps    = ppf1->PairSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_PairSet( &ps[n], format1, format2 );
+
+    FREE( ps );
+  }
+}
+
+
+/* PairPosFormat2 */
+
+static HB_Error  Load_PairPos2( HB_PairPosFormat2*  ppf2,
+                               HB_UShort            format1,
+                               HB_UShort            format2,
+                               HB_Stream            stream )
+{
+  HB_Error  error;
+
+  HB_UShort          m, n, k, count1, count2;
+  HB_UInt           cur_offset, new_offset1, new_offset2, base_offset;
+
+  HB_Class1Record*  c1r;
+  HB_Class2Record*  c2r;
+
+
+  base_offset = FILE_Pos() - 8L;
+
+  if ( ACCESS_Frame( 8L ) )
+    return error;
+
+  new_offset1 = GET_UShort() + base_offset;
+  new_offset2 = GET_UShort() + base_offset;
+
+  /* `Class1Count' and `Class2Count' are the upper limits for klass
+     values, thus we read it now to make additional safety checks.  */
+
+  count1 = ppf2->Class1Count = GET_UShort();
+  count2 = ppf2->Class2Count = GET_UShort();
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset1 ) ||
+       ( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef1, count1,
+                                      stream ) ) != HB_Err_Ok )
+    return error;
+  if ( FILE_Seek( new_offset2 ) ||
+       ( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef2, count2,
+                                      stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  ppf2->Class1Record = NULL;
+
+  if ( ALLOC_ARRAY( ppf2->Class1Record, count1, HB_Class1Record ) )
+    goto Fail2;
+
+  c1r = ppf2->Class1Record;
+
+  for ( m = 0; m < count1; m++ )
+  {
+    c1r[m].Class2Record = NULL;
+
+    if ( ALLOC_ARRAY( c1r[m].Class2Record, count2, HB_Class2Record ) )
+      goto Fail1;
+
+    c2r = c1r[m].Class2Record;
+
+    for ( n = 0; n < count2; n++ )
+    {
+      if ( format1 )
+      {
+       error = Load_ValueRecord( &c2r[n].Value1, format1,
+                                 base_offset, stream );
+       if ( error )
+         goto Fail0;
+      }
+      if ( format2 )
+      {
+       error = Load_ValueRecord( &c2r[n].Value2, format2,
+                                 base_offset, stream );
+       if ( error )
+       {
+         if ( format1 )
+           Free_ValueRecord( &c2r[n].Value1, format1 );
+         goto Fail0;
+       }
+      }
+    }
+
+    continue;
+
+  Fail0:
+    for ( k = 0; k < n; k++ )
+    {
+      if ( format1 )
+       Free_ValueRecord( &c2r[k].Value1, format1 );
+      if ( format2 )
+       Free_ValueRecord( &c2r[k].Value2, format2 );
+    }
+    goto Fail1;
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( k = 0; k < m; k++ )
+  {
+    c2r = c1r[k].Class2Record;
+
+    for ( n = 0; n < count2; n++ )
+    {
+      if ( format1 )
+       Free_ValueRecord( &c2r[n].Value1, format1 );
+      if ( format2 )
+       Free_ValueRecord( &c2r[n].Value2, format2 );
+    }
+
+    FREE( c2r );
+  }
+
+  FREE( c1r );
+Fail2:
+
+  _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 );
+
+Fail3:
+  _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 );
+  return error;
+}
+
+
+static void  Free_PairPos2( HB_PairPosFormat2*  ppf2,
+                           HB_UShort            format1,
+                           HB_UShort            format2)
+{
+  HB_UShort          m, n, count1, count2;
+
+  HB_Class1Record*  c1r;
+  HB_Class2Record*  c2r;
+
+
+  if ( ppf2->Class1Record )
+  {
+    c1r    = ppf2->Class1Record;
+    count1 = ppf2->Class1Count;
+    count2 = ppf2->Class2Count;
+
+    for ( m = 0; m < count1; m++ )
+    {
+      c2r = c1r[m].Class2Record;
+
+      for ( n = 0; n < count2; n++ )
+      {
+       if ( format1 )
+         Free_ValueRecord( &c2r[n].Value1, format1 );
+       if ( format2 )
+         Free_ValueRecord( &c2r[n].Value2, format2 );
+      }
+
+      FREE( c2r );
+    }
+
+    FREE( c1r );
+
+    _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef2 );
+    _HB_OPEN_Free_ClassDefinition( &ppf2->ClassDef1 );
+  }
+}
+
+
+static HB_Error  Load_PairPos( HB_GPOS_SubTable* st,
+                              HB_Stream     stream )
+{
+  HB_Error  error;
+  HB_PairPos*     pp = &st->pair;
+
+  HB_UShort         format1, format2;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 8L ) )
+    return error;
+
+  pp->PosFormat = GET_UShort();
+  new_offset    = GET_UShort() + base_offset;
+
+  format1 = pp->ValueFormat1 = GET_UShort();
+  format2 = pp->ValueFormat2 = GET_UShort();
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &pp->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  switch ( pp->PosFormat )
+  {
+  case 1:
+    error = Load_PairPos1( &pp->ppf.ppf1, format1, format2, stream );
+    if ( error )
+      goto Fail;
+    break;
+
+  case 2:
+    error = Load_PairPos2( &pp->ppf.ppf2, format1, format2, stream );
+    if ( error )
+      goto Fail;
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  _HB_OPEN_Free_Coverage( &pp->Coverage );
+  return error;
+}
+
+
+static void  Free_PairPos( HB_GPOS_SubTable* st )
+{
+  HB_UShort  format1, format2;
+  HB_PairPos*     pp = &st->pair;
+
+
+  format1 = pp->ValueFormat1;
+  format2 = pp->ValueFormat2;
+
+  switch ( pp->PosFormat )
+  {
+  case 1:
+    Free_PairPos1( &pp->ppf.ppf1, format1, format2 );
+    break;
+
+  case 2:
+    Free_PairPos2( &pp->ppf.ppf2, format1, format2 );
+    break;
+
+  default:
+    break;
+  }
+
+  _HB_OPEN_Free_Coverage( &pp->Coverage );
+}
+
+
+static HB_Error  Lookup_PairPos1( GPOS_Instance*       gpi,
+                                 HB_PairPosFormat1*  ppf1,
+                                 HB_Buffer           buffer,
+                                 HB_UInt              first_pos,
+                                 HB_UShort            index,
+                                 HB_UShort            format1,
+                                 HB_UShort            format2 )
+{
+  HB_Error              error;
+  HB_UShort             numpvr, glyph2;
+
+  HB_PairValueRecord*  pvr;
+
+
+  if ( index >= ppf1->PairSetCount )
+     return ERR_HB(HB_Err_Invalid_SubTable);
+
+  pvr = ppf1->PairSet[index].PairValueRecord;
+  if ( !pvr )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  glyph2 = IN_CURGLYPH();
+
+  for ( numpvr = ppf1->PairSet[index].PairValueCount;
+       numpvr;
+       numpvr--, pvr++ )
+  {
+    if ( glyph2 == pvr->SecondGlyph )
+    {
+      error = Get_ValueRecord( gpi, &pvr->Value1, format1,
+                              POSITION( first_pos ) );
+      if ( error )
+       return error;
+      return Get_ValueRecord( gpi, &pvr->Value2, format2,
+                             POSITION( buffer->in_pos ) );
+    }
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Lookup_PairPos2( GPOS_Instance*       gpi,
+                                 HB_PairPosFormat2*  ppf2,
+                                 HB_Buffer           buffer,
+                                 HB_UInt              first_pos,
+                                 HB_UShort            format1,
+                                 HB_UShort            format2 )
+{
+  HB_Error           error;
+  HB_UShort          cl1 = 0, cl2 = 0; /* shut compiler up */
+
+  HB_Class1Record*  c1r;
+  HB_Class2Record*  c2r;
+
+
+  error = _HB_OPEN_Get_Class( &ppf2->ClassDef1, IN_GLYPH( first_pos ),
+                    &cl1, NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    return error;
+  error = _HB_OPEN_Get_Class( &ppf2->ClassDef2, IN_CURGLYPH(),
+                    &cl2, NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    return error;
+
+  c1r = &ppf2->Class1Record[cl1];
+  if ( !c1r )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+  c2r = &c1r->Class2Record[cl2];
+
+  error = Get_ValueRecord( gpi, &c2r->Value1, format1, POSITION( first_pos ) );
+  if ( error )
+    return error;
+  return Get_ValueRecord( gpi, &c2r->Value2, format2, POSITION( buffer->in_pos ) );
+}
+
+
+static HB_Error  Lookup_PairPos( GPOS_Instance*    gpi,
+                                HB_GPOS_SubTable* st,
+                                HB_Buffer        buffer,
+                                HB_UShort         flags,
+                                HB_UShort         context_length,
+                                int               nesting_level )
+{
+  HB_Error         error;
+  HB_UShort        index, property;
+  HB_UInt          first_pos;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_PairPos*     pp = &st->pair;
+
+  HB_UNUSED(nesting_level);
+
+  if ( buffer->in_pos >= buffer->in_length - 1 )
+    return HB_Err_Not_Covered;           /* Not enough glyphs in stream */
+
+  if ( context_length != 0xFFFF && context_length < 2 )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &pp->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  /* second glyph */
+
+  first_pos = buffer->in_pos;
+  (buffer->in_pos)++;
+
+  while ( CHECK_Property( gpos->gdef, IN_CURITEM(),
+                         flags, &property ) )
+  {
+    if ( error && error != HB_Err_Not_Covered )
+      return error;
+
+    if ( buffer->in_pos == buffer->in_length )
+      {
+       buffer->in_pos = first_pos;
+        return HB_Err_Not_Covered;
+      }
+    (buffer->in_pos)++;
+
+  }
+
+  switch ( pp->PosFormat )
+  {
+  case 1:
+    error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, buffer,
+                            first_pos, index,
+                            pp->ValueFormat1, pp->ValueFormat2 );
+    break;
+
+  case 2:
+    error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, buffer, first_pos,
+                            pp->ValueFormat1, pp->ValueFormat2 );
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  /* if we don't have coverage for the second glyph don't skip it for
+     further lookups but reset in_pos back to the first_glyph and let
+     the caller in Do_String_Lookup increment in_pos */
+  if ( error == HB_Err_Not_Covered )
+      buffer->in_pos = first_pos;
+
+  /* adjusting the `next' glyph */
+
+  if ( pp->ValueFormat2 )
+    (buffer->in_pos)++;
+
+  return error;
+}
+
+
+/* LookupType 3 */
+
+/* CursivePosFormat1 */
+
+static HB_Error  Load_CursivePos( HB_GPOS_SubTable* st,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+  HB_CursivePos*  cp = &st->cursive;
+
+  HB_UShort             n, m, count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_EntryExitRecord*  eer;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  cp->PosFormat = GET_UShort();
+  new_offset    = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &cp->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = cp->EntryExitCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cp->EntryExitRecord = NULL;
+
+  if ( ALLOC_ARRAY( cp->EntryExitRecord, count, HB_EntryExitRecord ) )
+    goto Fail2;
+
+  eer = cp->EntryExitRecord;
+
+  for ( n = 0; n < count; n++ )
+  {
+    HB_UInt entry_offset;
+
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    entry_offset = new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_Anchor( &eer[n].EntryAnchor,
+                                 stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      eer[n].EntryAnchor.PosFormat   = 0;
+
+    if ( ACCESS_Frame( 2L ) )
+      return error;
+
+    new_offset = GET_UShort();
+
+    FORGET_Frame();
+
+    if ( new_offset )
+    {
+      new_offset += base_offset;
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_Anchor( &eer[n].ExitAnchor,
+                                 stream ) ) != HB_Err_Ok )
+      {
+       if ( entry_offset )
+         Free_Anchor( &eer[n].EntryAnchor );
+       goto Fail1;
+      }
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+      eer[n].ExitAnchor.PosFormat   = 0;
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+  {
+    Free_Anchor( &eer[m].EntryAnchor );
+    Free_Anchor( &eer[m].ExitAnchor );
+  }
+
+  FREE( eer );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &cp->Coverage );
+  return error;
+}
+
+
+static void  Free_CursivePos( HB_GPOS_SubTable* st )
+{
+  HB_UShort             n, count;
+  HB_CursivePos*  cp = &st->cursive;
+
+  HB_EntryExitRecord*  eer;
+
+
+  if ( cp->EntryExitRecord )
+  {
+    count = cp->EntryExitCount;
+    eer   = cp->EntryExitRecord;
+
+    for ( n = 0; n < count; n++ )
+    {
+      Free_Anchor( &eer[n].EntryAnchor );
+      Free_Anchor( &eer[n].ExitAnchor );
+    }
+
+    FREE( eer );
+  }
+
+  _HB_OPEN_Free_Coverage( &cp->Coverage );
+}
+
+
+static HB_Error  Lookup_CursivePos( GPOS_Instance*    gpi,
+                                   HB_GPOS_SubTable* st,
+                                   HB_Buffer        buffer,
+                                   HB_UShort         flags,
+                                   HB_UShort         context_length,
+                                   int               nesting_level )
+{
+  HB_UShort        index, property;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_CursivePos*  cp = &st->cursive;
+
+  HB_EntryExitRecord*  eer;
+  HB_Fixed                entry_x, entry_y;
+  HB_Fixed                exit_x, exit_y;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+  {
+    gpi->last = 0xFFFF;
+    return HB_Err_Not_Covered;
+  }
+
+  /* Glyphs not having the right GDEF properties will be ignored, i.e.,
+     gpi->last won't be reset (contrary to user defined properties). */
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  /* We don't handle mark glyphs here.  According to Andrei, this isn't
+     possible, but who knows...                                         */
+
+  if ( property == HB_GDEF_MARK )
+  {
+    gpi->last = 0xFFFF;
+    return HB_Err_Not_Covered;
+  }
+
+  error = _HB_OPEN_Coverage_Index( &cp->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+  {
+    gpi->last = 0xFFFF;
+    return error;
+  }
+
+  if ( index >= cp->EntryExitCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  eer = &cp->EntryExitRecord[index];
+
+  /* Now comes the messiest part of the whole OpenType
+     specification.  At first glance, cursive connections seem easy
+     to understand, but there are pitfalls!  The reason is that
+     the specs don't mention how to compute the advance values
+     resp. glyph offsets.  I was told it would be an omission, to
+     be fixed in the next OpenType version...  Again many thanks to
+     Andrei Burago <andreib@microsoft.com> for clarifications.
+
+     Consider the following example:
+
+                     |  xadv1    |
+                      +---------+
+                      |         |
+                +-----+--+ 1    |
+                |     | .|      |
+                |    0+--+------+
+                |   2    |
+                |        |
+               0+--------+
+               |  xadv2   |
+
+       glyph1: advance width = 12
+              anchor point = (3,1)
+
+       glyph2: advance width = 11
+              anchor point = (9,4)
+
+       LSB is 1 for both glyphs (so the boxes drawn above are glyph
+       bboxes).  Writing direction is R2L; `0' denotes the glyph's
+       coordinate origin.
+
+     Now the surprising part: The advance width of the *left* glyph
+     (resp. of the *bottom* glyph) will be modified, no matter
+     whether the writing direction is L2R or R2L (resp. T2B or
+     B2T)!  This assymetry is caused by the fact that the glyph's
+     coordinate origin is always the lower left corner for all
+     writing directions.
+
+     Continuing the above example, we can compute the new
+     (horizontal) advance width of glyph2 as
+
+       9 - 3 = 6  ,
+
+     and the new vertical offset of glyph2 as
+
+       1 - 4 = -3  .
+
+
+     Vertical writing direction is far more complicated:
+
+     a) Assuming that we recompute the advance height of the lower glyph:
+
+                                 --
+                      +---------+
+             --       |         |
+                +-----+--+ 1    | yadv1
+                |     | .|      |
+          yadv2 |    0+--+------+        -- BSB1  --
+                |   2    |       --      --        y_offset
+                |        |
+   BSB2 --      0+--------+                        --
+       --    --
+
+       glyph1: advance height = 6
+              anchor point = (3,1)
+
+       glyph2: advance height = 7
+              anchor point = (9,4)
+
+       TSB is 1 for both glyphs; writing direction is T2B.
+
+
+        BSB1     = yadv1 - (TSB1 + ymax1)
+        BSB2     = yadv2 - (TSB2 + ymax2)
+        y_offset = y2 - y1
+
+       vertical advance width of glyph2
+        = y_offset + BSB2 - BSB1
+        = (y2 - y1) + (yadv2 - (TSB2 + ymax2)) - (yadv1 - (TSB1 + ymax1))
+        = y2 - y1 + yadv2 - TSB2 - ymax2 - (yadv1 - TSB1 - ymax1)
+        = y2 - y1 + yadv2 - TSB2 - ymax2 - yadv1 + TSB1 + ymax1
+
+
+     b) Assuming that we recompute the advance height of the upper glyph:
+
+                                 --      --
+                      +---------+        -- TSB1
+       --    --       |         |
+   TSB2 --       +-----+--+ 1    | yadv1   ymax1
+                |     | .|      |
+          yadv2 |    0+--+------+        --       --
+    ymax2        |   2    |       --                y_offset
+                |        |
+       --      0+--------+                        --
+             --
+
+       glyph1: advance height = 6
+              anchor point = (3,1)
+
+       glyph2: advance height = 7
+              anchor point = (9,4)
+
+       TSB is 1 for both glyphs; writing direction is T2B.
+
+       y_offset = y2 - y1
+
+       vertical advance width of glyph2
+        = TSB1 + ymax1 + y_offset - (TSB2 + ymax2)
+        = TSB1 + ymax1 + y2 - y1 - TSB2 - ymax2
+
+
+     Comparing a) with b) shows that b) is easier to compute.  I'll wait
+     for a reply from Andrei to see what should really be implemented...
+
+     Since horizontal advance widths or vertical advance heights
+     can be used alone but not together, no ambiguity occurs.        */
+
+  if ( gpi->last == 0xFFFF )
+    goto end;
+
+  /* Get_Anchor() returns HB_Err_Not_Covered if there is no anchor
+     table.                                                         */
+
+  error = Get_Anchor( gpi, &eer->EntryAnchor, IN_CURGLYPH(),
+                     &entry_x, &entry_y );
+  if ( error == HB_Err_Not_Covered )
+    goto end;
+  if ( error )
+    return error;
+
+  if ( gpi->r2l )
+  {
+    POSITION( buffer->in_pos )->x_advance   = entry_x - gpi->anchor_x;
+    POSITION( buffer->in_pos )->new_advance = TRUE;
+  }
+  else
+  {
+    POSITION( gpi->last )->x_advance   = gpi->anchor_x - entry_x;
+    POSITION( gpi->last )->new_advance = TRUE;
+  }
+
+  if ( flags & HB_LOOKUP_FLAG_RIGHT_TO_LEFT )
+  {
+    POSITION( gpi->last )->cursive_chain = gpi->last - buffer->in_pos;
+    POSITION( gpi->last )->y_pos = entry_y - gpi->anchor_y;
+  }
+  else
+  {
+    POSITION( buffer->in_pos )->cursive_chain = buffer->in_pos - gpi->last;
+    POSITION( buffer->in_pos )->y_pos = gpi->anchor_y - entry_y;
+  }
+
+end:
+  error = Get_Anchor( gpi, &eer->ExitAnchor, IN_CURGLYPH(),
+                     &exit_x, &exit_y );
+  if ( error == HB_Err_Not_Covered )
+    gpi->last = 0xFFFF;
+  else
+  {
+    gpi->last     = buffer->in_pos;
+    gpi->anchor_x = exit_x;
+    gpi->anchor_y = exit_y;
+  }
+  if ( error )
+    return error;
+
+  (buffer->in_pos)++;
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 4 */
+
+/* BaseArray */
+
+static HB_Error  Load_BaseArray( HB_BaseArray*  ba,
+                                HB_UShort       num_classes,
+                                HB_Stream       stream )
+{
+  HB_Error  error;
+
+  HB_UShort       m, n, count;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_BaseRecord  *br;
+  HB_Anchor      *ban, *bans;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ba->BaseCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ba->BaseRecord = NULL;
+
+  if ( ALLOC_ARRAY( ba->BaseRecord, count, HB_BaseRecord ) )
+    return error;
+
+  br = ba->BaseRecord;
+
+  bans = NULL;
+
+  if ( ALLOC_ARRAY( bans, count * num_classes, HB_Anchor ) )
+    goto Fail;
+
+  for ( m = 0; m < count; m++ )
+  {
+    br[m].BaseAnchor = NULL;
+
+    ban = br[m].BaseAnchor = bans + m * num_classes;
+
+    for ( n = 0; n < num_classes; n++ )
+    {
+      if ( ACCESS_Frame( 2L ) )
+       goto Fail;
+
+      new_offset = GET_UShort() + base_offset;
+
+      FORGET_Frame();
+
+      if (new_offset == base_offset) {
+       /* XXX
+        * Doulos SIL Regular is buggy and has zero offsets here.
+        * Skip it
+        */
+       ban[n].PosFormat = 0;
+       continue;
+      }
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_Anchor( &ban[n], stream ) ) != HB_Err_Ok )
+       goto Fail;
+      (void)FILE_Seek( cur_offset );
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  FREE( bans );
+  FREE( br );
+  return error;
+}
+
+
+static void  Free_BaseArray( HB_BaseArray*  ba,
+                            HB_UShort       num_classes )
+{
+  HB_BaseRecord  *br;
+  HB_Anchor      *bans;
+
+  if ( ba->BaseRecord )
+  {
+    br    = ba->BaseRecord;
+
+    if ( ba->BaseCount )
+    {
+      HB_UShort i, count;
+      count = num_classes * ba->BaseCount;
+      bans = br[0].BaseAnchor;
+      for (i = 0; i < count; i++)
+        Free_Anchor (&bans[i]);
+      FREE( bans );
+    }
+
+    FREE( br );
+  }
+}
+
+
+/* MarkBasePosFormat1 */
+
+static HB_Error  Load_MarkBasePos( HB_GPOS_SubTable* st,
+                                  HB_Stream         stream )
+{
+  HB_Error  error;
+  HB_MarkBasePos* mbp = &st->markbase;
+
+  HB_UInt  cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  mbp->PosFormat = GET_UShort();
+  new_offset     = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  if (mbp->PosFormat != 1)
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mbp->MarkCoverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mbp->BaseCoverage, stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 4L ) )
+    goto Fail2;
+
+  mbp->ClassCount = GET_UShort();
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_MarkArray( &mbp->MarkArray, stream ) ) != HB_Err_Ok )
+    goto Fail2;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail1;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_BaseArray( &mbp->BaseArray, mbp->ClassCount,
+                                stream ) ) != HB_Err_Ok )
+    goto Fail1;
+
+  return HB_Err_Ok;
+
+Fail1:
+  Free_MarkArray( &mbp->MarkArray );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &mbp->BaseCoverage );
+
+Fail3:
+  _HB_OPEN_Free_Coverage( &mbp->MarkCoverage );
+  return error;
+}
+
+
+static void  Free_MarkBasePos( HB_GPOS_SubTable* st )
+{
+  HB_MarkBasePos* mbp = &st->markbase;
+
+  Free_BaseArray( &mbp->BaseArray, mbp->ClassCount );
+  Free_MarkArray( &mbp->MarkArray );
+  _HB_OPEN_Free_Coverage( &mbp->BaseCoverage );
+  _HB_OPEN_Free_Coverage( &mbp->MarkCoverage );
+}
+
+
+static HB_Error  Lookup_MarkBasePos( GPOS_Instance*    gpi,
+                                    HB_GPOS_SubTable* st,
+                                    HB_Buffer        buffer,
+                                    HB_UShort         flags,
+                                    HB_UShort         context_length,
+                                    int               nesting_level )
+{
+  HB_UShort        i, j, mark_index, base_index, property, klass;
+  HB_Fixed           x_mark_value, y_mark_value, x_base_value, y_base_value;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_MarkBasePos* mbp = &st->markbase;
+
+  HB_MarkArray*   ma;
+  HB_BaseArray*   ba;
+  HB_BaseRecord*  br;
+  HB_Anchor*      mark_anchor;
+  HB_Anchor*      base_anchor;
+
+  HB_Position     o;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( flags & HB_LOOKUP_FLAG_IGNORE_BASE_GLYPHS )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(),
+                      flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &mbp->MarkCoverage, IN_CURGLYPH(),
+                         &mark_index );
+  if ( error )
+    return error;
+
+  /* now we search backwards for a non-mark glyph */
+
+  i = 1;
+  j = buffer->in_pos - 1;
+
+  while ( i <= buffer->in_pos )
+  {
+    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),
+                                       &property );
+    if ( error )
+      return error;
+
+    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )
+      break;
+
+    i++;
+    j--;
+  }
+
+  /* The following assertion is too strong -- at least for mangal.ttf. */
+#if 0
+  if ( property != HB_GDEF_BASE_GLYPH )
+    return HB_Err_Not_Covered;
+#endif
+
+  if ( i > buffer->in_pos )
+    return HB_Err_Not_Covered;
+
+  error = _HB_OPEN_Coverage_Index( &mbp->BaseCoverage, IN_GLYPH( j ),
+                         &base_index );
+  if ( error )
+    return error;
+
+  ma = &mbp->MarkArray;
+
+  if ( mark_index >= ma->MarkCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  klass       = ma->MarkRecord[mark_index].Class;
+  mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;
+
+  if ( klass >= mbp->ClassCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  ba = &mbp->BaseArray;
+
+  if ( base_index >= ba->BaseCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  br          = &ba->BaseRecord[base_index];
+  base_anchor = &br->BaseAnchor[klass];
+
+  error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(),
+                     &x_mark_value, &y_mark_value );
+  if ( error )
+    return error;
+
+  error = Get_Anchor( gpi, base_anchor, IN_GLYPH( j ),
+                     &x_base_value, &y_base_value );
+  if ( error )
+    return error;
+
+  /* anchor points are not cumulative */
+
+  o = POSITION( buffer->in_pos );
+
+  o->x_pos     = x_base_value - x_mark_value;
+  o->y_pos     = y_base_value - y_mark_value;
+  o->x_advance = 0;
+  o->y_advance = 0;
+  o->back      = i;
+
+  (buffer->in_pos)++;
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 5 */
+
+/* LigatureAttach */
+
+static HB_Error  Load_LigatureAttach( HB_LigatureAttach*  lat,
+                                     HB_UShort            num_classes,
+                                     HB_Stream            stream )
+{
+  HB_Error  error;
+
+  HB_UShort             m, n, k, count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_ComponentRecord*  cr;
+  HB_Anchor*           lan;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = lat->ComponentCount = GET_UShort();
+
+  FORGET_Frame();
+
+  lat->ComponentRecord = NULL;
+
+  if ( ALLOC_ARRAY( lat->ComponentRecord, count, HB_ComponentRecord ) )
+    return error;
+
+  cr = lat->ComponentRecord;
+
+  for ( m = 0; m < count; m++ )
+  {
+    cr[m].LigatureAnchor = NULL;
+
+    if ( ALLOC_ARRAY( cr[m].LigatureAnchor, num_classes, HB_Anchor ) )
+      goto Fail;
+
+    lan = cr[m].LigatureAnchor;
+
+    for ( n = 0; n < num_classes; n++ )
+    {
+      if ( ACCESS_Frame( 2L ) )
+       goto Fail0;
+
+      new_offset = GET_UShort();
+
+      FORGET_Frame();
+
+      if ( new_offset )
+      {
+       new_offset += base_offset;
+
+       cur_offset = FILE_Pos();
+       if ( FILE_Seek( new_offset ) ||
+            ( error = Load_Anchor( &lan[n], stream ) ) != HB_Err_Ok )
+         goto Fail0;
+       (void)FILE_Seek( cur_offset );
+      }
+      else
+       lan[n].PosFormat = 0;
+    }
+
+    continue;
+  Fail0:
+    for ( k = 0; k < n; k++ )
+      Free_Anchor( &lan[k] );
+    goto Fail;
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( k = 0; k < m; k++ )
+  {
+    lan = cr[k].LigatureAnchor;
+
+    for ( n = 0; n < num_classes; n++ )
+      Free_Anchor( &lan[n] );
+
+    FREE( lan );
+  }
+
+  FREE( cr );
+  return error;
+}
+
+
+static void  Free_LigatureAttach( HB_LigatureAttach*  lat,
+                                 HB_UShort            num_classes )
+{
+  HB_UShort        m, n, count;
+
+  HB_ComponentRecord*  cr;
+  HB_Anchor*           lan;
+
+
+  if ( lat->ComponentRecord )
+  {
+    count = lat->ComponentCount;
+    cr    = lat->ComponentRecord;
+
+    for ( m = 0; m < count; m++ )
+    {
+      lan = cr[m].LigatureAnchor;
+
+      for ( n = 0; n < num_classes; n++ )
+       Free_Anchor( &lan[n] );
+
+      FREE( lan );
+    }
+
+    FREE( cr );
+  }
+}
+
+
+/* LigatureArray */
+
+static HB_Error  Load_LigatureArray( HB_LigatureArray*  la,
+                                    HB_UShort           num_classes,
+                                    HB_Stream           stream )
+{
+  HB_Error  error;
+
+  HB_UShort            n, m, count;
+  HB_UInt             cur_offset, new_offset, base_offset;
+
+  HB_LigatureAttach*  lat;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = la->LigatureCount = GET_UShort();
+
+  FORGET_Frame();
+
+  la->LigatureAttach = NULL;
+
+  if ( ALLOC_ARRAY( la->LigatureAttach, count, HB_LigatureAttach ) )
+    return error;
+
+  lat = la->LigatureAttach;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LigatureAttach( &lat[n], num_classes,
+                                       stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_LigatureAttach( &lat[m], num_classes );
+
+  FREE( lat );
+  return error;
+}
+
+
+static void  Free_LigatureArray( HB_LigatureArray*  la,
+                                HB_UShort           num_classes )
+{
+  HB_UShort            n, count;
+
+  HB_LigatureAttach*  lat;
+
+
+  if ( la->LigatureAttach )
+  {
+    count = la->LigatureCount;
+    lat   = la->LigatureAttach;
+
+    for ( n = 0; n < count; n++ )
+      Free_LigatureAttach( &lat[n], num_classes );
+
+    FREE( lat );
+  }
+}
+
+
+/* MarkLigPosFormat1 */
+
+static HB_Error  Load_MarkLigPos( HB_GPOS_SubTable* st,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+  HB_MarkLigPos*  mlp = &st->marklig;
+
+  HB_UInt  cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  mlp->PosFormat = GET_UShort();
+  new_offset     = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mlp->MarkCoverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mlp->LigatureCoverage,
+                               stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 4L ) )
+    goto Fail2;
+
+  mlp->ClassCount = GET_UShort();
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_MarkArray( &mlp->MarkArray, stream ) ) != HB_Err_Ok )
+    goto Fail2;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail1;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_LigatureArray( &mlp->LigatureArray, mlp->ClassCount,
+                                    stream ) ) != HB_Err_Ok )
+    goto Fail1;
+
+  return HB_Err_Ok;
+
+Fail1:
+  Free_MarkArray( &mlp->MarkArray );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage );
+
+Fail3:
+  _HB_OPEN_Free_Coverage( &mlp->MarkCoverage );
+  return error;
+}
+
+
+static void  Free_MarkLigPos( HB_GPOS_SubTable* st)
+{
+  HB_MarkLigPos*  mlp = &st->marklig;
+
+  Free_LigatureArray( &mlp->LigatureArray, mlp->ClassCount );
+  Free_MarkArray( &mlp->MarkArray );
+  _HB_OPEN_Free_Coverage( &mlp->LigatureCoverage );
+  _HB_OPEN_Free_Coverage( &mlp->MarkCoverage );
+}
+
+
+static HB_Error  Lookup_MarkLigPos( GPOS_Instance*    gpi,
+                                   HB_GPOS_SubTable* st,
+                                   HB_Buffer        buffer,
+                                   HB_UShort         flags,
+                                   HB_UShort         context_length,
+                                   int               nesting_level )
+{
+  HB_UShort        i, j, mark_index, lig_index, property, klass;
+  HB_UShort        mark_glyph;
+  HB_Fixed           x_mark_value, y_mark_value, x_lig_value, y_lig_value;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_MarkLigPos*  mlp = &st->marklig;
+
+  HB_MarkArray*        ma;
+  HB_LigatureArray*    la;
+  HB_LigatureAttach*   lat;
+  HB_ComponentRecord*  cr;
+  HB_UShort             comp_index;
+  HB_Anchor*           mark_anchor;
+  HB_Anchor*           lig_anchor;
+
+  HB_Position    o;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( flags & HB_LOOKUP_FLAG_IGNORE_LIGATURES )
+    return HB_Err_Not_Covered;
+
+  mark_glyph = IN_CURGLYPH();
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index );
+  if ( error )
+    return error;
+
+  /* now we search backwards for a non-mark glyph */
+
+  i = 1;
+  j = buffer->in_pos - 1;
+
+  while ( i <= buffer->in_pos )
+  {
+    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),
+                                       &property );
+    if ( error )
+      return error;
+
+    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )
+      break;
+
+    i++;
+    j--;
+  }
+
+  /* Similar to Lookup_MarkBasePos(), I suspect that this assertion is
+     too strong, thus it is commented out.                             */
+#if 0
+  if ( property != HB_GDEF_LIGATURE )
+    return HB_Err_Not_Covered;
+#endif
+
+  if ( i > buffer->in_pos )
+    return HB_Err_Not_Covered;
+
+  error = _HB_OPEN_Coverage_Index( &mlp->LigatureCoverage, IN_GLYPH( j ),
+                         &lig_index );
+  if ( error )
+    return error;
+
+  ma = &mlp->MarkArray;
+
+  if ( mark_index >= ma->MarkCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  klass       = ma->MarkRecord[mark_index].Class;
+  mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;
+
+  if ( klass >= mlp->ClassCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  la = &mlp->LigatureArray;
+
+  if ( lig_index >= la->LigatureCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  lat = &la->LigatureAttach[lig_index];
+
+  /* We must now check whether the ligature ID of the current mark glyph
+     is identical to the ligature ID of the found ligature.  If yes, we
+     can directly use the component index.  If not, we attach the mark
+     glyph to the last component of the ligature.                        */
+
+  if ( IN_LIGID( j ) == IN_LIGID( buffer->in_pos) )
+  {
+    comp_index = IN_COMPONENT( buffer->in_pos );
+    if ( comp_index >= lat->ComponentCount )
+      return HB_Err_Not_Covered;
+  }
+  else
+    comp_index = lat->ComponentCount - 1;
+
+  cr         = &lat->ComponentRecord[comp_index];
+  lig_anchor = &cr->LigatureAnchor[klass];
+
+  error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(),
+                     &x_mark_value, &y_mark_value );
+  if ( error )
+    return error;
+  error = Get_Anchor( gpi, lig_anchor, IN_GLYPH( j ),
+                     &x_lig_value, &y_lig_value );
+  if ( error )
+    return error;
+
+  /* anchor points are not cumulative */
+
+  o = POSITION( buffer->in_pos );
+
+  o->x_pos     = x_lig_value - x_mark_value;
+  o->y_pos     = y_lig_value - y_mark_value;
+  o->x_advance = 0;
+  o->y_advance = 0;
+  o->back      = i;
+
+  (buffer->in_pos)++;
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 6 */
+
+/* Mark2Array */
+
+static HB_Error  Load_Mark2Array( HB_Mark2Array*  m2a,
+                                 HB_UShort        num_classes,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+
+  HB_UShort        m, n, count;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_Mark2Record  *m2r;
+  HB_Anchor       *m2an, *m2ans;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = m2a->Mark2Count = GET_UShort();
+
+  FORGET_Frame();
+
+  m2a->Mark2Record = NULL;
+
+  if ( ALLOC_ARRAY( m2a->Mark2Record, count, HB_Mark2Record ) )
+    return error;
+
+  m2r = m2a->Mark2Record;
+
+  m2ans = NULL;
+
+  if ( ALLOC_ARRAY( m2ans, count * num_classes, HB_Anchor ) )
+    goto Fail;
+
+  for ( m = 0; m < count; m++ )
+  {
+    m2an = m2r[m].Mark2Anchor = m2ans + m * num_classes;
+
+    for ( n = 0; n < num_classes; n++ )
+    {
+      if ( ACCESS_Frame( 2L ) )
+       goto Fail;
+
+      new_offset = GET_UShort() + base_offset;
+
+      FORGET_Frame();
+
+      if (new_offset == base_offset) {
+        /* Anchor table not provided.  Skip loading.
+        * Some versions of FreeSans hit this. */
+        m2an[n].PosFormat = 0;
+       continue;
+      }
+
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_Anchor( &m2an[n], stream ) ) != HB_Err_Ok )
+       goto Fail;
+      (void)FILE_Seek( cur_offset );
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  FREE( m2ans );
+  FREE( m2r );
+  return error;
+}
+
+
+static void  Free_Mark2Array( HB_Mark2Array*  m2a,
+                             HB_UShort        num_classes )
+{
+  HB_Mark2Record  *m2r;
+  HB_Anchor       *m2ans;
+
+  HB_UNUSED(num_classes);
+
+  if ( m2a->Mark2Record )
+  {
+    m2r   = m2a->Mark2Record;
+
+    if ( m2a->Mark2Count )
+    {
+      m2ans = m2r[0].Mark2Anchor;
+      FREE( m2ans );
+    }
+
+    FREE( m2r );
+  }
+}
+
+
+/* MarkMarkPosFormat1 */
+
+static HB_Error  Load_MarkMarkPos( HB_GPOS_SubTable* st,
+                                  HB_Stream         stream )
+{
+  HB_Error  error;
+  HB_MarkMarkPos* mmp = &st->markmark;
+
+  HB_UInt  cur_offset, new_offset, base_offset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  mmp->PosFormat = GET_UShort();
+  new_offset     = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mmp->Mark1Coverage,
+                               stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &mmp->Mark2Coverage,
+                               stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 4L ) )
+    goto Fail2;
+
+  mmp->ClassCount = GET_UShort();
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_MarkArray( &mmp->Mark1Array, stream ) ) != HB_Err_Ok )
+    goto Fail2;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail1;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = Load_Mark2Array( &mmp->Mark2Array, mmp->ClassCount,
+                                 stream ) ) != HB_Err_Ok )
+    goto Fail1;
+
+  return HB_Err_Ok;
+
+Fail1:
+  Free_MarkArray( &mmp->Mark1Array );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage );
+
+Fail3:
+  _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage );
+  return error;
+}
+
+
+static void  Free_MarkMarkPos( HB_GPOS_SubTable* st)
+{
+  HB_MarkMarkPos* mmp = &st->markmark;
+
+  Free_Mark2Array( &mmp->Mark2Array, mmp->ClassCount );
+  Free_MarkArray( &mmp->Mark1Array );
+  _HB_OPEN_Free_Coverage( &mmp->Mark2Coverage );
+  _HB_OPEN_Free_Coverage( &mmp->Mark1Coverage );
+}
+
+
+static HB_Error  Lookup_MarkMarkPos( GPOS_Instance*    gpi,
+                                    HB_GPOS_SubTable* st,
+                                    HB_Buffer        buffer,
+                                    HB_UShort         flags,
+                                    HB_UShort         context_length,
+                                    int               nesting_level )
+{
+  HB_UShort        i, j, mark1_index, mark2_index, property, klass;
+  HB_Fixed           x_mark1_value, y_mark1_value,
+                  x_mark2_value, y_mark2_value;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+  HB_MarkMarkPos* mmp = &st->markmark;
+
+  HB_MarkArray*    ma1;
+  HB_Mark2Array*   ma2;
+  HB_Mark2Record*  m2r;
+  HB_Anchor*       mark1_anchor;
+  HB_Anchor*       mark2_anchor;
+
+  HB_Position    o;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( flags & HB_LOOKUP_FLAG_IGNORE_MARKS )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gpos->gdef, IN_CURITEM(),
+                      flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &mmp->Mark1Coverage, IN_CURGLYPH(),
+                         &mark1_index );
+  if ( error )
+    return error;
+
+  /* now we search backwards for a suitable mark glyph until a non-mark
+     glyph                                                */
+
+  if ( buffer->in_pos == 0 )
+    return HB_Err_Not_Covered;
+
+  i = 1;
+  j = buffer->in_pos - 1;
+  while ( i <= buffer->in_pos )
+  {
+    error = HB_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ),
+                                       &property );
+    if ( error )
+      return error;
+
+    if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )
+      return HB_Err_Not_Covered;
+
+    if ( flags & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )
+    {
+      if ( property == (flags & 0xFF00) )
+        break;
+    }
+    else
+      break;
+
+    i++;
+    j--;
+  }
+
+  error = _HB_OPEN_Coverage_Index( &mmp->Mark2Coverage, IN_GLYPH( j ),
+                         &mark2_index );
+  if ( error )
+    return error;
+
+  ma1 = &mmp->Mark1Array;
+
+  if ( mark1_index >= ma1->MarkCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  klass        = ma1->MarkRecord[mark1_index].Class;
+  mark1_anchor = &ma1->MarkRecord[mark1_index].MarkAnchor;
+
+  if ( klass >= mmp->ClassCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  ma2 = &mmp->Mark2Array;
+
+  if ( mark2_index >= ma2->Mark2Count )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  m2r          = &ma2->Mark2Record[mark2_index];
+  mark2_anchor = &m2r->Mark2Anchor[klass];
+
+  error = Get_Anchor( gpi, mark1_anchor, IN_CURGLYPH(),
+                     &x_mark1_value, &y_mark1_value );
+  if ( error )
+    return error;
+  error = Get_Anchor( gpi, mark2_anchor, IN_GLYPH( j ),
+                     &x_mark2_value, &y_mark2_value );
+  if ( error )
+    return error;
+
+  /* anchor points are not cumulative */
+
+  o = POSITION( buffer->in_pos );
+
+  o->x_pos     = x_mark2_value - x_mark1_value;
+  o->y_pos     = y_mark2_value - y_mark1_value;
+  o->x_advance = 0;
+  o->y_advance = 0;
+  o->back      = 1;
+
+  (buffer->in_pos)++;
+
+  return HB_Err_Ok;
+}
+
+
+/* Do the actual positioning for a context positioning (either format
+   7 or 8).  This is only called after we've determined that the stream
+   matches the subrule.                                                 */
+
+static HB_Error  Do_ContextPos( GPOS_Instance*        gpi,
+                               HB_UShort             GlyphCount,
+                               HB_UShort             PosCount,
+                               HB_PosLookupRecord*  pos,
+                               HB_Buffer            buffer,
+                               int                   nesting_level )
+{
+  HB_Error  error;
+  HB_UInt   i, old_pos;
+
+
+  i = 0;
+
+  while ( i < GlyphCount )
+  {
+    if ( PosCount && i == pos->SequenceIndex )
+    {
+      old_pos = buffer->in_pos;
+
+      /* Do a positioning */
+
+      error = GPOS_Do_Glyph_Lookup( gpi, pos->LookupListIndex, buffer,
+                                   GlyphCount, nesting_level );
+
+      if ( error )
+       return error;
+
+      pos++;
+      PosCount--;
+      i += buffer->in_pos - old_pos;
+    }
+    else
+    {
+      i++;
+      (buffer->in_pos)++;
+    }
+  }
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 7 */
+
+/* PosRule */
+
+static HB_Error  Load_PosRule( HB_PosRule*  pr,
+                              HB_Stream     stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, count;
+  HB_UShort*            i;
+
+  HB_PosLookupRecord*  plr;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  pr->GlyphCount = GET_UShort();
+  pr->PosCount   = GET_UShort();
+
+  FORGET_Frame();
+
+  pr->Input = NULL;
+
+  count = pr->GlyphCount - 1;         /* only GlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( pr->Input, count, HB_UShort ) )
+    return error;
+
+  i = pr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  pr->PosLookupRecord = NULL;
+
+  count = pr->PosCount;
+
+  if ( ALLOC_ARRAY( pr->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = pr->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  FREE( i );
+  return error;
+}
+
+
+static void  Free_PosRule( HB_PosRule*  pr )
+{
+  FREE( pr->PosLookupRecord );
+  FREE( pr->Input );
+}
+
+
+/* PosRuleSet */
+
+static HB_Error  Load_PosRuleSet( HB_PosRuleSet*  prs,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+
+  HB_UShort     n, m, count;
+  HB_UInt      cur_offset, new_offset, base_offset;
+
+  HB_PosRule*  pr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = prs->PosRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  prs->PosRule = NULL;
+
+  if ( ALLOC_ARRAY( prs->PosRule, count, HB_PosRule ) )
+    return error;
+
+  pr = prs->PosRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_PosRule( &pr[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_PosRule( &pr[m] );
+
+  FREE( pr );
+  return error;
+}
+
+
+static void  Free_PosRuleSet( HB_PosRuleSet*  prs )
+{
+  HB_UShort     n, count;
+
+  HB_PosRule*  pr;
+
+
+  if ( prs->PosRule )
+  {
+    count = prs->PosRuleCount;
+    pr    = prs->PosRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_PosRule( &pr[n] );
+
+    FREE( pr );
+  }
+}
+
+
+/* ContextPosFormat1 */
+
+static HB_Error  Load_ContextPos1( HB_ContextPosFormat1*  cpf1,
+                                  HB_Stream               stream )
+{
+  HB_Error  error;
+
+  HB_UShort        n, m, count;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_PosRuleSet*  prs;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &cpf1->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = cpf1->PosRuleSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpf1->PosRuleSet = NULL;
+
+  if ( ALLOC_ARRAY( cpf1->PosRuleSet, count, HB_PosRuleSet ) )
+    goto Fail2;
+
+  prs = cpf1->PosRuleSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_PosRuleSet( &prs[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_PosRuleSet( &prs[m] );
+
+  FREE( prs );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &cpf1->Coverage );
+  return error;
+}
+
+
+static void  Free_ContextPos1( HB_ContextPosFormat1*  cpf1 )
+{
+  HB_UShort        n, count;
+
+  HB_PosRuleSet*  prs;
+
+
+  if ( cpf1->PosRuleSet )
+  {
+    count = cpf1->PosRuleSetCount;
+    prs   = cpf1->PosRuleSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_PosRuleSet( &prs[n] );
+
+    FREE( prs );
+  }
+
+  _HB_OPEN_Free_Coverage( &cpf1->Coverage );
+}
+
+
+/* PosClassRule */
+
+static HB_Error  Load_PosClassRule( HB_ContextPosFormat2*  cpf2,
+                                   HB_PosClassRule*       pcr,
+                                   HB_Stream               stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, count;
+
+  HB_UShort*            c;
+  HB_PosLookupRecord*  plr;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  pcr->GlyphCount = GET_UShort();
+  pcr->PosCount   = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( pcr->GlyphCount > cpf2->MaxContextLength )
+    cpf2->MaxContextLength = pcr->GlyphCount;
+
+  pcr->Class = NULL;
+
+  count = pcr->GlyphCount - 1;        /* only GlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( pcr->Class, count, HB_UShort ) )
+    return error;
+
+  c = pcr->Class;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    c[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  pcr->PosLookupRecord = NULL;
+
+  count = pcr->PosCount;
+
+  if ( ALLOC_ARRAY( pcr->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = pcr->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  FREE( c );
+  return error;
+}
+
+
+static void  Free_PosClassRule( HB_PosClassRule*  pcr )
+{
+  FREE( pcr->PosLookupRecord );
+  FREE( pcr->Class );
+}
+
+
+/* PosClassSet */
+
+static HB_Error  Load_PosClassSet( HB_ContextPosFormat2*  cpf2,
+                                  HB_PosClassSet*        pcs,
+                                  HB_Stream               stream )
+{
+  HB_Error  error;
+
+  HB_UShort          n, m, count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_PosClassRule*  pcr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = pcs->PosClassRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  pcs->PosClassRule = NULL;
+
+  if ( ALLOC_ARRAY( pcs->PosClassRule, count, HB_PosClassRule ) )
+    return error;
+
+  pcr = pcs->PosClassRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_PosClassRule( cpf2, &pcr[n],
+                                     stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_PosClassRule( &pcr[m] );
+
+  FREE( pcr );
+  return error;
+}
+
+
+static void  Free_PosClassSet( HB_PosClassSet*  pcs )
+{
+  HB_UShort          n, count;
+
+  HB_PosClassRule*  pcr;
+
+
+  if ( pcs->PosClassRule )
+  {
+    count = pcs->PosClassRuleCount;
+    pcr   = pcs->PosClassRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_PosClassRule( &pcr[n] );
+
+    FREE( pcr );
+  }
+}
+
+
+/* ContextPosFormat2 */
+
+static HB_Error  Load_ContextPos2( HB_ContextPosFormat2*  cpf2,
+                                  HB_Stream               stream )
+{
+  HB_Error  error;
+
+  HB_UShort         n, m, count;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_PosClassSet*  pcs;
+
+
+  base_offset = FILE_Pos() - 2;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &cpf2->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 4L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  /* `PosClassSetCount' is the upper limit for klass values, thus we
+     read it now to make an additional safety check.                 */
+
+  count = cpf2->PosClassSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_ClassDefinition( &cpf2->ClassDef, count,
+                                      stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  cpf2->PosClassSet      = NULL;
+  cpf2->MaxContextLength = 0;
+
+  if ( ALLOC_ARRAY( cpf2->PosClassSet, count, HB_PosClassSet ) )
+    goto Fail2;
+
+  pcs = cpf2->PosClassSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    if ( new_offset != base_offset )      /* not a NULL offset */
+    {
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_PosClassSet( cpf2, &pcs[n],
+                                      stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      /* we create a PosClassSet table with no entries */
+
+      cpf2->PosClassSet[n].PosClassRuleCount = 0;
+      cpf2->PosClassSet[n].PosClassRule      = NULL;
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; n++ )
+    Free_PosClassSet( &pcs[m] );
+
+  FREE( pcs );
+
+Fail2:
+  _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef );
+
+Fail3:
+  _HB_OPEN_Free_Coverage( &cpf2->Coverage );
+  return error;
+}
+
+
+static void  Free_ContextPos2( HB_ContextPosFormat2*  cpf2 )
+{
+  HB_UShort         n, count;
+
+  HB_PosClassSet*  pcs;
+
+
+  if ( cpf2->PosClassSet )
+  {
+    count = cpf2->PosClassSetCount;
+    pcs   = cpf2->PosClassSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_PosClassSet( &pcs[n] );
+
+    FREE( pcs );
+  }
+
+  _HB_OPEN_Free_ClassDefinition( &cpf2->ClassDef );
+  _HB_OPEN_Free_Coverage( &cpf2->Coverage );
+}
+
+
+/* ContextPosFormat3 */
+
+static HB_Error  Load_ContextPos3( HB_ContextPosFormat3*  cpf3,
+                                  HB_Stream               stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_Coverage*         c;
+  HB_PosLookupRecord*  plr;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  cpf3->GlyphCount = GET_UShort();
+  cpf3->PosCount   = GET_UShort();
+
+  FORGET_Frame();
+
+  cpf3->Coverage = NULL;
+
+  count = cpf3->GlyphCount;
+
+  if ( ALLOC_ARRAY( cpf3->Coverage, count, HB_Coverage ) )
+    return error;
+
+  c = cpf3->Coverage;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  cpf3->PosLookupRecord = NULL;
+
+  count = cpf3->PosCount;
+
+  if ( ALLOC_ARRAY( cpf3->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = cpf3->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  for ( n = 0; n < count; n++ )
+    _HB_OPEN_Free_Coverage( &c[n] );
+
+  FREE( c );
+  return error;
+}
+
+
+static void  Free_ContextPos3( HB_ContextPosFormat3*  cpf3 )
+{
+  HB_UShort      n, count;
+
+  HB_Coverage*  c;
+
+
+  FREE( cpf3->PosLookupRecord );
+
+  if ( cpf3->Coverage )
+  {
+    count = cpf3->GlyphCount;
+    c     = cpf3->Coverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+}
+
+
+/* ContextPos */
+
+static HB_Error  Load_ContextPos( HB_GPOS_SubTable* st,
+                                 HB_Stream        stream )
+{
+  HB_Error  error;
+  HB_ContextPos*   cp = &st->context;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cp->PosFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( cp->PosFormat )
+  {
+  case 1:
+    return Load_ContextPos1( &cp->cpf.cpf1, stream );
+
+  case 2:
+    return Load_ContextPos2( &cp->cpf.cpf2, stream );
+
+  case 3:
+    return Load_ContextPos3( &cp->cpf.cpf3, stream );
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+static void  Free_ContextPos( HB_GPOS_SubTable* st )
+{
+  HB_ContextPos*   cp = &st->context;
+
+  switch ( cp->PosFormat )
+  {
+  case 1:  Free_ContextPos1( &cp->cpf.cpf1 ); break;
+  case 2:  Free_ContextPos2( &cp->cpf.cpf2 ); break;
+  case 3:  Free_ContextPos3( &cp->cpf.cpf3 ); break;
+  default:                                           break;
+  }
+}
+
+
+static HB_Error  Lookup_ContextPos1( GPOS_Instance*          gpi,
+                                    HB_ContextPosFormat1*  cpf1,
+                                    HB_Buffer              buffer,
+                                    HB_UShort               flags,
+                                    HB_UShort               context_length,
+                                    int                     nesting_level )
+{
+  HB_UShort        index, property;
+  HB_UShort        i, j, k, numpr;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+
+  HB_PosRule*     pr;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &cpf1->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  pr    = cpf1->PosRuleSet[index].PosRule;
+  numpr = cpf1->PosRuleSet[index].PosRuleCount;
+
+  for ( k = 0; k < numpr; k++ )
+  {
+    if ( context_length != 0xFFFF && context_length < pr[k].GlyphCount )
+      goto next_posrule;
+
+    if ( buffer->in_pos + pr[k].GlyphCount > buffer->in_length )
+      goto next_posrule;                       /* context is too long */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < pr[k].GlyphCount; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + pr[k].GlyphCount - i == (HB_Int)buffer->in_length )
+         goto next_posrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != pr[k].Input[i - 1] )
+       goto next_posrule;
+    }
+
+    return Do_ContextPos( gpi, pr[k].GlyphCount,
+                         pr[k].PosCount, pr[k].PosLookupRecord,
+                         buffer,
+                         nesting_level );
+
+    next_posrule:
+      ;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Lookup_ContextPos2( GPOS_Instance*          gpi,
+                                    HB_ContextPosFormat2*  cpf2,
+                                    HB_Buffer              buffer,
+                                    HB_UShort               flags,
+                                    HB_UShort               context_length,
+                                    int                     nesting_level )
+{
+  HB_UShort          index, property;
+  HB_Error           error;
+  HB_UShort          i, j, k, known_classes;
+
+  HB_UShort*         classes;
+  HB_UShort*         cl;
+  HB_GPOSHeader*    gpos = gpi->gpos;
+
+  HB_PosClassSet*   pcs;
+  HB_PosClassRule*  pr;
+  HB_GDEFHeader*    gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  /* Note: The coverage table in format 2 doesn't give an index into
+          anything.  It just lets us know whether or not we need to
+          do any lookup at all.                                     */
+
+  error = _HB_OPEN_Coverage_Index( &cpf2->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if (cpf2->MaxContextLength < 1)
+    return HB_Err_Not_Covered;
+
+  if ( ALLOC_ARRAY( classes, cpf2->MaxContextLength, HB_UShort ) )
+    return error;
+
+  error = _HB_OPEN_Get_Class( &cpf2->ClassDef, IN_CURGLYPH(),
+                    &classes[0], NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    goto End;
+  known_classes = 0;
+
+  pcs = &cpf2->PosClassSet[classes[0]];
+  if ( !pcs )
+  {
+    error = ERR_HB(HB_Err_Invalid_SubTable);
+    goto End;
+  }
+
+  for ( k = 0; k < pcs->PosClassRuleCount; k++ )
+  {
+    pr = &pcs->PosClassRule[k];
+
+    if ( context_length != 0xFFFF && context_length < pr->GlyphCount )
+      goto next_posclassrule;
+
+    if ( buffer->in_pos + pr->GlyphCount > buffer->in_length )
+      goto next_posclassrule;                /* context is too long */
+
+    cl   = pr->Class;
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < pr->GlyphCount; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End;
+
+       if ( j + pr->GlyphCount - i == (HB_Int)buffer->in_length )
+         goto next_posclassrule;
+       j++;
+      }
+
+      if ( i > known_classes )
+      {
+       /* Keeps us from having to do this for each rule */
+
+       error = _HB_OPEN_Get_Class( &cpf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End;
+       known_classes = i;
+      }
+
+      if ( cl[i - 1] != classes[i] )
+       goto next_posclassrule;
+    }
+
+    error = Do_ContextPos( gpi, pr->GlyphCount,
+                          pr->PosCount, pr->PosLookupRecord,
+                          buffer,
+                          nesting_level );
+    goto End;
+
+  next_posclassrule:
+    ;
+  }
+
+  error = HB_Err_Not_Covered;
+
+End:
+  FREE( classes );
+  return error;
+}
+
+
+static HB_Error  Lookup_ContextPos3( GPOS_Instance*          gpi,
+                                    HB_ContextPosFormat3*  cpf3,
+                                    HB_Buffer              buffer,
+                                    HB_UShort               flags,
+                                    HB_UShort               context_length,
+                                    int                     nesting_level )
+{
+  HB_Error         error;
+  HB_UShort        index, i, j, property;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+
+  HB_Coverage*    c;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  if ( context_length != 0xFFFF && context_length < cpf3->GlyphCount )
+    return HB_Err_Not_Covered;
+
+  if ( buffer->in_pos + cpf3->GlyphCount > buffer->in_length )
+    return HB_Err_Not_Covered;         /* context is too long */
+
+  c    = cpf3->Coverage;
+
+  for ( i = 1, j = 1; i < cpf3->GlyphCount; i++, j++ )
+  {
+    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + cpf3->GlyphCount - i == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &c[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  return Do_ContextPos( gpi, cpf3->GlyphCount,
+                       cpf3->PosCount, cpf3->PosLookupRecord,
+                       buffer,
+                       nesting_level );
+}
+
+
+static HB_Error  Lookup_ContextPos( GPOS_Instance*    gpi,
+                                   HB_GPOS_SubTable* st,
+                                   HB_Buffer        buffer,
+                                   HB_UShort         flags,
+                                   HB_UShort         context_length,
+                                   int               nesting_level )
+{
+  HB_ContextPos*   cp = &st->context;
+
+  switch ( cp->PosFormat )
+  {
+  case 1:
+    return Lookup_ContextPos1( gpi, &cp->cpf.cpf1, buffer,
+                              flags, context_length, nesting_level );
+
+  case 2:
+    return Lookup_ContextPos2( gpi, &cp->cpf.cpf2, buffer,
+                              flags, context_length, nesting_level );
+
+  case 3:
+    return Lookup_ContextPos3( gpi, &cp->cpf.cpf3, buffer,
+                              flags, context_length, nesting_level );
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+/* LookupType 8 */
+
+/* ChainPosRule */
+
+static HB_Error  Load_ChainPosRule( HB_ChainPosRule*  cpr,
+                                   HB_Stream          stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, count;
+  HB_UShort*            b;
+  HB_UShort*            i;
+  HB_UShort*            l;
+
+  HB_PosLookupRecord*  plr;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cpr->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpr->Backtrack = NULL;
+
+  count = cpr->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( cpr->Backtrack, count, HB_UShort ) )
+    return error;
+
+  b = cpr->Backtrack;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail4;
+
+  for ( n = 0; n < count; n++ )
+    b[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  cpr->InputGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpr->Input = NULL;
+
+  count = cpr->InputGlyphCount - 1;  /* only InputGlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( cpr->Input, count, HB_UShort ) )
+    goto Fail4;
+
+  i = cpr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail3;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  cpr->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpr->Lookahead = NULL;
+
+  count = cpr->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( cpr->Lookahead, count, HB_UShort ) )
+    goto Fail3;
+
+  l = cpr->Lookahead;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    l[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  cpr->PosCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpr->PosLookupRecord = NULL;
+
+  count = cpr->PosCount;
+
+  if ( ALLOC_ARRAY( cpr->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = cpr->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  FREE( l );
+
+Fail3:
+  FREE( i );
+
+Fail4:
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainPosRule( HB_ChainPosRule*  cpr )
+{
+  FREE( cpr->PosLookupRecord );
+  FREE( cpr->Lookahead );
+  FREE( cpr->Input );
+  FREE( cpr->Backtrack );
+}
+
+
+/* ChainPosRuleSet */
+
+static HB_Error  Load_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs,
+                                      HB_Stream             stream )
+{
+  HB_Error  error;
+
+  HB_UShort          n, m, count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_ChainPosRule*  cpr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = cprs->ChainPosRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cprs->ChainPosRule = NULL;
+
+  if ( ALLOC_ARRAY( cprs->ChainPosRule, count, HB_ChainPosRule ) )
+    return error;
+
+  cpr = cprs->ChainPosRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainPosRule( &cpr[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_ChainPosRule( &cpr[m] );
+
+  FREE( cpr );
+  return error;
+}
+
+
+static void  Free_ChainPosRuleSet( HB_ChainPosRuleSet*  cprs )
+{
+  HB_UShort          n, count;
+
+  HB_ChainPosRule*  cpr;
+
+
+  if ( cprs->ChainPosRule )
+  {
+    count = cprs->ChainPosRuleCount;
+    cpr   = cprs->ChainPosRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainPosRule( &cpr[n] );
+
+    FREE( cpr );
+  }
+}
+
+
+/* ChainContextPosFormat1 */
+
+static HB_Error  Load_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1,
+                                       HB_Stream                    stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, m, count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_ChainPosRuleSet*  cprs;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ccpf1->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = ccpf1->ChainPosRuleSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccpf1->ChainPosRuleSet = NULL;
+
+  if ( ALLOC_ARRAY( ccpf1->ChainPosRuleSet, count, HB_ChainPosRuleSet ) )
+    goto Fail2;
+
+  cprs = ccpf1->ChainPosRuleSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainPosRuleSet( &cprs[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_ChainPosRuleSet( &cprs[m] );
+
+  FREE( cprs );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &ccpf1->Coverage );
+  return error;
+}
+
+
+static void  Free_ChainContextPos1( HB_ChainContextPosFormat1*  ccpf1 )
+{
+  HB_UShort             n, count;
+
+  HB_ChainPosRuleSet*  cprs;
+
+
+  if ( ccpf1->ChainPosRuleSet )
+  {
+    count = ccpf1->ChainPosRuleSetCount;
+    cprs  = ccpf1->ChainPosRuleSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainPosRuleSet( &cprs[n] );
+
+    FREE( cprs );
+  }
+
+  _HB_OPEN_Free_Coverage( &ccpf1->Coverage );
+}
+
+
+/* ChainPosClassRule */
+
+static HB_Error  Load_ChainPosClassRule(
+                  HB_ChainContextPosFormat2*  ccpf2,
+                  HB_ChainPosClassRule*       cpcr,
+                  HB_Stream                    stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, count;
+
+  HB_UShort*            b;
+  HB_UShort*            i;
+  HB_UShort*            l;
+  HB_PosLookupRecord*  plr;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cpcr->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( cpcr->BacktrackGlyphCount > ccpf2->MaxBacktrackLength )
+    ccpf2->MaxBacktrackLength = cpcr->BacktrackGlyphCount;
+
+  cpcr->Backtrack = NULL;
+
+  count = cpcr->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( cpcr->Backtrack, count, HB_UShort ) )
+    return error;
+
+  b = cpcr->Backtrack;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail4;
+
+  for ( n = 0; n < count; n++ )
+    b[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  cpcr->InputGlyphCount = GET_UShort();
+
+  if ( cpcr->InputGlyphCount > ccpf2->MaxInputLength )
+    ccpf2->MaxInputLength = cpcr->InputGlyphCount;
+
+  FORGET_Frame();
+
+  cpcr->Input = NULL;
+
+  count = cpcr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( cpcr->Input, count, HB_UShort ) )
+    goto Fail4;
+
+  i = cpcr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail3;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  cpcr->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( cpcr->LookaheadGlyphCount > ccpf2->MaxLookaheadLength )
+    ccpf2->MaxLookaheadLength = cpcr->LookaheadGlyphCount;
+
+  cpcr->Lookahead = NULL;
+
+  count = cpcr->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( cpcr->Lookahead, count, HB_UShort ) )
+    goto Fail3;
+
+  l = cpcr->Lookahead;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    l[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  cpcr->PosCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpcr->PosLookupRecord = NULL;
+
+  count = cpcr->PosCount;
+
+  if ( ALLOC_ARRAY( cpcr->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = cpcr->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  FREE( l );
+
+Fail3:
+  FREE( i );
+
+Fail4:
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainPosClassRule( HB_ChainPosClassRule*  cpcr )
+{
+  FREE( cpcr->PosLookupRecord );
+  FREE( cpcr->Lookahead );
+  FREE( cpcr->Input );
+  FREE( cpcr->Backtrack );
+}
+
+
+/* PosClassSet */
+
+static HB_Error  Load_ChainPosClassSet(
+                  HB_ChainContextPosFormat2*  ccpf2,
+                  HB_ChainPosClassSet*        cpcs,
+                  HB_Stream                    stream )
+{
+  HB_Error  error;
+
+  HB_UShort               n, m, count;
+  HB_UInt                cur_offset, new_offset, base_offset;
+
+  HB_ChainPosClassRule*  cpcr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = cpcs->ChainPosClassRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cpcs->ChainPosClassRule = NULL;
+
+  if ( ALLOC_ARRAY( cpcs->ChainPosClassRule, count,
+                   HB_ChainPosClassRule ) )
+    return error;
+
+  cpcr = cpcs->ChainPosClassRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainPosClassRule( ccpf2, &cpcr[n],
+                                          stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_ChainPosClassRule( &cpcr[m] );
+
+  FREE( cpcr );
+  return error;
+}
+
+
+static void  Free_ChainPosClassSet( HB_ChainPosClassSet*  cpcs )
+{
+  HB_UShort               n, count;
+
+  HB_ChainPosClassRule*  cpcr;
+
+
+  if ( cpcs->ChainPosClassRule )
+  {
+    count = cpcs->ChainPosClassRuleCount;
+    cpcr  = cpcs->ChainPosClassRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainPosClassRule( &cpcr[n] );
+
+    FREE( cpcr );
+  }
+}
+
+
+/* ChainContextPosFormat2 */
+
+static HB_Error  Load_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2,
+                                       HB_Stream                    stream )
+{
+  HB_Error  error;
+
+  HB_UShort              n, m, count;
+  HB_UInt               cur_offset, new_offset, base_offset;
+  HB_UInt               backtrack_offset, input_offset, lookahead_offset;
+
+  HB_ChainPosClassSet*  cpcs;
+
+
+  base_offset = FILE_Pos() - 2;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ccpf2->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 8L ) )
+    goto Fail5;
+
+  backtrack_offset = GET_UShort();
+  input_offset     = GET_UShort();
+  lookahead_offset = GET_UShort();
+
+  /* `ChainPosClassSetCount' is the upper limit for input klass values,
+     thus we read it now to make an additional safety check. No limit
+     is known or needed for the other two klass definitions          */
+
+  count = ccpf2->ChainPosClassSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535,
+                                                      backtrack_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+    goto Fail5;
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count,
+                                                      input_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+    goto Fail4;
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535,
+                                                      lookahead_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+    goto Fail3;
+
+  ccpf2->ChainPosClassSet   = NULL;
+  ccpf2->MaxBacktrackLength = 0;
+  ccpf2->MaxInputLength     = 0;
+  ccpf2->MaxLookaheadLength = 0;
+
+  if ( ALLOC_ARRAY( ccpf2->ChainPosClassSet, count, HB_ChainPosClassSet ) )
+    goto Fail2;
+
+  cpcs = ccpf2->ChainPosClassSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    if ( new_offset != base_offset )      /* not a NULL offset */
+    {
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_ChainPosClassSet( ccpf2, &cpcs[n],
+                                           stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      /* we create a ChainPosClassSet table with no entries */
+
+      ccpf2->ChainPosClassSet[n].ChainPosClassRuleCount = 0;
+      ccpf2->ChainPosClassSet[n].ChainPosClassRule      = NULL;
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_ChainPosClassSet( &cpcs[m] );
+
+  FREE( cpcs );
+
+Fail2:
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef );
+
+Fail3:
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef );
+
+Fail4:
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef );
+
+Fail5:
+  _HB_OPEN_Free_Coverage( &ccpf2->Coverage );
+  return error;
+}
+
+
+static void  Free_ChainContextPos2( HB_ChainContextPosFormat2*  ccpf2 )
+{
+  HB_UShort              n, count;
+
+  HB_ChainPosClassSet*  cpcs;
+
+
+  if ( ccpf2->ChainPosClassSet )
+  {
+    count = ccpf2->ChainPosClassSetCount;
+    cpcs  = ccpf2->ChainPosClassSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainPosClassSet( &cpcs[n] );
+
+    FREE( cpcs );
+  }
+
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->LookaheadClassDef );
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->InputClassDef );
+  _HB_OPEN_Free_ClassDefinition( &ccpf2->BacktrackClassDef );
+
+  _HB_OPEN_Free_Coverage( &ccpf2->Coverage );
+}
+
+
+/* ChainContextPosFormat3 */
+
+static HB_Error  Load_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3,
+                                       HB_Stream                    stream )
+{
+  HB_Error  error;
+
+  HB_UShort             n, nb, ni, nl, m, count;
+  HB_UShort             backtrack_count, input_count, lookahead_count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_Coverage*         b;
+  HB_Coverage*         i;
+  HB_Coverage*         l;
+  HB_PosLookupRecord*  plr;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  ccpf3->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccpf3->BacktrackCoverage = NULL;
+
+  backtrack_count = ccpf3->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( ccpf3->BacktrackCoverage, backtrack_count,
+                   HB_Coverage ) )
+    return error;
+
+  b = ccpf3->BacktrackCoverage;
+
+  for ( nb = 0; nb < backtrack_count; nb++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail4;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
+      goto Fail4;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  ccpf3->InputGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccpf3->InputCoverage = NULL;
+
+  input_count = ccpf3->InputGlyphCount;
+
+  if ( ALLOC_ARRAY( ccpf3->InputCoverage, input_count, HB_Coverage ) )
+    goto Fail4;
+
+  i = ccpf3->InputCoverage;
+
+  for ( ni = 0; ni < input_count; ni++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail3;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )
+      goto Fail3;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  ccpf3->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccpf3->LookaheadCoverage = NULL;
+
+  lookahead_count = ccpf3->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( ccpf3->LookaheadCoverage, lookahead_count,
+                   HB_Coverage ) )
+    goto Fail3;
+
+  l = ccpf3->LookaheadCoverage;
+
+  for ( nl = 0; nl < lookahead_count; nl++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  ccpf3->PosCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccpf3->PosLookupRecord = NULL;
+
+  count = ccpf3->PosCount;
+
+  if ( ALLOC_ARRAY( ccpf3->PosLookupRecord, count, HB_PosLookupRecord ) )
+    goto Fail2;
+
+  plr = ccpf3->PosLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    plr[n].SequenceIndex   = GET_UShort();
+    plr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( plr );
+
+Fail2:
+  for ( m = 0; m < nl; m++ )
+    _HB_OPEN_Free_Coverage( &l[m] );
+
+  FREE( l );
+
+Fail3:
+  for ( m = 0; m < ni; m++ )
+    _HB_OPEN_Free_Coverage( &i[m] );
+
+  FREE( i );
+
+Fail4:
+  for ( m = 0; m < nb; m++ )
+    _HB_OPEN_Free_Coverage( &b[m] );
+
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainContextPos3( HB_ChainContextPosFormat3*  ccpf3 )
+{
+  HB_UShort      n, count;
+
+  HB_Coverage*  c;
+
+
+  FREE( ccpf3->PosLookupRecord );
+
+  if ( ccpf3->LookaheadCoverage )
+  {
+    count = ccpf3->LookaheadGlyphCount;
+    c     = ccpf3->LookaheadCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  if ( ccpf3->InputCoverage )
+  {
+    count = ccpf3->InputGlyphCount;
+    c     = ccpf3->InputCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  if ( ccpf3->BacktrackCoverage )
+  {
+    count = ccpf3->BacktrackGlyphCount;
+    c     = ccpf3->BacktrackCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+}
+
+
+/* ChainContextPos */
+
+static HB_Error  Load_ChainContextPos( HB_GPOS_SubTable* st,
+                                      HB_Stream             stream )
+{
+  HB_Error  error;
+  HB_ChainContextPos*  ccp = &st->chain;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  ccp->PosFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( ccp->PosFormat )
+  {
+  case 1:
+    return Load_ChainContextPos1( &ccp->ccpf.ccpf1, stream );
+
+  case 2:
+    return Load_ChainContextPos2( &ccp->ccpf.ccpf2, stream );
+
+  case 3:
+    return Load_ChainContextPos3( &ccp->ccpf.ccpf3, stream );
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+static void  Free_ChainContextPos( HB_GPOS_SubTable* st )
+{
+  HB_ChainContextPos*  ccp = &st->chain;
+
+  switch ( ccp->PosFormat )
+  {
+  case 1:  Free_ChainContextPos1( &ccp->ccpf.ccpf1 ); break;
+  case 2:  Free_ChainContextPos2( &ccp->ccpf.ccpf2 ); break;
+  case 3:  Free_ChainContextPos3( &ccp->ccpf.ccpf3 ); break;
+  default:                                                   break;
+  }
+}
+
+
+static HB_Error  Lookup_ChainContextPos1(
+                  GPOS_Instance*               gpi,
+                  HB_ChainContextPosFormat1*  ccpf1,
+                  HB_Buffer                   buffer,
+                  HB_UShort                    flags,
+                  HB_UShort                    context_length,
+                  int                          nesting_level )
+{
+  HB_UShort          index, property;
+  HB_UShort          i, j, k, num_cpr;
+  HB_UShort          bgc, igc, lgc;
+  HB_Error           error;
+  HB_GPOSHeader*    gpos = gpi->gpos;
+
+  HB_ChainPosRule*  cpr;
+  HB_ChainPosRule   curr_cpr;
+  HB_GDEFHeader*    gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &ccpf1->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  cpr     = ccpf1->ChainPosRuleSet[index].ChainPosRule;
+  num_cpr = ccpf1->ChainPosRuleSet[index].ChainPosRuleCount;
+
+  for ( k = 0; k < num_cpr; k++ )
+  {
+    curr_cpr = cpr[k];
+    bgc      = curr_cpr.BacktrackGlyphCount;
+    igc      = curr_cpr.InputGlyphCount;
+    lgc      = curr_cpr.LookaheadGlyphCount;
+
+    if ( context_length != 0xFFFF && context_length < igc )
+      goto next_chainposrule;
+
+    /* check whether context is too long; it is a first guess only */
+
+    if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+      goto next_chainposrule;
+
+    if ( bgc )
+    {
+      /* Since we don't know in advance the number of glyphs to inspect,
+        we search backwards for matches in the backtrack glyph array    */
+
+      for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
+      {
+       while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+       {
+         if ( error && error != HB_Err_Not_Covered )
+           return error;
+
+         if ( j + 1 == bgc - i )
+           goto next_chainposrule;
+         j--;
+       }
+
+       /* In OpenType 1.3, it is undefined whether the offsets of
+          backtrack glyphs is in logical order or not.  Version 1.4
+          will clarify this:
+
+            Logical order -      a  b  c  d  e  f  g  h  i  j
+                                             i
+            Input offsets -                  0  1
+            Backtrack offsets -  3  2  1  0
+            Lookahead offsets -                    0  1  2  3           */
+
+       if ( IN_GLYPH( j ) != curr_cpr.Backtrack[i] )
+         goto next_chainposrule;
+      }
+    }
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+         goto next_chainposrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != curr_cpr.Input[i - 1] )
+       goto next_chainposrule;
+    }
+
+    /* we are starting to check for lookahead glyphs right after the
+       last context glyph                                            */
+
+    for ( i = 0; i < lgc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + lgc - i == (HB_Int)buffer->in_length )
+         goto next_chainposrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != curr_cpr.Lookahead[i] )
+       goto next_chainposrule;
+    }
+
+    return Do_ContextPos( gpi, igc,
+                         curr_cpr.PosCount,
+                         curr_cpr.PosLookupRecord,
+                         buffer,
+                         nesting_level );
+
+  next_chainposrule:
+    ;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Lookup_ChainContextPos2(
+                  GPOS_Instance*               gpi,
+                  HB_ChainContextPosFormat2*  ccpf2,
+                  HB_Buffer                   buffer,
+                  HB_UShort                    flags,
+                  HB_UShort                    context_length,
+                  int                          nesting_level )
+{
+  HB_UShort              index, property;
+  HB_Error               error;
+  HB_UShort              i, j, k;
+  HB_UShort              bgc, igc, lgc;
+  HB_UShort              known_backtrack_classes,
+                        known_input_classes,
+                        known_lookahead_classes;
+
+  HB_UShort*             backtrack_classes;
+  HB_UShort*             input_classes;
+  HB_UShort*             lookahead_classes;
+
+  HB_UShort*             bc;
+  HB_UShort*             ic;
+  HB_UShort*             lc;
+  HB_GPOSHeader*        gpos = gpi->gpos;
+
+  HB_ChainPosClassSet*  cpcs;
+  HB_ChainPosClassRule  cpcr;
+  HB_GDEFHeader*        gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  /* Note: The coverage table in format 2 doesn't give an index into
+          anything.  It just lets us know whether or not we need to
+          do any lookup at all.                                     */
+
+  error = _HB_OPEN_Coverage_Index( &ccpf2->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if ( ALLOC_ARRAY( backtrack_classes, ccpf2->MaxBacktrackLength, HB_UShort ) )
+    return error;
+  known_backtrack_classes = 0;
+
+  if (ccpf2->MaxInputLength < 1)
+    return HB_Err_Not_Covered;
+
+  if ( ALLOC_ARRAY( input_classes, ccpf2->MaxInputLength, HB_UShort ) )
+    goto End3;
+  known_input_classes = 1;
+
+  if ( ALLOC_ARRAY( lookahead_classes, ccpf2->MaxLookaheadLength, HB_UShort ) )
+    goto End2;
+  known_lookahead_classes = 0;
+
+  error = _HB_OPEN_Get_Class( &ccpf2->InputClassDef, IN_CURGLYPH(),
+                    &input_classes[0], NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    goto End1;
+
+  cpcs = &ccpf2->ChainPosClassSet[input_classes[0]];
+  if ( !cpcs )
+  {
+    error = ERR_HB(HB_Err_Invalid_SubTable);
+    goto End1;
+  }
+
+  for ( k = 0; k < cpcs->ChainPosClassRuleCount; k++ )
+  {
+    cpcr = cpcs->ChainPosClassRule[k];
+    bgc  = cpcr.BacktrackGlyphCount;
+    igc  = cpcr.InputGlyphCount;
+    lgc  = cpcr.LookaheadGlyphCount;
+
+    if ( context_length != 0xFFFF && context_length < igc )
+      goto next_chainposclassrule;
+
+    /* check whether context is too long; it is a first guess only */
+
+    if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+      goto next_chainposclassrule;
+
+    if ( bgc )
+    {
+      /* Since we don't know in advance the number of glyphs to inspect,
+        we search backwards for matches in the backtrack glyph array.
+        Note that `known_backtrack_classes' starts at index 0.         */
+
+      bc       = cpcr.Backtrack;
+
+      for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
+      {
+       while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+       {
+         if ( error && error != HB_Err_Not_Covered )
+           goto End1;
+
+         if ( j + 1 == bgc - i )
+           goto next_chainposclassrule;
+         j++;
+       }
+
+       if ( i >= known_backtrack_classes )
+       {
+         /* Keeps us from having to do this for each rule */
+
+         error = _HB_OPEN_Get_Class( &ccpf2->BacktrackClassDef, IN_GLYPH( j ),
+                            &backtrack_classes[i], NULL );
+         if ( error && error != HB_Err_Not_Covered )
+           goto End1;
+         known_backtrack_classes = i;
+       }
+
+       if ( bc[i] != backtrack_classes[i] )
+         goto next_chainposclassrule;
+      }
+    }
+
+    ic       = cpcr.Input;
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+
+       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+         goto next_chainposclassrule;
+       j++;
+      }
+
+      if ( i >= known_input_classes )
+      {
+       error = _HB_OPEN_Get_Class( &ccpf2->InputClassDef, IN_GLYPH( j ),
+                          &input_classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+       known_input_classes = i;
+      }
+
+      if ( ic[i - 1] != input_classes[i] )
+       goto next_chainposclassrule;
+    }
+
+    /* we are starting to check for lookahead glyphs right after the
+       last context glyph                                            */
+
+    lc       = cpcr.Lookahead;
+
+    for ( i = 0; i < lgc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+
+       if ( j + lgc - i == (HB_Int)buffer->in_length )
+         goto next_chainposclassrule;
+       j++;
+      }
+
+      if ( i >= known_lookahead_classes )
+      {
+       error = _HB_OPEN_Get_Class( &ccpf2->LookaheadClassDef, IN_GLYPH( j ),
+                          &lookahead_classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+       known_lookahead_classes = i;
+      }
+
+      if ( lc[i] != lookahead_classes[i] )
+       goto next_chainposclassrule;
+    }
+
+    error = Do_ContextPos( gpi, igc,
+                          cpcr.PosCount,
+                          cpcr.PosLookupRecord,
+                          buffer,
+                          nesting_level );
+    goto End1;
+
+  next_chainposclassrule:
+    ;
+  }
+
+  error = HB_Err_Not_Covered;
+
+End1:
+  FREE( lookahead_classes );
+
+End2:
+  FREE( input_classes );
+
+End3:
+  FREE( backtrack_classes );
+  return error;
+}
+
+
+static HB_Error  Lookup_ChainContextPos3(
+                  GPOS_Instance*               gpi,
+                  HB_ChainContextPosFormat3*  ccpf3,
+                  HB_Buffer                   buffer,
+                  HB_UShort                    flags,
+                  HB_UShort                    context_length,
+                  int                          nesting_level )
+{
+  HB_UShort        index, i, j, property;
+  HB_UShort        bgc, igc, lgc;
+  HB_Error         error;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+
+  HB_Coverage*    bc;
+  HB_Coverage*    ic;
+  HB_Coverage*    lc;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gpos->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  bgc = ccpf3->BacktrackGlyphCount;
+  igc = ccpf3->InputGlyphCount;
+  lgc = ccpf3->LookaheadGlyphCount;
+
+  if ( context_length != 0xFFFF && context_length < igc )
+    return HB_Err_Not_Covered;
+
+  /* check whether context is too long; it is a first guess only */
+
+  if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+    return HB_Err_Not_Covered;
+
+  if ( bgc )
+  {
+    /* Since we don't know in advance the number of glyphs to inspect,
+       we search backwards for matches in the backtrack glyph array    */
+
+    bc       = ccpf3->BacktrackCoverage;
+
+    for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + 1 == bgc - i )
+         return HB_Err_Not_Covered;
+       j--;
+      }
+
+      error = _HB_OPEN_Coverage_Index( &bc[i], IN_GLYPH( j ), &index );
+      if ( error )
+       return error;
+    }
+  }
+
+  ic       = ccpf3->InputCoverage;
+
+  for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )
+  {
+    /* We already called CHECK_Property for IN_GLYPH ( buffer->in_pos ) */
+    while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &ic[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  /* we are starting to check for lookahead glyphs right after the
+     last context glyph                                            */
+
+  lc       = ccpf3->LookaheadCoverage;
+
+  for ( i = 0; i < lgc; i++, j++ )
+  {
+    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + lgc - i == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  return Do_ContextPos( gpi, igc,
+                       ccpf3->PosCount,
+                       ccpf3->PosLookupRecord,
+                       buffer,
+                       nesting_level );
+}
+
+
+static HB_Error  Lookup_ChainContextPos(
+                  GPOS_Instance*        gpi,
+                  HB_GPOS_SubTable* st,
+                  HB_Buffer            buffer,
+                  HB_UShort             flags,
+                  HB_UShort             context_length,
+                  int                   nesting_level )
+{
+  HB_ChainContextPos*  ccp = &st->chain;
+
+  switch ( ccp->PosFormat )
+  {
+  case 1:
+    return Lookup_ChainContextPos1( gpi, &ccp->ccpf.ccpf1, buffer,
+                                   flags, context_length,
+                                   nesting_level );
+
+  case 2:
+    return Lookup_ChainContextPos2( gpi, &ccp->ccpf.ccpf2, buffer,
+                                   flags, context_length,
+                                   nesting_level );
+
+  case 3:
+    return Lookup_ChainContextPos3( gpi, &ccp->ccpf.ccpf3, buffer,
+                                   flags, context_length,
+                                   nesting_level );
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+
+/***********
+ * GPOS API
+ ***********/
+
+
+
+HB_Error  HB_GPOS_Select_Script( HB_GPOSHeader*  gpos,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index )
+{
+  HB_UShort          n;
+
+  HB_ScriptList*    sl;
+  HB_ScriptRecord*  sr;
+
+
+  if ( !gpos || !script_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  for ( n = 0; n < sl->ScriptCount; n++ )
+    if ( script_tag == sr[n].ScriptTag )
+    {
+      *script_index = n;
+
+      return HB_Err_Ok;
+    }
+
+  return HB_Err_Not_Covered;
+}
+
+
+
+HB_Error  HB_GPOS_Select_Language( HB_GPOSHeader*  gpos,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index )
+{
+  HB_UShort           n;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*         s;
+  HB_LangSysRecord*  lsr;
+
+
+  if ( !gpos || !language_index || !req_feature_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  for ( n = 0; n < s->LangSysCount; n++ )
+    if ( language_tag == lsr[n].LangSysTag )
+    {
+      *language_index = n;
+      *req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
+
+      return HB_Err_Ok;
+    }
+
+  return HB_Err_Not_Covered;
+}
+
+
+/* selecting 0xFFFF for language_index asks for the values of the
+   default language (DefaultLangSys)                              */
+
+
+HB_Error  HB_GPOS_Select_Feature( HB_GPOSHeader*  gpos,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index )
+{
+  HB_UShort           n;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*         s;
+  HB_LangSysRecord*  lsr;
+  HB_LangSys*        ls;
+  HB_UShort*          fi;
+
+  HB_FeatureList*    fl;
+  HB_FeatureRecord*  fr;
+
+
+  if ( !gpos || !feature_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  fl = &gpos->FeatureList;
+  fr = fl->FeatureRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( language_index == 0xFFFF )
+    ls = &s->DefaultLangSys;
+  else
+  {
+    if ( language_index >= s->LangSysCount )
+      return ERR_HB(HB_Err_Invalid_Argument);
+
+    ls = &lsr[language_index].LangSys;
+  }
+
+  fi = ls->FeatureIndex;
+
+  for ( n = 0; n < ls->FeatureCount; n++ )
+  {
+    if ( fi[n] >= fl->FeatureCount )
+      return ERR_HB(HB_Err_Invalid_SubTable_Format);
+
+    if ( feature_tag == fr[fi[n]].FeatureTag )
+    {
+      *feature_index = fi[n];
+
+      return HB_Err_Ok;
+    }
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+/* The next three functions return a null-terminated list */
+
+
+HB_Error  HB_GPOS_Query_Scripts( HB_GPOSHeader*  gpos,
+                                HB_UInt**       script_tag_list )
+{
+  HB_Error           error;
+  HB_UShort          n;
+  HB_UInt*          stl;
+
+  HB_ScriptList*    sl;
+  HB_ScriptRecord*  sr;
+
+
+  if ( !gpos || !script_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < sl->ScriptCount; n++ )
+    stl[n] = sr[n].ScriptTag;
+  stl[n] = 0;
+
+  *script_tag_list = stl;
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GPOS_Query_Languages( HB_GPOSHeader*  gpos,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list )
+{
+  HB_Error            error;
+  HB_UShort           n;
+  HB_UInt*           ltl;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+
+
+  if ( !gpos || !language_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < s->LangSysCount; n++ )
+    ltl[n] = lsr[n].LangSysTag;
+  ltl[n] = 0;
+
+  *language_tag_list = ltl;
+
+  return HB_Err_Ok;
+}
+
+
+/* selecting 0xFFFF for language_index asks for the values of the
+   default language (DefaultLangSys)                              */
+
+
+HB_Error  HB_GPOS_Query_Features( HB_GPOSHeader*  gpos,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list )
+{
+  HB_UShort           n;
+  HB_Error            error;
+  HB_UInt*           ftl;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+  HB_LangSys*        ls;
+  HB_UShort*          fi;
+
+  HB_FeatureList*    fl;
+  HB_FeatureRecord*  fr;
+
+
+  if ( !gpos || !feature_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gpos->ScriptList;
+  sr = sl->ScriptRecord;
+
+  fl = &gpos->FeatureList;
+  fr = fl->FeatureRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( language_index == 0xFFFF )
+    ls = &s->DefaultLangSys;
+  else
+  {
+    if ( language_index >= s->LangSysCount )
+      return ERR_HB(HB_Err_Invalid_Argument);
+
+    ls = &lsr[language_index].LangSys;
+  }
+
+  fi = ls->FeatureIndex;
+
+  if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < ls->FeatureCount; n++ )
+  {
+    if ( fi[n] >= fl->FeatureCount )
+    {
+      FREE( ftl );
+      return ERR_HB(HB_Err_Invalid_SubTable_Format);
+    }
+    ftl[n] = fr[fi[n]].FeatureTag;
+  }
+  ftl[n] = 0;
+
+  *feature_tag_list = ftl;
+
+  return HB_Err_Ok;
+}
+
+
+/* Do an individual subtable lookup.  Returns HB_Err_Ok if positioning
+   has been done, or HB_Err_Not_Covered if not.                        */
+static HB_Error  GPOS_Do_Glyph_Lookup( GPOS_Instance*    gpi,
+                                      HB_UShort         lookup_index,
+                                      HB_Buffer        buffer,
+                                      HB_UShort         context_length,
+                                      int               nesting_level )
+{
+  HB_Error             error = HB_Err_Not_Covered;
+  HB_UShort            i, flags, lookup_count;
+  HB_GPOSHeader*       gpos = gpi->gpos;
+  HB_Lookup*           lo;
+  int                 lookup_type;
+
+
+  nesting_level++;
+
+  if ( nesting_level > HB_MAX_NESTING_LEVEL )
+    return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */
+
+  lookup_count = gpos->LookupList.LookupCount;
+  if (lookup_index >= lookup_count)
+    return error;
+
+  lo    = &gpos->LookupList.Lookup[lookup_index];
+  flags = lo->LookupFlag;
+  lookup_type = lo->LookupType;
+
+  for ( i = 0; i < lo->SubTableCount; i++ )
+  {
+    HB_GPOS_SubTable *st = &lo->SubTable[i].st.gpos;
+
+    switch (lookup_type) {
+      case HB_GPOS_LOOKUP_SINGLE:
+        error = Lookup_SinglePos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_PAIR:
+       error = Lookup_PairPos          ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_CURSIVE:
+       error = Lookup_CursivePos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_MARKBASE:
+       error = Lookup_MarkBasePos      ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_MARKLIG:
+       error = Lookup_MarkLigPos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_MARKMARK:
+       error = Lookup_MarkMarkPos      ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_CONTEXT:
+       error = Lookup_ContextPos       ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GPOS_LOOKUP_CHAIN:
+       error = Lookup_ChainContextPos  ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+    /*case HB_GPOS_LOOKUP_EXTENSION:
+       error = Lookup_ExtensionPos     ( gpi, st, buffer, flags, context_length, nesting_level ); break;*/
+      default:
+       error = HB_Err_Not_Covered;
+    }
+
+    /* Check whether we have a successful positioning or an error other
+       than HB_Err_Not_Covered                                         */
+    if ( error != HB_Err_Not_Covered )
+      return error;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+HB_INTERNAL HB_Error
+_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+                       HB_Stream         stream,
+                       HB_UShort         lookup_type )
+{
+  switch ( lookup_type ) {
+    case HB_GPOS_LOOKUP_SINGLE:                return Load_SinglePos           ( st, stream );
+    case HB_GPOS_LOOKUP_PAIR:          return Load_PairPos             ( st, stream );
+    case HB_GPOS_LOOKUP_CURSIVE:       return Load_CursivePos          ( st, stream );
+    case HB_GPOS_LOOKUP_MARKBASE:      return Load_MarkBasePos         ( st, stream );
+    case HB_GPOS_LOOKUP_MARKLIG:       return Load_MarkLigPos          ( st, stream );
+    case HB_GPOS_LOOKUP_MARKMARK:      return Load_MarkMarkPos         ( st, stream );
+    case HB_GPOS_LOOKUP_CONTEXT:       return Load_ContextPos          ( st, stream );
+    case HB_GPOS_LOOKUP_CHAIN:         return Load_ChainContextPos     ( st, stream );
+  /*case HB_GPOS_LOOKUP_EXTENSION:     return Load_ExtensionPos        ( st, stream );*/
+    default:                           return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+}
+
+
+HB_INTERNAL void
+_HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
+                       HB_UShort         lookup_type )
+{
+  switch ( lookup_type ) {
+    case HB_GPOS_LOOKUP_SINGLE:                Free_SinglePos          ( st ); return;
+    case HB_GPOS_LOOKUP_PAIR:          Free_PairPos            ( st ); return;
+    case HB_GPOS_LOOKUP_CURSIVE:       Free_CursivePos         ( st ); return;
+    case HB_GPOS_LOOKUP_MARKBASE:      Free_MarkBasePos        ( st ); return;
+    case HB_GPOS_LOOKUP_MARKLIG:       Free_MarkLigPos         ( st ); return;
+    case HB_GPOS_LOOKUP_MARKMARK:      Free_MarkMarkPos        ( st ); return;
+    case HB_GPOS_LOOKUP_CONTEXT:       Free_ContextPos         ( st ); return;
+    case HB_GPOS_LOOKUP_CHAIN:         Free_ChainContextPos    ( st ); return;
+  /*case HB_GPOS_LOOKUP_EXTENSION:     Free_ExtensionPos       ( st ); return;*/
+    default:                                                                   return;
+  }
+}
+
+
+/* apply one lookup to the input string object */
+
+static HB_Error  GPOS_Do_String_Lookup( GPOS_Instance*    gpi,
+                                  HB_UShort         lookup_index,
+                                  HB_Buffer        buffer )
+{
+  HB_Error         error, retError = HB_Err_Not_Covered;
+  HB_GPOSHeader*  gpos = gpi->gpos;
+
+  HB_UInt*  properties = gpos->LookupList.Properties;
+
+  const int       nesting_level = 0;
+  /* 0xFFFF indicates that we don't have a context length yet */
+  const HB_UShort context_length = 0xFFFF;
+
+
+  gpi->last  = 0xFFFF;     /* no last valid glyph for cursive pos. */
+
+  buffer->in_pos = 0;
+  while ( buffer->in_pos < buffer->in_length )
+  {
+    if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
+    {
+      /* Note that the connection between mark and base glyphs hold
+        exactly one (string) lookup.  For example, it would be possible
+        that in the first lookup, mark glyph X is attached to base
+        glyph A, and in the next lookup it is attached to base glyph B.
+        It is up to the font designer to provide meaningful lookups and
+        lookup order.                                                   */
+
+      error = GPOS_Do_Glyph_Lookup( gpi, lookup_index, buffer, context_length, nesting_level );
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+    }
+    else
+    {
+      /* Contrary to properties defined in GDEF, user-defined properties
+        will always stop a possible cursive positioning.                */
+      gpi->last = 0xFFFF;
+
+      error = HB_Err_Not_Covered;
+    }
+
+    if ( error == HB_Err_Not_Covered )
+      (buffer->in_pos)++;
+    else
+      retError = error;
+  }
+
+  return retError;
+}
+
+
+static HB_Error  Position_CursiveChain ( HB_Buffer     buffer )
+{
+  HB_UInt   i, j;
+  HB_Position positions = buffer->positions;
+
+  /* First handle all left-to-right connections */
+  for (j = 0; j < buffer->in_length; j++)
+  {
+    if (positions[j].cursive_chain > 0)
+      positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;
+  }
+
+  /* Then handle all right-to-left connections */
+  for (i = buffer->in_length; i > 0; i--)
+  {
+    j = i - 1;
+
+    if (positions[j].cursive_chain < 0)
+      positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+HB_Error  HB_GPOS_Add_Feature( HB_GPOSHeader*  gpos,
+                              HB_UShort        feature_index,
+                              HB_UInt          property )
+{
+  HB_UShort    i;
+
+  HB_Feature  feature;
+  HB_UInt*     properties;
+  HB_UShort*   index;
+  HB_UShort    lookup_count;
+
+  /* Each feature can only be added once */
+
+  if ( !gpos ||
+       feature_index >= gpos->FeatureList.FeatureCount ||
+       gpos->FeatureList.ApplyCount == gpos->FeatureList.FeatureCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gpos->FeatureList.ApplyOrder[gpos->FeatureList.ApplyCount++] = feature_index;
+
+  properties = gpos->LookupList.Properties;
+
+  feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;
+  index   = feature.LookupListIndex;
+  lookup_count = gpos->LookupList.LookupCount;
+
+  for ( i = 0; i < feature.LookupListCount; i++ )
+  {
+    HB_UShort lookup_index = index[i];
+    if (lookup_index < lookup_count)
+      properties[lookup_index] |= property;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GPOS_Clear_Features( HB_GPOSHeader*  gpos )
+{
+  HB_UShort i;
+
+  HB_UInt*  properties;
+
+
+  if ( !gpos )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gpos->FeatureList.ApplyCount = 0;
+
+  properties = gpos->LookupList.Properties;
+
+  for ( i = 0; i < gpos->LookupList.LookupCount; i++ )
+    properties[i] = 0;
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GPOS_Register_MM_Function( HB_GPOSHeader*  gpos,
+                                       HB_MMFunction   mmfunc,
+                                       void*            data )
+{
+  if ( !gpos )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gpos->mmfunc = mmfunc;
+  gpos->data   = data;
+
+  return HB_Err_Ok;
+}
+
+/* If `dvi' is TRUE, glyph contour points for anchor points and device
+   tables are ignored -- you will get device independent values.         */
+
+
+HB_Error  HB_GPOS_Apply_String( HB_Font            font,
+                               HB_GPOSHeader*    gpos,
+                               HB_UShort          load_flags,
+                               HB_Buffer         buffer,
+                               HB_Bool            dvi,
+                               HB_Bool            r2l )
+{
+  HB_Error       error, retError = HB_Err_Not_Covered;
+  GPOS_Instance  gpi;
+  int            i, j, lookup_count, num_features;
+
+  if ( !font || !gpos || !buffer )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( buffer->in_length == 0 )
+    return HB_Err_Not_Covered;
+
+  gpi.font       = font;
+  gpi.gpos       = gpos;
+  gpi.load_flags = load_flags;
+  gpi.r2l        = r2l;
+  gpi.dvi        = dvi;
+
+  lookup_count = gpos->LookupList.LookupCount;
+  num_features = gpos->FeatureList.ApplyCount;
+
+  if ( num_features )
+    {
+      error = _hb_buffer_clear_positions( buffer );
+      if ( error )
+       return error;
+    }
+
+  for ( i = 0; i < num_features; i++ )
+  {
+    HB_UShort  feature_index = gpos->FeatureList.ApplyOrder[i];
+    HB_Feature feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;
+
+    for ( j = 0; j < feature.LookupListCount; j++ )
+    {
+      HB_UShort lookup_index = feature.LookupListIndex[j];
+
+      /* Skip nonexistant lookups */
+      if (lookup_index >= lookup_count)
+       continue;
+
+      error = GPOS_Do_String_Lookup( &gpi, lookup_index, buffer );
+      if ( error )
+      {
+       if ( error != HB_Err_Not_Covered )
+         return error;
+      }
+      else
+       retError = error;
+    }
+  }
+
+  if ( num_features )
+    {
+  error = Position_CursiveChain ( buffer );
+  if ( error )
+    return error;
+    }
+
+  return retError;
+}
+
+/* END */
index f262389..ed05530 100755 (executable)
-/*\r
- * Copyright (C) 1998-2004  David Turner and Werner Lemberg\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- * Copyright (C) 2007  Red Hat, Inc.\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-gsub-private.h"\r
-#include "harfbuzz-open-private.h"\r
-#include "harfbuzz-gdef-private.h"\r
-\r
-static HB_Error  GSUB_Do_Glyph_Lookup( HB_GSUBHeader*   gsub,\r
-                                      HB_UShort         lookup_index,\r
-                                      HB_Buffer        buffer,\r
-                                      HB_UShort         context_length,\r
-                                      int               nesting_level );\r
-\r
-\r
-\r
-/**********************\r
- * Auxiliary functions\r
- **********************/\r
-\r
-\r
-\r
-HB_Error  HB_Load_GSUB_Table( HB_Stream stream,\r
-                             HB_GSUBHeader** retptr,\r
-                             HB_GDEFHeader*  gdef,\r
-                              HB_Stream       gdefStream )\r
-{\r
-  HB_Error         error;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_GSUBHeader*  gsub;\r
-\r
-  if ( !retptr )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( GOTO_Table( TTAG_GSUB ) )\r
-    return error;\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ALLOC ( gsub, sizeof( *gsub ), HB_GSUBHeader* ) ) \r
-      return error;\r
-  \r
-\r
-  /* skip version */\r
-\r
-  if ( FILE_Seek( base_offset + 4L ) ||\r
-       ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_ScriptList( &gsub->ScriptList,\r
-                                 stream ) ) != HB_Err_Ok )\r
-    goto Fail4;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_FeatureList( &gsub->FeatureList,\r
-                                  stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_LookupList( &gsub->LookupList,\r
-                                 stream, HB_Type_GSUB ) ) != HB_Err_Ok )\r
-    goto Fail2;\r
-\r
-  gsub->gdef = gdef;      /* can be NULL */\r
-\r
-  if ( ( error =  _HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( gdef, gdefStream,\r
-                                                                    gsub->LookupList.Lookup,\r
-                                                                    gsub->LookupList.LookupCount ) ) )\r
-    goto Fail1;\r
-\r
-  *retptr = gsub;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_FeatureList( &gsub->FeatureList );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_ScriptList( &gsub->ScriptList );\r
-\r
-Fail4:\r
-  FREE ( gsub );\r
-\r
-\r
-  return error;\r
-}\r
-\r
-\r
-HB_Error   HB_Done_GSUB_Table( HB_GSUBHeader* gsub )\r
-{\r
-  _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB );\r
-  _HB_OPEN_Free_FeatureList( &gsub->FeatureList );\r
-  _HB_OPEN_Free_ScriptList( &gsub->ScriptList );\r
-\r
-  FREE( gsub );\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-/*****************************\r
- * SubTable related functions\r
- *****************************/\r
-\r
-\r
-/* LookupType 1 */\r
-\r
-/* SingleSubstFormat1 */\r
-/* SingleSubstFormat2 */\r
-\r
-static HB_Error  Load_SingleSubst( HB_GSUB_SubTable* st,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_SingleSubst*  ss = &st->single;\r
-\r
-  HB_UShort n, count;\r
-  HB_UInt cur_offset, new_offset, base_offset;\r
-\r
-  HB_UShort*  s;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  ss->SubstFormat = GET_UShort();\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ss->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  switch ( ss->SubstFormat )\r
-  {\r
-  case 1:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    ss->ssf.ssf1.DeltaGlyphID = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    break;\r
-\r
-  case 2:\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    count = ss->ssf.ssf2.GlyphCount = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    ss->ssf.ssf2.Substitute = NULL;\r
-\r
-    if ( ALLOC_ARRAY( ss->ssf.ssf2.Substitute, count, HB_UShort ) )\r
-      goto Fail2;\r
-\r
-    s = ss->ssf.ssf2.Substitute;\r
-\r
-    if ( ACCESS_Frame( count * 2L ) )\r
-      goto Fail1;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      s[n] = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( s );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &ss->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SingleSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_SingleSubst*  ss = &st->single;\r
-\r
-  switch ( ss->SubstFormat )\r
-  {\r
-  case 1:\r
-    break;\r
-\r
-  case 2:\r
-    FREE( ss->ssf.ssf2.Substitute );\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &ss->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,\r
-                                    HB_GSUB_SubTable* st,\r
-                                    HB_Buffer        buffer,\r
-                                    HB_UShort         flags,\r
-                                    HB_UShort         context_length,\r
-                                    int               nesting_level )\r
-{\r
-  HB_UShort index, value, property;\r
-  HB_Error  error;\r
-  HB_SingleSubst*  ss = &st->single;\r
-  HB_GDEFHeader*   gdef = gsub->gdef;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ss->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  switch ( ss->SubstFormat )\r
-  {\r
-  case 1:\r
-    value = ( IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF;\r
-    if ( REPLACE_Glyph( buffer, value, nesting_level ) )\r
-      return error;\r
-    break;\r
-\r
-  case 2:\r
-    if ( index >= ss->ssf.ssf2.GlyphCount )\r
-      return ERR_HB(HB_Err_Invalid_SubTable);\r
-    value = ss->ssf.ssf2.Substitute[index];\r
-    if ( REPLACE_Glyph( buffer, value, nesting_level ) )\r
-      return error;\r
-    break;\r
-\r
-  default:\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-  }\r
-\r
-  if ( gdef && gdef->NewGlyphClasses )\r
-  {\r
-    /* we inherit the old glyph class to the substituted glyph */\r
-\r
-    error = _HB_GDEF_Add_Glyph_Property( gdef, value, property );\r
-    if ( error && error != HB_Err_Not_Covered )\r
-      return error;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 2 */\r
-\r
-/* Sequence */\r
-\r
-static HB_Error  Load_Sequence( HB_Sequence*  s,\r
-                               HB_Stream      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort n, count;\r
-  HB_UShort*  sub;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = s->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  s->Substitute = NULL;\r
-\r
-  if ( count )\r
-  {\r
-    if ( ALLOC_ARRAY( s->Substitute, count, HB_UShort ) )\r
-      return error;\r
-\r
-    sub = s->Substitute;\r
-\r
-    if ( ACCESS_Frame( count * 2L ) )\r
-    {\r
-      FREE( sub );\r
-      return error;\r
-    }\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      sub[n] = GET_UShort();\r
-\r
-    FORGET_Frame();\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_Sequence( HB_Sequence*  s )\r
-{\r
-  FREE( s->Substitute );\r
-}\r
-\r
-\r
-/* MultipleSubstFormat1 */\r
-\r
-static HB_Error  Load_MultipleSubst( HB_GSUB_SubTable* st,\r
-                                    HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_MultipleSubst*  ms = &st->multiple;\r
-\r
-  HB_UShort      n = 0, m, count;\r
-  HB_UInt       cur_offset, new_offset, base_offset;\r
-\r
-  HB_Sequence*  s;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  ms->SubstFormat = GET_UShort();             /* should be 1 */\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ms->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = ms->SequenceCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ms->Sequence = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ms->Sequence, count, HB_Sequence ) )\r
-    goto Fail2;\r
-\r
-  s = ms->Sequence;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_Sequence( &s[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_Sequence( &s[m] );\r
-\r
-  FREE( s );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &ms->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_MultipleSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_UShort      n, count;\r
-  HB_MultipleSubst*  ms = &st->multiple;\r
-\r
-  HB_Sequence*  s;\r
-\r
-\r
-  if ( ms->Sequence )\r
-  {\r
-    count = ms->SequenceCount;\r
-    s     = ms->Sequence;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Sequence( &s[n] );\r
-\r
-    FREE( s );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &ms->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_MultipleSubst( HB_GSUBHeader*    gsub,\r
-                                      HB_GSUB_SubTable* st,\r
-                                      HB_Buffer         buffer,\r
-                                      HB_UShort          flags,\r
-                                      HB_UShort          context_length,\r
-                                      int                nesting_level )\r
-{\r
-  HB_Error  error;\r
-  HB_UShort index, property, n, count;\r
-  HB_UShort*s;\r
-  HB_MultipleSubst*  ms = &st->multiple;\r
-  HB_GDEFHeader*     gdef = gsub->gdef;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ms->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( index >= ms->SequenceCount )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  count = ms->Sequence[index].GlyphCount;\r
-  s     = ms->Sequence[index].Substitute;\r
-\r
-  if ( ADD_String( buffer, 1, count, s, 0xFFFF, 0xFFFF ) )\r
-    return error;\r
-\r
-  if ( gdef && gdef->NewGlyphClasses )\r
-  {\r
-    /* this is a guess only ... */\r
-\r
-    if ( property == HB_GDEF_LIGATURE )\r
-      property = HB_GDEF_BASE_GLYPH;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-    {\r
-      error = _HB_GDEF_Add_Glyph_Property( gdef, s[n], property );\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 3 */\r
-\r
-/* AlternateSet */\r
-\r
-static HB_Error  Load_AlternateSet( HB_AlternateSet*  as,\r
-                                   HB_Stream          stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort n, count;\r
-  HB_UShort*  a;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = as->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  as->Alternate = NULL;\r
-\r
-  if ( ALLOC_ARRAY( as->Alternate, count, HB_UShort ) )\r
-    return error;\r
-\r
-  a = as->Alternate;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( a );\r
-    return error;\r
-  }\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    a[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_AlternateSet( HB_AlternateSet*  as )\r
-{\r
-  FREE( as->Alternate );\r
-}\r
-\r
-\r
-/* AlternateSubstFormat1 */\r
-\r
-static HB_Error  Load_AlternateSubst( HB_GSUB_SubTable* st,\r
-                                     HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_AlternateSubst* as = &st->alternate;\r
-\r
-  HB_UShort          n = 0, m, count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_AlternateSet*  aset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  as->SubstFormat = GET_UShort();             /* should be 1 */\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &as->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = as->AlternateSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  as->AlternateSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( as->AlternateSet, count, HB_AlternateSet ) )\r
-    goto Fail2;\r
-\r
-  aset = as->AlternateSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_AlternateSet( &aset[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_AlternateSet( &aset[m] );\r
-\r
-  FREE( aset );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &as->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_AlternateSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_UShort          n, count;\r
-  HB_AlternateSubst* as = &st->alternate;\r
-\r
-  HB_AlternateSet*  aset;\r
-\r
-\r
-  if ( as->AlternateSet )\r
-  {\r
-    count = as->AlternateSetCount;\r
-    aset  = as->AlternateSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_AlternateSet( &aset[n] );\r
-\r
-    FREE( aset );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &as->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_AlternateSubst( HB_GSUBHeader*    gsub,\r
-                                       HB_GSUB_SubTable* st,\r
-                                       HB_Buffer         buffer,\r
-                                       HB_UShort          flags,\r
-                                       HB_UShort          context_length,\r
-                                       int                nesting_level )\r
-{\r
-  HB_Error          error;\r
-  HB_UShort         index, value, alt_index, property;\r
-  HB_AlternateSubst* as = &st->alternate;\r
-  HB_GDEFHeader*     gdef = gsub->gdef;\r
-  HB_AlternateSet  aset;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( context_length != 0xFFFF && context_length < 1 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &as->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  aset = as->AlternateSet[index];\r
-\r
-  /* we use a user-defined callback function to get the alternate index */\r
-\r
-  if ( gsub->altfunc )\r
-    alt_index = (gsub->altfunc)( buffer->out_pos, IN_CURGLYPH(),\r
-                                aset.GlyphCount, aset.Alternate,\r
-                                gsub->data );\r
-  else\r
-    alt_index = 0;\r
-\r
-  value = aset.Alternate[alt_index];\r
-  if ( REPLACE_Glyph( buffer, value, nesting_level ) )\r
-    return error;\r
-\r
-  if ( gdef && gdef->NewGlyphClasses )\r
-  {\r
-    /* we inherit the old glyph class to the substituted glyph */\r
-\r
-    error = _HB_GDEF_Add_Glyph_Property( gdef, value, property );\r
-    if ( error && error != HB_Err_Not_Covered )\r
-      return error;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 4 */\r
-\r
-/* Ligature */\r
-\r
-static HB_Error  Load_Ligature( HB_Ligature*  l,\r
-                               HB_Stream      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort n, count;\r
-  HB_UShort*  c;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  l->LigGlyph       = GET_UShort();\r
-  l->ComponentCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  l->Component = NULL;\r
-\r
-  count = l->ComponentCount - 1;      /* only ComponentCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( l->Component, count, HB_UShort ) )\r
-    return error;\r
-\r
-  c = l->Component;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( c );\r
-    return error;\r
-  }\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    c[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_Ligature( HB_Ligature*  l )\r
-{\r
-  FREE( l->Component );\r
-}\r
-\r
-\r
-/* LigatureSet */\r
-\r
-static HB_Error  Load_LigatureSet( HB_LigatureSet*  ls,\r
-                                  HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort      n = 0, m, count;\r
-  HB_UInt       cur_offset, new_offset, base_offset;\r
-\r
-  HB_Ligature*  l;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ls->LigatureCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ls->Ligature = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ls->Ligature, count, HB_Ligature ) )\r
-    return error;\r
-\r
-  l = ls->Ligature;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_Ligature( &l[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_Ligature( &l[m] );\r
-\r
-  FREE( l );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigatureSet( HB_LigatureSet*  ls )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_Ligature*  l;\r
-\r
-\r
-  if ( ls->Ligature )\r
-  {\r
-    count = ls->LigatureCount;\r
-    l     = ls->Ligature;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Ligature( &l[n] );\r
-\r
-    FREE( l );\r
-  }\r
-}\r
-\r
-\r
-/* LigatureSubstFormat1 */\r
-\r
-static HB_Error  Load_LigatureSubst( HB_GSUB_SubTable* st,\r
-                                    HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_LigatureSubst*  ls = &st->ligature;\r
-\r
-  HB_UShort         n = 0, m, count;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_LigatureSet*  lset;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  ls->SubstFormat = GET_UShort();             /* should be 1 */\r
-  new_offset      = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ls->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = ls->LigatureSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ls->LigatureSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ls->LigatureSet, count, HB_LigatureSet ) )\r
-    goto Fail2;\r
-\r
-  lset = ls->LigatureSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LigatureSet( &lset[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_LigatureSet( &lset[m] );\r
-\r
-  FREE( lset );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &ls->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_LigatureSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_UShort         n, count;\r
-  HB_LigatureSubst*  ls = &st->ligature;\r
-\r
-  HB_LigatureSet*  lset;\r
-\r
-\r
-  if ( ls->LigatureSet )\r
-  {\r
-    count = ls->LigatureSetCount;\r
-    lset  = ls->LigatureSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_LigatureSet( &lset[n] );\r
-\r
-    FREE( lset );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &ls->Coverage );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_LigatureSubst( HB_GSUBHeader*    gsub,\r
-                                      HB_GSUB_SubTable* st,\r
-                                      HB_Buffer         buffer,\r
-                                      HB_UShort          flags,\r
-                                      HB_UShort          context_length,\r
-                                      int                nesting_level )\r
-{\r
-  HB_UShort      index, property;\r
-  HB_Error       error;\r
-  HB_UShort      numlig, i, j, is_mark, first_is_mark = FALSE;\r
-  HB_UShort*     c;\r
-  HB_LigatureSubst*  ls = &st->ligature;\r
-  HB_GDEFHeader*     gdef = gsub->gdef;\r
-\r
-  HB_Ligature*  lig;\r
-\r
-  HB_UNUSED(nesting_level);\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  if ( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )\r
-    first_is_mark = TRUE;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ls->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( index >= ls->LigatureSetCount )\r
-     return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  lig = ls->LigatureSet[index].Ligature;\r
-\r
-  for ( numlig = ls->LigatureSet[index].LigatureCount;\r
-       numlig;\r
-       numlig--, lig++ )\r
-  {\r
-    if ( buffer->in_pos + lig->ComponentCount > buffer->in_length )\r
-      goto next_ligature;               /* Not enough glyphs in input */\r
-\r
-    c    = lig->Component;\r
-\r
-    is_mark = first_is_mark;\r
-\r
-    if ( context_length != 0xFFFF && context_length < lig->ComponentCount )\r
-      break;\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < lig->ComponentCount; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + lig->ComponentCount - i == (HB_Int)buffer->in_length )\r
-         goto next_ligature;\r
-       j++;\r
-      }\r
-\r
-      if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )\r
-       is_mark = FALSE;\r
-\r
-      if ( IN_GLYPH( j ) != c[i - 1] )\r
-       goto next_ligature;\r
-    }\r
-\r
-    if ( gdef && gdef->NewGlyphClasses )\r
-    {\r
-      /* this is just a guess ... */\r
-\r
-      error = _HB_GDEF_Add_Glyph_Property( gdef, lig->LigGlyph,\r
-                                 is_mark ? HB_GDEF_MARK : HB_GDEF_LIGATURE );\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-    }\r
-\r
-    if ( j == buffer->in_pos + i ) /* No input glyphs skipped */\r
-    {\r
-      /* We don't use a new ligature ID if there are no skipped\r
-        glyphs and the ligature already has an ID.             */\r
-\r
-      if ( IN_LIGID( buffer->in_pos ) )\r
-      {\r
-       if ( ADD_String( buffer, i, 1, &lig->LigGlyph,\r
-                       0xFFFF, 0xFFFF ) )\r
-         return error;\r
-      }\r
-      else\r
-      {\r
-       HB_UShort ligID = _hb_buffer_allocate_ligid( buffer );\r
-       if ( ADD_String( buffer, i, 1, &lig->LigGlyph,\r
-                       0xFFFF, ligID ) )\r
-         return error;\r
-      }\r
-    }\r
-    else\r
-    {\r
-      HB_UShort ligID = _hb_buffer_allocate_ligid( buffer );\r
-      if ( ADD_Glyph( buffer, lig->LigGlyph, 0xFFFF, ligID ) )\r
-       return error;\r
-\r
-      /* Now we must do a second loop to copy the skipped glyphs to\r
-        `out' and assign component values to it.  We start with the\r
-        glyph after the first component.  Glyphs between component\r
-        i and i+1 belong to component i.  Together with the ligID\r
-        value it is later possible to check whether a specific\r
-        component value really belongs to a given ligature.         */\r
-\r
-      for ( i = 0; i < lig->ComponentCount - 1; i++ )\r
-      {\r
-       while ( CHECK_Property( gdef, IN_CURITEM(),\r
-                               flags, &property ) )\r
-         if ( ADD_Glyph( buffer, IN_CURGLYPH(), i, ligID ) )\r
-           return error;\r
-\r
-       (buffer->in_pos)++;\r
-      }\r
-    }\r
-\r
-    return HB_Err_Ok;\r
-\r
-  next_ligature:\r
-    ;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-/* Do the actual substitution for a context substitution (either format\r
-   5 or 6).  This is only called after we've determined that the input\r
-   matches the subrule.                                                 */\r
-\r
-static HB_Error  Do_ContextSubst( HB_GSUBHeader*        gsub,\r
-                                 HB_UShort              GlyphCount,\r
-                                 HB_UShort              SubstCount,\r
-                                 HB_SubstLookupRecord* subst,\r
-                                 HB_Buffer             buffer,\r
-                                 int                    nesting_level )\r
-{\r
-  HB_Error  error;\r
-  HB_UInt   i, old_pos;\r
-\r
-\r
-  i = 0;\r
-\r
-  while ( i < GlyphCount )\r
-  {\r
-    if ( SubstCount && i == subst->SequenceIndex )\r
-    {\r
-      old_pos = buffer->in_pos;\r
-\r
-      /* Do a substitution */\r
-\r
-      error = GSUB_Do_Glyph_Lookup( gsub, subst->LookupListIndex, buffer,\r
-                                   GlyphCount, nesting_level );\r
-\r
-      subst++;\r
-      SubstCount--;\r
-      i += buffer->in_pos - old_pos;\r
-\r
-      if ( error == HB_Err_Not_Covered )\r
-      {\r
-       if ( COPY_Glyph( buffer ) )\r
-         return error;\r
-       i++;\r
-      }\r
-      else if ( error )\r
-       return error;\r
-    }\r
-    else\r
-    {\r
-      /* No substitution for this index */\r
-\r
-      if ( COPY_Glyph( buffer ) )\r
-       return error;\r
-      i++;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* LookupType 5 */\r
-\r
-/* SubRule */\r
-\r
-static HB_Error  Load_SubRule( HB_SubRule*  sr,\r
-                              HB_Stream     stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n, count;\r
-  HB_UShort*              i;\r
-\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  sr->GlyphCount = GET_UShort();\r
-  sr->SubstCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  sr->Input = NULL;\r
-\r
-  count = sr->GlyphCount - 1;         /* only GlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( sr->Input, count, HB_UShort ) )\r
-    return error;\r
-\r
-  i = sr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  sr->SubstLookupRecord = NULL;\r
-\r
-  count = sr->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( sr->SubstLookupRecord, count, HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = sr->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  FREE( i );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SubRule( HB_SubRule*  sr )\r
-{\r
-  FREE( sr->SubstLookupRecord );\r
-  FREE( sr->Input );\r
-}\r
-\r
-\r
-/* SubRuleSet */\r
-\r
-static HB_Error  Load_SubRuleSet( HB_SubRuleSet*  srs,\r
-                                 HB_Stream        stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort     n = 0, m, count;\r
-  HB_UInt      cur_offset, new_offset, base_offset;\r
-\r
-  HB_SubRule*  sr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = srs->SubRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  srs->SubRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( srs->SubRule, count, HB_SubRule ) )\r
-    return error;\r
-\r
-  sr = srs->SubRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_SubRule( &sr[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_SubRule( &sr[m] );\r
-\r
-  FREE( sr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SubRuleSet( HB_SubRuleSet*  srs )\r
-{\r
-  HB_UShort     n, count;\r
-\r
-  HB_SubRule*  sr;\r
-\r
-\r
-  if ( srs->SubRule )\r
-  {\r
-    count = srs->SubRuleCount;\r
-    sr    = srs->SubRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_SubRule( &sr[n] );\r
-\r
-    FREE( sr );\r
-  }\r
-}\r
-\r
-\r
-/* ContextSubstFormat1 */\r
-\r
-static HB_Error  Load_ContextSubst1( HB_ContextSubstFormat1*  csf1,\r
-                                    HB_Stream                 stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort        n = 0, m, count;\r
-  HB_UInt         cur_offset, new_offset, base_offset;\r
-\r
-  HB_SubRuleSet*  srs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &csf1->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = csf1->SubRuleSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csf1->SubRuleSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( csf1->SubRuleSet, count, HB_SubRuleSet ) )\r
-    goto Fail2;\r
-\r
-  srs = csf1->SubRuleSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_SubRuleSet( &srs[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_SubRuleSet( &srs[m] );\r
-\r
-  FREE( srs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &csf1->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextSubst1( HB_ContextSubstFormat1* csf1 )\r
-{\r
-  HB_UShort        n, count;\r
-\r
-  HB_SubRuleSet*  srs;\r
-\r
-\r
-  if ( csf1->SubRuleSet )\r
-  {\r
-    count = csf1->SubRuleSetCount;\r
-    srs   = csf1->SubRuleSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_SubRuleSet( &srs[n] );\r
-\r
-    FREE( srs );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &csf1->Coverage );\r
-}\r
-\r
-\r
-/* SubClassRule */\r
-\r
-static HB_Error  Load_SubClassRule( HB_ContextSubstFormat2*  csf2,\r
-                                   HB_SubClassRule*         scr,\r
-                                   HB_Stream                 stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n, count;\r
-\r
-  HB_UShort*              c;\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  scr->GlyphCount = GET_UShort();\r
-  scr->SubstCount = GET_UShort();\r
-\r
-  if ( scr->GlyphCount > csf2->MaxContextLength )\r
-    csf2->MaxContextLength = scr->GlyphCount;\r
-\r
-  FORGET_Frame();\r
-\r
-  scr->Class = NULL;\r
-\r
-  count = scr->GlyphCount - 1;        /* only GlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( scr->Class, count, HB_UShort ) )\r
-    return error;\r
-\r
-  c = scr->Class;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    c[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  scr->SubstLookupRecord = NULL;\r
-\r
-  count = scr->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( scr->SubstLookupRecord, count, HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = scr->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  FREE( c );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SubClassRule( HB_SubClassRule*  scr )\r
-{\r
-  FREE( scr->SubstLookupRecord );\r
-  FREE( scr->Class );\r
-}\r
-\r
-\r
-/* SubClassSet */\r
-\r
-static HB_Error  Load_SubClassSet( HB_ContextSubstFormat2*  csf2,\r
-                                  HB_SubClassSet*          scs,\r
-                                  HB_Stream                 stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort          n = 0, m, count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_SubClassRule*  scr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = scs->SubClassRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  scs->SubClassRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( scs->SubClassRule, count, HB_SubClassRule ) )\r
-    return error;\r
-\r
-  scr = scs->SubClassRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_SubClassRule( csf2, &scr[n],\r
-                                     stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_SubClassRule( &scr[m] );\r
-\r
-  FREE( scr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_SubClassSet( HB_SubClassSet*  scs )\r
-{\r
-  HB_UShort          n, count;\r
-\r
-  HB_SubClassRule*  scr;\r
-\r
-\r
-  if ( scs->SubClassRule )\r
-  {\r
-    count = scs->SubClassRuleCount;\r
-    scr   = scs->SubClassRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_SubClassRule( &scr[n] );\r
-\r
-    FREE( scr );\r
-  }\r
-}\r
-\r
-\r
-/* ContextSubstFormat2 */\r
-\r
-static HB_Error  Load_ContextSubst2( HB_ContextSubstFormat2*  csf2,\r
-                                    HB_Stream                 stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort         n = 0, m, count;\r
-  HB_UInt          cur_offset, new_offset, base_offset;\r
-\r
-  HB_SubClassSet*  scs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &csf2->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    goto Fail3;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  /* `SubClassSetCount' is the upper limit for class values, thus we\r
-     read it now to make an additional safety check.                 */\r
-\r
-  count = csf2->SubClassSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_ClassDefinition( &csf2->ClassDef, count,\r
-                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  csf2->SubClassSet      = NULL;\r
-  csf2->MaxContextLength = 0;\r
-\r
-  if ( ALLOC_ARRAY( csf2->SubClassSet, count, HB_SubClassSet ) )\r
-    goto Fail2;\r
-\r
-  scs = csf2->SubClassSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset != base_offset )      /* not a NULL offset */\r
-    {\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_SubClassSet( csf2, &scs[n],\r
-                                      stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      /* we create a SubClassSet table with no entries */\r
-\r
-      csf2->SubClassSet[n].SubClassRuleCount = 0;\r
-      csf2->SubClassSet[n].SubClassRule      = NULL;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_SubClassSet( &scs[m] );\r
-\r
-  FREE( scs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_Coverage( &csf2->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextSubst2( HB_ContextSubstFormat2*  csf2 )\r
-{\r
-  HB_UShort         n, count;\r
-\r
-  HB_SubClassSet*  scs;\r
-\r
-\r
-  if ( csf2->SubClassSet )\r
-  {\r
-    count = csf2->SubClassSetCount;\r
-    scs   = csf2->SubClassSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_SubClassSet( &scs[n] );\r
-\r
-    FREE( scs );\r
-  }\r
-\r
-  _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef );\r
-  _HB_OPEN_Free_Coverage( &csf2->Coverage );\r
-}\r
-\r
-\r
-/* ContextSubstFormat3 */\r
-\r
-static HB_Error  Load_ContextSubst3( HB_ContextSubstFormat3*  csf3,\r
-                                    HB_Stream                 stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n = 0, m, count;\r
-  HB_UInt                cur_offset, new_offset, base_offset;\r
-\r
-  HB_Coverage*           c;\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  csf3->GlyphCount = GET_UShort();\r
-  csf3->SubstCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csf3->Coverage = NULL;\r
-\r
-  count = csf3->GlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( csf3->Coverage, count, HB_Coverage ) )\r
-    return error;\r
-\r
-  c = csf3->Coverage;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  csf3->SubstLookupRecord = NULL;\r
-\r
-  count = csf3->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( csf3->SubstLookupRecord, count,\r
-                   HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = csf3->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  for ( m = 0; m < n; m++ )\r
-    _HB_OPEN_Free_Coverage( &c[m] );\r
-\r
-  FREE( c );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ContextSubst3( HB_ContextSubstFormat3*  csf3 )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_Coverage*  c;\r
-\r
-\r
-  FREE( csf3->SubstLookupRecord );\r
-\r
-  if ( csf3->Coverage )\r
-  {\r
-    count = csf3->GlyphCount;\r
-    c     = csf3->Coverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-}\r
-\r
-\r
-/* ContextSubst */\r
-\r
-static HB_Error  Load_ContextSubst( HB_GSUB_SubTable* st,\r
-                                   HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_ContextSubst*  cs = &st->context;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cs->SubstFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( cs->SubstFormat )\r
-  {\r
-  case 1:  return Load_ContextSubst1( &cs->csf.csf1, stream );\r
-  case 2:  return Load_ContextSubst2( &cs->csf.csf2, stream );\r
-  case 3:  return Load_ContextSubst3( &cs->csf.csf3, stream );\r
-  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-static void  Free_ContextSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_ContextSubst*  cs = &st->context;\r
-\r
-  switch ( cs->SubstFormat )\r
-  {\r
-  case 1:  Free_ContextSubst1( &cs->csf.csf1 ); break;\r
-  case 2:  Free_ContextSubst2( &cs->csf.csf2 ); break;\r
-  case 3:  Free_ContextSubst3( &cs->csf.csf3 ); break;\r
-  default:                                             break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextSubst1( HB_GSUBHeader*          gsub,\r
-                                      HB_ContextSubstFormat1* csf1,\r
-                                      HB_Buffer               buffer,\r
-                                      HB_UShort                flags,\r
-                                      HB_UShort                context_length,\r
-                                      int                      nesting_level )\r
-{\r
-  HB_UShort        index, property;\r
-  HB_UShort        i, j, k, numsr;\r
-  HB_Error         error;\r
-\r
-  HB_SubRule*     sr;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &csf1->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  sr    = csf1->SubRuleSet[index].SubRule;\r
-  numsr = csf1->SubRuleSet[index].SubRuleCount;\r
-\r
-  for ( k = 0; k < numsr; k++ )\r
-  {\r
-    if ( context_length != 0xFFFF && context_length < sr[k].GlyphCount )\r
-      goto next_subrule;\r
-\r
-    if ( buffer->in_pos + sr[k].GlyphCount > buffer->in_length )\r
-      goto next_subrule;                        /* context is too long */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < sr[k].GlyphCount; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + sr[k].GlyphCount - i == (HB_Int)buffer->in_length )\r
-         goto next_subrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != sr[k].Input[i - 1] )\r
-       goto next_subrule;\r
-    }\r
-\r
-    return Do_ContextSubst( gsub, sr[k].GlyphCount,\r
-                           sr[k].SubstCount, sr[k].SubstLookupRecord,\r
-                           buffer,\r
-                           nesting_level );\r
-  next_subrule:\r
-    ;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextSubst2( HB_GSUBHeader*          gsub,\r
-                                      HB_ContextSubstFormat2* csf2,\r
-                                      HB_Buffer               buffer,\r
-                                      HB_UShort                flags,\r
-                                      HB_UShort                context_length,\r
-                                      int                      nesting_level )\r
-{\r
-  HB_UShort          index, property;\r
-  HB_Error           error;\r
-  HB_UShort          i, j, k, known_classes;\r
-\r
-  HB_UShort*         classes;\r
-  HB_UShort*         cl;\r
-\r
-  HB_SubClassSet*   scs;\r
-  HB_SubClassRule*  sr;\r
-  HB_GDEFHeader*    gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  /* Note: The coverage table in format 2 doesn't give an index into\r
-          anything.  It just lets us know whether or not we need to\r
-          do any lookup at all.                                     */\r
-\r
-  error = _HB_OPEN_Coverage_Index( &csf2->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if (csf2->MaxContextLength < 1)\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( ALLOC_ARRAY( classes, csf2->MaxContextLength, HB_UShort ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Get_Class( &csf2->ClassDef, IN_CURGLYPH(),\r
-                    &classes[0], NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    goto End;\r
-  known_classes = 0;\r
-\r
-  scs = &csf2->SubClassSet[classes[0]];\r
-  if ( !scs )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_SubTable);\r
-    goto End;\r
-  }\r
-\r
-  for ( k = 0; k < scs->SubClassRuleCount; k++ )\r
-  {\r
-    sr  = &scs->SubClassRule[k];\r
-\r
-    if ( context_length != 0xFFFF && context_length < sr->GlyphCount )\r
-      goto next_subclassrule;\r
-\r
-    if ( buffer->in_pos + sr->GlyphCount > buffer->in_length )\r
-      goto next_subclassrule;                      /* context is too long */\r
-\r
-    cl   = sr->Class;\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < sr->GlyphCount; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End;\r
-\r
-       if ( j + sr->GlyphCount - i < (HB_Int)buffer->in_length )\r
-         goto next_subclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i > known_classes )\r
-      {\r
-       /* Keeps us from having to do this for each rule */\r
-\r
-       error = _HB_OPEN_Get_Class( &csf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End;\r
-       known_classes = i;\r
-      }\r
-\r
-      if ( cl[i - 1] != classes[i] )\r
-       goto next_subclassrule;\r
-    }\r
-\r
-    error = Do_ContextSubst( gsub, sr->GlyphCount,\r
-                            sr->SubstCount, sr->SubstLookupRecord,\r
-                            buffer,\r
-                            nesting_level );\r
-    goto End;\r
-\r
-  next_subclassrule:\r
-    ;\r
-  }\r
-\r
-  error = HB_Err_Not_Covered;\r
-\r
-End:\r
-  FREE( classes );\r
-  return error;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextSubst3( HB_GSUBHeader*          gsub,\r
-                                      HB_ContextSubstFormat3* csf3,\r
-                                      HB_Buffer               buffer,\r
-                                      HB_UShort                flags,\r
-                                      HB_UShort                context_length,\r
-                                      int                      nesting_level )\r
-{\r
-  HB_Error         error;\r
-  HB_UShort        index, i, j, property;\r
-\r
-  HB_Coverage*    c;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  if ( context_length != 0xFFFF && context_length < csf3->GlyphCount )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( buffer->in_pos + csf3->GlyphCount > buffer->in_length )\r
-    return HB_Err_Not_Covered;         /* context is too long */\r
-\r
-  c    = csf3->Coverage;\r
-\r
-  for ( i = 1, j = buffer->in_pos + 1; i < csf3->GlyphCount; i++, j++ )\r
-  {\r
-    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + csf3->GlyphCount - i == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &c[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  return Do_ContextSubst( gsub, csf3->GlyphCount,\r
-                         csf3->SubstCount, csf3->SubstLookupRecord,\r
-                         buffer,\r
-                         nesting_level );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ContextSubst( HB_GSUBHeader*    gsub,\r
-                                     HB_GSUB_SubTable* st,\r
-                                     HB_Buffer         buffer,\r
-                                     HB_UShort          flags,\r
-                                     HB_UShort          context_length,\r
-                                     int                nesting_level )\r
-{\r
-  HB_ContextSubst*  cs = &st->context;\r
-\r
-  switch ( cs->SubstFormat )\r
-  {\r
-  case 1:  return Lookup_ContextSubst1( gsub, &cs->csf.csf1, buffer, flags, context_length, nesting_level );\r
-  case 2:  return Lookup_ContextSubst2( gsub, &cs->csf.csf2, buffer, flags, context_length, nesting_level );\r
-  case 3:  return Lookup_ContextSubst3( gsub, &cs->csf.csf3, buffer, flags, context_length, nesting_level );\r
-  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-/* LookupType 6 */\r
-\r
-/* ChainSubRule */\r
-\r
-static HB_Error  Load_ChainSubRule( HB_ChainSubRule*  csr,\r
-                                   HB_Stream          stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n, count;\r
-  HB_UShort*              b;\r
-  HB_UShort*              i;\r
-  HB_UShort*              l;\r
-\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  csr->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csr->Backtrack = NULL;\r
-\r
-  count = csr->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( csr->Backtrack, count, HB_UShort ) )\r
-    return error;\r
-\r
-  b = csr->Backtrack;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail4;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    b[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  csr->InputGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csr->Input = NULL;\r
-\r
-  count = csr->InputGlyphCount - 1;  /* only InputGlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( csr->Input, count, HB_UShort ) )\r
-    goto Fail4;\r
-\r
-  i = csr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail3;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  csr->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csr->Lookahead = NULL;\r
-\r
-  count = csr->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( csr->Lookahead, count, HB_UShort ) )\r
-    goto Fail3;\r
-\r
-  l = csr->Lookahead;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    l[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  csr->SubstCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csr->SubstLookupRecord = NULL;\r
-\r
-  count = csr->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( csr->SubstLookupRecord, count, HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = csr->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  FREE( l );\r
-\r
-Fail3:\r
-  FREE( i );\r
-\r
-Fail4:\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainSubRule( HB_ChainSubRule*  csr )\r
-{\r
-  FREE( csr->SubstLookupRecord );\r
-  FREE( csr->Lookahead );\r
-  FREE( csr->Input );\r
-  FREE( csr->Backtrack );\r
-}\r
-\r
-\r
-/* ChainSubRuleSet */\r
-\r
-static HB_Error  Load_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs,\r
-                                      HB_Stream             stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort          n = 0, m, count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainSubRule*  csr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = csrs->ChainSubRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  csrs->ChainSubRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( csrs->ChainSubRule, count, HB_ChainSubRule ) )\r
-    return error;\r
-\r
-  csr = csrs->ChainSubRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainSubRule( &csr[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainSubRule( &csr[m] );\r
-\r
-  FREE( csr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs )\r
-{\r
-  HB_UShort          n, count;\r
-\r
-  HB_ChainSubRule*  csr;\r
-\r
-\r
-  if ( csrs->ChainSubRule )\r
-  {\r
-    count = csrs->ChainSubRuleCount;\r
-    csr   = csrs->ChainSubRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainSubRule( &csr[n] );\r
-\r
-    FREE( csr );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextSubstFormat1 */\r
-\r
-static HB_Error  Load_ChainContextSubst1(\r
-                  HB_ChainContextSubstFormat1*  ccsf1,\r
-                  HB_Stream                      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort             n = 0, m, count;\r
-  HB_UInt              cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainSubRuleSet*  csrs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ccsf1->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = ccsf1->ChainSubRuleSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccsf1->ChainSubRuleSet = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ccsf1->ChainSubRuleSet, count, HB_ChainSubRuleSet ) )\r
-    goto Fail2;\r
-\r
-  csrs = ccsf1->ChainSubRuleSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainSubRuleSet( &csrs[n], stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainSubRuleSet( &csrs[m] );\r
-\r
-  FREE( csrs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_Coverage( &ccsf1->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextSubst1( HB_ChainContextSubstFormat1*  ccsf1 )\r
-{\r
-  HB_UShort             n, count;\r
-\r
-  HB_ChainSubRuleSet*  csrs;\r
-\r
-\r
-  if ( ccsf1->ChainSubRuleSet )\r
-  {\r
-    count = ccsf1->ChainSubRuleSetCount;\r
-    csrs  = ccsf1->ChainSubRuleSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainSubRuleSet( &csrs[n] );\r
-\r
-    FREE( csrs );\r
-  }\r
-\r
-  _HB_OPEN_Free_Coverage( &ccsf1->Coverage );\r
-}\r
-\r
-\r
-/* ChainSubClassRule */\r
-\r
-static HB_Error  Load_ChainSubClassRule(\r
-                  HB_ChainContextSubstFormat2*  ccsf2,\r
-                  HB_ChainSubClassRule*         cscr,\r
-                  HB_Stream                      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n, count;\r
-\r
-  HB_UShort*              b;\r
-  HB_UShort*              i;\r
-  HB_UShort*              l;\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cscr->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( cscr->BacktrackGlyphCount > ccsf2->MaxBacktrackLength )\r
-    ccsf2->MaxBacktrackLength = cscr->BacktrackGlyphCount;\r
-\r
-  cscr->Backtrack = NULL;\r
-\r
-  count = cscr->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cscr->Backtrack, count, HB_UShort ) )\r
-    return error;\r
-\r
-  b = cscr->Backtrack;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail4;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    b[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  cscr->InputGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( cscr->InputGlyphCount > ccsf2->MaxInputLength )\r
-    ccsf2->MaxInputLength = cscr->InputGlyphCount;\r
-\r
-  cscr->Input = NULL;\r
-\r
-  count = cscr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */\r
-\r
-  if ( ALLOC_ARRAY( cscr->Input, count, HB_UShort ) )\r
-    goto Fail4;\r
-\r
-  i = cscr->Input;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail3;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    i[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  cscr->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( cscr->LookaheadGlyphCount > ccsf2->MaxLookaheadLength )\r
-    ccsf2->MaxLookaheadLength = cscr->LookaheadGlyphCount;\r
-\r
-  cscr->Lookahead = NULL;\r
-\r
-  count = cscr->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( cscr->Lookahead, count, HB_UShort ) )\r
-    goto Fail3;\r
-\r
-  l = cscr->Lookahead;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail2;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    l[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  cscr->SubstCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cscr->SubstLookupRecord = NULL;\r
-\r
-  count = cscr->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( cscr->SubstLookupRecord, count,\r
-                   HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = cscr->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  FREE( l );\r
-\r
-Fail3:\r
-  FREE( i );\r
-\r
-Fail4:\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainSubClassRule( HB_ChainSubClassRule*  cscr )\r
-{\r
-  FREE( cscr->SubstLookupRecord );\r
-  FREE( cscr->Lookahead );\r
-  FREE( cscr->Input );\r
-  FREE( cscr->Backtrack );\r
-}\r
-\r
-\r
-/* SubClassSet */\r
-\r
-static HB_Error  Load_ChainSubClassSet(\r
-                  HB_ChainContextSubstFormat2*  ccsf2,\r
-                  HB_ChainSubClassSet*          cscs,\r
-                  HB_Stream                      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n = 0, m, count;\r
-  HB_UInt                cur_offset, new_offset, base_offset;\r
-\r
-  HB_ChainSubClassRule*  cscr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = cscs->ChainSubClassRuleCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cscs->ChainSubClassRule = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cscs->ChainSubClassRule, count,\r
-                   HB_ChainSubClassRule ) )\r
-    return error;\r
-\r
-  cscr = cscs->ChainSubClassRule;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_ChainSubClassRule( ccsf2, &cscr[n],\r
-                                          stream ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainSubClassRule( &cscr[m] );\r
-\r
-  FREE( cscr );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainSubClassSet( HB_ChainSubClassSet*  cscs )\r
-{\r
-  HB_UShort               n, count;\r
-\r
-  HB_ChainSubClassRule*  cscr;\r
-\r
-\r
-  if ( cscs->ChainSubClassRule )\r
-  {\r
-    count = cscs->ChainSubClassRuleCount;\r
-    cscr  = cscs->ChainSubClassRule;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainSubClassRule( &cscr[n] );\r
-\r
-    FREE( cscr );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextSubstFormat2 */\r
-\r
-static HB_Error  Load_ChainContextSubst2(\r
-                  HB_ChainContextSubstFormat2*  ccsf2,\r
-                  HB_Stream                      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort              n = 0, m, count;\r
-  HB_UInt               cur_offset, new_offset, base_offset;\r
-  HB_UInt               backtrack_offset, input_offset, lookahead_offset;\r
-\r
-  HB_ChainSubClassSet*  cscs;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &ccsf2->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-  if ( ACCESS_Frame( 8L ) )\r
-    goto Fail5;\r
-\r
-  backtrack_offset = GET_UShort();\r
-  input_offset     = GET_UShort();\r
-  lookahead_offset = GET_UShort();\r
-\r
-  /* `ChainSubClassSetCount' is the upper limit for input class values,\r
-     thus we read it now to make an additional safety check. No limit\r
-     is known or needed for the other two class definitions          */\r
-\r
-  count = ccsf2->ChainSubClassSetCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535,\r
-                                                      backtrack_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-      goto Fail5;\r
-\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count,\r
-                                                      input_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-      goto Fail4;\r
-  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535,\r
-                                                      lookahead_offset, base_offset,\r
-                                                      stream ) ) != HB_Err_Ok )\r
-    goto Fail3;\r
-\r
-  ccsf2->ChainSubClassSet   = NULL;\r
-  ccsf2->MaxBacktrackLength = 0;\r
-  ccsf2->MaxInputLength     = 0;\r
-  ccsf2->MaxLookaheadLength = 0;\r
-\r
-  if ( ALLOC_ARRAY( ccsf2->ChainSubClassSet, count, HB_ChainSubClassSet ) )\r
-    goto Fail2;\r
-\r
-  cscs = ccsf2->ChainSubClassSet;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    if ( new_offset != base_offset )      /* not a NULL offset */\r
-    {\r
-      cur_offset = FILE_Pos();\r
-      if ( FILE_Seek( new_offset ) ||\r
-          ( error = Load_ChainSubClassSet( ccsf2, &cscs[n],\r
-                                           stream ) ) != HB_Err_Ok )\r
-       goto Fail1;\r
-      (void)FILE_Seek( cur_offset );\r
-    }\r
-    else\r
-    {\r
-      /* we create a ChainSubClassSet table with no entries */\r
-\r
-      ccsf2->ChainSubClassSet[n].ChainSubClassRuleCount = 0;\r
-      ccsf2->ChainSubClassSet[n].ChainSubClassRule      = NULL;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_ChainSubClassSet( &cscs[m] );\r
-\r
-  FREE( cscs );\r
-\r
-Fail2:\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef );\r
-\r
-Fail3:\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef );\r
-\r
-Fail4:\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef );\r
-\r
-Fail5:\r
-  _HB_OPEN_Free_Coverage( &ccsf2->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextSubst2( HB_ChainContextSubstFormat2*  ccsf2 )\r
-{\r
-  HB_UShort              n, count;\r
-\r
-  HB_ChainSubClassSet*  cscs;\r
-\r
-\r
-  if ( ccsf2->ChainSubClassSet )\r
-  {\r
-    count = ccsf2->ChainSubClassSetCount;\r
-    cscs  = ccsf2->ChainSubClassSet;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_ChainSubClassSet( &cscs[n] );\r
-\r
-    FREE( cscs );\r
-  }\r
-\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef );\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef );\r
-  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef );\r
-\r
-  _HB_OPEN_Free_Coverage( &ccsf2->Coverage );\r
-}\r
-\r
-\r
-/* ChainContextSubstFormat3 */\r
-\r
-static HB_Error  Load_ChainContextSubst3(\r
-                  HB_ChainContextSubstFormat3*  ccsf3,\r
-                  HB_Stream                      stream )\r
-{\r
-  HB_Error error;\r
-\r
-  HB_UShort               n, nb = 0, ni =0, nl = 0, m, count;\r
-  HB_UShort               backtrack_count, input_count, lookahead_count;\r
-  HB_UInt                cur_offset, new_offset, base_offset;\r
-\r
-  HB_Coverage*           b;\r
-  HB_Coverage*           i;\r
-  HB_Coverage*           l;\r
-  HB_SubstLookupRecord*  slr;\r
-\r
-\r
-  base_offset = FILE_Pos() - 2L;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  ccsf3->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccsf3->BacktrackCoverage = NULL;\r
-\r
-  backtrack_count = ccsf3->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccsf3->BacktrackCoverage, backtrack_count,\r
-                   HB_Coverage ) )\r
-    return error;\r
-\r
-  b = ccsf3->BacktrackCoverage;\r
-\r
-  for ( nb = 0; nb < backtrack_count; nb++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail4;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )\r
-      goto Fail4;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  ccsf3->InputGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccsf3->InputCoverage = NULL;\r
-\r
-  input_count = ccsf3->InputGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccsf3->InputCoverage, input_count, HB_Coverage ) )\r
-    goto Fail4;\r
-\r
-  i = ccsf3->InputCoverage;\r
-\r
-  for ( ni = 0; ni < input_count; ni++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail3;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )\r
-      goto Fail3;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  ccsf3->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccsf3->LookaheadCoverage = NULL;\r
-\r
-  lookahead_count = ccsf3->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( ccsf3->LookaheadCoverage, lookahead_count,\r
-                   HB_Coverage ) )\r
-    goto Fail3;\r
-\r
-  l = ccsf3->LookaheadCoverage;\r
-\r
-  for ( nl = 0; nl < lookahead_count; nl++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  ccsf3->SubstCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ccsf3->SubstLookupRecord = NULL;\r
-\r
-  count = ccsf3->SubstCount;\r
-\r
-  if ( ALLOC_ARRAY( ccsf3->SubstLookupRecord, count,\r
-                   HB_SubstLookupRecord ) )\r
-    goto Fail2;\r
-\r
-  slr = ccsf3->SubstLookupRecord;\r
-\r
-  if ( ACCESS_Frame( count * 4L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    slr[n].SequenceIndex   = GET_UShort();\r
-    slr[n].LookupListIndex = GET_UShort();\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( slr );\r
-\r
-Fail2:\r
-  for ( m = 0; m < nl; m++ )\r
-    _HB_OPEN_Free_Coverage( &l[m] );\r
-\r
-  FREE( l );\r
-\r
-Fail3:\r
-  for ( m = 0; m < ni; m++ )\r
-    _HB_OPEN_Free_Coverage( &i[m] );\r
-\r
-  FREE( i );\r
-\r
-Fail4:\r
-  for ( m = 0; m < nb; m++ )\r
-    _HB_OPEN_Free_Coverage( &b[m] );\r
-\r
-  FREE( b );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ChainContextSubst3( HB_ChainContextSubstFormat3*  ccsf3 )\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_Coverage*  c;\r
-\r
-\r
-  FREE( ccsf3->SubstLookupRecord );\r
-\r
-  if ( ccsf3->LookaheadCoverage )\r
-  {\r
-    count = ccsf3->LookaheadGlyphCount;\r
-    c     = ccsf3->LookaheadCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  if ( ccsf3->InputCoverage )\r
-  {\r
-    count = ccsf3->InputGlyphCount;\r
-    c     = ccsf3->InputCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  if ( ccsf3->BacktrackCoverage )\r
-  {\r
-    count = ccsf3->BacktrackGlyphCount;\r
-    c     = ccsf3->BacktrackCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-}\r
-\r
-\r
-/* ChainContextSubst */\r
-\r
-static HB_Error  Load_ChainContextSubst( HB_GSUB_SubTable* st,\r
-                                        HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_ChainContextSubst*  ccs = &st->chain;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  ccs->SubstFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( ccs->SubstFormat ) {\r
-    case 1:  return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream );\r
-    case 2:  return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream );\r
-    case 3:  return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream );\r
-    default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-static void  Free_ChainContextSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_ChainContextSubst*  ccs = &st->chain;\r
-\r
-  switch ( ccs->SubstFormat ) {\r
-    case 1:  Free_ChainContextSubst1( &ccs->ccsf.ccsf1 ); break;\r
-    case 2:  Free_ChainContextSubst2( &ccs->ccsf.ccsf2 ); break;\r
-    case 3:  Free_ChainContextSubst3( &ccs->ccsf.ccsf3 ); break;\r
-    default:                                                     break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextSubst1( HB_GSUBHeader*               gsub,\r
-                                           HB_ChainContextSubstFormat1* ccsf1,\r
-                                           HB_Buffer                    buffer,\r
-                                           HB_UShort                     flags,\r
-                                           HB_UShort                     context_length,\r
-                                           int                           nesting_level )\r
-{\r
-  HB_UShort          index, property;\r
-  HB_UShort          i, j, k, num_csr;\r
-  HB_UShort          bgc, igc, lgc;\r
-  HB_Error           error;\r
-\r
-  HB_ChainSubRule*  csr;\r
-  HB_ChainSubRule   curr_csr;\r
-  HB_GDEFHeader*    gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ccsf1->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  csr     = ccsf1->ChainSubRuleSet[index].ChainSubRule;\r
-  num_csr = ccsf1->ChainSubRuleSet[index].ChainSubRuleCount;\r
-\r
-  for ( k = 0; k < num_csr; k++ )\r
-  {\r
-    curr_csr = csr[k];\r
-    bgc      = curr_csr.BacktrackGlyphCount;\r
-    igc      = curr_csr.InputGlyphCount;\r
-    lgc      = curr_csr.LookaheadGlyphCount;\r
-\r
-    if ( context_length != 0xFFFF && context_length < igc )\r
-      goto next_chainsubrule;\r
-\r
-    /* check whether context is too long; it is a first guess only */\r
-\r
-    if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-      goto next_chainsubrule;\r
-\r
-    if ( bgc )\r
-    {\r
-      /* since we don't know in advance the number of glyphs to inspect,\r
-        we search backwards for matches in the backtrack glyph array    */\r
-\r
-      for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )\r
-      {\r
-       while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )\r
-       {\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           return error;\r
-\r
-         if ( j + 1 == bgc - i )\r
-           goto next_chainsubrule;\r
-         j--;\r
-       }\r
-\r
-       /* In OpenType 1.3, it is undefined whether the offsets of\r
-          backtrack glyphs is in logical order or not.  Version 1.4\r
-          will clarify this:\r
-\r
-            Logical order -      a  b  c  d  e  f  g  h  i  j\r
-                                             i\r
-            Input offsets -                  0  1\r
-            Backtrack offsets -  3  2  1  0\r
-            Lookahead offsets -                    0  1  2  3           */\r
-\r
-       if ( OUT_GLYPH( j ) != curr_csr.Backtrack[i] )\r
-         goto next_chainsubrule;\r
-      }\r
-    }\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-         goto next_chainsubrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != curr_csr.Input[i - 1] )\r
-         goto next_chainsubrule;\r
-    }\r
-\r
-    /* we are starting to check for lookahead glyphs right after the\r
-       last context glyph                                            */\r
-\r
-    for ( i = 0; i < lgc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-         goto next_chainsubrule;\r
-       j++;\r
-      }\r
-\r
-      if ( IN_GLYPH( j ) != curr_csr.Lookahead[i] )\r
-       goto next_chainsubrule;\r
-    }\r
-\r
-    return Do_ContextSubst( gsub, igc,\r
-                           curr_csr.SubstCount,\r
-                           curr_csr.SubstLookupRecord,\r
-                           buffer,\r
-                           nesting_level );\r
-\r
-  next_chainsubrule:\r
-    ;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextSubst2( HB_GSUBHeader*               gsub,\r
-                                           HB_ChainContextSubstFormat2* ccsf2,\r
-                                           HB_Buffer                    buffer,\r
-                                           HB_UShort                     flags,\r
-                                           HB_UShort                     context_length,\r
-                                           int                           nesting_level )\r
-{\r
-  HB_UShort              index, property;\r
-  HB_Error               error;\r
-  HB_UShort              i, j, k;\r
-  HB_UShort              bgc, igc, lgc;\r
-  HB_UShort              known_backtrack_classes,\r
-                        known_input_classes,\r
-                        known_lookahead_classes;\r
-\r
-  HB_UShort*             backtrack_classes;\r
-  HB_UShort*             input_classes;\r
-  HB_UShort*             lookahead_classes;\r
-\r
-  HB_UShort*             bc;\r
-  HB_UShort*             ic;\r
-  HB_UShort*             lc;\r
-\r
-  HB_ChainSubClassSet*  cscs;\r
-  HB_ChainSubClassRule  ccsr;\r
-  HB_GDEFHeader*        gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  /* Note: The coverage table in format 2 doesn't give an index into\r
-          anything.  It just lets us know whether or not we need to\r
-          do any lookup at all.                                     */\r
-\r
-  error = _HB_OPEN_Coverage_Index( &ccsf2->Coverage, IN_CURGLYPH(), &index );\r
-  if ( error )\r
-    return error;\r
-\r
-  if ( ALLOC_ARRAY( backtrack_classes, ccsf2->MaxBacktrackLength, HB_UShort ) )\r
-    return error;\r
-  known_backtrack_classes = 0;\r
-\r
-  if (ccsf2->MaxInputLength < 1)\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( ALLOC_ARRAY( input_classes, ccsf2->MaxInputLength, HB_UShort ) )\r
-    goto End3;\r
-  known_input_classes = 1;\r
-\r
-  if ( ALLOC_ARRAY( lookahead_classes, ccsf2->MaxLookaheadLength, HB_UShort ) )\r
-    goto End2;\r
-  known_lookahead_classes = 0;\r
-\r
-  error = _HB_OPEN_Get_Class( &ccsf2->InputClassDef, IN_CURGLYPH(),\r
-                    &input_classes[0], NULL );\r
-  if ( error && error != HB_Err_Not_Covered )\r
-    goto End1;\r
-\r
-  cscs = &ccsf2->ChainSubClassSet[input_classes[0]];\r
-  if ( !cscs )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_SubTable);\r
-    goto End1;\r
-  }\r
-\r
-  for ( k = 0; k < cscs->ChainSubClassRuleCount; k++ )\r
-  {\r
-    ccsr = cscs->ChainSubClassRule[k];\r
-    bgc  = ccsr.BacktrackGlyphCount;\r
-    igc  = ccsr.InputGlyphCount;\r
-    lgc  = ccsr.LookaheadGlyphCount;\r
-\r
-    if ( context_length != 0xFFFF && context_length < igc )\r
-      goto next_chainsubclassrule;\r
-\r
-    /* check whether context is too long; it is a first guess only */\r
-\r
-    if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-      goto next_chainsubclassrule;\r
-\r
-    if ( bgc )\r
-    {\r
-      /* Since we don't know in advance the number of glyphs to inspect,\r
-        we search backwards for matches in the backtrack glyph array.\r
-        Note that `known_backtrack_classes' starts at index 0.         */\r
-\r
-      bc       = ccsr.Backtrack;\r
-\r
-      for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )\r
-      {\r
-       while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )\r
-       {\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           goto End1;\r
-\r
-         if ( j + 1 == bgc - i )\r
-           goto next_chainsubclassrule;\r
-         j--;\r
-       }\r
-\r
-       if ( i >= known_backtrack_classes )\r
-       {\r
-         /* Keeps us from having to do this for each rule */\r
-\r
-         error = _HB_OPEN_Get_Class( &ccsf2->BacktrackClassDef, OUT_GLYPH( j ),\r
-                            &backtrack_classes[i], NULL );\r
-         if ( error && error != HB_Err_Not_Covered )\r
-           goto End1;\r
-         known_backtrack_classes = i;\r
-       }\r
-\r
-       if ( bc[i] != backtrack_classes[i] )\r
-         goto next_chainsubclassrule;\r
-      }\r
-    }\r
-\r
-    ic       = ccsr.Input;\r
-\r
-    /* Start at 1 because [0] is implied */\r
-\r
-    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-\r
-       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-         goto next_chainsubclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i >= known_input_classes )\r
-      {\r
-       error = _HB_OPEN_Get_Class( &ccsf2->InputClassDef, IN_GLYPH( j ),\r
-                          &input_classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-       known_input_classes = i;\r
-      }\r
-\r
-      if ( ic[i - 1] != input_classes[i] )\r
-       goto next_chainsubclassrule;\r
-    }\r
-\r
-    /* we are starting to check for lookahead glyphs right after the\r
-       last context glyph                                            */\r
-\r
-    lc       = ccsr.Lookahead;\r
-\r
-    for ( i = 0; i < lgc; i++, j++ )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-\r
-       if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-         goto next_chainsubclassrule;\r
-       j++;\r
-      }\r
-\r
-      if ( i >= known_lookahead_classes )\r
-      {\r
-       error = _HB_OPEN_Get_Class( &ccsf2->LookaheadClassDef, IN_GLYPH( j ),\r
-                          &lookahead_classes[i], NULL );\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         goto End1;\r
-       known_lookahead_classes = i;\r
-      }\r
-\r
-      if ( lc[i] != lookahead_classes[i] )\r
-       goto next_chainsubclassrule;\r
-    }\r
-\r
-    error = Do_ContextSubst( gsub, igc,\r
-                            ccsr.SubstCount,\r
-                            ccsr.SubstLookupRecord,\r
-                            buffer,\r
-                            nesting_level );\r
-    goto End1;\r
-\r
-  next_chainsubclassrule:\r
-    ;\r
-  }\r
-\r
-  error = HB_Err_Not_Covered;\r
-\r
-End1:\r
-  FREE( lookahead_classes );\r
-\r
-End2:\r
-  FREE( input_classes );\r
-\r
-End3:\r
-  FREE( backtrack_classes );\r
-  return error;\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextSubst3( HB_GSUBHeader*               gsub,\r
-                                           HB_ChainContextSubstFormat3* ccsf3,\r
-                                           HB_Buffer                    buffer,\r
-                                           HB_UShort                     flags,\r
-                                           HB_UShort                     context_length,\r
-                                           int                           nesting_level )\r
-{\r
-  HB_UShort        index, i, j, property;\r
-  HB_UShort        bgc, igc, lgc;\r
-  HB_Error         error;\r
-\r
-  HB_Coverage*    bc;\r
-  HB_Coverage*    ic;\r
-  HB_Coverage*    lc;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  bgc = ccsf3->BacktrackGlyphCount;\r
-  igc = ccsf3->InputGlyphCount;\r
-  lgc = ccsf3->LookaheadGlyphCount;\r
-\r
-  if ( context_length != 0xFFFF && context_length < igc )\r
-    return HB_Err_Not_Covered;\r
-\r
-  /* check whether context is too long; it is a first guess only */\r
-\r
-  if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( bgc )\r
-  {\r
-    /* Since we don't know in advance the number of glyphs to inspect,\r
-       we search backwards for matches in the backtrack glyph array    */\r
-\r
-    bc       = ccsf3->BacktrackCoverage;\r
-\r
-    for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )\r
-    {\r
-      while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + 1 == bgc - i )\r
-         return HB_Err_Not_Covered;\r
-       j--;\r
-      }\r
-\r
-      error = _HB_OPEN_Coverage_Index( &bc[i], OUT_GLYPH( j ), &index );\r
-      if ( error )\r
-       return error;\r
-    }\r
-  }\r
-\r
-  ic       = ccsf3->InputCoverage;\r
-\r
-  for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )\r
-  {\r
-    /* We already called CHECK_Property for IN_GLYPH( buffer->in_pos ) */\r
-    while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + igc - i + lgc == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &ic[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  /* we are starting for lookahead glyphs right after the last context\r
-     glyph                                                             */\r
-\r
-  lc       = ccsf3->LookaheadCoverage;\r
-\r
-  for ( i = 0; i < lgc; i++, j++ )\r
-  {\r
-    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  return Do_ContextSubst( gsub, igc,\r
-                         ccsf3->SubstCount,\r
-                         ccsf3->SubstLookupRecord,\r
-                         buffer,\r
-                         nesting_level );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ChainContextSubst( HB_GSUBHeader*    gsub,\r
-                                          HB_GSUB_SubTable* st,\r
-                                          HB_Buffer         buffer,\r
-                                          HB_UShort          flags,\r
-                                          HB_UShort          context_length,\r
-                                          int                nesting_level )\r
-{\r
-  HB_ChainContextSubst*  ccs = &st->chain;\r
-\r
-  switch ( ccs->SubstFormat ) {\r
-    case 1:  return Lookup_ChainContextSubst1( gsub, &ccs->ccsf.ccsf1, buffer, flags, context_length, nesting_level );\r
-    case 2:  return Lookup_ChainContextSubst2( gsub, &ccs->ccsf.ccsf2, buffer, flags, context_length, nesting_level );\r
-    case 3:  return Lookup_ChainContextSubst3( gsub, &ccs->ccsf.ccsf3, buffer, flags, context_length, nesting_level );\r
-    default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,\r
-                                               HB_Stream         stream )\r
-{\r
-  HB_Error error;\r
-  HB_ReverseChainContextSubst*  rccs = &st->reverse;\r
-\r
-  HB_UShort               m, count;\r
-\r
-  HB_UShort               nb = 0, nl = 0, n;\r
-  HB_UShort               backtrack_count, lookahead_count;\r
-  HB_UInt                cur_offset, new_offset, base_offset;\r
-\r
-  HB_Coverage*           b;\r
-  HB_Coverage*           l;\r
-  HB_UShort*              sub;\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  rccs->SubstFormat = GET_UShort();\r
-\r
-  if ( rccs->SubstFormat != 1 )\r
-    return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  cur_offset = FILE_Pos();\r
-  if ( FILE_Seek( new_offset ) ||\r
-       ( error = _HB_OPEN_Load_Coverage( &rccs->Coverage, stream ) ) != HB_Err_Ok )\r
-    return error;\r
-  (void)FILE_Seek( cur_offset );\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail4;\r
-\r
-  rccs->BacktrackGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  rccs->BacktrackCoverage = NULL;\r
-\r
-  backtrack_count = rccs->BacktrackGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( rccs->BacktrackCoverage, backtrack_count,\r
-                   HB_Coverage ) )\r
-    goto Fail4;\r
-\r
-  b = rccs->BacktrackCoverage;\r
-\r
-  for ( nb = 0; nb < backtrack_count; nb++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail3;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )\r
-      goto Fail3;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail3;\r
-\r
-  rccs->LookaheadGlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  rccs->LookaheadCoverage = NULL;\r
-\r
-  lookahead_count = rccs->LookaheadGlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( rccs->LookaheadCoverage, lookahead_count,\r
-                   HB_Coverage ) )\r
-    goto Fail3;\r
-\r
-  l = rccs->LookaheadCoverage;\r
-\r
-  for ( nl = 0; nl < lookahead_count; nl++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail2;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )\r
-      goto Fail2;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  rccs->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  rccs->Substitute = NULL;\r
-\r
-  count = rccs->GlyphCount;\r
-\r
-  if ( ALLOC_ARRAY( rccs->Substitute, count,\r
-                   HB_UShort ) )\r
-    goto Fail2;\r
-\r
-  sub = rccs->Substitute;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail1;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    sub[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( sub );\r
-\r
-Fail2:\r
-  for ( m = 0; m < nl; m++ )\r
-    _HB_OPEN_Free_Coverage( &l[m] );\r
-\r
-  FREE( l );\r
-\r
-Fail3:\r
-  for ( m = 0; m < nb; m++ )\r
-    _HB_OPEN_Free_Coverage( &b[m] );\r
-\r
-  FREE( b );\r
-\r
-Fail4:\r
-  _HB_OPEN_Free_Coverage( &rccs->Coverage );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ReverseChainContextSubst( HB_GSUB_SubTable* st )\r
-{\r
-  HB_UShort      n, count;\r
-  HB_ReverseChainContextSubst*  rccs = &st->reverse;\r
-\r
-  HB_Coverage*  c;\r
-\r
-  _HB_OPEN_Free_Coverage( &rccs->Coverage );\r
-\r
-  if ( rccs->LookaheadCoverage )\r
-  {\r
-    count = rccs->LookaheadGlyphCount;\r
-    c     = rccs->LookaheadCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  if ( rccs->BacktrackCoverage )\r
-  {\r
-    count = rccs->BacktrackGlyphCount;\r
-    c     = rccs->BacktrackCoverage;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      _HB_OPEN_Free_Coverage( &c[n] );\r
-\r
-    FREE( c );\r
-  }\r
-\r
-  FREE ( rccs->Substitute );\r
-}\r
-\r
-\r
-static HB_Error  Lookup_ReverseChainContextSubst( HB_GSUBHeader*    gsub,\r
-                                                 HB_GSUB_SubTable* st,\r
-                                                 HB_Buffer         buffer,\r
-                                                 HB_UShort          flags,\r
-                                                 HB_UShort         context_length,\r
-                                                 int               nesting_level )\r
-{\r
-  HB_UShort        index, input_index, i, j, property;\r
-  HB_UShort        bgc, lgc;\r
-  HB_Error         error;\r
-\r
-  HB_ReverseChainContextSubst*  rccs = &st->reverse;\r
-  HB_Coverage*    bc;\r
-  HB_Coverage*    lc;\r
-  HB_GDEFHeader*  gdef;\r
-\r
-  if ( nesting_level != 1 || context_length != 0xFFFF )\r
-    return HB_Err_Not_Covered;\r
-\r
-  gdef = gsub->gdef;\r
-\r
-  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )\r
-    return error;\r
-\r
-  bgc = rccs->BacktrackGlyphCount;\r
-  lgc = rccs->LookaheadGlyphCount;\r
-\r
-  /* check whether context is too long; it is a first guess only */\r
-\r
-  if ( bgc > buffer->in_pos || buffer->in_pos + 1 + lgc > buffer->in_length )\r
-    return HB_Err_Not_Covered;\r
-\r
-  if ( bgc )\r
-  {\r
-    /* Since we don't know in advance the number of glyphs to inspect,\r
-       we search backwards for matches in the backtrack glyph array    */\r
-\r
-    bc       = rccs->BacktrackCoverage;\r
-\r
-    for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )\r
-    {\r
-      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-      {\r
-       if ( error && error != HB_Err_Not_Covered )\r
-         return error;\r
-\r
-       if ( j + 1 == bgc - i )\r
-         return HB_Err_Not_Covered;\r
-       j--;\r
-      }\r
-\r
-      error = _HB_OPEN_Coverage_Index( &bc[i], IN_GLYPH( j ), &index );\r
-      if ( error )\r
-       return error;\r
-    }\r
-  }\r
-\r
-  j = buffer->in_pos;\r
-\r
-  error = _HB_OPEN_Coverage_Index( &rccs->Coverage, IN_GLYPH( j ), &input_index );\r
-  if ( error )\r
-      return error;\r
-\r
-  lc       = rccs->LookaheadCoverage;\r
-\r
-  for ( i = 0, j = buffer->in_pos + 1; i < lgc; i++, j++ )\r
-  {\r
-    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )\r
-    {\r
-      if ( error && error != HB_Err_Not_Covered )\r
-       return error;\r
-\r
-      if ( j + lgc - i == (HB_Int)buffer->in_length )\r
-       return HB_Err_Not_Covered;\r
-      j++;\r
-    }\r
-\r
-    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );\r
-    if ( error )\r
-      return error;\r
-  }\r
-\r
-  IN_CURGLYPH() = rccs->Substitute[input_index];\r
-  buffer->in_pos--; /* Reverse! */\r
-\r
-  return error;\r
-}\r
-\r
-\r
-\r
-/***********\r
- * GSUB API\r
- ***********/\r
-\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,\r
-                                HB_UInt         script_tag,\r
-                                HB_UShort*       script_index )\r
-{\r
-  HB_UShort          n;\r
-\r
-  HB_ScriptList*    sl;\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  if ( !gsub || !script_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  for ( n = 0; n < sl->ScriptCount; n++ )\r
-    if ( script_tag == sr[n].ScriptTag )\r
-    {\r
-      *script_index = n;\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,\r
-                                  HB_UInt         language_tag,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UShort*       language_index,\r
-                                  HB_UShort*       req_feature_index )\r
-{\r
-  HB_UShort           n;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  if ( !gsub || !language_index || !req_feature_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  for ( n = 0; n < s->LangSysCount; n++ )\r
-    if ( language_tag == lsr[n].LangSysTag )\r
-    {\r
-      *language_index = n;\r
-      *req_feature_index = lsr[n].LangSys.ReqFeatureIndex;\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-/* selecting 0xFFFF for language_index asks for the values of the\r
-   default language (DefaultLangSys)                              */\r
-\r
-\r
-HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,\r
-                                 HB_UInt         feature_tag,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UShort*       feature_index )\r
-{\r
-  HB_UShort           n;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-  HB_LangSys*        ls;\r
-  HB_UShort*          fi;\r
-\r
-  HB_FeatureList*    fl;\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  if ( !gsub || !feature_index )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  fl = &gsub->FeatureList;\r
-  fr = fl->FeatureRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( language_index == 0xFFFF )\r
-    ls = &s->DefaultLangSys;\r
-  else\r
-  {\r
-    if ( language_index >= s->LangSysCount )\r
-      return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-    ls = &lsr[language_index].LangSys;\r
-  }\r
-\r
-  fi = ls->FeatureIndex;\r
-\r
-  for ( n = 0; n < ls->FeatureCount; n++ )\r
-  {\r
-    if ( fi[n] >= fl->FeatureCount )\r
-      return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-\r
-    if ( feature_tag == fr[fi[n]].FeatureTag )\r
-    {\r
-      *feature_index = fi[n];\r
-\r
-      return HB_Err_Ok;\r
-    }\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-/* The next three functions return a null-terminated list */\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,\r
-                                HB_UInt**       script_tag_list )\r
-{\r
-  HB_UShort          n;\r
-  HB_Error           error;\r
-  HB_UInt*          stl;\r
-\r
-  HB_ScriptList*    sl;\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  if ( !gsub || !script_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < sl->ScriptCount; n++ )\r
-    stl[n] = sr[n].ScriptTag;\r
-  stl[n] = 0;\r
-\r
-  *script_tag_list = stl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,\r
-                                  HB_UShort        script_index,\r
-                                  HB_UInt**       language_tag_list )\r
-{\r
-  HB_UShort           n;\r
-  HB_Error            error;\r
-  HB_UInt*           ltl;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  if ( !gsub || !language_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < s->LangSysCount; n++ )\r
-    ltl[n] = lsr[n].LangSysTag;\r
-  ltl[n] = 0;\r
-\r
-  *language_tag_list = ltl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* selecting 0xFFFF for language_index asks for the values of the\r
-   default language (DefaultLangSys)                              */\r
-\r
-\r
-HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,\r
-                                 HB_UShort        script_index,\r
-                                 HB_UShort        language_index,\r
-                                 HB_UInt**       feature_tag_list )\r
-{\r
-  HB_UShort           n;\r
-  HB_Error            error;\r
-  HB_UInt*           ftl;\r
-\r
-  HB_ScriptList*     sl;\r
-  HB_ScriptRecord*   sr;\r
-  HB_ScriptTable*    s;\r
-  HB_LangSysRecord*  lsr;\r
-  HB_LangSys*        ls;\r
-  HB_UShort*          fi;\r
-\r
-  HB_FeatureList*    fl;\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  if ( !gsub || !feature_tag_list )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  sl = &gsub->ScriptList;\r
-  sr = sl->ScriptRecord;\r
-\r
-  fl = &gsub->FeatureList;\r
-  fr = fl->FeatureRecord;\r
-\r
-  if ( script_index >= sl->ScriptCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  s   = &sr[script_index].Script;\r
-  lsr = s->LangSysRecord;\r
-\r
-  if ( language_index == 0xFFFF )\r
-    ls = &s->DefaultLangSys;\r
-  else\r
-  {\r
-    if ( language_index >= s->LangSysCount )\r
-      return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-    ls = &lsr[language_index].LangSys;\r
-  }\r
-\r
-  fi = ls->FeatureIndex;\r
-\r
-  if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, HB_UInt ) )\r
-    return error;\r
-\r
-  for ( n = 0; n < ls->FeatureCount; n++ )\r
-  {\r
-    if ( fi[n] >= fl->FeatureCount )\r
-    {\r
-      FREE( ftl );\r
-      return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-    }\r
-    ftl[n] = fr[fi[n]].FeatureTag;\r
-  }\r
-  ftl[n] = 0;\r
-\r
-  *feature_tag_list = ftl;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-/* Do an individual subtable lookup.  Returns HB_Err_Ok if substitution\r
-   has been done, or HB_Err_Not_Covered if not.                        */\r
-static HB_Error  GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,\r
-                                      HB_UShort       lookup_index,\r
-                                      HB_Buffer      buffer,\r
-                                      HB_UShort       context_length,\r
-                                      int             nesting_level )\r
-{\r
-  HB_Error               error = HB_Err_Not_Covered;\r
-  HB_UShort              i, flags, lookup_count;\r
-  HB_Lookup*             lo;\r
-  int                    lookup_type;\r
-\r
-  nesting_level++;\r
-\r
-  if ( nesting_level > HB_MAX_NESTING_LEVEL )\r
-    return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */\r
-\r
-  lookup_count = gsub->LookupList.LookupCount;\r
-  if (lookup_index >= lookup_count)\r
-    return error;\r
-\r
-  lo    = &gsub->LookupList.Lookup[lookup_index];\r
-  flags = lo->LookupFlag;\r
-  lookup_type = lo->LookupType;\r
-\r
-  for ( i = 0; i < lo->SubTableCount; i++ )\r
-  {\r
-    HB_GSUB_SubTable *st = &lo->SubTable[i].st.gsub;\r
-\r
-    switch (lookup_type) {\r
-      case HB_GSUB_LOOKUP_SINGLE:\r
-       error = Lookup_SingleSubst              ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GSUB_LOOKUP_MULTIPLE:\r
-       error = Lookup_MultipleSubst            ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GSUB_LOOKUP_ALTERNATE:\r
-       error = Lookup_AlternateSubst           ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GSUB_LOOKUP_LIGATURE:\r
-       error = Lookup_LigatureSubst            ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GSUB_LOOKUP_CONTEXT:\r
-       error = Lookup_ContextSubst             ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      case HB_GSUB_LOOKUP_CHAIN:\r
-       error = Lookup_ChainContextSubst        ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-    /*case HB_GSUB_LOOKUP_EXTENSION:\r
-       error = Lookup_ExtensionSubst           ( gsub, st, buffer, flags, context_length, nesting_level ); break;*/\r
-      case HB_GSUB_LOOKUP_REVERSE_CHAIN:\r
-       error = Lookup_ReverseChainContextSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;\r
-      default:\r
-       error = HB_Err_Not_Covered;\r
-    };\r
-\r
-    /* Check whether we have a successful substitution or an error other\r
-       than HB_Err_Not_Covered                                          */\r
-    if ( error != HB_Err_Not_Covered )\r
-      return error;\r
-  }\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,\r
-                       HB_Stream         stream,\r
-                       HB_UShort         lookup_type )\r
-{\r
-  switch (lookup_type) {\r
-    case HB_GSUB_LOOKUP_SINGLE:                return Load_SingleSubst                 ( st, stream );\r
-    case HB_GSUB_LOOKUP_MULTIPLE:      return Load_MultipleSubst               ( st, stream );\r
-    case HB_GSUB_LOOKUP_ALTERNATE:     return Load_AlternateSubst              ( st, stream );\r
-    case HB_GSUB_LOOKUP_LIGATURE:      return Load_LigatureSubst               ( st, stream );\r
-    case HB_GSUB_LOOKUP_CONTEXT:       return Load_ContextSubst                ( st, stream );\r
-    case HB_GSUB_LOOKUP_CHAIN:         return Load_ChainContextSubst           ( st, stream );\r
-  /*case HB_GSUB_LOOKUP_EXTENSION:     return Load_ExtensionSubst              ( st, stream );*/\r
-    case HB_GSUB_LOOKUP_REVERSE_CHAIN: return Load_ReverseChainContextSubst    ( st, stream );\r
-    default:                           return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  };\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,\r
-                       HB_UShort         lookup_type )\r
-{\r
-  switch ( lookup_type ) {\r
-    case HB_GSUB_LOOKUP_SINGLE:                Free_SingleSubst                ( st ); return;\r
-    case HB_GSUB_LOOKUP_MULTIPLE:      Free_MultipleSubst              ( st ); return;\r
-    case HB_GSUB_LOOKUP_ALTERNATE:     Free_AlternateSubst             ( st ); return;\r
-    case HB_GSUB_LOOKUP_LIGATURE:      Free_LigatureSubst              ( st ); return;\r
-    case HB_GSUB_LOOKUP_CONTEXT:       Free_ContextSubst               ( st ); return;\r
-    case HB_GSUB_LOOKUP_CHAIN:         Free_ChainContextSubst          ( st ); return;\r
-  /*case HB_GSUB_LOOKUP_EXTENSION:     Free_ExtensionSubst             ( st ); return;*/\r
-    case HB_GSUB_LOOKUP_REVERSE_CHAIN: Free_ReverseChainContextSubst   ( st ); return;\r
-    default:                                                                   return;\r
-  };\r
-}\r
-\r
-\r
-\r
-/* apply one lookup to the input string object */\r
-\r
-static HB_Error  GSUB_Do_String_Lookup( HB_GSUBHeader*   gsub,\r
-                                  HB_UShort         lookup_index,\r
-                                  HB_Buffer        buffer )\r
-{\r
-  HB_Error  error, retError = HB_Err_Not_Covered;\r
-\r
-  HB_UInt*  properties = gsub->LookupList.Properties;\r
-  int       lookup_type = gsub->LookupList.Lookup[lookup_index].LookupType;\r
-\r
-  const int       nesting_level = 0;\r
-  /* 0xFFFF indicates that we don't have a context length yet */\r
-  const HB_UShort context_length = 0xFFFF;\r
-\r
-  switch (lookup_type) {\r
-\r
-    case HB_GSUB_LOOKUP_SINGLE:\r
-    case HB_GSUB_LOOKUP_MULTIPLE:\r
-    case HB_GSUB_LOOKUP_ALTERNATE:\r
-    case HB_GSUB_LOOKUP_LIGATURE:\r
-    case HB_GSUB_LOOKUP_CONTEXT:\r
-    case HB_GSUB_LOOKUP_CHAIN:\r
-      /* in/out forward substitution (implemented lazy) */\r
-\r
-      _hb_buffer_clear_output ( buffer );\r
-      buffer->in_pos = 0;\r
-  while ( buffer->in_pos < buffer->in_length )\r
-  {\r
-    if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )\r
-    {\r
-         error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );\r
-      if ( error )\r
-      {\r
-       if ( error != HB_Err_Not_Covered )\r
-         return error;\r
-      }\r
-      else\r
-       retError = error;\r
-    }\r
-    else\r
-      error = HB_Err_Not_Covered;\r
-\r
-    if ( error == HB_Err_Not_Covered )\r
-         if ( COPY_Glyph ( buffer ) )\r
-       return error;\r
-  }\r
-      /* we shouldn't swap if error occurred.\r
-       *\r
-       * also don't swap if nothing changed (ie HB_Err_Not_Covered).\r
-       * shouldn't matter in that case though.\r
-       */\r
-      if ( retError == HB_Err_Ok )\r
-       _hb_buffer_swap( buffer );\r
-\r
-  return retError;\r
-\r
-    case HB_GSUB_LOOKUP_REVERSE_CHAIN:\r
-      /* in-place backward substitution */\r
-\r
-      buffer->in_pos = buffer->in_length - 1;\r
-    do\r
-    {\r
-      if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )\r
-       {\r
-         error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );\r
-         if ( error )\r
-           {\r
-             if ( error != HB_Err_Not_Covered )\r
-               return error;\r
-           }\r
-         else\r
-           retError = error;\r
-       }\r
-       else\r
-         error = HB_Err_Not_Covered;\r
-\r
-       if ( error == HB_Err_Not_Covered )\r
-         buffer->in_pos--;\r
-      }\r
-      while ((HB_Int) buffer->in_pos >= 0);\r
-\r
-      return retError;\r
-\r
-  /*case HB_GSUB_LOOKUP_EXTENSION:*/\r
-    default:\r
-  return retError;\r
-  };\r
-}\r
-\r
-\r
-HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,\r
-                              HB_UShort        feature_index,\r
-                              HB_UInt          property )\r
-{\r
-  HB_UShort    i;\r
-\r
-  HB_Feature  feature;\r
-  HB_UInt*     properties;\r
-  HB_UShort*   index;\r
-  HB_UShort    lookup_count;\r
-\r
-  /* Each feature can only be added once */\r
-\r
-  if ( !gsub ||\r
-       feature_index >= gsub->FeatureList.FeatureCount ||\r
-       gsub->FeatureList.ApplyCount == gsub->FeatureList.FeatureCount )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index;\r
-\r
-  properties = gsub->LookupList.Properties;\r
-\r
-  feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;\r
-  index   = feature.LookupListIndex;\r
-  lookup_count = gsub->LookupList.LookupCount;\r
-\r
-  for ( i = 0; i < feature.LookupListCount; i++ )\r
-  {\r
-    HB_UShort lookup_index = index[i];\r
-    if (lookup_index < lookup_count)\r
-      properties[lookup_index] |= property;\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub )\r
-{\r
-  HB_UShort i;\r
-\r
-  HB_UInt*  properties;\r
-\r
-\r
-  if ( !gsub )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gsub->FeatureList.ApplyCount = 0;\r
-\r
-  properties = gsub->LookupList.Properties;\r
-\r
-  for ( i = 0; i < gsub->LookupList.LookupCount; i++ )\r
-    properties[i] = 0;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-\r
-HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,\r
-                                              HB_AltFunction  altfunc,\r
-                                              void*            data )\r
-{\r
-  if ( !gsub )\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  gsub->altfunc = altfunc;\r
-  gsub->data    = data;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-/* returns error if one happened, otherwise returns HB_Err_Not_Covered if no\r
- * feature were applied, or HB_Err_Ok otherwise.\r
- */\r
-HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,\r
-                               HB_Buffer        buffer )\r
-{\r
-  HB_Error          error, retError = HB_Err_Not_Covered;\r
-  int               i, j, lookup_count, num_features;\r
-\r
-  if ( !gsub ||\r
-       !buffer)\r
-    return ERR_HB(HB_Err_Invalid_Argument);\r
-\r
-  if ( buffer->in_length == 0 )\r
-    return retError;\r
-\r
-  lookup_count = gsub->LookupList.LookupCount;\r
-  num_features = gsub->FeatureList.ApplyCount;\r
-\r
-  for ( i = 0; i < num_features; i++)\r
-  {\r
-    HB_UShort  feature_index = gsub->FeatureList.ApplyOrder[i];\r
-    HB_Feature feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;\r
-\r
-    for ( j = 0; j < feature.LookupListCount; j++ )\r
-    {\r
-      HB_UShort         lookup_index = feature.LookupListIndex[j];\r
-\r
-      /* Skip nonexistant lookups */\r
-      if (lookup_index >= lookup_count)\r
-       continue;\r
-\r
-       error = GSUB_Do_String_Lookup( gsub, lookup_index, buffer );\r
-      if ( error )\r
-      {\r
-       if ( error != HB_Err_Not_Covered )\r
-         return error;\r
-      }\r
-      else\r
-       retError = error;\r
-    }\r
-  }\r
-\r
-  error = retError;\r
-\r
-  return error;\r
-}\r
-\r
-\r
-/* END */\r
+/*
+ * Copyright (C) 1998-2004  David Turner and Werner Lemberg
+ * Copyright (C) 2006  Behdad Esfahbod
+ * Copyright (C) 2007  Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-gsub-private.h"
+#include "harfbuzz-open-private.h"
+#include "harfbuzz-gdef-private.h"
+
+static HB_Error  GSUB_Do_Glyph_Lookup( HB_GSUBHeader*   gsub,
+                                      HB_UShort         lookup_index,
+                                      HB_Buffer        buffer,
+                                      HB_UShort         context_length,
+                                      int               nesting_level );
+
+
+
+/**********************
+ * Auxiliary functions
+ **********************/
+
+
+
+HB_Error  HB_Load_GSUB_Table( HB_Stream stream,
+                             HB_GSUBHeader** retptr,
+                             HB_GDEFHeader*  gdef,
+                              HB_Stream       gdefStream )
+{
+  HB_Error         error;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_GSUBHeader*  gsub;
+
+  if ( !retptr )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( GOTO_Table( TTAG_GSUB ) )
+    return error;
+
+  base_offset = FILE_Pos();
+
+  if ( ALLOC ( gsub, sizeof( *gsub ), HB_GSUBHeader* ) ) 
+      return error;
+  
+
+  /* skip version */
+
+  if ( FILE_Seek( base_offset + 4L ) ||
+       ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_ScriptList( &gsub->ScriptList,
+                                 stream ) ) != HB_Err_Ok )
+    goto Fail4;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_FeatureList( &gsub->FeatureList,
+                                  stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_LookupList( &gsub->LookupList,
+                                 stream, HB_Type_GSUB ) ) != HB_Err_Ok )
+    goto Fail2;
+
+  gsub->gdef = gdef;      /* can be NULL */
+
+  if ( ( error =  _HB_GDEF_LoadMarkAttachClassDef_From_LookupFlags( gdef, gdefStream,
+                                                                    gsub->LookupList.Lookup,
+                                                                    gsub->LookupList.LookupCount ) ) )
+    goto Fail1;
+
+  *retptr = gsub;
+
+  return HB_Err_Ok;
+
+Fail1:
+  _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB );
+
+Fail2:
+  _HB_OPEN_Free_FeatureList( &gsub->FeatureList );
+
+Fail3:
+  _HB_OPEN_Free_ScriptList( &gsub->ScriptList );
+
+Fail4:
+  FREE ( gsub );
+
+
+  return error;
+}
+
+
+HB_Error   HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
+{
+  _HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB );
+  _HB_OPEN_Free_FeatureList( &gsub->FeatureList );
+  _HB_OPEN_Free_ScriptList( &gsub->ScriptList );
+
+  FREE( gsub );
+
+  return HB_Err_Ok;
+}
+
+/*****************************
+ * SubTable related functions
+ *****************************/
+
+
+/* LookupType 1 */
+
+/* SingleSubstFormat1 */
+/* SingleSubstFormat2 */
+
+static HB_Error  Load_SingleSubst( HB_GSUB_SubTable* st,
+                                  HB_Stream         stream )
+{
+  HB_Error error;
+  HB_SingleSubst*  ss = &st->single;
+
+  HB_UShort n, count;
+  HB_UInt cur_offset, new_offset, base_offset;
+
+  HB_UShort*  s;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  ss->SubstFormat = GET_UShort();
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ss->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  switch ( ss->SubstFormat )
+  {
+  case 1:
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    ss->ssf.ssf1.DeltaGlyphID = GET_UShort();
+
+    FORGET_Frame();
+
+    break;
+
+  case 2:
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    count = ss->ssf.ssf2.GlyphCount = GET_UShort();
+
+    FORGET_Frame();
+
+    ss->ssf.ssf2.Substitute = NULL;
+
+    if ( ALLOC_ARRAY( ss->ssf.ssf2.Substitute, count, HB_UShort ) )
+      goto Fail2;
+
+    s = ss->ssf.ssf2.Substitute;
+
+    if ( ACCESS_Frame( count * 2L ) )
+      goto Fail1;
+
+    for ( n = 0; n < count; n++ )
+      s[n] = GET_UShort();
+
+    FORGET_Frame();
+
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( s );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &ss->Coverage );
+  return error;
+}
+
+
+static void  Free_SingleSubst( HB_GSUB_SubTable* st )
+{
+  HB_SingleSubst*  ss = &st->single;
+
+  switch ( ss->SubstFormat )
+  {
+  case 1:
+    break;
+
+  case 2:
+    FREE( ss->ssf.ssf2.Substitute );
+    break;
+
+  default:
+    break;
+  }
+
+  _HB_OPEN_Free_Coverage( &ss->Coverage );
+}
+
+
+static HB_Error  Lookup_SingleSubst( HB_GSUBHeader*   gsub,
+                                    HB_GSUB_SubTable* st,
+                                    HB_Buffer        buffer,
+                                    HB_UShort         flags,
+                                    HB_UShort         context_length,
+                                    int               nesting_level )
+{
+  HB_UShort index, value, property;
+  HB_Error  error;
+  HB_SingleSubst*  ss = &st->single;
+  HB_GDEFHeader*   gdef = gsub->gdef;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &ss->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  switch ( ss->SubstFormat )
+  {
+  case 1:
+    value = ( IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF;
+    if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+      return error;
+    break;
+
+  case 2:
+    if ( index >= ss->ssf.ssf2.GlyphCount )
+      return ERR_HB(HB_Err_Invalid_SubTable);
+    value = ss->ssf.ssf2.Substitute[index];
+    if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+      return error;
+    break;
+
+  default:
+    return ERR_HB(HB_Err_Invalid_SubTable);
+  }
+
+  if ( gdef && gdef->NewGlyphClasses )
+  {
+    /* we inherit the old glyph class to the substituted glyph */
+
+    error = _HB_GDEF_Add_Glyph_Property( gdef, value, property );
+    if ( error && error != HB_Err_Not_Covered )
+      return error;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 2 */
+
+/* Sequence */
+
+static HB_Error  Load_Sequence( HB_Sequence*  s,
+                               HB_Stream      stream )
+{
+  HB_Error error;
+
+  HB_UShort n, count;
+  HB_UShort*  sub;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = s->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  s->Substitute = NULL;
+
+  if ( count )
+  {
+    if ( ALLOC_ARRAY( s->Substitute, count, HB_UShort ) )
+      return error;
+
+    sub = s->Substitute;
+
+    if ( ACCESS_Frame( count * 2L ) )
+    {
+      FREE( sub );
+      return error;
+    }
+
+    for ( n = 0; n < count; n++ )
+      sub[n] = GET_UShort();
+
+    FORGET_Frame();
+  }
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_Sequence( HB_Sequence*  s )
+{
+  FREE( s->Substitute );
+}
+
+
+/* MultipleSubstFormat1 */
+
+static HB_Error  Load_MultipleSubst( HB_GSUB_SubTable* st,
+                                    HB_Stream         stream )
+{
+  HB_Error error;
+  HB_MultipleSubst*  ms = &st->multiple;
+
+  HB_UShort      n = 0, m, count;
+  HB_UInt       cur_offset, new_offset, base_offset;
+
+  HB_Sequence*  s;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  ms->SubstFormat = GET_UShort();             /* should be 1 */
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ms->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = ms->SequenceCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ms->Sequence = NULL;
+
+  if ( ALLOC_ARRAY( ms->Sequence, count, HB_Sequence ) )
+    goto Fail2;
+
+  s = ms->Sequence;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_Sequence( &s[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_Sequence( &s[m] );
+
+  FREE( s );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &ms->Coverage );
+  return error;
+}
+
+
+static void  Free_MultipleSubst( HB_GSUB_SubTable* st )
+{
+  HB_UShort      n, count;
+  HB_MultipleSubst*  ms = &st->multiple;
+
+  HB_Sequence*  s;
+
+
+  if ( ms->Sequence )
+  {
+    count = ms->SequenceCount;
+    s     = ms->Sequence;
+
+    for ( n = 0; n < count; n++ )
+      Free_Sequence( &s[n] );
+
+    FREE( s );
+  }
+
+  _HB_OPEN_Free_Coverage( &ms->Coverage );
+}
+
+
+static HB_Error  Lookup_MultipleSubst( HB_GSUBHeader*    gsub,
+                                      HB_GSUB_SubTable* st,
+                                      HB_Buffer         buffer,
+                                      HB_UShort          flags,
+                                      HB_UShort          context_length,
+                                      int                nesting_level )
+{
+  HB_Error  error;
+  HB_UShort index, property, n, count;
+  HB_UShort*s;
+  HB_MultipleSubst*  ms = &st->multiple;
+  HB_GDEFHeader*     gdef = gsub->gdef;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &ms->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if ( index >= ms->SequenceCount )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  count = ms->Sequence[index].GlyphCount;
+  s     = ms->Sequence[index].Substitute;
+
+  if ( ADD_String( buffer, 1, count, s, 0xFFFF, 0xFFFF ) )
+    return error;
+
+  if ( gdef && gdef->NewGlyphClasses )
+  {
+    /* this is a guess only ... */
+
+    if ( property == HB_GDEF_LIGATURE )
+      property = HB_GDEF_BASE_GLYPH;
+
+    for ( n = 0; n < count; n++ )
+    {
+      error = _HB_GDEF_Add_Glyph_Property( gdef, s[n], property );
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+    }
+  }
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 3 */
+
+/* AlternateSet */
+
+static HB_Error  Load_AlternateSet( HB_AlternateSet*  as,
+                                   HB_Stream          stream )
+{
+  HB_Error error;
+
+  HB_UShort n, count;
+  HB_UShort*  a;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = as->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  as->Alternate = NULL;
+
+  if ( ALLOC_ARRAY( as->Alternate, count, HB_UShort ) )
+    return error;
+
+  a = as->Alternate;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( a );
+    return error;
+  }
+
+  for ( n = 0; n < count; n++ )
+    a[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_AlternateSet( HB_AlternateSet*  as )
+{
+  FREE( as->Alternate );
+}
+
+
+/* AlternateSubstFormat1 */
+
+static HB_Error  Load_AlternateSubst( HB_GSUB_SubTable* st,
+                                     HB_Stream         stream )
+{
+  HB_Error error;
+  HB_AlternateSubst* as = &st->alternate;
+
+  HB_UShort          n = 0, m, count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_AlternateSet*  aset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  as->SubstFormat = GET_UShort();             /* should be 1 */
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &as->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = as->AlternateSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  as->AlternateSet = NULL;
+
+  if ( ALLOC_ARRAY( as->AlternateSet, count, HB_AlternateSet ) )
+    goto Fail2;
+
+  aset = as->AlternateSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_AlternateSet( &aset[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_AlternateSet( &aset[m] );
+
+  FREE( aset );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &as->Coverage );
+  return error;
+}
+
+
+static void  Free_AlternateSubst( HB_GSUB_SubTable* st )
+{
+  HB_UShort          n, count;
+  HB_AlternateSubst* as = &st->alternate;
+
+  HB_AlternateSet*  aset;
+
+
+  if ( as->AlternateSet )
+  {
+    count = as->AlternateSetCount;
+    aset  = as->AlternateSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_AlternateSet( &aset[n] );
+
+    FREE( aset );
+  }
+
+  _HB_OPEN_Free_Coverage( &as->Coverage );
+}
+
+
+static HB_Error  Lookup_AlternateSubst( HB_GSUBHeader*    gsub,
+                                       HB_GSUB_SubTable* st,
+                                       HB_Buffer         buffer,
+                                       HB_UShort          flags,
+                                       HB_UShort          context_length,
+                                       int                nesting_level )
+{
+  HB_Error          error;
+  HB_UShort         index, value, alt_index, property;
+  HB_AlternateSubst* as = &st->alternate;
+  HB_GDEFHeader*     gdef = gsub->gdef;
+  HB_AlternateSet  aset;
+
+  HB_UNUSED(nesting_level);
+
+  if ( context_length != 0xFFFF && context_length < 1 )
+    return HB_Err_Not_Covered;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &as->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  aset = as->AlternateSet[index];
+
+  /* we use a user-defined callback function to get the alternate index */
+
+  if ( gsub->altfunc )
+    alt_index = (gsub->altfunc)( buffer->out_pos, IN_CURGLYPH(),
+                                aset.GlyphCount, aset.Alternate,
+                                gsub->data );
+  else
+    alt_index = 0;
+
+  value = aset.Alternate[alt_index];
+  if ( REPLACE_Glyph( buffer, value, nesting_level ) )
+    return error;
+
+  if ( gdef && gdef->NewGlyphClasses )
+  {
+    /* we inherit the old glyph class to the substituted glyph */
+
+    error = _HB_GDEF_Add_Glyph_Property( gdef, value, property );
+    if ( error && error != HB_Err_Not_Covered )
+      return error;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 4 */
+
+/* Ligature */
+
+static HB_Error  Load_Ligature( HB_Ligature*  l,
+                               HB_Stream      stream )
+{
+  HB_Error error;
+
+  HB_UShort n, count;
+  HB_UShort*  c;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  l->LigGlyph       = GET_UShort();
+  l->ComponentCount = GET_UShort();
+
+  FORGET_Frame();
+
+  l->Component = NULL;
+
+  count = l->ComponentCount - 1;      /* only ComponentCount - 1 elements */
+
+  if ( ALLOC_ARRAY( l->Component, count, HB_UShort ) )
+    return error;
+
+  c = l->Component;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( c );
+    return error;
+  }
+
+  for ( n = 0; n < count; n++ )
+    c[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_Ligature( HB_Ligature*  l )
+{
+  FREE( l->Component );
+}
+
+
+/* LigatureSet */
+
+static HB_Error  Load_LigatureSet( HB_LigatureSet*  ls,
+                                  HB_Stream         stream )
+{
+  HB_Error error;
+
+  HB_UShort      n = 0, m, count;
+  HB_UInt       cur_offset, new_offset, base_offset;
+
+  HB_Ligature*  l;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ls->LigatureCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ls->Ligature = NULL;
+
+  if ( ALLOC_ARRAY( ls->Ligature, count, HB_Ligature ) )
+    return error;
+
+  l = ls->Ligature;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_Ligature( &l[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_Ligature( &l[m] );
+
+  FREE( l );
+  return error;
+}
+
+
+static void  Free_LigatureSet( HB_LigatureSet*  ls )
+{
+  HB_UShort      n, count;
+
+  HB_Ligature*  l;
+
+
+  if ( ls->Ligature )
+  {
+    count = ls->LigatureCount;
+    l     = ls->Ligature;
+
+    for ( n = 0; n < count; n++ )
+      Free_Ligature( &l[n] );
+
+    FREE( l );
+  }
+}
+
+
+/* LigatureSubstFormat1 */
+
+static HB_Error  Load_LigatureSubst( HB_GSUB_SubTable* st,
+                                    HB_Stream         stream )
+{
+  HB_Error error;
+  HB_LigatureSubst*  ls = &st->ligature;
+
+  HB_UShort         n = 0, m, count;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_LigatureSet*  lset;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  ls->SubstFormat = GET_UShort();             /* should be 1 */
+  new_offset      = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ls->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = ls->LigatureSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ls->LigatureSet = NULL;
+
+  if ( ALLOC_ARRAY( ls->LigatureSet, count, HB_LigatureSet ) )
+    goto Fail2;
+
+  lset = ls->LigatureSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LigatureSet( &lset[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_LigatureSet( &lset[m] );
+
+  FREE( lset );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &ls->Coverage );
+  return error;
+}
+
+
+static void  Free_LigatureSubst( HB_GSUB_SubTable* st )
+{
+  HB_UShort         n, count;
+  HB_LigatureSubst*  ls = &st->ligature;
+
+  HB_LigatureSet*  lset;
+
+
+  if ( ls->LigatureSet )
+  {
+    count = ls->LigatureSetCount;
+    lset  = ls->LigatureSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_LigatureSet( &lset[n] );
+
+    FREE( lset );
+  }
+
+  _HB_OPEN_Free_Coverage( &ls->Coverage );
+}
+
+
+static HB_Error  Lookup_LigatureSubst( HB_GSUBHeader*    gsub,
+                                      HB_GSUB_SubTable* st,
+                                      HB_Buffer         buffer,
+                                      HB_UShort          flags,
+                                      HB_UShort          context_length,
+                                      int                nesting_level )
+{
+  HB_UShort      index, property;
+  HB_Error       error;
+  HB_UShort      numlig, i, j, is_mark, first_is_mark = FALSE;
+  HB_UShort*     c;
+  HB_LigatureSubst*  ls = &st->ligature;
+  HB_GDEFHeader*     gdef = gsub->gdef;
+
+  HB_Ligature*  lig;
+
+  HB_UNUSED(nesting_level);
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  if ( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS )
+    first_is_mark = TRUE;
+
+  error = _HB_OPEN_Coverage_Index( &ls->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if ( index >= ls->LigatureSetCount )
+     return ERR_HB(HB_Err_Invalid_SubTable);
+
+  lig = ls->LigatureSet[index].Ligature;
+
+  for ( numlig = ls->LigatureSet[index].LigatureCount;
+       numlig;
+       numlig--, lig++ )
+  {
+    if ( buffer->in_pos + lig->ComponentCount > buffer->in_length )
+      goto next_ligature;               /* Not enough glyphs in input */
+
+    c    = lig->Component;
+
+    is_mark = first_is_mark;
+
+    if ( context_length != 0xFFFF && context_length < lig->ComponentCount )
+      break;
+
+    for ( i = 1, j = buffer->in_pos + 1; i < lig->ComponentCount; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + lig->ComponentCount - i == (HB_Int)buffer->in_length )
+         goto next_ligature;
+       j++;
+      }
+
+      if ( !( property == HB_GDEF_MARK || property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS ) )
+       is_mark = FALSE;
+
+      if ( IN_GLYPH( j ) != c[i - 1] )
+       goto next_ligature;
+    }
+
+    if ( gdef && gdef->NewGlyphClasses )
+    {
+      /* this is just a guess ... */
+
+      error = _HB_GDEF_Add_Glyph_Property( gdef, lig->LigGlyph,
+                                 is_mark ? HB_GDEF_MARK : HB_GDEF_LIGATURE );
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+    }
+
+    if ( j == buffer->in_pos + i ) /* No input glyphs skipped */
+    {
+      /* We don't use a new ligature ID if there are no skipped
+        glyphs and the ligature already has an ID.             */
+
+      if ( IN_LIGID( buffer->in_pos ) )
+      {
+       if ( ADD_String( buffer, i, 1, &lig->LigGlyph,
+                       0xFFFF, 0xFFFF ) )
+         return error;
+      }
+      else
+      {
+       HB_UShort ligID = _hb_buffer_allocate_ligid( buffer );
+       if ( ADD_String( buffer, i, 1, &lig->LigGlyph,
+                       0xFFFF, ligID ) )
+         return error;
+      }
+    }
+    else
+    {
+      HB_UShort ligID = _hb_buffer_allocate_ligid( buffer );
+      if ( ADD_Glyph( buffer, lig->LigGlyph, 0xFFFF, ligID ) )
+       return error;
+
+      /* Now we must do a second loop to copy the skipped glyphs to
+        `out' and assign component values to it.  We start with the
+        glyph after the first component.  Glyphs between component
+        i and i+1 belong to component i.  Together with the ligID
+        value it is later possible to check whether a specific
+        component value really belongs to a given ligature.         */
+
+      for ( i = 0; i < lig->ComponentCount - 1; i++ )
+      {
+       while ( CHECK_Property( gdef, IN_CURITEM(),
+                               flags, &property ) )
+         if ( ADD_Glyph( buffer, IN_CURGLYPH(), i, ligID ) )
+           return error;
+
+       (buffer->in_pos)++;
+      }
+    }
+
+    return HB_Err_Ok;
+
+  next_ligature:
+    ;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+/* Do the actual substitution for a context substitution (either format
+   5 or 6).  This is only called after we've determined that the input
+   matches the subrule.                                                 */
+
+static HB_Error  Do_ContextSubst( HB_GSUBHeader*        gsub,
+                                 HB_UShort              GlyphCount,
+                                 HB_UShort              SubstCount,
+                                 HB_SubstLookupRecord* subst,
+                                 HB_Buffer             buffer,
+                                 int                    nesting_level )
+{
+  HB_Error  error;
+  HB_UInt   i, old_pos;
+
+
+  i = 0;
+
+  while ( i < GlyphCount )
+  {
+    if ( SubstCount && i == subst->SequenceIndex )
+    {
+      old_pos = buffer->in_pos;
+
+      /* Do a substitution */
+
+      error = GSUB_Do_Glyph_Lookup( gsub, subst->LookupListIndex, buffer,
+                                   GlyphCount, nesting_level );
+
+      subst++;
+      SubstCount--;
+      i += buffer->in_pos - old_pos;
+
+      if ( error == HB_Err_Not_Covered )
+      {
+       if ( COPY_Glyph( buffer ) )
+         return error;
+       i++;
+      }
+      else if ( error )
+       return error;
+    }
+    else
+    {
+      /* No substitution for this index */
+
+      if ( COPY_Glyph( buffer ) )
+       return error;
+      i++;
+    }
+  }
+
+  return HB_Err_Ok;
+}
+
+
+/* LookupType 5 */
+
+/* SubRule */
+
+static HB_Error  Load_SubRule( HB_SubRule*  sr,
+                              HB_Stream     stream )
+{
+  HB_Error error;
+
+  HB_UShort               n, count;
+  HB_UShort*              i;
+
+  HB_SubstLookupRecord*  slr;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  sr->GlyphCount = GET_UShort();
+  sr->SubstCount = GET_UShort();
+
+  FORGET_Frame();
+
+  sr->Input = NULL;
+
+  count = sr->GlyphCount - 1;         /* only GlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( sr->Input, count, HB_UShort ) )
+    return error;
+
+  i = sr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  sr->SubstLookupRecord = NULL;
+
+  count = sr->SubstCount;
+
+  if ( ALLOC_ARRAY( sr->SubstLookupRecord, count, HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = sr->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  FREE( i );
+  return error;
+}
+
+
+static void  Free_SubRule( HB_SubRule*  sr )
+{
+  FREE( sr->SubstLookupRecord );
+  FREE( sr->Input );
+}
+
+
+/* SubRuleSet */
+
+static HB_Error  Load_SubRuleSet( HB_SubRuleSet*  srs,
+                                 HB_Stream        stream )
+{
+  HB_Error error;
+
+  HB_UShort     n = 0, m, count;
+  HB_UInt      cur_offset, new_offset, base_offset;
+
+  HB_SubRule*  sr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = srs->SubRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  srs->SubRule = NULL;
+
+  if ( ALLOC_ARRAY( srs->SubRule, count, HB_SubRule ) )
+    return error;
+
+  sr = srs->SubRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_SubRule( &sr[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_SubRule( &sr[m] );
+
+  FREE( sr );
+  return error;
+}
+
+
+static void  Free_SubRuleSet( HB_SubRuleSet*  srs )
+{
+  HB_UShort     n, count;
+
+  HB_SubRule*  sr;
+
+
+  if ( srs->SubRule )
+  {
+    count = srs->SubRuleCount;
+    sr    = srs->SubRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_SubRule( &sr[n] );
+
+    FREE( sr );
+  }
+}
+
+
+/* ContextSubstFormat1 */
+
+static HB_Error  Load_ContextSubst1( HB_ContextSubstFormat1*  csf1,
+                                    HB_Stream                 stream )
+{
+  HB_Error error;
+
+  HB_UShort        n = 0, m, count;
+  HB_UInt         cur_offset, new_offset, base_offset;
+
+  HB_SubRuleSet*  srs;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &csf1->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = csf1->SubRuleSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csf1->SubRuleSet = NULL;
+
+  if ( ALLOC_ARRAY( csf1->SubRuleSet, count, HB_SubRuleSet ) )
+    goto Fail2;
+
+  srs = csf1->SubRuleSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_SubRuleSet( &srs[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_SubRuleSet( &srs[m] );
+
+  FREE( srs );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &csf1->Coverage );
+  return error;
+}
+
+
+static void  Free_ContextSubst1( HB_ContextSubstFormat1* csf1 )
+{
+  HB_UShort        n, count;
+
+  HB_SubRuleSet*  srs;
+
+
+  if ( csf1->SubRuleSet )
+  {
+    count = csf1->SubRuleSetCount;
+    srs   = csf1->SubRuleSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_SubRuleSet( &srs[n] );
+
+    FREE( srs );
+  }
+
+  _HB_OPEN_Free_Coverage( &csf1->Coverage );
+}
+
+
+/* SubClassRule */
+
+static HB_Error  Load_SubClassRule( HB_ContextSubstFormat2*  csf2,
+                                   HB_SubClassRule*         scr,
+                                   HB_Stream                 stream )
+{
+  HB_Error error;
+
+  HB_UShort               n, count;
+
+  HB_UShort*              c;
+  HB_SubstLookupRecord*  slr;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  scr->GlyphCount = GET_UShort();
+  scr->SubstCount = GET_UShort();
+
+  if ( scr->GlyphCount > csf2->MaxContextLength )
+    csf2->MaxContextLength = scr->GlyphCount;
+
+  FORGET_Frame();
+
+  scr->Class = NULL;
+
+  count = scr->GlyphCount - 1;        /* only GlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( scr->Class, count, HB_UShort ) )
+    return error;
+
+  c = scr->Class;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    c[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  scr->SubstLookupRecord = NULL;
+
+  count = scr->SubstCount;
+
+  if ( ALLOC_ARRAY( scr->SubstLookupRecord, count, HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = scr->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  FREE( c );
+  return error;
+}
+
+
+static void  Free_SubClassRule( HB_SubClassRule*  scr )
+{
+  FREE( scr->SubstLookupRecord );
+  FREE( scr->Class );
+}
+
+
+/* SubClassSet */
+
+static HB_Error  Load_SubClassSet( HB_ContextSubstFormat2*  csf2,
+                                  HB_SubClassSet*          scs,
+                                  HB_Stream                 stream )
+{
+  HB_Error error;
+
+  HB_UShort          n = 0, m, count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_SubClassRule*  scr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = scs->SubClassRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  scs->SubClassRule = NULL;
+
+  if ( ALLOC_ARRAY( scs->SubClassRule, count, HB_SubClassRule ) )
+    return error;
+
+  scr = scs->SubClassRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_SubClassRule( csf2, &scr[n],
+                                     stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_SubClassRule( &scr[m] );
+
+  FREE( scr );
+  return error;
+}
+
+
+static void  Free_SubClassSet( HB_SubClassSet*  scs )
+{
+  HB_UShort          n, count;
+
+  HB_SubClassRule*  scr;
+
+
+  if ( scs->SubClassRule )
+  {
+    count = scs->SubClassRuleCount;
+    scr   = scs->SubClassRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_SubClassRule( &scr[n] );
+
+    FREE( scr );
+  }
+}
+
+
+/* ContextSubstFormat2 */
+
+static HB_Error  Load_ContextSubst2( HB_ContextSubstFormat2*  csf2,
+                                    HB_Stream                 stream )
+{
+  HB_Error error;
+
+  HB_UShort         n = 0, m, count;
+  HB_UInt          cur_offset, new_offset, base_offset;
+
+  HB_SubClassSet*  scs;
+
+
+  base_offset = FILE_Pos() - 2;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &csf2->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 4L ) )
+    goto Fail3;
+
+  new_offset = GET_UShort() + base_offset;
+
+  /* `SubClassSetCount' is the upper limit for class values, thus we
+     read it now to make an additional safety check.                 */
+
+  count = csf2->SubClassSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_ClassDefinition( &csf2->ClassDef, count,
+                                      stream ) ) != HB_Err_Ok )
+    goto Fail3;
+  (void)FILE_Seek( cur_offset );
+
+  csf2->SubClassSet      = NULL;
+  csf2->MaxContextLength = 0;
+
+  if ( ALLOC_ARRAY( csf2->SubClassSet, count, HB_SubClassSet ) )
+    goto Fail2;
+
+  scs = csf2->SubClassSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    if ( new_offset != base_offset )      /* not a NULL offset */
+    {
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_SubClassSet( csf2, &scs[n],
+                                      stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      /* we create a SubClassSet table with no entries */
+
+      csf2->SubClassSet[n].SubClassRuleCount = 0;
+      csf2->SubClassSet[n].SubClassRule      = NULL;
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_SubClassSet( &scs[m] );
+
+  FREE( scs );
+
+Fail2:
+  _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef );
+
+Fail3:
+  _HB_OPEN_Free_Coverage( &csf2->Coverage );
+  return error;
+}
+
+
+static void  Free_ContextSubst2( HB_ContextSubstFormat2*  csf2 )
+{
+  HB_UShort         n, count;
+
+  HB_SubClassSet*  scs;
+
+
+  if ( csf2->SubClassSet )
+  {
+    count = csf2->SubClassSetCount;
+    scs   = csf2->SubClassSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_SubClassSet( &scs[n] );
+
+    FREE( scs );
+  }
+
+  _HB_OPEN_Free_ClassDefinition( &csf2->ClassDef );
+  _HB_OPEN_Free_Coverage( &csf2->Coverage );
+}
+
+
+/* ContextSubstFormat3 */
+
+static HB_Error  Load_ContextSubst3( HB_ContextSubstFormat3*  csf3,
+                                    HB_Stream                 stream )
+{
+  HB_Error error;
+
+  HB_UShort               n = 0, m, count;
+  HB_UInt                cur_offset, new_offset, base_offset;
+
+  HB_Coverage*           c;
+  HB_SubstLookupRecord*  slr;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  csf3->GlyphCount = GET_UShort();
+  csf3->SubstCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csf3->Coverage = NULL;
+
+  count = csf3->GlyphCount;
+
+  if ( ALLOC_ARRAY( csf3->Coverage, count, HB_Coverage ) )
+    return error;
+
+  c = csf3->Coverage;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  csf3->SubstLookupRecord = NULL;
+
+  count = csf3->SubstCount;
+
+  if ( ALLOC_ARRAY( csf3->SubstLookupRecord, count,
+                   HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = csf3->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  for ( m = 0; m < n; m++ )
+    _HB_OPEN_Free_Coverage( &c[m] );
+
+  FREE( c );
+  return error;
+}
+
+
+static void  Free_ContextSubst3( HB_ContextSubstFormat3*  csf3 )
+{
+  HB_UShort      n, count;
+
+  HB_Coverage*  c;
+
+
+  FREE( csf3->SubstLookupRecord );
+
+  if ( csf3->Coverage )
+  {
+    count = csf3->GlyphCount;
+    c     = csf3->Coverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+}
+
+
+/* ContextSubst */
+
+static HB_Error  Load_ContextSubst( HB_GSUB_SubTable* st,
+                                   HB_Stream         stream )
+{
+  HB_Error error;
+  HB_ContextSubst*  cs = &st->context;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cs->SubstFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( cs->SubstFormat )
+  {
+  case 1:  return Load_ContextSubst1( &cs->csf.csf1, stream );
+  case 2:  return Load_ContextSubst2( &cs->csf.csf2, stream );
+  case 3:  return Load_ContextSubst3( &cs->csf.csf3, stream );
+  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+static void  Free_ContextSubst( HB_GSUB_SubTable* st )
+{
+  HB_ContextSubst*  cs = &st->context;
+
+  switch ( cs->SubstFormat )
+  {
+  case 1:  Free_ContextSubst1( &cs->csf.csf1 ); break;
+  case 2:  Free_ContextSubst2( &cs->csf.csf2 ); break;
+  case 3:  Free_ContextSubst3( &cs->csf.csf3 ); break;
+  default:                                             break;
+  }
+}
+
+
+static HB_Error  Lookup_ContextSubst1( HB_GSUBHeader*          gsub,
+                                      HB_ContextSubstFormat1* csf1,
+                                      HB_Buffer               buffer,
+                                      HB_UShort                flags,
+                                      HB_UShort                context_length,
+                                      int                      nesting_level )
+{
+  HB_UShort        index, property;
+  HB_UShort        i, j, k, numsr;
+  HB_Error         error;
+
+  HB_SubRule*     sr;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &csf1->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  sr    = csf1->SubRuleSet[index].SubRule;
+  numsr = csf1->SubRuleSet[index].SubRuleCount;
+
+  for ( k = 0; k < numsr; k++ )
+  {
+    if ( context_length != 0xFFFF && context_length < sr[k].GlyphCount )
+      goto next_subrule;
+
+    if ( buffer->in_pos + sr[k].GlyphCount > buffer->in_length )
+      goto next_subrule;                        /* context is too long */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < sr[k].GlyphCount; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + sr[k].GlyphCount - i == (HB_Int)buffer->in_length )
+         goto next_subrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != sr[k].Input[i - 1] )
+       goto next_subrule;
+    }
+
+    return Do_ContextSubst( gsub, sr[k].GlyphCount,
+                           sr[k].SubstCount, sr[k].SubstLookupRecord,
+                           buffer,
+                           nesting_level );
+  next_subrule:
+    ;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Lookup_ContextSubst2( HB_GSUBHeader*          gsub,
+                                      HB_ContextSubstFormat2* csf2,
+                                      HB_Buffer               buffer,
+                                      HB_UShort                flags,
+                                      HB_UShort                context_length,
+                                      int                      nesting_level )
+{
+  HB_UShort          index, property;
+  HB_Error           error;
+  HB_UShort          i, j, k, known_classes;
+
+  HB_UShort*         classes;
+  HB_UShort*         cl;
+
+  HB_SubClassSet*   scs;
+  HB_SubClassRule*  sr;
+  HB_GDEFHeader*    gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  /* Note: The coverage table in format 2 doesn't give an index into
+          anything.  It just lets us know whether or not we need to
+          do any lookup at all.                                     */
+
+  error = _HB_OPEN_Coverage_Index( &csf2->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if (csf2->MaxContextLength < 1)
+    return HB_Err_Not_Covered;
+
+  if ( ALLOC_ARRAY( classes, csf2->MaxContextLength, HB_UShort ) )
+    return error;
+
+  error = _HB_OPEN_Get_Class( &csf2->ClassDef, IN_CURGLYPH(),
+                    &classes[0], NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    goto End;
+  known_classes = 0;
+
+  scs = &csf2->SubClassSet[classes[0]];
+  if ( !scs )
+  {
+    error = ERR_HB(HB_Err_Invalid_SubTable);
+    goto End;
+  }
+
+  for ( k = 0; k < scs->SubClassRuleCount; k++ )
+  {
+    sr  = &scs->SubClassRule[k];
+
+    if ( context_length != 0xFFFF && context_length < sr->GlyphCount )
+      goto next_subclassrule;
+
+    if ( buffer->in_pos + sr->GlyphCount > buffer->in_length )
+      goto next_subclassrule;                      /* context is too long */
+
+    cl   = sr->Class;
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < sr->GlyphCount; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End;
+
+       if ( j + sr->GlyphCount - i < (HB_Int)buffer->in_length )
+         goto next_subclassrule;
+       j++;
+      }
+
+      if ( i > known_classes )
+      {
+       /* Keeps us from having to do this for each rule */
+
+       error = _HB_OPEN_Get_Class( &csf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End;
+       known_classes = i;
+      }
+
+      if ( cl[i - 1] != classes[i] )
+       goto next_subclassrule;
+    }
+
+    error = Do_ContextSubst( gsub, sr->GlyphCount,
+                            sr->SubstCount, sr->SubstLookupRecord,
+                            buffer,
+                            nesting_level );
+    goto End;
+
+  next_subclassrule:
+    ;
+  }
+
+  error = HB_Err_Not_Covered;
+
+End:
+  FREE( classes );
+  return error;
+}
+
+
+static HB_Error  Lookup_ContextSubst3( HB_GSUBHeader*          gsub,
+                                      HB_ContextSubstFormat3* csf3,
+                                      HB_Buffer               buffer,
+                                      HB_UShort                flags,
+                                      HB_UShort                context_length,
+                                      int                      nesting_level )
+{
+  HB_Error         error;
+  HB_UShort        index, i, j, property;
+
+  HB_Coverage*    c;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  if ( context_length != 0xFFFF && context_length < csf3->GlyphCount )
+    return HB_Err_Not_Covered;
+
+  if ( buffer->in_pos + csf3->GlyphCount > buffer->in_length )
+    return HB_Err_Not_Covered;         /* context is too long */
+
+  c    = csf3->Coverage;
+
+  for ( i = 1, j = buffer->in_pos + 1; i < csf3->GlyphCount; i++, j++ )
+  {
+    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + csf3->GlyphCount - i == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &c[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  return Do_ContextSubst( gsub, csf3->GlyphCount,
+                         csf3->SubstCount, csf3->SubstLookupRecord,
+                         buffer,
+                         nesting_level );
+}
+
+
+static HB_Error  Lookup_ContextSubst( HB_GSUBHeader*    gsub,
+                                     HB_GSUB_SubTable* st,
+                                     HB_Buffer         buffer,
+                                     HB_UShort          flags,
+                                     HB_UShort          context_length,
+                                     int                nesting_level )
+{
+  HB_ContextSubst*  cs = &st->context;
+
+  switch ( cs->SubstFormat )
+  {
+  case 1:  return Lookup_ContextSubst1( gsub, &cs->csf.csf1, buffer, flags, context_length, nesting_level );
+  case 2:  return Lookup_ContextSubst2( gsub, &cs->csf.csf2, buffer, flags, context_length, nesting_level );
+  case 3:  return Lookup_ContextSubst3( gsub, &cs->csf.csf3, buffer, flags, context_length, nesting_level );
+  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+/* LookupType 6 */
+
+/* ChainSubRule */
+
+static HB_Error  Load_ChainSubRule( HB_ChainSubRule*  csr,
+                                   HB_Stream          stream )
+{
+  HB_Error error;
+
+  HB_UShort               n, count;
+  HB_UShort*              b;
+  HB_UShort*              i;
+  HB_UShort*              l;
+
+  HB_SubstLookupRecord*  slr;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  csr->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csr->Backtrack = NULL;
+
+  count = csr->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( csr->Backtrack, count, HB_UShort ) )
+    return error;
+
+  b = csr->Backtrack;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail4;
+
+  for ( n = 0; n < count; n++ )
+    b[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  csr->InputGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csr->Input = NULL;
+
+  count = csr->InputGlyphCount - 1;  /* only InputGlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( csr->Input, count, HB_UShort ) )
+    goto Fail4;
+
+  i = csr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail3;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  csr->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csr->Lookahead = NULL;
+
+  count = csr->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( csr->Lookahead, count, HB_UShort ) )
+    goto Fail3;
+
+  l = csr->Lookahead;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    l[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  csr->SubstCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csr->SubstLookupRecord = NULL;
+
+  count = csr->SubstCount;
+
+  if ( ALLOC_ARRAY( csr->SubstLookupRecord, count, HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = csr->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  FREE( l );
+
+Fail3:
+  FREE( i );
+
+Fail4:
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainSubRule( HB_ChainSubRule*  csr )
+{
+  FREE( csr->SubstLookupRecord );
+  FREE( csr->Lookahead );
+  FREE( csr->Input );
+  FREE( csr->Backtrack );
+}
+
+
+/* ChainSubRuleSet */
+
+static HB_Error  Load_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs,
+                                      HB_Stream             stream )
+{
+  HB_Error error;
+
+  HB_UShort          n = 0, m, count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_ChainSubRule*  csr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = csrs->ChainSubRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  csrs->ChainSubRule = NULL;
+
+  if ( ALLOC_ARRAY( csrs->ChainSubRule, count, HB_ChainSubRule ) )
+    return error;
+
+  csr = csrs->ChainSubRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainSubRule( &csr[n], stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_ChainSubRule( &csr[m] );
+
+  FREE( csr );
+  return error;
+}
+
+
+static void  Free_ChainSubRuleSet( HB_ChainSubRuleSet*  csrs )
+{
+  HB_UShort          n, count;
+
+  HB_ChainSubRule*  csr;
+
+
+  if ( csrs->ChainSubRule )
+  {
+    count = csrs->ChainSubRuleCount;
+    csr   = csrs->ChainSubRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainSubRule( &csr[n] );
+
+    FREE( csr );
+  }
+}
+
+
+/* ChainContextSubstFormat1 */
+
+static HB_Error  Load_ChainContextSubst1(
+                  HB_ChainContextSubstFormat1*  ccsf1,
+                  HB_Stream                      stream )
+{
+  HB_Error error;
+
+  HB_UShort             n = 0, m, count;
+  HB_UInt              cur_offset, new_offset, base_offset;
+
+  HB_ChainSubRuleSet*  csrs;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ccsf1->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = ccsf1->ChainSubRuleSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccsf1->ChainSubRuleSet = NULL;
+
+  if ( ALLOC_ARRAY( ccsf1->ChainSubRuleSet, count, HB_ChainSubRuleSet ) )
+    goto Fail2;
+
+  csrs = ccsf1->ChainSubRuleSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainSubRuleSet( &csrs[n], stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_ChainSubRuleSet( &csrs[m] );
+
+  FREE( csrs );
+
+Fail2:
+  _HB_OPEN_Free_Coverage( &ccsf1->Coverage );
+  return error;
+}
+
+
+static void  Free_ChainContextSubst1( HB_ChainContextSubstFormat1*  ccsf1 )
+{
+  HB_UShort             n, count;
+
+  HB_ChainSubRuleSet*  csrs;
+
+
+  if ( ccsf1->ChainSubRuleSet )
+  {
+    count = ccsf1->ChainSubRuleSetCount;
+    csrs  = ccsf1->ChainSubRuleSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainSubRuleSet( &csrs[n] );
+
+    FREE( csrs );
+  }
+
+  _HB_OPEN_Free_Coverage( &ccsf1->Coverage );
+}
+
+
+/* ChainSubClassRule */
+
+static HB_Error  Load_ChainSubClassRule(
+                  HB_ChainContextSubstFormat2*  ccsf2,
+                  HB_ChainSubClassRule*         cscr,
+                  HB_Stream                      stream )
+{
+  HB_Error error;
+
+  HB_UShort               n, count;
+
+  HB_UShort*              b;
+  HB_UShort*              i;
+  HB_UShort*              l;
+  HB_SubstLookupRecord*  slr;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cscr->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( cscr->BacktrackGlyphCount > ccsf2->MaxBacktrackLength )
+    ccsf2->MaxBacktrackLength = cscr->BacktrackGlyphCount;
+
+  cscr->Backtrack = NULL;
+
+  count = cscr->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( cscr->Backtrack, count, HB_UShort ) )
+    return error;
+
+  b = cscr->Backtrack;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail4;
+
+  for ( n = 0; n < count; n++ )
+    b[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  cscr->InputGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( cscr->InputGlyphCount > ccsf2->MaxInputLength )
+    ccsf2->MaxInputLength = cscr->InputGlyphCount;
+
+  cscr->Input = NULL;
+
+  count = cscr->InputGlyphCount - 1; /* only InputGlyphCount - 1 elements */
+
+  if ( ALLOC_ARRAY( cscr->Input, count, HB_UShort ) )
+    goto Fail4;
+
+  i = cscr->Input;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail3;
+
+  for ( n = 0; n < count; n++ )
+    i[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  cscr->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( cscr->LookaheadGlyphCount > ccsf2->MaxLookaheadLength )
+    ccsf2->MaxLookaheadLength = cscr->LookaheadGlyphCount;
+
+  cscr->Lookahead = NULL;
+
+  count = cscr->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( cscr->Lookahead, count, HB_UShort ) )
+    goto Fail3;
+
+  l = cscr->Lookahead;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail2;
+
+  for ( n = 0; n < count; n++ )
+    l[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  cscr->SubstCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cscr->SubstLookupRecord = NULL;
+
+  count = cscr->SubstCount;
+
+  if ( ALLOC_ARRAY( cscr->SubstLookupRecord, count,
+                   HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = cscr->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  FREE( l );
+
+Fail3:
+  FREE( i );
+
+Fail4:
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainSubClassRule( HB_ChainSubClassRule*  cscr )
+{
+  FREE( cscr->SubstLookupRecord );
+  FREE( cscr->Lookahead );
+  FREE( cscr->Input );
+  FREE( cscr->Backtrack );
+}
+
+
+/* SubClassSet */
+
+static HB_Error  Load_ChainSubClassSet(
+                  HB_ChainContextSubstFormat2*  ccsf2,
+                  HB_ChainSubClassSet*          cscs,
+                  HB_Stream                      stream )
+{
+  HB_Error error;
+
+  HB_UShort               n = 0, m, count;
+  HB_UInt                cur_offset, new_offset, base_offset;
+
+  HB_ChainSubClassRule*  cscr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = cscs->ChainSubClassRuleCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cscs->ChainSubClassRule = NULL;
+
+  if ( ALLOC_ARRAY( cscs->ChainSubClassRule, count,
+                   HB_ChainSubClassRule ) )
+    return error;
+
+  cscr = cscs->ChainSubClassRule;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_ChainSubClassRule( ccsf2, &cscr[n],
+                                          stream ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_ChainSubClassRule( &cscr[m] );
+
+  FREE( cscr );
+  return error;
+}
+
+
+static void  Free_ChainSubClassSet( HB_ChainSubClassSet*  cscs )
+{
+  HB_UShort               n, count;
+
+  HB_ChainSubClassRule*  cscr;
+
+
+  if ( cscs->ChainSubClassRule )
+  {
+    count = cscs->ChainSubClassRuleCount;
+    cscr  = cscs->ChainSubClassRule;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainSubClassRule( &cscr[n] );
+
+    FREE( cscr );
+  }
+}
+
+
+/* ChainContextSubstFormat2 */
+
+static HB_Error  Load_ChainContextSubst2(
+                  HB_ChainContextSubstFormat2*  ccsf2,
+                  HB_Stream                      stream )
+{
+  HB_Error error;
+
+  HB_UShort              n = 0, m, count;
+  HB_UInt               cur_offset, new_offset, base_offset;
+  HB_UInt               backtrack_offset, input_offset, lookahead_offset;
+
+  HB_ChainSubClassSet*  cscs;
+
+
+  base_offset = FILE_Pos() - 2;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &ccsf2->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+  if ( ACCESS_Frame( 8L ) )
+    goto Fail5;
+
+  backtrack_offset = GET_UShort();
+  input_offset     = GET_UShort();
+  lookahead_offset = GET_UShort();
+
+  /* `ChainSubClassSetCount' is the upper limit for input class values,
+     thus we read it now to make an additional safety check. No limit
+     is known or needed for the other two class definitions          */
+
+  count = ccsf2->ChainSubClassSetCount = GET_UShort();
+
+  FORGET_Frame();
+
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535,
+                                                      backtrack_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+      goto Fail5;
+
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count,
+                                                      input_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+      goto Fail4;
+  if ( ( error = _HB_OPEN_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535,
+                                                      lookahead_offset, base_offset,
+                                                      stream ) ) != HB_Err_Ok )
+    goto Fail3;
+
+  ccsf2->ChainSubClassSet   = NULL;
+  ccsf2->MaxBacktrackLength = 0;
+  ccsf2->MaxInputLength     = 0;
+  ccsf2->MaxLookaheadLength = 0;
+
+  if ( ALLOC_ARRAY( ccsf2->ChainSubClassSet, count, HB_ChainSubClassSet ) )
+    goto Fail2;
+
+  cscs = ccsf2->ChainSubClassSet;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    if ( new_offset != base_offset )      /* not a NULL offset */
+    {
+      cur_offset = FILE_Pos();
+      if ( FILE_Seek( new_offset ) ||
+          ( error = Load_ChainSubClassSet( ccsf2, &cscs[n],
+                                           stream ) ) != HB_Err_Ok )
+       goto Fail1;
+      (void)FILE_Seek( cur_offset );
+    }
+    else
+    {
+      /* we create a ChainSubClassSet table with no entries */
+
+      ccsf2->ChainSubClassSet[n].ChainSubClassRuleCount = 0;
+      ccsf2->ChainSubClassSet[n].ChainSubClassRule      = NULL;
+    }
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_ChainSubClassSet( &cscs[m] );
+
+  FREE( cscs );
+
+Fail2:
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef );
+
+Fail3:
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef );
+
+Fail4:
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef );
+
+Fail5:
+  _HB_OPEN_Free_Coverage( &ccsf2->Coverage );
+  return error;
+}
+
+
+static void  Free_ChainContextSubst2( HB_ChainContextSubstFormat2*  ccsf2 )
+{
+  HB_UShort              n, count;
+
+  HB_ChainSubClassSet*  cscs;
+
+
+  if ( ccsf2->ChainSubClassSet )
+  {
+    count = ccsf2->ChainSubClassSetCount;
+    cscs  = ccsf2->ChainSubClassSet;
+
+    for ( n = 0; n < count; n++ )
+      Free_ChainSubClassSet( &cscs[n] );
+
+    FREE( cscs );
+  }
+
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->LookaheadClassDef );
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->InputClassDef );
+  _HB_OPEN_Free_ClassDefinition( &ccsf2->BacktrackClassDef );
+
+  _HB_OPEN_Free_Coverage( &ccsf2->Coverage );
+}
+
+
+/* ChainContextSubstFormat3 */
+
+static HB_Error  Load_ChainContextSubst3(
+                  HB_ChainContextSubstFormat3*  ccsf3,
+                  HB_Stream                      stream )
+{
+  HB_Error error;
+
+  HB_UShort               n, nb = 0, ni =0, nl = 0, m, count;
+  HB_UShort               backtrack_count, input_count, lookahead_count;
+  HB_UInt                cur_offset, new_offset, base_offset;
+
+  HB_Coverage*           b;
+  HB_Coverage*           i;
+  HB_Coverage*           l;
+  HB_SubstLookupRecord*  slr;
+
+
+  base_offset = FILE_Pos() - 2L;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  ccsf3->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccsf3->BacktrackCoverage = NULL;
+
+  backtrack_count = ccsf3->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( ccsf3->BacktrackCoverage, backtrack_count,
+                   HB_Coverage ) )
+    return error;
+
+  b = ccsf3->BacktrackCoverage;
+
+  for ( nb = 0; nb < backtrack_count; nb++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail4;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
+      goto Fail4;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  ccsf3->InputGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccsf3->InputCoverage = NULL;
+
+  input_count = ccsf3->InputGlyphCount;
+
+  if ( ALLOC_ARRAY( ccsf3->InputCoverage, input_count, HB_Coverage ) )
+    goto Fail4;
+
+  i = ccsf3->InputCoverage;
+
+  for ( ni = 0; ni < input_count; ni++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail3;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )
+      goto Fail3;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  ccsf3->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccsf3->LookaheadCoverage = NULL;
+
+  lookahead_count = ccsf3->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( ccsf3->LookaheadCoverage, lookahead_count,
+                   HB_Coverage ) )
+    goto Fail3;
+
+  l = ccsf3->LookaheadCoverage;
+
+  for ( nl = 0; nl < lookahead_count; nl++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  ccsf3->SubstCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ccsf3->SubstLookupRecord = NULL;
+
+  count = ccsf3->SubstCount;
+
+  if ( ALLOC_ARRAY( ccsf3->SubstLookupRecord, count,
+                   HB_SubstLookupRecord ) )
+    goto Fail2;
+
+  slr = ccsf3->SubstLookupRecord;
+
+  if ( ACCESS_Frame( count * 4L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+  {
+    slr[n].SequenceIndex   = GET_UShort();
+    slr[n].LookupListIndex = GET_UShort();
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( slr );
+
+Fail2:
+  for ( m = 0; m < nl; m++ )
+    _HB_OPEN_Free_Coverage( &l[m] );
+
+  FREE( l );
+
+Fail3:
+  for ( m = 0; m < ni; m++ )
+    _HB_OPEN_Free_Coverage( &i[m] );
+
+  FREE( i );
+
+Fail4:
+  for ( m = 0; m < nb; m++ )
+    _HB_OPEN_Free_Coverage( &b[m] );
+
+  FREE( b );
+  return error;
+}
+
+
+static void  Free_ChainContextSubst3( HB_ChainContextSubstFormat3*  ccsf3 )
+{
+  HB_UShort      n, count;
+
+  HB_Coverage*  c;
+
+
+  FREE( ccsf3->SubstLookupRecord );
+
+  if ( ccsf3->LookaheadCoverage )
+  {
+    count = ccsf3->LookaheadGlyphCount;
+    c     = ccsf3->LookaheadCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  if ( ccsf3->InputCoverage )
+  {
+    count = ccsf3->InputGlyphCount;
+    c     = ccsf3->InputCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  if ( ccsf3->BacktrackCoverage )
+  {
+    count = ccsf3->BacktrackGlyphCount;
+    c     = ccsf3->BacktrackCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+}
+
+
+/* ChainContextSubst */
+
+static HB_Error  Load_ChainContextSubst( HB_GSUB_SubTable* st,
+                                        HB_Stream         stream )
+{
+  HB_Error error;
+  HB_ChainContextSubst*  ccs = &st->chain;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  ccs->SubstFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( ccs->SubstFormat ) {
+    case 1:  return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream );
+    case 2:  return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream );
+    case 3:  return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream );
+    default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+static void  Free_ChainContextSubst( HB_GSUB_SubTable* st )
+{
+  HB_ChainContextSubst*  ccs = &st->chain;
+
+  switch ( ccs->SubstFormat ) {
+    case 1:  Free_ChainContextSubst1( &ccs->ccsf.ccsf1 ); break;
+    case 2:  Free_ChainContextSubst2( &ccs->ccsf.ccsf2 ); break;
+    case 3:  Free_ChainContextSubst3( &ccs->ccsf.ccsf3 ); break;
+    default:                                                     break;
+  }
+}
+
+
+static HB_Error  Lookup_ChainContextSubst1( HB_GSUBHeader*               gsub,
+                                           HB_ChainContextSubstFormat1* ccsf1,
+                                           HB_Buffer                    buffer,
+                                           HB_UShort                     flags,
+                                           HB_UShort                     context_length,
+                                           int                           nesting_level )
+{
+  HB_UShort          index, property;
+  HB_UShort          i, j, k, num_csr;
+  HB_UShort          bgc, igc, lgc;
+  HB_Error           error;
+
+  HB_ChainSubRule*  csr;
+  HB_ChainSubRule   curr_csr;
+  HB_GDEFHeader*    gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  error = _HB_OPEN_Coverage_Index( &ccsf1->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  csr     = ccsf1->ChainSubRuleSet[index].ChainSubRule;
+  num_csr = ccsf1->ChainSubRuleSet[index].ChainSubRuleCount;
+
+  for ( k = 0; k < num_csr; k++ )
+  {
+    curr_csr = csr[k];
+    bgc      = curr_csr.BacktrackGlyphCount;
+    igc      = curr_csr.InputGlyphCount;
+    lgc      = curr_csr.LookaheadGlyphCount;
+
+    if ( context_length != 0xFFFF && context_length < igc )
+      goto next_chainsubrule;
+
+    /* check whether context is too long; it is a first guess only */
+
+    if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+      goto next_chainsubrule;
+
+    if ( bgc )
+    {
+      /* since we don't know in advance the number of glyphs to inspect,
+        we search backwards for matches in the backtrack glyph array    */
+
+      for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )
+      {
+       while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )
+       {
+         if ( error && error != HB_Err_Not_Covered )
+           return error;
+
+         if ( j + 1 == bgc - i )
+           goto next_chainsubrule;
+         j--;
+       }
+
+       /* In OpenType 1.3, it is undefined whether the offsets of
+          backtrack glyphs is in logical order or not.  Version 1.4
+          will clarify this:
+
+            Logical order -      a  b  c  d  e  f  g  h  i  j
+                                             i
+            Input offsets -                  0  1
+            Backtrack offsets -  3  2  1  0
+            Lookahead offsets -                    0  1  2  3           */
+
+       if ( OUT_GLYPH( j ) != curr_csr.Backtrack[i] )
+         goto next_chainsubrule;
+      }
+    }
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+         goto next_chainsubrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != curr_csr.Input[i - 1] )
+         goto next_chainsubrule;
+    }
+
+    /* we are starting to check for lookahead glyphs right after the
+       last context glyph                                            */
+
+    for ( i = 0; i < lgc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + lgc - i == (HB_Int)buffer->in_length )
+         goto next_chainsubrule;
+       j++;
+      }
+
+      if ( IN_GLYPH( j ) != curr_csr.Lookahead[i] )
+       goto next_chainsubrule;
+    }
+
+    return Do_ContextSubst( gsub, igc,
+                           curr_csr.SubstCount,
+                           curr_csr.SubstLookupRecord,
+                           buffer,
+                           nesting_level );
+
+  next_chainsubrule:
+    ;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Lookup_ChainContextSubst2( HB_GSUBHeader*               gsub,
+                                           HB_ChainContextSubstFormat2* ccsf2,
+                                           HB_Buffer                    buffer,
+                                           HB_UShort                     flags,
+                                           HB_UShort                     context_length,
+                                           int                           nesting_level )
+{
+  HB_UShort              index, property;
+  HB_Error               error;
+  HB_UShort              i, j, k;
+  HB_UShort              bgc, igc, lgc;
+  HB_UShort              known_backtrack_classes,
+                        known_input_classes,
+                        known_lookahead_classes;
+
+  HB_UShort*             backtrack_classes;
+  HB_UShort*             input_classes;
+  HB_UShort*             lookahead_classes;
+
+  HB_UShort*             bc;
+  HB_UShort*             ic;
+  HB_UShort*             lc;
+
+  HB_ChainSubClassSet*  cscs;
+  HB_ChainSubClassRule  ccsr;
+  HB_GDEFHeader*        gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  /* Note: The coverage table in format 2 doesn't give an index into
+          anything.  It just lets us know whether or not we need to
+          do any lookup at all.                                     */
+
+  error = _HB_OPEN_Coverage_Index( &ccsf2->Coverage, IN_CURGLYPH(), &index );
+  if ( error )
+    return error;
+
+  if ( ALLOC_ARRAY( backtrack_classes, ccsf2->MaxBacktrackLength, HB_UShort ) )
+    return error;
+  known_backtrack_classes = 0;
+
+  if (ccsf2->MaxInputLength < 1)
+    return HB_Err_Not_Covered;
+
+  if ( ALLOC_ARRAY( input_classes, ccsf2->MaxInputLength, HB_UShort ) )
+    goto End3;
+  known_input_classes = 1;
+
+  if ( ALLOC_ARRAY( lookahead_classes, ccsf2->MaxLookaheadLength, HB_UShort ) )
+    goto End2;
+  known_lookahead_classes = 0;
+
+  error = _HB_OPEN_Get_Class( &ccsf2->InputClassDef, IN_CURGLYPH(),
+                    &input_classes[0], NULL );
+  if ( error && error != HB_Err_Not_Covered )
+    goto End1;
+
+  cscs = &ccsf2->ChainSubClassSet[input_classes[0]];
+  if ( !cscs )
+  {
+    error = ERR_HB(HB_Err_Invalid_SubTable);
+    goto End1;
+  }
+
+  for ( k = 0; k < cscs->ChainSubClassRuleCount; k++ )
+  {
+    ccsr = cscs->ChainSubClassRule[k];
+    bgc  = ccsr.BacktrackGlyphCount;
+    igc  = ccsr.InputGlyphCount;
+    lgc  = ccsr.LookaheadGlyphCount;
+
+    if ( context_length != 0xFFFF && context_length < igc )
+      goto next_chainsubclassrule;
+
+    /* check whether context is too long; it is a first guess only */
+
+    if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+      goto next_chainsubclassrule;
+
+    if ( bgc )
+    {
+      /* Since we don't know in advance the number of glyphs to inspect,
+        we search backwards for matches in the backtrack glyph array.
+        Note that `known_backtrack_classes' starts at index 0.         */
+
+      bc       = ccsr.Backtrack;
+
+      for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )
+      {
+       while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )
+       {
+         if ( error && error != HB_Err_Not_Covered )
+           goto End1;
+
+         if ( j + 1 == bgc - i )
+           goto next_chainsubclassrule;
+         j--;
+       }
+
+       if ( i >= known_backtrack_classes )
+       {
+         /* Keeps us from having to do this for each rule */
+
+         error = _HB_OPEN_Get_Class( &ccsf2->BacktrackClassDef, OUT_GLYPH( j ),
+                            &backtrack_classes[i], NULL );
+         if ( error && error != HB_Err_Not_Covered )
+           goto End1;
+         known_backtrack_classes = i;
+       }
+
+       if ( bc[i] != backtrack_classes[i] )
+         goto next_chainsubclassrule;
+      }
+    }
+
+    ic       = ccsr.Input;
+
+    /* Start at 1 because [0] is implied */
+
+    for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+
+       if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+         goto next_chainsubclassrule;
+       j++;
+      }
+
+      if ( i >= known_input_classes )
+      {
+       error = _HB_OPEN_Get_Class( &ccsf2->InputClassDef, IN_GLYPH( j ),
+                          &input_classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+       known_input_classes = i;
+      }
+
+      if ( ic[i - 1] != input_classes[i] )
+       goto next_chainsubclassrule;
+    }
+
+    /* we are starting to check for lookahead glyphs right after the
+       last context glyph                                            */
+
+    lc       = ccsr.Lookahead;
+
+    for ( i = 0; i < lgc; i++, j++ )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+
+       if ( j + lgc - i == (HB_Int)buffer->in_length )
+         goto next_chainsubclassrule;
+       j++;
+      }
+
+      if ( i >= known_lookahead_classes )
+      {
+       error = _HB_OPEN_Get_Class( &ccsf2->LookaheadClassDef, IN_GLYPH( j ),
+                          &lookahead_classes[i], NULL );
+       if ( error && error != HB_Err_Not_Covered )
+         goto End1;
+       known_lookahead_classes = i;
+      }
+
+      if ( lc[i] != lookahead_classes[i] )
+       goto next_chainsubclassrule;
+    }
+
+    error = Do_ContextSubst( gsub, igc,
+                            ccsr.SubstCount,
+                            ccsr.SubstLookupRecord,
+                            buffer,
+                            nesting_level );
+    goto End1;
+
+  next_chainsubclassrule:
+    ;
+  }
+
+  error = HB_Err_Not_Covered;
+
+End1:
+  FREE( lookahead_classes );
+
+End2:
+  FREE( input_classes );
+
+End3:
+  FREE( backtrack_classes );
+  return error;
+}
+
+
+static HB_Error  Lookup_ChainContextSubst3( HB_GSUBHeader*               gsub,
+                                           HB_ChainContextSubstFormat3* ccsf3,
+                                           HB_Buffer                    buffer,
+                                           HB_UShort                     flags,
+                                           HB_UShort                     context_length,
+                                           int                           nesting_level )
+{
+  HB_UShort        index, i, j, property;
+  HB_UShort        bgc, igc, lgc;
+  HB_Error         error;
+
+  HB_Coverage*    bc;
+  HB_Coverage*    ic;
+  HB_Coverage*    lc;
+  HB_GDEFHeader*  gdef;
+
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  bgc = ccsf3->BacktrackGlyphCount;
+  igc = ccsf3->InputGlyphCount;
+  lgc = ccsf3->LookaheadGlyphCount;
+
+  if ( context_length != 0xFFFF && context_length < igc )
+    return HB_Err_Not_Covered;
+
+  /* check whether context is too long; it is a first guess only */
+
+  if ( bgc > buffer->out_pos || buffer->in_pos + igc + lgc > buffer->in_length )
+    return HB_Err_Not_Covered;
+
+  if ( bgc )
+  {
+    /* Since we don't know in advance the number of glyphs to inspect,
+       we search backwards for matches in the backtrack glyph array    */
+
+    bc       = ccsf3->BacktrackCoverage;
+
+    for ( i = 0, j = buffer->out_pos - 1; i < bgc; i++, j-- )
+    {
+      while ( CHECK_Property( gdef, OUT_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + 1 == bgc - i )
+         return HB_Err_Not_Covered;
+       j--;
+      }
+
+      error = _HB_OPEN_Coverage_Index( &bc[i], OUT_GLYPH( j ), &index );
+      if ( error )
+       return error;
+    }
+  }
+
+  ic       = ccsf3->InputCoverage;
+
+  for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ )
+  {
+    /* We already called CHECK_Property for IN_GLYPH( buffer->in_pos ) */
+    while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + igc - i + lgc == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &ic[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  /* we are starting for lookahead glyphs right after the last context
+     glyph                                                             */
+
+  lc       = ccsf3->LookaheadCoverage;
+
+  for ( i = 0; i < lgc; i++, j++ )
+  {
+    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + lgc - i == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  return Do_ContextSubst( gsub, igc,
+                         ccsf3->SubstCount,
+                         ccsf3->SubstLookupRecord,
+                         buffer,
+                         nesting_level );
+}
+
+
+static HB_Error  Lookup_ChainContextSubst( HB_GSUBHeader*    gsub,
+                                          HB_GSUB_SubTable* st,
+                                          HB_Buffer         buffer,
+                                          HB_UShort          flags,
+                                          HB_UShort          context_length,
+                                          int                nesting_level )
+{
+  HB_ChainContextSubst*  ccs = &st->chain;
+
+  switch ( ccs->SubstFormat ) {
+    case 1:  return Lookup_ChainContextSubst1( gsub, &ccs->ccsf.ccsf1, buffer, flags, context_length, nesting_level );
+    case 2:  return Lookup_ChainContextSubst2( gsub, &ccs->ccsf.ccsf2, buffer, flags, context_length, nesting_level );
+    case 3:  return Lookup_ChainContextSubst3( gsub, &ccs->ccsf.ccsf3, buffer, flags, context_length, nesting_level );
+    default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+}
+
+
+static HB_Error  Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
+                                               HB_Stream         stream )
+{
+  HB_Error error;
+  HB_ReverseChainContextSubst*  rccs = &st->reverse;
+
+  HB_UShort               m, count;
+
+  HB_UShort               nb = 0, nl = 0, n;
+  HB_UShort               backtrack_count, lookahead_count;
+  HB_UInt                cur_offset, new_offset, base_offset;
+
+  HB_Coverage*           b;
+  HB_Coverage*           l;
+  HB_UShort*              sub;
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  rccs->SubstFormat = GET_UShort();
+
+  if ( rccs->SubstFormat != 1 )
+    return ERR_HB(HB_Err_Invalid_SubTable_Format);
+
+  FORGET_Frame();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  cur_offset = FILE_Pos();
+  if ( FILE_Seek( new_offset ) ||
+       ( error = _HB_OPEN_Load_Coverage( &rccs->Coverage, stream ) ) != HB_Err_Ok )
+    return error;
+  (void)FILE_Seek( cur_offset );
+
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail4;
+
+  rccs->BacktrackGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  rccs->BacktrackCoverage = NULL;
+
+  backtrack_count = rccs->BacktrackGlyphCount;
+
+  if ( ALLOC_ARRAY( rccs->BacktrackCoverage, backtrack_count,
+                   HB_Coverage ) )
+    goto Fail4;
+
+  b = rccs->BacktrackCoverage;
+
+  for ( nb = 0; nb < backtrack_count; nb++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail3;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
+      goto Fail3;
+    (void)FILE_Seek( cur_offset );
+  }
+
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail3;
+
+  rccs->LookaheadGlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  rccs->LookaheadCoverage = NULL;
+
+  lookahead_count = rccs->LookaheadGlyphCount;
+
+  if ( ALLOC_ARRAY( rccs->LookaheadCoverage, lookahead_count,
+                   HB_Coverage ) )
+    goto Fail3;
+
+  l = rccs->LookaheadCoverage;
+
+  for ( nl = 0; nl < lookahead_count; nl++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail2;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
+      goto Fail2;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  rccs->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  rccs->Substitute = NULL;
+
+  count = rccs->GlyphCount;
+
+  if ( ALLOC_ARRAY( rccs->Substitute, count,
+                   HB_UShort ) )
+    goto Fail2;
+
+  sub = rccs->Substitute;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail1;
+
+  for ( n = 0; n < count; n++ )
+    sub[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( sub );
+
+Fail2:
+  for ( m = 0; m < nl; m++ )
+    _HB_OPEN_Free_Coverage( &l[m] );
+
+  FREE( l );
+
+Fail3:
+  for ( m = 0; m < nb; m++ )
+    _HB_OPEN_Free_Coverage( &b[m] );
+
+  FREE( b );
+
+Fail4:
+  _HB_OPEN_Free_Coverage( &rccs->Coverage );
+  return error;
+}
+
+
+static void  Free_ReverseChainContextSubst( HB_GSUB_SubTable* st )
+{
+  HB_UShort      n, count;
+  HB_ReverseChainContextSubst*  rccs = &st->reverse;
+
+  HB_Coverage*  c;
+
+  _HB_OPEN_Free_Coverage( &rccs->Coverage );
+
+  if ( rccs->LookaheadCoverage )
+  {
+    count = rccs->LookaheadGlyphCount;
+    c     = rccs->LookaheadCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  if ( rccs->BacktrackCoverage )
+  {
+    count = rccs->BacktrackGlyphCount;
+    c     = rccs->BacktrackCoverage;
+
+    for ( n = 0; n < count; n++ )
+      _HB_OPEN_Free_Coverage( &c[n] );
+
+    FREE( c );
+  }
+
+  FREE ( rccs->Substitute );
+}
+
+
+static HB_Error  Lookup_ReverseChainContextSubst( HB_GSUBHeader*    gsub,
+                                                 HB_GSUB_SubTable* st,
+                                                 HB_Buffer         buffer,
+                                                 HB_UShort          flags,
+                                                 HB_UShort         context_length,
+                                                 int               nesting_level )
+{
+  HB_UShort        index, input_index, i, j, property;
+  HB_UShort        bgc, lgc;
+  HB_Error         error;
+
+  HB_ReverseChainContextSubst*  rccs = &st->reverse;
+  HB_Coverage*    bc;
+  HB_Coverage*    lc;
+  HB_GDEFHeader*  gdef;
+
+  if ( nesting_level != 1 || context_length != 0xFFFF )
+    return HB_Err_Not_Covered;
+
+  gdef = gsub->gdef;
+
+  if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
+    return error;
+
+  bgc = rccs->BacktrackGlyphCount;
+  lgc = rccs->LookaheadGlyphCount;
+
+  /* check whether context is too long; it is a first guess only */
+
+  if ( bgc > buffer->in_pos || buffer->in_pos + 1 + lgc > buffer->in_length )
+    return HB_Err_Not_Covered;
+
+  if ( bgc )
+  {
+    /* Since we don't know in advance the number of glyphs to inspect,
+       we search backwards for matches in the backtrack glyph array    */
+
+    bc       = rccs->BacktrackCoverage;
+
+    for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
+    {
+      while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+      {
+       if ( error && error != HB_Err_Not_Covered )
+         return error;
+
+       if ( j + 1 == bgc - i )
+         return HB_Err_Not_Covered;
+       j--;
+      }
+
+      error = _HB_OPEN_Coverage_Index( &bc[i], IN_GLYPH( j ), &index );
+      if ( error )
+       return error;
+    }
+  }
+
+  j = buffer->in_pos;
+
+  error = _HB_OPEN_Coverage_Index( &rccs->Coverage, IN_GLYPH( j ), &input_index );
+  if ( error )
+      return error;
+
+  lc       = rccs->LookaheadCoverage;
+
+  for ( i = 0, j = buffer->in_pos + 1; i < lgc; i++, j++ )
+  {
+    while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
+    {
+      if ( error && error != HB_Err_Not_Covered )
+       return error;
+
+      if ( j + lgc - i == (HB_Int)buffer->in_length )
+       return HB_Err_Not_Covered;
+      j++;
+    }
+
+    error = _HB_OPEN_Coverage_Index( &lc[i], IN_GLYPH( j ), &index );
+    if ( error )
+      return error;
+  }
+
+  IN_CURGLYPH() = rccs->Substitute[input_index];
+  buffer->in_pos--; /* Reverse! */
+
+  return error;
+}
+
+
+
+/***********
+ * GSUB API
+ ***********/
+
+
+
+HB_Error  HB_GSUB_Select_Script( HB_GSUBHeader*  gsub,
+                                HB_UInt         script_tag,
+                                HB_UShort*       script_index )
+{
+  HB_UShort          n;
+
+  HB_ScriptList*    sl;
+  HB_ScriptRecord*  sr;
+
+
+  if ( !gsub || !script_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  for ( n = 0; n < sl->ScriptCount; n++ )
+    if ( script_tag == sr[n].ScriptTag )
+    {
+      *script_index = n;
+
+      return HB_Err_Ok;
+    }
+
+  return HB_Err_Not_Covered;
+}
+
+
+
+HB_Error  HB_GSUB_Select_Language( HB_GSUBHeader*  gsub,
+                                  HB_UInt         language_tag,
+                                  HB_UShort        script_index,
+                                  HB_UShort*       language_index,
+                                  HB_UShort*       req_feature_index )
+{
+  HB_UShort           n;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+
+
+  if ( !gsub || !language_index || !req_feature_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  for ( n = 0; n < s->LangSysCount; n++ )
+    if ( language_tag == lsr[n].LangSysTag )
+    {
+      *language_index = n;
+      *req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
+
+      return HB_Err_Ok;
+    }
+
+  return HB_Err_Not_Covered;
+}
+
+
+/* selecting 0xFFFF for language_index asks for the values of the
+   default language (DefaultLangSys)                              */
+
+
+HB_Error  HB_GSUB_Select_Feature( HB_GSUBHeader*  gsub,
+                                 HB_UInt         feature_tag,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UShort*       feature_index )
+{
+  HB_UShort           n;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+  HB_LangSys*        ls;
+  HB_UShort*          fi;
+
+  HB_FeatureList*    fl;
+  HB_FeatureRecord*  fr;
+
+
+  if ( !gsub || !feature_index )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  fl = &gsub->FeatureList;
+  fr = fl->FeatureRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( language_index == 0xFFFF )
+    ls = &s->DefaultLangSys;
+  else
+  {
+    if ( language_index >= s->LangSysCount )
+      return ERR_HB(HB_Err_Invalid_Argument);
+
+    ls = &lsr[language_index].LangSys;
+  }
+
+  fi = ls->FeatureIndex;
+
+  for ( n = 0; n < ls->FeatureCount; n++ )
+  {
+    if ( fi[n] >= fl->FeatureCount )
+      return ERR_HB(HB_Err_Invalid_SubTable_Format);
+
+    if ( feature_tag == fr[fi[n]].FeatureTag )
+    {
+      *feature_index = fi[n];
+
+      return HB_Err_Ok;
+    }
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+/* The next three functions return a null-terminated list */
+
+
+HB_Error  HB_GSUB_Query_Scripts( HB_GSUBHeader*  gsub,
+                                HB_UInt**       script_tag_list )
+{
+  HB_UShort          n;
+  HB_Error           error;
+  HB_UInt*          stl;
+
+  HB_ScriptList*    sl;
+  HB_ScriptRecord*  sr;
+
+
+  if ( !gsub || !script_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( ALLOC_ARRAY( stl, sl->ScriptCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < sl->ScriptCount; n++ )
+    stl[n] = sr[n].ScriptTag;
+  stl[n] = 0;
+
+  *script_tag_list = stl;
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GSUB_Query_Languages( HB_GSUBHeader*  gsub,
+                                  HB_UShort        script_index,
+                                  HB_UInt**       language_tag_list )
+{
+  HB_UShort           n;
+  HB_Error            error;
+  HB_UInt*           ltl;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+
+
+  if ( !gsub || !language_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( ALLOC_ARRAY( ltl, s->LangSysCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < s->LangSysCount; n++ )
+    ltl[n] = lsr[n].LangSysTag;
+  ltl[n] = 0;
+
+  *language_tag_list = ltl;
+
+  return HB_Err_Ok;
+}
+
+
+/* selecting 0xFFFF for language_index asks for the values of the
+   default language (DefaultLangSys)                              */
+
+
+HB_Error  HB_GSUB_Query_Features( HB_GSUBHeader*  gsub,
+                                 HB_UShort        script_index,
+                                 HB_UShort        language_index,
+                                 HB_UInt**       feature_tag_list )
+{
+  HB_UShort           n;
+  HB_Error            error;
+  HB_UInt*           ftl;
+
+  HB_ScriptList*     sl;
+  HB_ScriptRecord*   sr;
+  HB_ScriptTable*    s;
+  HB_LangSysRecord*  lsr;
+  HB_LangSys*        ls;
+  HB_UShort*          fi;
+
+  HB_FeatureList*    fl;
+  HB_FeatureRecord*  fr;
+
+
+  if ( !gsub || !feature_tag_list )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  sl = &gsub->ScriptList;
+  sr = sl->ScriptRecord;
+
+  fl = &gsub->FeatureList;
+  fr = fl->FeatureRecord;
+
+  if ( script_index >= sl->ScriptCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  s   = &sr[script_index].Script;
+  lsr = s->LangSysRecord;
+
+  if ( language_index == 0xFFFF )
+    ls = &s->DefaultLangSys;
+  else
+  {
+    if ( language_index >= s->LangSysCount )
+      return ERR_HB(HB_Err_Invalid_Argument);
+
+    ls = &lsr[language_index].LangSys;
+  }
+
+  fi = ls->FeatureIndex;
+
+  if ( ALLOC_ARRAY( ftl, ls->FeatureCount + 1, HB_UInt ) )
+    return error;
+
+  for ( n = 0; n < ls->FeatureCount; n++ )
+  {
+    if ( fi[n] >= fl->FeatureCount )
+    {
+      FREE( ftl );
+      return ERR_HB(HB_Err_Invalid_SubTable_Format);
+    }
+    ftl[n] = fr[fi[n]].FeatureTag;
+  }
+  ftl[n] = 0;
+
+  *feature_tag_list = ftl;
+
+  return HB_Err_Ok;
+}
+
+
+/* Do an individual subtable lookup.  Returns HB_Err_Ok if substitution
+   has been done, or HB_Err_Not_Covered if not.                        */
+static HB_Error  GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
+                                      HB_UShort       lookup_index,
+                                      HB_Buffer      buffer,
+                                      HB_UShort       context_length,
+                                      int             nesting_level )
+{
+  HB_Error               error = HB_Err_Not_Covered;
+  HB_UShort              i, flags, lookup_count;
+  HB_Lookup*             lo;
+  int                    lookup_type;
+
+  nesting_level++;
+
+  if ( nesting_level > HB_MAX_NESTING_LEVEL )
+    return ERR_HB(HB_Err_Not_Covered); /* ERR_HB() call intended */
+
+  lookup_count = gsub->LookupList.LookupCount;
+  if (lookup_index >= lookup_count)
+    return error;
+
+  lo    = &gsub->LookupList.Lookup[lookup_index];
+  flags = lo->LookupFlag;
+  lookup_type = lo->LookupType;
+
+  for ( i = 0; i < lo->SubTableCount; i++ )
+  {
+    HB_GSUB_SubTable *st = &lo->SubTable[i].st.gsub;
+
+    switch (lookup_type) {
+      case HB_GSUB_LOOKUP_SINGLE:
+       error = Lookup_SingleSubst              ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GSUB_LOOKUP_MULTIPLE:
+       error = Lookup_MultipleSubst            ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GSUB_LOOKUP_ALTERNATE:
+       error = Lookup_AlternateSubst           ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GSUB_LOOKUP_LIGATURE:
+       error = Lookup_LigatureSubst            ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GSUB_LOOKUP_CONTEXT:
+       error = Lookup_ContextSubst             ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      case HB_GSUB_LOOKUP_CHAIN:
+       error = Lookup_ChainContextSubst        ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+    /*case HB_GSUB_LOOKUP_EXTENSION:
+       error = Lookup_ExtensionSubst           ( gsub, st, buffer, flags, context_length, nesting_level ); break;*/
+      case HB_GSUB_LOOKUP_REVERSE_CHAIN:
+       error = Lookup_ReverseChainContextSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+      default:
+       error = HB_Err_Not_Covered;
+    };
+
+    /* Check whether we have a successful substitution or an error other
+       than HB_Err_Not_Covered                                          */
+    if ( error != HB_Err_Not_Covered )
+      return error;
+  }
+
+  return HB_Err_Not_Covered;
+}
+
+
+HB_INTERNAL HB_Error
+_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+                       HB_Stream         stream,
+                       HB_UShort         lookup_type )
+{
+  switch (lookup_type) {
+    case HB_GSUB_LOOKUP_SINGLE:                return Load_SingleSubst                 ( st, stream );
+    case HB_GSUB_LOOKUP_MULTIPLE:      return Load_MultipleSubst               ( st, stream );
+    case HB_GSUB_LOOKUP_ALTERNATE:     return Load_AlternateSubst              ( st, stream );
+    case HB_GSUB_LOOKUP_LIGATURE:      return Load_LigatureSubst               ( st, stream );
+    case HB_GSUB_LOOKUP_CONTEXT:       return Load_ContextSubst                ( st, stream );
+    case HB_GSUB_LOOKUP_CHAIN:         return Load_ChainContextSubst           ( st, stream );
+  /*case HB_GSUB_LOOKUP_EXTENSION:     return Load_ExtensionSubst              ( st, stream );*/
+    case HB_GSUB_LOOKUP_REVERSE_CHAIN: return Load_ReverseChainContextSubst    ( st, stream );
+    default:                           return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  };
+}
+
+
+HB_INTERNAL void
+_HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
+                       HB_UShort         lookup_type )
+{
+  switch ( lookup_type ) {
+    case HB_GSUB_LOOKUP_SINGLE:                Free_SingleSubst                ( st ); return;
+    case HB_GSUB_LOOKUP_MULTIPLE:      Free_MultipleSubst              ( st ); return;
+    case HB_GSUB_LOOKUP_ALTERNATE:     Free_AlternateSubst             ( st ); return;
+    case HB_GSUB_LOOKUP_LIGATURE:      Free_LigatureSubst              ( st ); return;
+    case HB_GSUB_LOOKUP_CONTEXT:       Free_ContextSubst               ( st ); return;
+    case HB_GSUB_LOOKUP_CHAIN:         Free_ChainContextSubst          ( st ); return;
+  /*case HB_GSUB_LOOKUP_EXTENSION:     Free_ExtensionSubst             ( st ); return;*/
+    case HB_GSUB_LOOKUP_REVERSE_CHAIN: Free_ReverseChainContextSubst   ( st ); return;
+    default:                                                                   return;
+  };
+}
+
+
+
+/* apply one lookup to the input string object */
+
+static HB_Error  GSUB_Do_String_Lookup( HB_GSUBHeader*   gsub,
+                                  HB_UShort         lookup_index,
+                                  HB_Buffer        buffer )
+{
+  HB_Error  error, retError = HB_Err_Not_Covered;
+
+  HB_UInt*  properties = gsub->LookupList.Properties;
+  int       lookup_type = gsub->LookupList.Lookup[lookup_index].LookupType;
+
+  const int       nesting_level = 0;
+  /* 0xFFFF indicates that we don't have a context length yet */
+  const HB_UShort context_length = 0xFFFF;
+
+  switch (lookup_type) {
+
+    case HB_GSUB_LOOKUP_SINGLE:
+    case HB_GSUB_LOOKUP_MULTIPLE:
+    case HB_GSUB_LOOKUP_ALTERNATE:
+    case HB_GSUB_LOOKUP_LIGATURE:
+    case HB_GSUB_LOOKUP_CONTEXT:
+    case HB_GSUB_LOOKUP_CHAIN:
+      /* in/out forward substitution (implemented lazy) */
+
+      _hb_buffer_clear_output ( buffer );
+      buffer->in_pos = 0;
+  while ( buffer->in_pos < buffer->in_length )
+  {
+    if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
+    {
+         error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );
+      if ( error )
+      {
+       if ( error != HB_Err_Not_Covered )
+         return error;
+      }
+      else
+       retError = error;
+    }
+    else
+      error = HB_Err_Not_Covered;
+
+    if ( error == HB_Err_Not_Covered )
+         if ( COPY_Glyph ( buffer ) )
+       return error;
+  }
+      /* we shouldn't swap if error occurred.
+       *
+       * also don't swap if nothing changed (ie HB_Err_Not_Covered).
+       * shouldn't matter in that case though.
+       */
+      if ( retError == HB_Err_Ok )
+       _hb_buffer_swap( buffer );
+
+  return retError;
+
+    case HB_GSUB_LOOKUP_REVERSE_CHAIN:
+      /* in-place backward substitution */
+
+      buffer->in_pos = buffer->in_length - 1;
+    do
+    {
+      if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
+       {
+         error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );
+         if ( error )
+           {
+             if ( error != HB_Err_Not_Covered )
+               return error;
+           }
+         else
+           retError = error;
+       }
+       else
+         error = HB_Err_Not_Covered;
+
+       if ( error == HB_Err_Not_Covered )
+         buffer->in_pos--;
+      }
+      while ((HB_Int) buffer->in_pos >= 0);
+
+      return retError;
+
+  /*case HB_GSUB_LOOKUP_EXTENSION:*/
+    default:
+  return retError;
+  };
+}
+
+
+HB_Error  HB_GSUB_Add_Feature( HB_GSUBHeader*  gsub,
+                              HB_UShort        feature_index,
+                              HB_UInt          property )
+{
+  HB_UShort    i;
+
+  HB_Feature  feature;
+  HB_UInt*     properties;
+  HB_UShort*   index;
+  HB_UShort    lookup_count;
+
+  /* Each feature can only be added once */
+
+  if ( !gsub ||
+       feature_index >= gsub->FeatureList.FeatureCount ||
+       gsub->FeatureList.ApplyCount == gsub->FeatureList.FeatureCount )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index;
+
+  properties = gsub->LookupList.Properties;
+
+  feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
+  index   = feature.LookupListIndex;
+  lookup_count = gsub->LookupList.LookupCount;
+
+  for ( i = 0; i < feature.LookupListCount; i++ )
+  {
+    HB_UShort lookup_index = index[i];
+    if (lookup_index < lookup_count)
+      properties[lookup_index] |= property;
+  }
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GSUB_Clear_Features( HB_GSUBHeader*  gsub )
+{
+  HB_UShort i;
+
+  HB_UInt*  properties;
+
+
+  if ( !gsub )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gsub->FeatureList.ApplyCount = 0;
+
+  properties = gsub->LookupList.Properties;
+
+  for ( i = 0; i < gsub->LookupList.LookupCount; i++ )
+    properties[i] = 0;
+
+  return HB_Err_Ok;
+}
+
+
+
+HB_Error  HB_GSUB_Register_Alternate_Function( HB_GSUBHeader*  gsub,
+                                              HB_AltFunction  altfunc,
+                                              void*            data )
+{
+  if ( !gsub )
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  gsub->altfunc = altfunc;
+  gsub->data    = data;
+
+  return HB_Err_Ok;
+}
+
+/* returns error if one happened, otherwise returns HB_Err_Not_Covered if no
+ * feature were applied, or HB_Err_Ok otherwise.
+ */
+HB_Error  HB_GSUB_Apply_String( HB_GSUBHeader*   gsub,
+                               HB_Buffer        buffer )
+{
+  HB_Error          error, retError = HB_Err_Not_Covered;
+  int               i, j, lookup_count, num_features;
+
+  if ( !gsub ||
+       !buffer)
+    return ERR_HB(HB_Err_Invalid_Argument);
+
+  if ( buffer->in_length == 0 )
+    return retError;
+
+  lookup_count = gsub->LookupList.LookupCount;
+  num_features = gsub->FeatureList.ApplyCount;
+
+  for ( i = 0; i < num_features; i++)
+  {
+    HB_UShort  feature_index = gsub->FeatureList.ApplyOrder[i];
+    HB_Feature feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
+
+    for ( j = 0; j < feature.LookupListCount; j++ )
+    {
+      HB_UShort         lookup_index = feature.LookupListIndex[j];
+
+      /* Skip nonexistant lookups */
+      if (lookup_index >= lookup_count)
+       continue;
+
+       error = GSUB_Do_String_Lookup( gsub, lookup_index, buffer );
+      if ( error )
+      {
+       if ( error != HB_Err_Not_Covered )
+         return error;
+      }
+      else
+       retError = error;
+    }
+  }
+
+  error = retError;
+
+  return error;
+}
+
+
+/* END */
index 6ab940d..be1ecec 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-\r
-/*\r
-// Hangul is a syllable based script. Unicode reserves a large range\r
-// for precomposed hangul, where syllables are already precomposed to\r
-// their final glyph shape. In addition, a so called jamo range is\r
-// defined, that can be used to express old Hangul. Modern hangul\r
-// syllables can also be expressed as jamo, and should be composed\r
-// into syllables. The operation is rather simple and mathematical.\r
-\r
-// Every hangul jamo is classified as being either a Leading consonant\r
-// (L), and intermediat Vowel (V) or a trailing consonant (T). Modern\r
-// hangul syllables (the ones in the precomposed area can be of type\r
-// LV or LVT.\r
-//\r
-// Syllable breaks do _not_ occur between:\r
-//\r
-// L              L, V or precomposed\r
-// V, LV          V, T\r
-// LVT, T         T\r
-//\r
-// A standard syllable is of the form L+V+T*. The above rules allow\r
-// nonstandard syllables L*V*T*. To transform them into standard\r
-// syllables fill characters L_f and V_f can be inserted.\r
-*/\r
-\r
-enum {\r
-    Hangul_SBase = 0xac00,\r
-    Hangul_LBase = 0x1100,\r
-    Hangul_VBase = 0x1161,\r
-    Hangul_TBase = 0x11a7,\r
-    Hangul_SCount = 11172,\r
-    Hangul_LCount = 19,\r
-    Hangul_VCount = 21,\r
-    Hangul_TCount = 28,\r
-    Hangul_NCount = 21*28\r
-};\r
-\r
-#define hangul_isPrecomposed(uc) \\r
-    (uc >= Hangul_SBase && uc < Hangul_SBase + Hangul_SCount)\r
-\r
-#define hangul_isLV(uc) \\r
-    ((uc - Hangul_SBase) % Hangul_TCount == 0)\r
-\r
-typedef enum {\r
-    L,\r
-    V,\r
-    T,\r
-    LV,\r
-    LVT,\r
-    X\r
-} HangulType;\r
-\r
-static HangulType hangul_type(unsigned short uc) {\r
-    if (uc > Hangul_SBase && uc < Hangul_SBase + Hangul_SCount)\r
-        return hangul_isLV(uc) ? LV : LVT;\r
-    if (uc < Hangul_LBase || uc > 0x11ff)\r
-        return X;\r
-    if (uc < Hangul_VBase)\r
-        return L;\r
-    if (uc < Hangul_TBase)\r
-        return V;\r
-    return T;\r
-}\r
-\r
-static int hangul_nextSyllableBoundary(const HB_UChar16 *s, int start, int end)\r
-{\r
-    const HB_UChar16 *uc = s + start;\r
-\r
-    HangulType state = hangul_type(*uc);\r
-    int pos = 1;\r
-\r
-    while (pos < end - start) {\r
-        HangulType newState = hangul_type(uc[pos]);\r
-        switch(newState) {\r
-        case X:\r
-            goto finish;\r
-        case L:\r
-        case V:\r
-        case T:\r
-            if (state > newState)\r
-                goto finish;\r
-            state = newState;\r
-            break;\r
-        case LV:\r
-            if (state > L)\r
-                goto finish;\r
-            state = V;\r
-            break;\r
-        case LVT:\r
-            if (state > L)\r
-                goto finish;\r
-            state = T;\r
-        }\r
-        ++pos;\r
-    }\r
-\r
- finish:\r
-    return start+pos;\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-static const HB_OpenTypeFeature hangul_features [] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('l', 'j', 'm', 'o'), CcmpProperty },\r
-    { HB_MAKE_TAG('j', 'j', 'm', 'o'), CcmpProperty },\r
-    { HB_MAKE_TAG('t', 'j', 'm', 'o'), CcmpProperty },\r
-    { 0, 0 }\r
-};\r
-#endif\r
-\r
-static HB_Bool hangul_shape_syllable(HB_ShaperItem *item, HB_Bool openType)\r
-{\r
-    const HB_UChar16 *ch = item->string + item->item.pos;\r
-    int len = item->item.length;\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = item->num_glyphs;\r
-#endif\r
-\r
-    int i;\r
-    HB_UChar16 composed = 0;\r
-    /* see if we can compose the syllable into a modern hangul */\r
-    if (item->item.length == 2) {\r
-        int LIndex = ch[0] - Hangul_LBase;\r
-        int VIndex = ch[1] - Hangul_VBase;\r
-        if (LIndex >= 0 && LIndex < Hangul_LCount &&\r
-            VIndex >= 0 && VIndex < Hangul_VCount)\r
-            composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + Hangul_SBase;\r
-    } else if (item->item.length == 3) {\r
-        int LIndex = ch[0] - Hangul_LBase;\r
-        int VIndex = ch[1] - Hangul_VBase;\r
-        int TIndex = ch[2] - Hangul_TBase;\r
-        if (LIndex >= 0 && LIndex < Hangul_LCount &&\r
-            VIndex >= 0 && VIndex < Hangul_VCount &&\r
-            TIndex >= 0 && TIndex < Hangul_TCount)\r
-            composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + TIndex + Hangul_SBase;\r
-    }\r
-\r
-\r
-\r
-    /* if we have a modern hangul use the composed form */\r
-    if (composed) {\r
-        ch = &composed;\r
-        len = 1;\r
-    }\r
-\r
-    if (!item->font->klass->convertStringToGlyphIndices(item->font,\r
-                                                        ch, len,\r
-                                                        item->glyphs, &item->num_glyphs,\r
-                                                        item->item.bidiLevel % 2))\r
-        return FALSE;\r
-    for (i = 0; i < len; i++) {\r
-        item->attributes[i].mark = FALSE;\r
-        item->attributes[i].clusterStart = FALSE;\r
-        item->attributes[i].justification = 0;\r
-        item->attributes[i].zeroWidth = FALSE;\r
-        /*IDEBUG("    %d: %4x", i, ch[i].unicode()); */\r
-    }\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (!composed && openType) {\r
-        HB_Bool positioned;\r
-\r
-        HB_STACKARRAY(unsigned short, logClusters, len);\r
-        for (i = 0; i < len; ++i)\r
-            logClusters[i] = i;\r
-        item->log_clusters = logClusters;\r
-\r
-        HB_OpenTypeShape(item, /*properties*/0);\r
-\r
-        positioned = HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE);\r
-\r
-        HB_FREE_STACKARRAY(logClusters);\r
-\r
-        if (!positioned)\r
-            return FALSE;\r
-    } else {\r
-        HB_HeuristicPosition(item);\r
-    }\r
-#endif\r
-\r
-    item->attributes[0].clusterStart = TRUE;\r
-    return TRUE;\r
-}\r
-\r
-HB_Bool HB_HangulShape(HB_ShaperItem *item)\r
-{\r
-    const HB_UChar16 *uc = item->string + item->item.pos;\r
-    HB_Bool allPrecomposed = TRUE;\r
-    int i;\r
-\r
-    assert(item->item.script == HB_Script_Hangul);\r
-\r
-    for (i = 0; i < (int)item->item.length; ++i) {\r
-        if (!hangul_isPrecomposed(uc[i])) {\r
-            allPrecomposed = FALSE;\r
-            break;\r
-        }\r
-    }\r
-\r
-    if (!allPrecomposed) {\r
-        HB_Bool openType = FALSE;\r
-        unsigned short *logClusters = item->log_clusters;\r
-        HB_ShaperItem syllable;\r
-        int first_glyph = 0;\r
-        int sstart = item->item.pos;\r
-        int end = sstart + item->item.length;\r
-\r
-#ifndef NO_OPENTYPE\r
-        openType = HB_SelectScript(item, hangul_features);\r
-#endif\r
-        syllable = *item;\r
-\r
-        while (sstart < end) {\r
-            int send = hangul_nextSyllableBoundary(item->string, sstart, end);\r
-\r
-            syllable.item.pos = sstart;\r
-            syllable.item.length = send-sstart;\r
-            syllable.glyphs = item->glyphs + first_glyph;\r
-            syllable.attributes = item->attributes + first_glyph;\r
-            syllable.offsets = item->offsets + first_glyph;\r
-            syllable.advances = item->advances + first_glyph;\r
-            syllable.num_glyphs = item->num_glyphs - first_glyph;\r
-            if (!hangul_shape_syllable(&syllable, openType)) {\r
-                item->num_glyphs += syllable.num_glyphs;\r
-                return FALSE;\r
-            }\r
-            /* fix logcluster array */\r
-            for (i = sstart; i < send; ++i)\r
-                logClusters[i-item->item.pos] = first_glyph;\r
-            sstart = send;\r
-            first_glyph += syllable.num_glyphs;\r
-        }\r
-        item->num_glyphs = first_glyph;\r
-        return TRUE;\r
-    }\r
-\r
-    return HB_BasicShape(item);\r
-}\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+
+/*
+// Hangul is a syllable based script. Unicode reserves a large range
+// for precomposed hangul, where syllables are already precomposed to
+// their final glyph shape. In addition, a so called jamo range is
+// defined, that can be used to express old Hangul. Modern hangul
+// syllables can also be expressed as jamo, and should be composed
+// into syllables. The operation is rather simple and mathematical.
+
+// Every hangul jamo is classified as being either a Leading consonant
+// (L), and intermediat Vowel (V) or a trailing consonant (T). Modern
+// hangul syllables (the ones in the precomposed area can be of type
+// LV or LVT.
+//
+// Syllable breaks do _not_ occur between:
+//
+// L              L, V or precomposed
+// V, LV          V, T
+// LVT, T         T
+//
+// A standard syllable is of the form L+V+T*. The above rules allow
+// nonstandard syllables L*V*T*. To transform them into standard
+// syllables fill characters L_f and V_f can be inserted.
+*/
+
+enum {
+    Hangul_SBase = 0xac00,
+    Hangul_LBase = 0x1100,
+    Hangul_VBase = 0x1161,
+    Hangul_TBase = 0x11a7,
+    Hangul_SCount = 11172,
+    Hangul_LCount = 19,
+    Hangul_VCount = 21,
+    Hangul_TCount = 28,
+    Hangul_NCount = 21*28
+};
+
+#define hangul_isPrecomposed(uc) \
+    (uc >= Hangul_SBase && uc < Hangul_SBase + Hangul_SCount)
+
+#define hangul_isLV(uc) \
+    ((uc - Hangul_SBase) % Hangul_TCount == 0)
+
+typedef enum {
+    L,
+    V,
+    T,
+    LV,
+    LVT,
+    X
+} HangulType;
+
+static HangulType hangul_type(unsigned short uc) {
+    if (uc > Hangul_SBase && uc < Hangul_SBase + Hangul_SCount)
+        return hangul_isLV(uc) ? LV : LVT;
+    if (uc < Hangul_LBase || uc > 0x11ff)
+        return X;
+    if (uc < Hangul_VBase)
+        return L;
+    if (uc < Hangul_TBase)
+        return V;
+    return T;
+}
+
+static int hangul_nextSyllableBoundary(const HB_UChar16 *s, int start, int end)
+{
+    const HB_UChar16 *uc = s + start;
+
+    HangulType state = hangul_type(*uc);
+    int pos = 1;
+
+    while (pos < end - start) {
+        HangulType newState = hangul_type(uc[pos]);
+        switch(newState) {
+        case X:
+            goto finish;
+        case L:
+        case V:
+        case T:
+            if (state > newState)
+                goto finish;
+            state = newState;
+            break;
+        case LV:
+            if (state > L)
+                goto finish;
+            state = V;
+            break;
+        case LVT:
+            if (state > L)
+                goto finish;
+            state = T;
+        }
+        ++pos;
+    }
+
+ finish:
+    return start+pos;
+}
+
+#ifndef NO_OPENTYPE
+static const HB_OpenTypeFeature hangul_features [] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('l', 'j', 'm', 'o'), CcmpProperty },
+    { HB_MAKE_TAG('j', 'j', 'm', 'o'), CcmpProperty },
+    { HB_MAKE_TAG('t', 'j', 'm', 'o'), CcmpProperty },
+    { 0, 0 }
+};
+#endif
+
+static HB_Bool hangul_shape_syllable(HB_ShaperItem *item, HB_Bool openType)
+{
+    const HB_UChar16 *ch = item->string + item->item.pos;
+    int len = item->item.length;
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = item->num_glyphs;
+#endif
+
+    int i;
+    HB_UChar16 composed = 0;
+    /* see if we can compose the syllable into a modern hangul */
+    if (item->item.length == 2) {
+        int LIndex = ch[0] - Hangul_LBase;
+        int VIndex = ch[1] - Hangul_VBase;
+        if (LIndex >= 0 && LIndex < Hangul_LCount &&
+            VIndex >= 0 && VIndex < Hangul_VCount)
+            composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + Hangul_SBase;
+    } else if (item->item.length == 3) {
+        int LIndex = ch[0] - Hangul_LBase;
+        int VIndex = ch[1] - Hangul_VBase;
+        int TIndex = ch[2] - Hangul_TBase;
+        if (LIndex >= 0 && LIndex < Hangul_LCount &&
+            VIndex >= 0 && VIndex < Hangul_VCount &&
+            TIndex >= 0 && TIndex < Hangul_TCount)
+            composed = (LIndex * Hangul_VCount + VIndex) * Hangul_TCount + TIndex + Hangul_SBase;
+    }
+
+
+
+    /* if we have a modern hangul use the composed form */
+    if (composed) {
+        ch = &composed;
+        len = 1;
+    }
+
+    if (!item->font->klass->convertStringToGlyphIndices(item->font,
+                                                        ch, len,
+                                                        item->glyphs, &item->num_glyphs,
+                                                        item->item.bidiLevel % 2))
+        return FALSE;
+    for (i = 0; i < len; i++) {
+        item->attributes[i].mark = FALSE;
+        item->attributes[i].clusterStart = FALSE;
+        item->attributes[i].justification = 0;
+        item->attributes[i].zeroWidth = FALSE;
+        /*IDEBUG("    %d: %4x", i, ch[i].unicode()); */
+    }
+
+#ifndef NO_OPENTYPE
+    if (!composed && openType) {
+        HB_Bool positioned;
+
+        HB_STACKARRAY(unsigned short, logClusters, len);
+        for (i = 0; i < len; ++i)
+            logClusters[i] = i;
+        item->log_clusters = logClusters;
+
+        HB_OpenTypeShape(item, /*properties*/0);
+
+        positioned = HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE);
+
+        HB_FREE_STACKARRAY(logClusters);
+
+        if (!positioned)
+            return FALSE;
+    } else {
+        HB_HeuristicPosition(item);
+    }
+#endif
+
+    item->attributes[0].clusterStart = TRUE;
+    return TRUE;
+}
+
+HB_Bool HB_HangulShape(HB_ShaperItem *item)
+{
+    const HB_UChar16 *uc = item->string + item->item.pos;
+    HB_Bool allPrecomposed = TRUE;
+    int i;
+
+    assert(item->item.script == HB_Script_Hangul);
+
+    for (i = 0; i < (int)item->item.length; ++i) {
+        if (!hangul_isPrecomposed(uc[i])) {
+            allPrecomposed = FALSE;
+            break;
+        }
+    }
+
+    if (!allPrecomposed) {
+        HB_Bool openType = FALSE;
+        unsigned short *logClusters = item->log_clusters;
+        HB_ShaperItem syllable;
+        int first_glyph = 0;
+        int sstart = item->item.pos;
+        int end = sstart + item->item.length;
+
+#ifndef NO_OPENTYPE
+        openType = HB_SelectScript(item, hangul_features);
+#endif
+        syllable = *item;
+
+        while (sstart < end) {
+            int send = hangul_nextSyllableBoundary(item->string, sstart, end);
+
+            syllable.item.pos = sstart;
+            syllable.item.length = send-sstart;
+            syllable.glyphs = item->glyphs + first_glyph;
+            syllable.attributes = item->attributes + first_glyph;
+            syllable.offsets = item->offsets + first_glyph;
+            syllable.advances = item->advances + first_glyph;
+            syllable.num_glyphs = item->num_glyphs - first_glyph;
+            if (!hangul_shape_syllable(&syllable, openType)) {
+                item->num_glyphs += syllable.num_glyphs;
+                return FALSE;
+            }
+            /* fix logcluster array */
+            for (i = sstart; i < send; ++i)
+                logClusters[i-item->item.pos] = first_glyph;
+            sstart = send;
+            first_glyph += syllable.num_glyphs;
+        }
+        item->num_glyphs = first_glyph;
+        return TRUE;
+    }
+
+    return HB_BasicShape(item);
+}
+
+
index 4d3442d..27e22b3 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-#include <assert.h>\r
-\r
-/*\r
-// Uniscribe also defines dlig for Hebrew, but we leave this out for now, as it's mostly\r
-// ligatures one does not want in modern Hebrew (as lam-alef ligatures).\r
-*/\r
-#ifndef NO_OPENTYPE\r
-static const HB_OpenTypeFeature hebrew_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    {0, 0}\r
-};\r
-#endif\r
-\r
-/* Hebrew shaping. In the non opentype case we try to use the\r
-   presentation forms specified for Hebrew. Especially for the\r
-   ligatures with Dagesh this gives much better results than we could\r
-   achieve manually.\r
-*/\r
-HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)\r
-{\r
-    enum {\r
-        Dagesh = 0x5bc,\r
-        ShinDot = 0x5c1,\r
-        SinDot = 0x5c2,\r
-        Patah = 0x5b7,\r
-        Qamats = 0x5b8,\r
-        Holam = 0x5b9,\r
-        Rafe = 0x5bf\r
-    };\r
-\r
-    assert(shaper_item->item.script == HB_Script_Hebrew);\r
-\r
-    HB_HeuristicSetGlyphAttributes(shaper_item);\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (HB_SelectScript(shaper_item, hebrew_features)) {\r
-\r
-        const int availableGlyphs = shaper_item->num_glyphs;\r
-        if (!HB_ConvertStringToGlyphIndices(shaper_item))\r
-            return FALSE;\r
-\r
-\r
-        HB_OpenTypeShape(shaper_item, /*properties*/0);\r
-        return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/TRUE);\r
-    }\r
-#endif\r
-\r
-    {\r
-        const HB_UChar16 *uc = shaper_item->string + shaper_item->item.pos;\r
-        unsigned short *logClusters = shaper_item->log_clusters;\r
-        HB_GlyphAttributes *attributes = shaper_item->attributes;\r
-\r
-        HB_Bool haveGlyphs;\r
-        int slen = 1;\r
-        int cluster_start = 0;\r
-        hb_uint32 i;\r
-\r
-        HB_STACKARRAY(HB_UChar16, shapedChars, 2 * shaper_item->item.length);\r
-        *shapedChars = *uc;\r
-        logClusters[0] = 0;\r
-\r
-        for (i = 1; i < shaper_item->item.length; ++i) {\r
-            hb_uint16 base = shapedChars[slen-1];\r
-            hb_uint16 shaped = 0;\r
-            HB_Bool invalid = FALSE;\r
-            if (uc[i] == Dagesh) {\r
-                if (base >= 0x5d0\r
-                    && base <= 0x5ea\r
-                    && base != 0x5d7\r
-                    && base != 0x5dd\r
-                    && base != 0x5df\r
-                    && base != 0x5e2\r
-                    && base != 0x5e5) {\r
-                    shaped = base - 0x5d0 + 0xfb30;\r
-                } else if (base == 0xfb2a || base == 0xfb2b /* Shin with Shin or Sin dot */) {\r
-                    shaped = base + 2;\r
-                } else {\r
-                    invalid = TRUE;\r
-                }\r
-            } else if (uc[i] == ShinDot) {\r
-                if (base == 0x05e9)\r
-                    shaped = 0xfb2a;\r
-                else if (base == 0xfb49)\r
-                    shaped = 0xfb2c;\r
-                else\r
-                    invalid = TRUE;\r
-            } else if (uc[i] == SinDot) {\r
-                if (base == 0x05e9)\r
-                    shaped = 0xfb2b;\r
-                else if (base == 0xfb49)\r
-                    shaped = 0xfb2d;\r
-                else\r
-                    invalid = TRUE;\r
-            } else if (uc[i] == Patah) {\r
-                if (base == 0x5d0)\r
-                    shaped = 0xfb2e;\r
-            } else if (uc[i] == Qamats) {\r
-                if (base == 0x5d0)\r
-                    shaped = 0xfb2f;\r
-            } else if (uc[i] == Holam) {\r
-                if (base == 0x5d5)\r
-                    shaped = 0xfb4b;\r
-            } else if (uc[i] == Rafe) {\r
-                if (base == 0x5d1)\r
-                    shaped = 0xfb4c;\r
-                else if (base == 0x5db)\r
-                    shaped = 0xfb4d;\r
-                else if (base == 0x5e4)\r
-                    shaped = 0xfb4e;\r
-            }\r
-\r
-            if (invalid) {\r
-                shapedChars[slen] = 0x25cc;\r
-                attributes[slen].clusterStart = TRUE;\r
-                attributes[slen].mark = FALSE;\r
-                attributes[slen].combiningClass = 0;\r
-                cluster_start = slen;\r
-                ++slen;\r
-            }\r
-            if (shaped) {\r
-                if (shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1)) {\r
-                    shapedChars[slen-1] = shaped;\r
-                } else\r
-                    shaped = 0;\r
-            }\r
-            if (!shaped) {\r
-                HB_CharCategory category;\r
-                int cmb;\r
-                shapedChars[slen] = uc[i];\r
-                HB_GetUnicodeCharProperties(uc[i], &category, &cmb);\r
-                if (category != HB_Mark_NonSpacing) {\r
-                    attributes[slen].clusterStart = TRUE;\r
-                    attributes[slen].mark = FALSE;\r
-                    attributes[slen].combiningClass = 0;\r
-                    attributes[slen].dontPrint = HB_IsControlChar(uc[i]);\r
-                    cluster_start = slen;\r
-                } else {\r
-                    attributes[slen].clusterStart = FALSE;\r
-                    attributes[slen].mark = TRUE;\r
-                    attributes[slen].combiningClass = cmb;\r
-                }\r
-                ++slen;\r
-            }\r
-            logClusters[i] = cluster_start;\r
-        }\r
-\r
-        haveGlyphs = shaper_item->font->klass\r
-            ->convertStringToGlyphIndices(shaper_item->font,\r
-                                          shapedChars, slen,\r
-                                          shaper_item->glyphs, &shaper_item->num_glyphs,\r
-                                          shaper_item->item.bidiLevel % 2);\r
-\r
-        HB_FREE_STACKARRAY(shapedChars);\r
-\r
-        if (!haveGlyphs)\r
-            return FALSE;\r
-\r
-        HB_HeuristicPosition(shaper_item);\r
-    }\r
-\r
-    return TRUE;\r
-}\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+#include <assert.h>
+
+/*
+// Uniscribe also defines dlig for Hebrew, but we leave this out for now, as it's mostly
+// ligatures one does not want in modern Hebrew (as lam-alef ligatures).
+*/
+#ifndef NO_OPENTYPE
+static const HB_OpenTypeFeature hebrew_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    {0, 0}
+};
+#endif
+
+/* Hebrew shaping. In the non opentype case we try to use the
+   presentation forms specified for Hebrew. Especially for the
+   ligatures with Dagesh this gives much better results than we could
+   achieve manually.
+*/
+HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
+{
+    enum {
+        Dagesh = 0x5bc,
+        ShinDot = 0x5c1,
+        SinDot = 0x5c2,
+        Patah = 0x5b7,
+        Qamats = 0x5b8,
+        Holam = 0x5b9,
+        Rafe = 0x5bf
+    };
+
+    assert(shaper_item->item.script == HB_Script_Hebrew);
+
+    HB_HeuristicSetGlyphAttributes(shaper_item);
+
+#ifndef NO_OPENTYPE
+    if (HB_SelectScript(shaper_item, hebrew_features)) {
+
+        const int availableGlyphs = shaper_item->num_glyphs;
+        if (!HB_ConvertStringToGlyphIndices(shaper_item))
+            return FALSE;
+
+
+        HB_OpenTypeShape(shaper_item, /*properties*/0);
+        return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/TRUE);
+    }
+#endif
+
+    {
+        const HB_UChar16 *uc = shaper_item->string + shaper_item->item.pos;
+        unsigned short *logClusters = shaper_item->log_clusters;
+        HB_GlyphAttributes *attributes = shaper_item->attributes;
+
+        HB_Bool haveGlyphs;
+        int slen = 1;
+        int cluster_start = 0;
+        hb_uint32 i;
+
+        HB_STACKARRAY(HB_UChar16, shapedChars, 2 * shaper_item->item.length);
+        *shapedChars = *uc;
+        logClusters[0] = 0;
+
+        for (i = 1; i < shaper_item->item.length; ++i) {
+            hb_uint16 base = shapedChars[slen-1];
+            hb_uint16 shaped = 0;
+            HB_Bool invalid = FALSE;
+            if (uc[i] == Dagesh) {
+                if (base >= 0x5d0
+                    && base <= 0x5ea
+                    && base != 0x5d7
+                    && base != 0x5dd
+                    && base != 0x5df
+                    && base != 0x5e2
+                    && base != 0x5e5) {
+                    shaped = base - 0x5d0 + 0xfb30;
+                } else if (base == 0xfb2a || base == 0xfb2b /* Shin with Shin or Sin dot */) {
+                    shaped = base + 2;
+                } else {
+                    invalid = TRUE;
+                }
+            } else if (uc[i] == ShinDot) {
+                if (base == 0x05e9)
+                    shaped = 0xfb2a;
+                else if (base == 0xfb49)
+                    shaped = 0xfb2c;
+                else
+                    invalid = TRUE;
+            } else if (uc[i] == SinDot) {
+                if (base == 0x05e9)
+                    shaped = 0xfb2b;
+                else if (base == 0xfb49)
+                    shaped = 0xfb2d;
+                else
+                    invalid = TRUE;
+            } else if (uc[i] == Patah) {
+                if (base == 0x5d0)
+                    shaped = 0xfb2e;
+            } else if (uc[i] == Qamats) {
+                if (base == 0x5d0)
+                    shaped = 0xfb2f;
+            } else if (uc[i] == Holam) {
+                if (base == 0x5d5)
+                    shaped = 0xfb4b;
+            } else if (uc[i] == Rafe) {
+                if (base == 0x5d1)
+                    shaped = 0xfb4c;
+                else if (base == 0x5db)
+                    shaped = 0xfb4d;
+                else if (base == 0x5e4)
+                    shaped = 0xfb4e;
+            }
+
+            if (invalid) {
+                shapedChars[slen] = 0x25cc;
+                attributes[slen].clusterStart = TRUE;
+                attributes[slen].mark = FALSE;
+                attributes[slen].combiningClass = 0;
+                cluster_start = slen;
+                ++slen;
+            }
+            if (shaped) {
+                if (shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1)) {
+                    shapedChars[slen-1] = shaped;
+                } else
+                    shaped = 0;
+            }
+            if (!shaped) {
+                HB_CharCategory category;
+                int cmb;
+                shapedChars[slen] = uc[i];
+                HB_GetUnicodeCharProperties(uc[i], &category, &cmb);
+                if (category != HB_Mark_NonSpacing) {
+                    attributes[slen].clusterStart = TRUE;
+                    attributes[slen].mark = FALSE;
+                    attributes[slen].combiningClass = 0;
+                    attributes[slen].dontPrint = HB_IsControlChar(uc[i]);
+                    cluster_start = slen;
+                } else {
+                    attributes[slen].clusterStart = FALSE;
+                    attributes[slen].mark = TRUE;
+                    attributes[slen].combiningClass = cmb;
+                }
+                ++slen;
+            }
+            logClusters[i] = cluster_start;
+        }
+
+        haveGlyphs = shaper_item->font->klass
+            ->convertStringToGlyphIndices(shaper_item->font,
+                                          shapedChars, slen,
+                                          shaper_item->glyphs, &shaper_item->num_glyphs,
+                                          shaper_item->item.bidiLevel % 2);
+
+        HB_FREE_STACKARRAY(shapedChars);
+
+        if (!haveGlyphs)
+            return FALSE;
+
+        HB_HeuristicPosition(shaper_item);
+    }
+
+    return TRUE;
+}
+
index 47003b1..8e6c83f 100755 (executable)
@@ -1,84 +1,84 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-\r
-\r
-//HB_INTERNAL \r
-HB_Pointer\r
-_hb_alloc(size_t     size,\r
-         HB_Error  *perror )\r
-{\r
-  HB_Error    error = (HB_Error)0;\r
-  HB_Pointer  block = NULL;\r
-\r
-  if ( size > 0 )\r
-  {\r
-    block = calloc( 1, size );\r
-    if ( !block )\r
-      error = ERR_HB(HB_Err_Out_Of_Memory);\r
-  }\r
-\r
-  *perror = error;\r
-  return block;\r
-}\r
-\r
-\r
-//HB_INTERNAL \r
-       HB_Pointer\r
-_hb_realloc(HB_Pointer  block,\r
-           size_t      new_size,\r
-           HB_Error   *perror )\r
-{\r
-    HB_Pointer  block2 = NULL;\r
-    HB_Error    error  = (HB_Error)0;\r
-\r
-    block2 = realloc( block, new_size );\r
-    if ( block2 == NULL && new_size != 0 )\r
-        error = ERR_HB(HB_Err_Out_Of_Memory);\r
-\r
-    if ( !error )\r
-        block = block2;\r
-\r
-    *perror = error;\r
-    return block;\r
-}\r
-\r
-\r
-//HB_INTERNAL \r
-       void\r
-_hb_free( HB_Pointer  block )\r
-{\r
-  if ( block )\r
-    free( block );\r
-}\r
-\r
-\r
-/* helper func to set a breakpoint on */\r
-//HB_INTERNAL \r
-HB_Error\r
-_hb_err(HB_Error code)\r
-{\r
-  return code;\r
-}\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+
+
+//HB_INTERNAL 
+HB_Pointer
+_hb_alloc(size_t     size,
+         HB_Error  *perror )
+{
+  HB_Error    error = (HB_Error)0;
+  HB_Pointer  block = NULL;
+
+  if ( size > 0 )
+  {
+    block = calloc( 1, size );
+    if ( !block )
+      error = ERR_HB(HB_Err_Out_Of_Memory);
+  }
+
+  *perror = error;
+  return block;
+}
+
+
+//HB_INTERNAL 
+       HB_Pointer
+_hb_realloc(HB_Pointer  block,
+           size_t      new_size,
+           HB_Error   *perror )
+{
+    HB_Pointer  block2 = NULL;
+    HB_Error    error  = (HB_Error)0;
+
+    block2 = realloc( block, new_size );
+    if ( block2 == NULL && new_size != 0 )
+        error = ERR_HB(HB_Err_Out_Of_Memory);
+
+    if ( !error )
+        block = block2;
+
+    *perror = error;
+    return block;
+}
+
+
+//HB_INTERNAL 
+       void
+_hb_free( HB_Pointer  block )
+{
+  if ( block )
+    free( block );
+}
+
+
+/* helper func to set a breakpoint on */
+//HB_INTERNAL 
+HB_Error
+_hb_err(HB_Error code)
+{
+  return code;
+}
index 891e084..036bb11 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-#include <stdio.h>\r
-\r
-#define FLAG(x) (1 << (x))\r
-\r
-static HB_Bool isLetter(HB_UChar16 ucs)\r
-{\r
-    const int test = FLAG(HB_Letter_Uppercase) |\r
-                     FLAG(HB_Letter_Lowercase) |\r
-                     FLAG(HB_Letter_Titlecase) |\r
-                     FLAG(HB_Letter_Modifier) |\r
-                     FLAG(HB_Letter_Other);\r
-    return FLAG(HB_GetUnicodeCharCategory(ucs)) & test;\r
-}\r
-\r
-static HB_Bool isMark(HB_UChar16 ucs)\r
-{\r
-    const int test = FLAG(HB_Mark_NonSpacing) |\r
-                     FLAG(HB_Mark_SpacingCombining) |\r
-                     FLAG(HB_Mark_Enclosing);\r
-    return FLAG(HB_GetUnicodeCharCategory(ucs)) & test;\r
-}\r
-\r
-typedef enum _Form {\r
-    Invalid = 0x0,\r
-    UnknownForm = Invalid,\r
-    Consonant,\r
-    Nukta,\r
-    Halant,\r
-    Matra,\r
-    VowelMark,\r
-    StressMark,\r
-    IndependentVowel,\r
-    LengthMark,\r
-    Control,\r
-    Other\r
-}Form;\r
-\r
-static const unsigned char indicForms[0xe00-0x900] = {\r
-    // Devangari\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Halant, UnknownForm, UnknownForm,\r
-\r
-    Other, StressMark, StressMark, StressMark,\r
-    StressMark, UnknownForm, UnknownForm, UnknownForm,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    IndependentVowel, IndependentVowel, VowelMark, VowelMark,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Consonant,\r
-    Consonant, Consonant /* ??? */, Consonant, Consonant,\r
-\r
-    // Bengali\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Invalid, Invalid, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, Invalid, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Invalid, Consonant, Invalid,\r
-    Invalid, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Invalid, Invalid, Matra,\r
-    Matra, Invalid, Invalid, Matra,\r
-    Matra, Halant, Consonant, UnknownForm,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, VowelMark,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Consonant, Consonant, Invalid, Consonant,\r
-\r
-    IndependentVowel, IndependentVowel, VowelMark, VowelMark,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Consonant, Consonant, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Gurmukhi\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,\r
-    Invalid, Invalid, Invalid, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, Invalid, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Invalid, Consonant, Consonant, Invalid,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Invalid,\r
-    Invalid, Invalid, Invalid, Matra,\r
-    Matra, Invalid, Invalid, Matra,\r
-    Matra, Halant, UnknownForm, UnknownForm,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, UnknownForm, UnknownForm, UnknownForm,\r
-    Invalid, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Invalid,\r
-\r
-    Other, Other, Invalid, Invalid,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    StressMark, StressMark, Consonant, Consonant,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Gujarati\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, Invalid, IndependentVowel,\r
-\r
-    IndependentVowel, IndependentVowel, Invalid, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Invalid, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Matra, Invalid, Matra,\r
-    Matra, Matra, Invalid, Matra,\r
-    Matra, Halant, UnknownForm, UnknownForm,\r
-\r
-    Other, UnknownForm, UnknownForm, UnknownForm,\r
-    UnknownForm, UnknownForm, UnknownForm, UnknownForm,\r
-    UnknownForm, UnknownForm, UnknownForm, UnknownForm,\r
-    UnknownForm, UnknownForm, UnknownForm, UnknownForm,\r
-\r
-    IndependentVowel, IndependentVowel, VowelMark, VowelMark,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Oriya\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Invalid, Invalid, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, Invalid, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Invalid, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Invalid, Invalid, Invalid, Matra,\r
-    Matra, Invalid, Invalid, Matra,\r
-    Matra, Halant, UnknownForm, UnknownForm,\r
-\r
-    Other, Invalid, Invalid, Invalid,\r
-    Invalid, UnknownForm, LengthMark, LengthMark,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Consonant, Consonant, Invalid, Consonant,\r
-\r
-    IndependentVowel, IndependentVowel, Invalid, Invalid,\r
-    Invalid, Invalid, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Consonant, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    //Tamil\r
-    Invalid, Invalid, VowelMark, Other,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,\r
-    Invalid, Invalid, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Consonant, Invalid, Invalid,\r
-    Invalid, Consonant, Consonant, Invalid,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-\r
-    Invalid, Invalid, Invalid, Consonant,\r
-    Consonant, Invalid, Invalid, Invalid,\r
-    Consonant, Consonant, Consonant, Invalid,\r
-    Invalid, Invalid, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Invalid, Invalid, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Invalid,\r
-    Invalid, Invalid, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Halant, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, LengthMark,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Telugu\r
-    Invalid, VowelMark, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Invalid, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Invalid, Invalid, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Halant, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, LengthMark, Matra, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-\r
-    IndependentVowel, IndependentVowel, Invalid, Invalid,\r
-    Invalid, Invalid, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Kannada\r
-    Invalid, Invalid, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Invalid, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Nukta, Other, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Halant, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, LengthMark, LengthMark, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Consonant, Invalid,\r
-\r
-    IndependentVowel, IndependentVowel, VowelMark, VowelMark,\r
-    Invalid, Invalid, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Malayalam\r
-    Invalid, Invalid, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, UnknownForm, UnknownForm,\r
-    Invalid, Invalid, Matra, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Invalid, Invalid, Matra, Matra,\r
-    Matra, Invalid, Matra, Matra,\r
-    Matra, Halant, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Matra,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-\r
-    IndependentVowel, IndependentVowel, Invalid, Invalid,\r
-    Invalid, Invalid, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-\r
-    // Sinhala\r
-    Invalid, Invalid, VowelMark, VowelMark,\r
-    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-\r
-    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,\r
-    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,\r
-    Invalid, Invalid, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-\r
-    Consonant, Consonant, Invalid, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Invalid, Consonant, Invalid, Invalid,\r
-\r
-    Consonant, Consonant, Consonant, Consonant,\r
-    Consonant, Consonant, Consonant, Invalid,\r
-    Invalid, Invalid, Halant, Invalid,\r
-    Invalid, Invalid, Invalid, Matra,\r
-\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Invalid, Matra, Invalid,\r
-    Matra, Matra, Matra, Matra,\r
-    Matra, Matra, Matra, Matra,\r
-\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-    Invalid, Invalid, Invalid, Invalid,\r
-\r
-    Invalid, Invalid, Matra, Matra,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-    Other, Other, Other, Other,\r
-};\r
-\r
-typedef enum _Position {\r
-    None,\r
-    Pre,\r
-    Above,\r
-    Below,\r
-    Post,\r
-    Split,\r
-    Base,\r
-    Reph,\r
-    Vattu,\r
-    Inherit\r
-}Position;\r
-\r
-static const unsigned char indicPosition[0xe00-0x900] = {\r
-    // Devanagari\r
-    None, Above, Above, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    Below, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, Post, Pre,\r
-\r
-    Post, Below, Below, Below,\r
-    Below, Above, Above, Above,\r
-    Above, Post, Post, Post,\r
-    Post, None, None, None,\r
-\r
-    None, Above, Below, Above,\r
-    Above, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, Below, Below,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Bengali\r
-    None, Above, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    Below, None, None, Post,\r
-\r
-    Below, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    Below, None, Post, Pre,\r
-\r
-    Post, Below, Below, Below,\r
-    Below, None, None, Pre,\r
-    Pre, None, None, Split,\r
-    Split, Below, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, Below, Below,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    Below, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Gurmukhi\r
-    None, Above, Above, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-\r
-    Below, None, None, None,\r
-    None, Below, None, None,\r
-    None, Below, None, None,\r
-    Below, None, Post, Pre,\r
-\r
-    Post, Below, Below, None,\r
-    None, None, None, Above,\r
-    Above, None, None, Above,\r
-    Above, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    Above, Above, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Gujarati\r
-    None, Above, Above, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    Below, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, Post, Pre,\r
-\r
-    Post, Below, Below, Below,\r
-    Below, Above, None, Above,\r
-    Above, Post, None, Post,\r
-    Post, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, Below, Below,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Oriya\r
-    None, Above, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    Below, None, None, None,\r
-    Below, None, None, None,\r
-    Below, Below, Below, Post,\r
-\r
-    Below, None, Below, Below,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, Post, Above,\r
-\r
-    Post, Below, Below, Below,\r
-    None, None, None, Pre,\r
-    Split, None, None, Split,\r
-    Split, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, Above, Post,\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, Below, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Tamil\r
-    None, None, Above, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, Post, Post,\r
-\r
-    Above, Below, Below, None,\r
-    None, None, Pre, Pre,\r
-    Pre, None, Split, Split,\r
-    Split, Halant, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Telugu\r
-    None, Post, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-    Below, None, Below, Below,\r
-    Below, Below, Below, Below,\r
-\r
-    Below, None, Below, Below,\r
-    None, Below, Below, Below,\r
-    Below, Below, None, None,\r
-    None, None, Post, Above,\r
-\r
-    Above, Post, Post, Post,\r
-    Post, None, Above, Above,\r
-    Split, None, Post, Above,\r
-    Above, Halant, None, None,\r
-\r
-    None, None, None, None,\r
-    None, Above, Below, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Kannada\r
-    None, None, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-    Below, Below, Below, Below,\r
-\r
-    Below, None, Below, Below,\r
-    None, Below, Below, Below,\r
-    Below, Below, None, None,\r
-    None, None, Post, Above,\r
-\r
-    Split, Post, Post, Post,\r
-    Post, None, Above, Split,\r
-    Split, None, Split, Split,\r
-    Above, Halant, None, None,\r
-\r
-    None, None, None, None,\r
-    None, Post, Post, None,\r
-    None, None, None, None,\r
-    None, None, Below, None,\r
-\r
-    None, None, Below, Below,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Malayalam\r
-    None, None, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-\r
-    Post, None, Below, None,\r
-    None, Post, None, None,\r
-    None, None, None, None,\r
-    None, None, Post, Post,\r
-\r
-    Post, Post, Post, Post,\r
-    None, None, Pre, Pre,\r
-    Pre, None, Split, Split,\r
-    Split, Halant, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    // Sinhala\r
-    None, None, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, Post,\r
-\r
-    Post, Post, Above, Above,\r
-    Below, None, Below, None,\r
-    Post, Pre, Split, Pre,\r
-    Split, Split, Split, Post,\r
-\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-\r
-    None, None, Post, Post,\r
-    None, None, None, None,\r
-    None, None, None, None,\r
-    None, None, None, None\r
-};\r
-\r
-static Form form(unsigned short uc) {\r
-    if (uc < 0x900 || uc > 0xdff) {\r
-        if (uc == 0x25cc)\r
-            return Consonant;\r
-        if (uc == 0x200c || uc == 0x200d)\r
-            return Control;\r
-        return Other;\r
-    }\r
-    return (Form)indicForms[uc-0x900];\r
-}\r
-\r
-static Position indic_position(unsigned short uc) {\r
-    if (uc < 0x900 || uc > 0xdff)\r
-        return None;\r
-    return (Position) indicPosition[uc-0x900];\r
-}\r
-\r
-\r
-enum IndicScriptProperties {\r
-    HasReph = 0x01,\r
-    HasSplit = 0x02\r
-};\r
-\r
-const hb_uint8 scriptProperties[10] = {\r
-    // Devanagari,\r
-    HasReph,\r
-    // Bengali,\r
-    HasReph|HasSplit,\r
-    // Gurmukhi,\r
-    0,\r
-    // Gujarati,\r
-    HasReph,\r
-    // Oriya,\r
-    HasReph|HasSplit,\r
-    // Tamil,\r
-    HasSplit,\r
-    // Telugu,\r
-    HasSplit,\r
-    // Kannada,\r
-    HasSplit|HasReph,\r
-    // Malayalam,\r
-    HasSplit,\r
-    // Sinhala,\r
-    HasSplit\r
-};\r
-\r
-typedef struct _IndicOrdering {\r
-    Form form;\r
-    Position position;\r
-}IndicOrdering;\r
-\r
-static const IndicOrdering devanagari_order [] = {\r
-    { Consonant, Below },\r
-    { Matra, Below },\r
-    { VowelMark, Below },\r
-    { StressMark, Below },\r
-    { Matra, Above },\r
-    { Matra, Post },\r
-    { Consonant, Reph },\r
-    { VowelMark, Above },\r
-    { StressMark, Above },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering bengali_order [] = {\r
-    { Consonant, Below },\r
-    { Matra, Below },\r
-    { Matra, Above },\r
-    { Consonant, Reph },\r
-    { VowelMark, Above },\r
-    { Consonant, Post },\r
-    { Matra, Post },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering gurmukhi_order [] = {\r
-    { Consonant, Below },\r
-    { Matra, Below },\r
-    { Matra, Above },\r
-    { Consonant, Post },\r
-    { Matra, Post },\r
-    { VowelMark, Above },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering tamil_order [] = {\r
-    { Matra, Above },\r
-    { Matra, Post },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering telugu_order [] = {\r
-    { Matra, Above },\r
-    { Matra, Below },\r
-    { Matra, Post },\r
-    { Consonant, Below },\r
-    { Consonant, Post },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering kannada_order [] = {\r
-    { Matra, Above },\r
-    { Matra, Post },\r
-    { Consonant, Below },\r
-    { Consonant, Post },\r
-    { LengthMark, Post },\r
-    { Consonant, Reph },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering malayalam_order [] = {\r
-    { Consonant, Below },\r
-    { Matra, Below },\r
-    { Consonant, Reph },\r
-    { Consonant, Post },\r
-    { Matra, Post },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering sinhala_order [] = {\r
-    { Matra, Below },\r
-    { Matra, Above },\r
-    { Matra, Post },\r
-    { VowelMark, Post },\r
-    { (Form)0, None }\r
-};\r
-\r
-static const IndicOrdering * const indic_order[] = {\r
-    devanagari_order, // Devanagari\r
-    bengali_order, // Bengali\r
-    gurmukhi_order, // Gurmukhi\r
-    devanagari_order, // Gujarati\r
-    bengali_order, // Oriya\r
-    tamil_order, // Tamil\r
-    telugu_order, // Telugu\r
-    kannada_order, // Kannada\r
-    malayalam_order, // Malayalam\r
-    sinhala_order // Sinhala\r
-};\r
-\r
-\r
-\r
-// vowel matras that have to be split into two parts.\r
-static const unsigned short split_matras[]  = {\r
-    //  matra, split1, split2, split3\r
-\r
-    // bengalis\r
-    0x9cb, 0x9c7, 0x9be, 0x0,\r
-    0x9cc, 0x9c7, 0x9d7, 0x0,\r
-    // oriya\r
-    0xb48, 0xb47, 0xb56, 0x0,\r
-    0xb4b, 0xb47, 0xb3e, 0x0,\r
-    0xb4c, 0xb47, 0xb57, 0x0,\r
-    // tamil\r
-    0xbca, 0xbc6, 0xbbe, 0x0,\r
-    0xbcb, 0xbc7, 0xbbe, 0x0,\r
-    0xbcc, 0xbc6, 0xbd7, 0x0,\r
-    // telugu\r
-    0xc48, 0xc46, 0xc56, 0x0,\r
-    // kannada\r
-    0xcc0, 0xcbf, 0xcd5, 0x0,\r
-    0xcc7, 0xcc6, 0xcd5, 0x0,\r
-    0xcc8, 0xcc6, 0xcd6, 0x0,\r
-    0xcca, 0xcc6, 0xcc2, 0x0,\r
-    0xccb, 0xcc6, 0xcc2, 0xcd5,\r
-    // malayalam\r
-    0xd4a, 0xd46, 0xd3e, 0x0,\r
-    0xd4b, 0xd47, 0xd3e, 0x0,\r
-    0xd4c, 0xd46, 0xd57, 0x0,\r
-    // sinhala\r
-    0xdda, 0xdd9, 0xdca, 0x0,\r
-    0xddc, 0xdd9, 0xdcf, 0x0,\r
-    0xddd, 0xdd9, 0xdcf, 0xdca,\r
-    0xdde, 0xdd9, 0xddf, 0x0,\r
-    0xffff\r
-};\r
-\r
-static void splitMatra(unsigned short *reordered, int matra, int *len)\r
-{\r
-    unsigned short matra_uc = reordered[matra];\r
-    //qDebug("matra=%d, reordered[matra]=%x", matra, reordered[matra]);\r
-\r
-    const unsigned short *split = split_matras;\r
-    while (split[0] < matra_uc)\r
-        split += 4;\r
-\r
-    assert(*split == matra_uc);\r
-    ++split;\r
-\r
-    int added_chars = split[2] == 0x0 ? 1 : 2;\r
-\r
-    memmove(reordered + matra + added_chars, reordered + matra, (*len-matra)*sizeof(unsigned short));\r
-    reordered[matra] = split[0];\r
-    reordered[matra+1] = split[1];\r
-    if(added_chars == 2)\r
-        reordered[matra+2] = split[2];\r
-    *len += added_chars;\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-static const HB_OpenTypeFeature indic_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },\r
-    { HB_MAKE_TAG('n', 'u', 'k', 't'), NuktaProperty },\r
-    { HB_MAKE_TAG('a', 'k', 'h', 'n'), AkhantProperty },\r
-    { HB_MAKE_TAG('r', 'p', 'h', 'f'), RephProperty },\r
-    { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },\r
-    { HB_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty },\r
-    { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },\r
-    { HB_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty },\r
-    { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },\r
-    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },\r
-    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },\r
-    { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },\r
-    { HB_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty },\r
-    { 0, 0 }\r
-};\r
-#endif\r
-\r
-// #define INDIC_DEBUG\r
-#ifdef INDIC_DEBUG\r
-#define IDEBUG hb_debug\r
-#include <stdarg.h>\r
-\r
-static void hb_debug(const char *msg, ...)\r
-{\r
-    va_list ap;\r
-    va_start(ap, msg); // use variable arg list\r
-    vfprintf(stderr, msg, ap);\r
-    va_end(ap);\r
-    fprintf(stderr, "\n");\r
-}\r
-\r
-#else\r
-#define IDEBUG if(0) printf\r
-#endif\r
-\r
-#if 0 //def INDIC_DEBUG\r
-static QString propertiesToString(int properties)\r
-{\r
-    QString res;\r
-    properties = ~properties;\r
-    if (properties & CcmpProperty)\r
-        res += "Ccmp ";\r
-    if (properties & InitProperty)\r
-        res += "Init ";\r
-    if (properties & NuktaProperty)\r
-        res += "Nukta ";\r
-    if (properties & AkhantProperty)\r
-        res += "Akhant ";\r
-    if (properties & RephProperty)\r
-        res += "Reph ";\r
-    if (properties & PreFormProperty)\r
-        res += "PreForm ";\r
-    if (properties & BelowFormProperty)\r
-        res += "BelowForm ";\r
-    if (properties & AboveFormProperty)\r
-        res += "AboveForm ";\r
-    if (properties & HalfFormProperty)\r
-        res += "HalfForm ";\r
-    if (properties & PostFormProperty)\r
-        res += "PostForm ";\r
-    if (properties & VattuProperty)\r
-        res += "Vattu ";\r
-    if (properties & PreSubstProperty)\r
-        res += "PreSubst ";\r
-    if (properties & BelowSubstProperty)\r
-        res += "BelowSubst ";\r
-    if (properties & AboveSubstProperty)\r
-        res += "AboveSubst ";\r
-    if (properties & PostSubstProperty)\r
-        res += "PostSubst ";\r
-    if (properties & HalantProperty)\r
-        res += "Halant ";\r
-    if (properties & CligProperty)\r
-        res += "Clig ";\r
-    return res;\r
-}\r
-#endif\r
-\r
-static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool invalid)\r
-{\r
-    HB_Script script = item->item.script;\r
-    assert(script >= HB_Script_Devanagari && script <= HB_Script_Sinhala);\r
-    const unsigned short script_base = 0x0900 + 0x80*(script-HB_Script_Devanagari);\r
-    const unsigned short ra = script_base + 0x30;\r
-    const unsigned short halant = script_base + 0x4d;\r
-    const unsigned short nukta = script_base + 0x3c;\r
-    bool control = false;\r
-\r
-    int len = (int)item->item.length;\r
-    IDEBUG(">>>>> indic shape: from=%d, len=%d invalid=%d", item->item.pos, item->item.length, invalid);\r
-\r
-    if ((int)item->num_glyphs < len+4) {\r
-        item->num_glyphs = len+4;\r
-        return false;\r
-    }\r
-\r
-    HB_STACKARRAY(HB_UChar16, reordered, len + 4);\r
-    HB_STACKARRAY(hb_uint8, position, len + 4);\r
-\r
-    unsigned char properties = scriptProperties[script-HB_Script_Devanagari];\r
-\r
-    if (invalid) {\r
-        *reordered = 0x25cc;\r
-        memcpy(reordered+1, item->string + item->item.pos, len*sizeof(HB_UChar16));\r
-        len++;\r
-    } else {\r
-        memcpy(reordered, item->string + item->item.pos, len*sizeof(HB_UChar16));\r
-    }\r
-    if (reordered[len-1] == 0x200c) // zero width non joiner\r
-        len--;\r
-\r
-    int i;\r
-    int base = 0;\r
-    int reph = -1;\r
-\r
-#ifdef INDIC_DEBUG\r
-    IDEBUG("original:");\r
-    for (i = 0; i < len; i++) {\r
-        IDEBUG("    %d: %4x", i, reordered[i]);\r
-    }\r
-#endif\r
-\r
-    if (len != 1) {\r
-        HB_UChar16 *uc = reordered;\r
-        bool beginsWithRa = false;\r
-\r
-        // Rule 1: find base consonant\r
-        //\r
-        // The shaping engine finds the base consonant of the\r
-        // syllable, using the following algorithm: starting from the\r
-        // end of the syllable, move backwards until a consonant is\r
-        // found that does not have a below-base or post-base form\r
-        // (post-base forms have to follow below-base forms), or\r
-        // arrive at the first consonant. The consonant stopped at\r
-        // will be the base.\r
-        //\r
-        //  * If the syllable starts with Ra + H (in a script that has\r
-        //    'Reph'), Ra is excluded from candidates for base\r
-        //    consonants.\r
-        //\r
-        // * In Kannada and Telugu, the base consonant cannot be\r
-        //   farther than 3 consonants from the end of the syllable.\r
-        // #### replace the HasReph property by testing if the feature exists in the font!\r
-        if (form(*uc) == Consonant || (script == HB_Script_Bengali && form(*uc) == IndependentVowel)) {\r
-            if ((properties & HasReph) && (len > 2) &&\r
-                (*uc == ra || *uc == 0x9f0) && *(uc+1) == halant)\r
-                beginsWithRa = true;\r
-\r
-            if (beginsWithRa && form(*(uc+2)) == Control)\r
-                beginsWithRa = false;\r
-\r
-            base = (beginsWithRa ? 2 : 0);\r
-            IDEBUG("    length = %d, beginsWithRa = %d, base=%d", len, beginsWithRa, base);\r
-\r
-            int lastConsonant = 0;\r
-            int matra = -1;\r
-            // we remember:\r
-            // * the last consonant since we need it for rule 2\r
-            // * the matras position for rule 3 and 4\r
-\r
-            // figure out possible base glyphs\r
-            memset(position, 0, len);\r
-            if (script == HB_Script_Devanagari || script == HB_Script_Gujarati) {\r
-                bool vattu = false;\r
-                for (i = base; i < len; ++i) {\r
-                    position[i] = form(uc[i]);\r
-                    if (position[i] == Consonant) {\r
-                        lastConsonant = i;\r
-                        vattu = (!vattu && uc[i] == ra);\r
-                        if (vattu) {\r
-                            IDEBUG("excluding vattu glyph at %d from base candidates", i);\r
-                            position[i] = Vattu;\r
-                        }\r
-                    } else if (position[i] == Matra) {\r
-                        matra = i;\r
-                    }\r
-                }\r
-            } else {\r
-                for (i = base; i < len; ++i) {\r
-                    position[i] = form(uc[i]);\r
-                    if (position[i] == Consonant)\r
-                        lastConsonant = i;\r
-                    else if (matra < 0 && position[i] == Matra)\r
-                        matra = i;\r
-                }\r
-            }\r
-            int skipped = 0;\r
-            Position pos = Post;\r
-            for (i = len-1; i > base; i--) {\r
-                if (position[i] != Consonant && (position[i] != Control || script == HB_Script_Kannada))\r
-                    continue;\r
-\r
-                Position charPosition = indic_position(uc[i]);\r
-                if (pos == Post && charPosition == Post) {\r
-                    pos = Post;\r
-                } else if ((pos == Post || pos == Below) && charPosition == Below) {\r
-                    if (script == HB_Script_Devanagari || script == HB_Script_Gujarati)\r
-                        base = i;\r
-                    pos = Below;\r
-                } else {\r
-                    base = i;\r
-                    break;\r
-                }\r
-                if (skipped == 2 && (script == HB_Script_Kannada || script == HB_Script_Telugu)) {\r
-                    base = i;\r
-                    break;\r
-                }\r
-                ++skipped;\r
-            }\r
-\r
-            IDEBUG("    base consonant at %d skipped=%d, lastConsonant=%d", base, skipped, lastConsonant);\r
-\r
-            // Rule 2:\r
-            //\r
-            // If the base consonant is not the last one, Uniscribe\r
-            // moves the halant from the base consonant to the last\r
-            // one.\r
-            if (lastConsonant > base) {\r
-                int halantPos = 0;\r
-                if (uc[base+1] == halant)\r
-                    halantPos = base + 1;\r
-                else if (uc[base+1] == nukta && uc[base+2] == halant)\r
-                    halantPos = base + 2;\r
-                if (halantPos > 0) {\r
-                    IDEBUG("    moving halant from %d to %d!", base+1, lastConsonant);\r
-                    for (i = halantPos; i < lastConsonant; i++)\r
-                        uc[i] = uc[i+1];\r
-                    uc[lastConsonant] = halant;\r
-                }\r
-            }\r
-\r
-            // Rule 3:\r
-            //\r
-            // If the syllable starts with Ra + H, Uniscribe moves\r
-            // this combination so that it follows either:\r
-\r
-            // * the post-base 'matra' (if any) or the base consonant\r
-            //   (in scripts that show similarity to Devanagari, i.e.,\r
-            //   Devanagari, Gujarati, Bengali)\r
-            // * the base consonant (other scripts)\r
-            // * the end of the syllable (Kannada)\r
-\r
-            Position matra_position = None;\r
-            if (matra > 0)\r
-                matra_position = indic_position(uc[matra]);\r
-            IDEBUG("    matra at %d with form %d, base=%d", matra, matra_position, base);\r
-\r
-            if (beginsWithRa && base != 0) {\r
-                int toPos = base+1;\r
-                if (toPos < len && uc[toPos] == nukta)\r
-                    toPos++;\r
-                if (toPos < len && uc[toPos] == halant)\r
-                    toPos++;\r
-                if (toPos < len && uc[toPos] == 0x200d)\r
-                    toPos++;\r
-                if (toPos < len-1 && uc[toPos] == ra && uc[toPos+1] == halant)\r
-                    toPos += 2;\r
-                if (script == HB_Script_Devanagari || script == HB_Script_Gujarati || script == HB_Script_Bengali) {\r
-                    if (matra_position == Post || matra_position == Split) {\r
-                        toPos = matra+1;\r
-                        matra -= 2;\r
-                    }\r
-                } else if (script == HB_Script_Kannada) {\r
-                    toPos = len;\r
-                    matra -= 2;\r
-                }\r
-\r
-                IDEBUG("moving leading ra+halant to position %d", toPos);\r
-                for (i = 2; i < toPos; i++)\r
-                    uc[i-2] = uc[i];\r
-                uc[toPos-2] = ra;\r
-                uc[toPos-1] = halant;\r
-                base -= 2;\r
-                if (properties & HasReph)\r
-                    reph = toPos-2;\r
-            }\r
-\r
-            // Rule 4:\r
-\r
-            // Uniscribe splits two- or three-part matras into their\r
-            // parts. This splitting is a character-to-character\r
-            // operation).\r
-            //\r
-            //      Uniscribe describes some moving operations for these\r
-            //      matras here. For shaping however all pre matras need\r
-            //      to be at the beginning of the syllable, so we just move\r
-            //      them there now.\r
-            if (matra_position == Split) {\r
-                splitMatra(uc, matra, &len);\r
-                // Handle three-part matras (0xccb in Kannada)\r
-                matra_position = indic_position(uc[matra]);\r
-            }\r
-\r
-            if (matra_position == Pre) {\r
-                unsigned short m = uc[matra];\r
-                while (matra--)\r
-                    uc[matra+1] = uc[matra];\r
-                uc[0] = m;\r
-                base++;\r
-            }\r
-        }\r
-\r
-        // Rule 5:\r
-        //\r
-        // Uniscribe classifies consonants and 'matra' parts as\r
-        // pre-base, above-base (Reph), below-base or post-base. This\r
-        // classification exists on the character code level and is\r
-        // language-dependent, not font-dependent.\r
-        for (i = 0; i < base; ++i)\r
-            position[i] = Pre;\r
-        position[base] = Base;\r
-        for (i = base+1; i < len; ++i) {\r
-            position[i] = indic_position(uc[i]);\r
-            // #### replace by adjusting table\r
-            if (uc[i] == nukta || uc[i] == halant)\r
-                position[i] = Inherit;\r
-        }\r
-        if (reph > 0) {\r
-            // recalculate reph, it might have changed.\r
-            for (i = base+1; i < len; ++i)\r
-                if (uc[i] == ra)\r
-                    reph = i;\r
-            position[reph] = Reph;\r
-            position[reph+1] = Inherit;\r
-        }\r
-\r
-        // all reordering happens now to the chars after the base\r
-        int fixed = base+1;\r
-        if (fixed < len && uc[fixed] == nukta)\r
-            fixed++;\r
-        if (fixed < len && uc[fixed] == halant)\r
-            fixed++;\r
-        if (fixed < len && uc[fixed] == 0x200d)\r
-            fixed++;\r
-\r
-#ifdef INDIC_DEBUG\r
-        for (i = fixed; i < len; ++i)\r
-            IDEBUG("position[%d] = %d, form=%d uc=%x", i, position[i], form(uc[i]), uc[i]);\r
-#endif\r
-        // we continuosly position the matras and vowel marks and increase the fixed\r
-        // until we reached the end.\r
-        const IndicOrdering *finalOrder = indic_order[script-HB_Script_Devanagari];\r
-\r
-        IDEBUG("    reordering pass:");\r
-        IDEBUG("        base=%d fixed=%d", base, fixed);\r
-        int toMove = 0;\r
-        while (finalOrder[toMove].form && fixed < len-1) {\r
-            IDEBUG("        fixed = %d, toMove=%d, moving form %d with pos %d", fixed, toMove, finalOrder[toMove].form, finalOrder[toMove].position);\r
-            for (i = fixed; i < len; i++) {\r
-//                IDEBUG() << "           i=" << i << "uc=" << hex << uc[i] << "form=" << form(uc[i])\r
-//                         << "position=" << position[i];\r
-                if (form(uc[i]) == finalOrder[toMove].form &&\r
-                     position[i] == finalOrder[toMove].position) {\r
-                     int j=0;\r
-                    // need to move this glyph\r
-                    int to = fixed;\r
-                    if (i < len-1 && position[i+1] == Inherit) {\r
-                        IDEBUG("         moving two chars from %d to %d", i, to);\r
-                        unsigned short ch = uc[i];\r
-                        unsigned short ch2 = uc[i+1];\r
-                        unsigned char pos = position[i];\r
-                        for (j = i+1; j > to+1; j--) {\r
-                            uc[j] = uc[j-2];\r
-                            position[j] = position[j-2];\r
-                        }\r
-                        uc[to] = ch;\r
-                        uc[to+1] = ch2;\r
-                        position[to] = pos;\r
-                        position[to+1] = pos;\r
-                        fixed += 2;\r
-                    } else {\r
-                        IDEBUG("         moving one char from %d to %d", i, to);\r
-                        unsigned short ch = uc[i];\r
-                        unsigned char pos = position[i];\r
-                        for (j = i; j > to; j--) {\r
-                            uc[j] = uc[j-1];\r
-                            position[j] = position[j-1];\r
-                        }\r
-                        uc[to] = ch;\r
-                        position[to] = pos;\r
-                        fixed++;\r
-                    }\r
-                }\r
-            }\r
-            toMove++;\r
-        }\r
-\r
-    }\r
-\r
-    if (reph > 0) {\r
-        // recalculate reph, it might have changed.\r
-        for (i = base+1; i < len; ++i)\r
-            if (reordered[i] == ra)\r
-                reph = i;\r
-    }\r
-\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = item->num_glyphs;\r
-#endif\r
-    if (!item->font->klass->convertStringToGlyphIndices(item->font,\r
-                                                        reordered, len,\r
-                                                        item->glyphs, &item->num_glyphs,\r
-                                                        item->item.bidiLevel % 2))\r
-        goto error;\r
-\r
-\r
-    IDEBUG("  base=%d, reph=%d", base, reph);\r
-    IDEBUG("reordered:");\r
-    for (i = 0; i < len; i++) {\r
-        item->attributes[i].mark = false;\r
-        item->attributes[i].clusterStart = false;\r
-        item->attributes[i].justification = 0;\r
-        item->attributes[i].zeroWidth = false;\r
-        IDEBUG("    %d: %4x", i, reordered[i]);\r
-    }\r
-\r
-    // now we have the syllable in the right order, and can start running it through open type.\r
-\r
-    for (i = 0; i < len; ++i)\r
-        control |= (form(reordered[i]) == Control);\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (openType) {\r
-\r
-        // we need to keep track of where the base glyph is for some\r
-        // scripts and use the cluster feature for this.  This\r
-        // also means we have to correct the logCluster output from\r
-        // the open type engine manually afterwards.  for indic this\r
-        // is rather simple, as all chars just point to the first\r
-        // glyph in the syllable.\r
-        HB_STACKARRAY(unsigned short, clusters, len);\r
-        HB_STACKARRAY(unsigned int, properties, len);\r
-\r
-        for (i = 0; i < len; ++i)\r
-            clusters[i] = i;\r
-\r
-        // features we should always apply\r
-        for (i = 0; i < len; ++i)\r
-            properties[i] = ~(CcmpProperty\r
-                              | NuktaProperty\r
-                              | VattuProperty\r
-                              | PreSubstProperty\r
-                              | BelowSubstProperty\r
-                              | AboveSubstProperty\r
-                              | HalantProperty\r
-                              | PositioningProperties);\r
-\r
-        // Ccmp always applies\r
-        // Init\r
-        if (item->item.pos == 0\r
-            || !(isLetter(item->string[item->item.pos-1]) || isMark(item->string[item->item.pos-1])))\r
-            properties[0] &= ~InitProperty;\r
-\r
-        // Nukta always applies\r
-        // Akhant\r
-        for (i = 0; i <= base; ++i)\r
-            properties[i] &= ~AkhantProperty;\r
-        // Reph\r
-        if (reph >= 0) {\r
-            properties[reph] &= ~RephProperty;\r
-            properties[reph+1] &= ~RephProperty;\r
-        }\r
-        // BelowForm\r
-        for (i = base+1; i < len; ++i)\r
-            properties[i] &= ~BelowFormProperty;\r
-\r
-        if (script == HB_Script_Devanagari || script == HB_Script_Gujarati) {\r
-            // vattu glyphs need this aswell\r
-            bool vattu = false;\r
-            for (i = base-2; i > 1; --i) {\r
-                if (form(reordered[i]) == Consonant) {\r
-                    vattu = (!vattu && reordered[i] == ra);\r
-                    if (vattu) {\r
-                        IDEBUG("forming vattu ligature at %d", i);\r
-                        properties[i] &= ~BelowFormProperty;\r
-                        properties[i+1] &= ~BelowFormProperty;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        // HalfFormProperty\r
-        for (i = 0; i < base; ++i)\r
-            properties[i] &= ~HalfFormProperty;\r
-        if (control) {\r
-            for (i = 2; i < len; ++i) {\r
-                if (reordered[i] == 0x200d /* ZWJ */) {\r
-                    properties[i-1] &= ~HalfFormProperty;\r
-                    properties[i-2] &= ~HalfFormProperty;\r
-                } else if (reordered[i] == 0x200c /* ZWNJ */) {\r
-                    properties[i-1] &= ~HalfFormProperty;\r
-                    properties[i-2] &= ~HalfFormProperty;\r
-                }\r
-            }\r
-        }\r
-        // PostFormProperty\r
-        for (i = base+1; i < len; ++i)\r
-            properties[i] &= ~PostFormProperty;\r
-        // vattu always applies\r
-        // pres always applies\r
-        // blws always applies\r
-        // abvs always applies\r
-\r
-        // psts\r
-        // ### this looks slightly different from before, but I believe it's correct\r
-        if (reordered[len-1] != halant || base != len-2)\r
-            properties[base] &= ~PostSubstProperty;\r
-        for (i = base+1; i < len; ++i)\r
-            properties[i] &= ~PostSubstProperty;\r
-\r
-        // halant always applies\r
-\r
-#ifdef INDIC_DEBUG\r
-//        {\r
-//            IDEBUG("OT properties:");\r
-//            for (int i = 0; i < len; ++i)\r
-//                qDebug("    i: %s", ::propertiesToString(properties[i]).toLatin1().data());\r
-//        }\r
-#endif\r
-\r
-        // initialize\r
-        item->log_clusters = clusters;\r
-        HB_OpenTypeShape(item, properties);\r
-\r
-        int newLen = item->face->buffer->in_length;\r
-        HB_GlyphItem otl_glyphs = item->face->buffer->in_string;\r
-\r
-        // move the left matra back to its correct position in malayalam and tamil\r
-        if ((script == HB_Script_Malayalam || script == HB_Script_Tamil) && (form(reordered[0]) == Matra)) {\r
-//             qDebug("reordering matra, len=%d", newLen);\r
-            // need to find the base in the shaped string and move the matra there\r
-            int basePos = 0;\r
-            while (basePos < newLen && (int)otl_glyphs[basePos].cluster <= base)\r
-                basePos++;\r
-            --basePos;\r
-            if (basePos < newLen && basePos > 1) {\r
-//                 qDebug("moving prebase matra to position %d in syllable newlen=%d", basePos, newLen);\r
-                HB_GlyphItemRec m = otl_glyphs[0];\r
-                --basePos;\r
-                for (i = 0; i < basePos; ++i)\r
-                    otl_glyphs[i] = otl_glyphs[i+1];\r
-                otl_glyphs[basePos] = m;\r
-            }\r
-        }\r
-\r
-        HB_Bool positioned = HB_OpenTypePosition(item, availableGlyphs, false);\r
-\r
-        HB_FREE_STACKARRAY(clusters);\r
-        HB_FREE_STACKARRAY(properties);\r
-\r
-        if (!positioned)\r
-            goto error;\r
-\r
-        if (control) {\r
-            IDEBUG("found a control char in the syllable");\r
-            hb_uint32 i = 0, j = 0;\r
-            while (i < item->num_glyphs) {\r
-                if (form(reordered[otl_glyphs[i].cluster]) == Control) {\r
-                    ++i;\r
-                    if (i >= item->num_glyphs)\r
-                        break;\r
-                }\r
-                item->glyphs[j] = item->glyphs[i];\r
-                item->attributes[j] = item->attributes[i];\r
-                ++i;\r
-                ++j;\r
-            }\r
-            item->num_glyphs = j;\r
-        }\r
-\r
-    } else {\r
-        HB_HeuristicPosition(item);\r
-    }\r
-#endif // NO_OPENTYPE\r
-    item->attributes[0].clusterStart = true;\r
-\r
-    HB_FREE_STACKARRAY(reordered);\r
-    HB_FREE_STACKARRAY(position);\r
-\r
-    IDEBUG("<<<<<<");\r
-    return true;\r
-\r
-error:\r
-    HB_FREE_STACKARRAY(reordered);\r
-    HB_FREE_STACKARRAY(position);\r
-    return false;\r
-}\r
-\r
-/* syllables are of the form:\r
-\r
-   (Consonant Nukta? Halant)* Consonant Matra? VowelMark? StressMark?\r
-   (Consonant Nukta? Halant)* Consonant Halant\r
-   IndependentVowel VowelMark? StressMark?\r
-\r
-   We return syllable boundaries on invalid combinations aswell\r
-*/\r
-/* SAMSUNG - Kaja Changes -Start */\r
-int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-//static int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-/* SAMSUNG - Kaja Changes -End */\r
-{\r
-    *invalid = false;\r
-    IDEBUG("indic_nextSyllableBoundary: start=%d, end=%d", start, end);\r
-    const HB_UChar16 *uc = s+start ;\r
-\r
-    int pos = 0;\r
-    Form state = form(uc[pos]);\r
-    IDEBUG("state[%d]=%d (uc=%4x)", pos, state, uc[pos]);\r
-    pos++;\r
-\r
-    if (state != Consonant && state != IndependentVowel) {\r
-        if (state != Other)\r
-            *invalid = true;\r
-        goto finish;\r
-    }\r
-\r
-    while (pos < end - start) {\r
-        Form newState = form(uc[pos]);\r
-        IDEBUG("state[%d]=%d (uc=%4x)", pos, newState, uc[pos]);\r
-        switch(newState) {\r
-        case Control:\r
-            newState = state;\r
-           if (state == Halant && uc[pos] == 0x200d /* ZWJ */)\r
-               break;\r
-            // the control character should be the last char in the item\r
-            ++pos;\r
-            goto finish;\r
-        case Consonant:\r
-           if (state == Halant && (script != HB_Script_Sinhala || uc[pos-1] == 0x200d /* ZWJ */))\r
-                break;\r
-            goto finish;\r
-        case Halant:\r
-            if (state == Nukta || state == Consonant)\r
-                break;\r
-            // Bengali has a special exception allowing the combination Vowel_A/E + Halant + Ya\r
-            if (script == HB_Script_Bengali && pos == 1 &&\r
-                 (uc[0] == 0x0985 || uc[0] == 0x098f))\r
-                break;\r
-            // Sinhala uses the Halant as a component of certain matras. Allow these, but keep the state on Matra.\r
-            if (script == HB_Script_Sinhala && state == Matra) {\r
-                ++pos;\r
-                continue;\r
-            }\r
-            if (script == HB_Script_Malayalam && state == Matra && uc[pos-1] == 0x0d41) {\r
-                ++pos;\r
-                continue;\r
-            }\r
-            goto finish;\r
-        case Nukta:\r
-            if (state == Consonant)\r
-                break;\r
-            goto finish;\r
-        case StressMark:\r
-            if (state == VowelMark)\r
-                break;\r
-            // fall through\r
-        case VowelMark:\r
-            if (state == Matra || state == LengthMark || state == IndependentVowel)\r
-                break;\r
-            // fall through\r
-        case Matra:\r
-            if (state == Consonant || state == Nukta)\r
-                break;\r
-            if (state == Matra) {\r
-                // ### needs proper testing for correct two/three part matras\r
-                break;\r
-            }\r
-            // ### not sure if this is correct. If it is, does it apply only to Bengali or should\r
-            // it work for all Indic languages?\r
-            // the combination Independent_A + Vowel Sign AA is allowed.\r
-            if (script == HB_Script_Bengali && uc[pos] == 0x9be && uc[pos-1] == 0x985)\r
-                break;\r
-            if (script == HB_Script_Tamil && state == Matra) {\r
-                if (uc[pos-1] == 0x0bc6 &&\r
-                     (uc[pos] == 0xbbe || uc[pos] == 0xbd7))\r
-                    break;\r
-                if (uc[pos-1] == 0x0bc7 && uc[pos] == 0xbbe)\r
-                    break;\r
-            }\r
-            goto finish;\r
-\r
-        case LengthMark:\r
-            if (state == Matra) {\r
-                // ### needs proper testing for correct two/three part matras\r
-                break;\r
-            }\r
-        case IndependentVowel:\r
-        case Invalid:\r
-        case Other:\r
-            goto finish;\r
-        }\r
-        state = newState;\r
-        pos++;\r
-    }\r
- finish:\r
-    return pos+start;\r
-}\r
-\r
-HB_Bool HB_IndicShape(HB_ShaperItem *item)\r
-{\r
-    assert(item->item.script >= HB_Script_Devanagari && item->item.script <= HB_Script_Sinhala);\r
-\r
-    HB_Bool openType = false;\r
-#ifndef NO_OPENTYPE\r
-    openType = HB_SelectScript(item, indic_features);\r
-#endif\r
-    unsigned short *logClusters = item->log_clusters;\r
-\r
-    HB_ShaperItem syllable = *item;\r
-    int first_glyph = 0;\r
-\r
-    int sstart = item->item.pos;\r
-    int end = sstart + item->item.length;\r
-    IDEBUG("indic_shape: from %d length %d", item->item.pos, item->item.length);\r
-    while (sstart < end) {\r
-        HB_Bool invalid;\r
-        int send = indic_nextSyllableBoundary(item->item.script, item->string, sstart, end, &invalid);\r
-        IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,\r
-               invalid ? "true" : "false");\r
-        syllable.item.pos = sstart;\r
-        syllable.item.length = send-sstart;\r
-        syllable.glyphs = item->glyphs + first_glyph;\r
-        syllable.attributes = item->attributes + first_glyph;\r
-        syllable.offsets = item->offsets + first_glyph;\r
-        syllable.advances = item->advances + first_glyph;\r
-        syllable.num_glyphs = item->num_glyphs - first_glyph;\r
-        if (!indic_shape_syllable(openType, &syllable, invalid)) {\r
-            IDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);\r
-            item->num_glyphs += syllable.num_glyphs;\r
-            return false;\r
-        }\r
-        // fix logcluster array\r
-        IDEBUG("syllable:");\r
-        hb_uint32 g;\r
-        for (g = first_glyph; g < first_glyph + syllable.num_glyphs; ++g)\r
-            IDEBUG("        %d -> glyph %x", g, item->glyphs[g]);\r
-        IDEBUG("    logclusters:");\r
-        int i;\r
-        for (i = sstart; i < send; ++i) {\r
-            IDEBUG("        %d -> glyph %d", i, first_glyph);\r
-            logClusters[i-item->item.pos] = first_glyph;\r
-        }\r
-        sstart = send;\r
-        first_glyph += syllable.num_glyphs;\r
-    }\r
-    item->num_glyphs = first_glyph;\r
-    return true;\r
-}\r
-\r
-void HB_IndicAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    int end = from + len;\r
-    const HB_UChar16 *uc = text + from;\r
-    attributes += from;\r
-    hb_uint32 i = 0;\r
-    while (i < len) {\r
-        HB_Bool invalid;\r
-        hb_uint32 boundary = indic_nextSyllableBoundary(script, text, from+i, end, &invalid) - from;\r
-         attributes[i].charStop = true;\r
-\r
-        if (boundary > len-1) boundary = len;\r
-        i++;\r
-        while (i < boundary) {\r
-            attributes[i].charStop = false;\r
-            ++uc;\r
-            ++i;\r
-        }\r
-        assert(i == boundary);\r
-    }\r
-\r
-\r
-}\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+#include <stdio.h>
+
+#define FLAG(x) (1 << (x))
+
+static HB_Bool isLetter(HB_UChar16 ucs)
+{
+    const int test = FLAG(HB_Letter_Uppercase) |
+                     FLAG(HB_Letter_Lowercase) |
+                     FLAG(HB_Letter_Titlecase) |
+                     FLAG(HB_Letter_Modifier) |
+                     FLAG(HB_Letter_Other);
+    return FLAG(HB_GetUnicodeCharCategory(ucs)) & test;
+}
+
+static HB_Bool isMark(HB_UChar16 ucs)
+{
+    const int test = FLAG(HB_Mark_NonSpacing) |
+                     FLAG(HB_Mark_SpacingCombining) |
+                     FLAG(HB_Mark_Enclosing);
+    return FLAG(HB_GetUnicodeCharCategory(ucs)) & test;
+}
+
+typedef enum _Form {
+    Invalid = 0x0,
+    UnknownForm = Invalid,
+    Consonant,
+    Nukta,
+    Halant,
+    Matra,
+    VowelMark,
+    StressMark,
+    IndependentVowel,
+    LengthMark,
+    Control,
+    Other
+}Form;
+
+static const unsigned char indicForms[0xe00-0x900] = {
+    // Devangari
+    Invalid, VowelMark, VowelMark, VowelMark,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Matra, Matra, Matra,
+    Matra, Matra, Matra, Matra,
+    Matra, Halant, UnknownForm, UnknownForm,
+
+    Other, StressMark, StressMark, StressMark,
+    StressMark, UnknownForm, UnknownForm, UnknownForm,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    IndependentVowel, IndependentVowel, VowelMark, VowelMark,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Consonant,
+    Consonant, Consonant /* ??? */, Consonant, Consonant,
+
+    // Bengali
+    Invalid, VowelMark, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Invalid, Invalid, IndependentVowel,
+
+    IndependentVowel, Invalid, Invalid, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Invalid, Consonant, Invalid,
+    Invalid, Invalid, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Invalid, Invalid, Matra,
+    Matra, Invalid, Invalid, Matra,
+    Matra, Halant, Consonant, UnknownForm,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, VowelMark,
+    Invalid, Invalid, Invalid, Invalid,
+    Consonant, Consonant, Invalid, Consonant,
+
+    IndependentVowel, IndependentVowel, VowelMark, VowelMark,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Consonant, Consonant, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Gurmukhi
+    Invalid, VowelMark, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,
+    Invalid, Invalid, Invalid, IndependentVowel,
+
+    IndependentVowel, Invalid, Invalid, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Invalid, Consonant, Consonant,
+    Invalid, Consonant, Consonant, Invalid,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Invalid,
+    Invalid, Invalid, Invalid, Matra,
+    Matra, Invalid, Invalid, Matra,
+    Matra, Halant, UnknownForm, UnknownForm,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, UnknownForm, UnknownForm, UnknownForm,
+    Invalid, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Invalid,
+
+    Other, Other, Invalid, Invalid,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    StressMark, StressMark, Consonant, Consonant,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Gujarati
+    Invalid, VowelMark, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, Invalid, IndependentVowel,
+
+    IndependentVowel, IndependentVowel, Invalid, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Invalid, Consonant, Consonant,
+    Invalid, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Matra, Invalid, Matra,
+    Matra, Matra, Invalid, Matra,
+    Matra, Halant, UnknownForm, UnknownForm,
+
+    Other, UnknownForm, UnknownForm, UnknownForm,
+    UnknownForm, UnknownForm, UnknownForm, UnknownForm,
+    UnknownForm, UnknownForm, UnknownForm, UnknownForm,
+    UnknownForm, UnknownForm, UnknownForm, UnknownForm,
+
+    IndependentVowel, IndependentVowel, VowelMark, VowelMark,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Oriya
+    Invalid, VowelMark, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Invalid, Invalid, IndependentVowel,
+
+    IndependentVowel, Invalid, Invalid, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Invalid, Consonant, Consonant,
+    Invalid, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Invalid, Invalid, Invalid, Matra,
+    Matra, Invalid, Invalid, Matra,
+    Matra, Halant, UnknownForm, UnknownForm,
+
+    Other, Invalid, Invalid, Invalid,
+    Invalid, UnknownForm, LengthMark, LengthMark,
+    Invalid, Invalid, Invalid, Invalid,
+    Consonant, Consonant, Invalid, Consonant,
+
+    IndependentVowel, IndependentVowel, Invalid, Invalid,
+    Invalid, Invalid, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Consonant, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    //Tamil
+    Invalid, Invalid, VowelMark, Other,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,
+    Invalid, Invalid, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+    IndependentVowel, Consonant, Invalid, Invalid,
+    Invalid, Consonant, Consonant, Invalid,
+    Consonant, Invalid, Consonant, Consonant,
+
+    Invalid, Invalid, Invalid, Consonant,
+    Consonant, Invalid, Invalid, Invalid,
+    Consonant, Consonant, Consonant, Invalid,
+    Invalid, Invalid, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Invalid, Invalid, Matra, Matra,
+
+    Matra, Matra, Matra, Invalid,
+    Invalid, Invalid, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Halant, Invalid, Invalid,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, LengthMark,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Telugu
+    Invalid, VowelMark, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Invalid, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Invalid, Invalid, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Halant, Invalid, Invalid,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, LengthMark, Matra, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+
+    IndependentVowel, IndependentVowel, Invalid, Invalid,
+    Invalid, Invalid, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Kannada
+    Invalid, Invalid, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Invalid, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Nukta, Other, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Halant, Invalid, Invalid,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, LengthMark, LengthMark, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Consonant, Invalid,
+
+    IndependentVowel, IndependentVowel, VowelMark, VowelMark,
+    Invalid, Invalid, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Malayalam
+    Invalid, Invalid, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, Invalid, IndependentVowel, IndependentVowel,
+    IndependentVowel, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, UnknownForm, UnknownForm,
+    Invalid, Invalid, Matra, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Invalid, Invalid, Matra, Matra,
+    Matra, Invalid, Matra, Matra,
+    Matra, Halant, Invalid, Invalid,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Matra,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+
+    IndependentVowel, IndependentVowel, Invalid, Invalid,
+    Invalid, Invalid, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+
+    // Sinhala
+    Invalid, Invalid, VowelMark, VowelMark,
+    Invalid, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+
+    IndependentVowel, IndependentVowel, IndependentVowel, IndependentVowel,
+    IndependentVowel, IndependentVowel, IndependentVowel, Invalid,
+    Invalid, Invalid, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+
+    Consonant, Consonant, Invalid, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Consonant,
+    Invalid, Consonant, Invalid, Invalid,
+
+    Consonant, Consonant, Consonant, Consonant,
+    Consonant, Consonant, Consonant, Invalid,
+    Invalid, Invalid, Halant, Invalid,
+    Invalid, Invalid, Invalid, Matra,
+
+    Matra, Matra, Matra, Matra,
+    Matra, Invalid, Matra, Invalid,
+    Matra, Matra, Matra, Matra,
+    Matra, Matra, Matra, Matra,
+
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+    Invalid, Invalid, Invalid, Invalid,
+
+    Invalid, Invalid, Matra, Matra,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+    Other, Other, Other, Other,
+};
+
+typedef enum _Position {
+    None,
+    Pre,
+    Above,
+    Below,
+    Post,
+    Split,
+    Base,
+    Reph,
+    Vattu,
+    Inherit
+}Position;
+
+static const unsigned char indicPosition[0xe00-0x900] = {
+    // Devanagari
+    None, Above, Above, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    Below, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, Post, Pre,
+
+    Post, Below, Below, Below,
+    Below, Above, Above, Above,
+    Above, Post, Post, Post,
+    Post, None, None, None,
+
+    None, Above, Below, Above,
+    Above, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, Below, Below,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Bengali
+    None, Above, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    Below, None, None, Post,
+
+    Below, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    Below, None, Post, Pre,
+
+    Post, Below, Below, Below,
+    Below, None, None, Pre,
+    Pre, None, None, Split,
+    Split, Below, None, None,
+
+    None, None, None, None,
+    None, None, None, Post,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, Below, Below,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    Below, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Gurmukhi
+    None, Above, Above, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, Post,
+
+    Below, None, None, None,
+    None, Below, None, None,
+    None, Below, None, None,
+    Below, None, Post, Pre,
+
+    Post, Below, Below, None,
+    None, None, None, Above,
+    Above, None, None, Above,
+    Above, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    Above, Above, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Gujarati
+    None, Above, Above, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    Below, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, Post, Pre,
+
+    Post, Below, Below, Below,
+    Below, Above, None, Above,
+    Above, Post, None, Post,
+    Post, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, Below, Below,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Oriya
+    None, Above, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    Below, None, None, None,
+    Below, None, None, None,
+    Below, Below, Below, Post,
+
+    Below, None, Below, Below,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, Post, Above,
+
+    Post, Below, Below, Below,
+    None, None, None, Pre,
+    Split, None, None, Split,
+    Split, None, None, None,
+
+    None, None, None, None,
+    None, None, Above, Post,
+    None, None, None, None,
+    None, None, None, Post,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, Below, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Tamil
+    None, None, Above, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, Post, Post,
+
+    Above, Below, Below, None,
+    None, None, Pre, Pre,
+    Pre, None, Split, Split,
+    Split, Halant, None, None,
+
+    None, None, None, None,
+    None, None, None, Post,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Telugu
+    None, Post, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, Below, Below, Below,
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+    Below, None, Below, Below,
+    Below, Below, Below, Below,
+
+    Below, None, Below, Below,
+    None, Below, Below, Below,
+    Below, Below, None, None,
+    None, None, Post, Above,
+
+    Above, Post, Post, Post,
+    Post, None, Above, Above,
+    Split, None, Post, Above,
+    Above, Halant, None, None,
+
+    None, None, None, None,
+    None, Above, Below, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Kannada
+    None, None, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, Below, Below, Below,
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+    Below, Below, Below, Below,
+
+    Below, None, Below, Below,
+    None, Below, Below, Below,
+    Below, Below, None, None,
+    None, None, Post, Above,
+
+    Split, Post, Post, Post,
+    Post, None, Above, Split,
+    Split, None, Split, Split,
+    Above, Halant, None, None,
+
+    None, None, None, None,
+    None, Post, Post, None,
+    None, None, None, None,
+    None, None, Below, None,
+
+    None, None, Below, Below,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Malayalam
+    None, None, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, Post,
+
+    Post, None, Below, None,
+    None, Post, None, None,
+    None, None, None, None,
+    None, None, Post, Post,
+
+    Post, Post, Post, Post,
+    None, None, Pre, Pre,
+    Pre, None, Split, Split,
+    Split, Halant, None, None,
+
+    None, None, None, None,
+    None, None, None, Post,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    // Sinhala
+    None, None, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, Post,
+
+    Post, Post, Above, Above,
+    Below, None, Below, None,
+    Post, Pre, Split, Pre,
+    Split, Split, Split, Post,
+
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None,
+
+    None, None, Post, Post,
+    None, None, None, None,
+    None, None, None, None,
+    None, None, None, None
+};
+
+static Form form(unsigned short uc) {
+    if (uc < 0x900 || uc > 0xdff) {
+        if (uc == 0x25cc)
+            return Consonant;
+        if (uc == 0x200c || uc == 0x200d)
+            return Control;
+        return Other;
+    }
+    return (Form)indicForms[uc-0x900];
+}
+
+static Position indic_position(unsigned short uc) {
+    if (uc < 0x900 || uc > 0xdff)
+        return None;
+    return (Position) indicPosition[uc-0x900];
+}
+
+
+enum IndicScriptProperties {
+    HasReph = 0x01,
+    HasSplit = 0x02
+};
+
+const hb_uint8 scriptProperties[10] = {
+    // Devanagari,
+    HasReph,
+    // Bengali,
+    HasReph|HasSplit,
+    // Gurmukhi,
+    0,
+    // Gujarati,
+    HasReph,
+    // Oriya,
+    HasReph|HasSplit,
+    // Tamil,
+    HasSplit,
+    // Telugu,
+    HasSplit,
+    // Kannada,
+    HasSplit|HasReph,
+    // Malayalam,
+    HasSplit,
+    // Sinhala,
+    HasSplit
+};
+
+typedef struct _IndicOrdering {
+    Form form;
+    Position position;
+}IndicOrdering;
+
+static const IndicOrdering devanagari_order [] = {
+    { Consonant, Below },
+    { Matra, Below },
+    { VowelMark, Below },
+    { StressMark, Below },
+    { Matra, Above },
+    { Matra, Post },
+    { Consonant, Reph },
+    { VowelMark, Above },
+    { StressMark, Above },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering bengali_order [] = {
+    { Consonant, Below },
+    { Matra, Below },
+    { Matra, Above },
+    { Consonant, Reph },
+    { VowelMark, Above },
+    { Consonant, Post },
+    { Matra, Post },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering gurmukhi_order [] = {
+    { Consonant, Below },
+    { Matra, Below },
+    { Matra, Above },
+    { Consonant, Post },
+    { Matra, Post },
+    { VowelMark, Above },
+    { (Form)0, None }
+};
+
+static const IndicOrdering tamil_order [] = {
+    { Matra, Above },
+    { Matra, Post },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering telugu_order [] = {
+    { Matra, Above },
+    { Matra, Below },
+    { Matra, Post },
+    { Consonant, Below },
+    { Consonant, Post },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering kannada_order [] = {
+    { Matra, Above },
+    { Matra, Post },
+    { Consonant, Below },
+    { Consonant, Post },
+    { LengthMark, Post },
+    { Consonant, Reph },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering malayalam_order [] = {
+    { Consonant, Below },
+    { Matra, Below },
+    { Consonant, Reph },
+    { Consonant, Post },
+    { Matra, Post },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering sinhala_order [] = {
+    { Matra, Below },
+    { Matra, Above },
+    { Matra, Post },
+    { VowelMark, Post },
+    { (Form)0, None }
+};
+
+static const IndicOrdering * const indic_order[] = {
+    devanagari_order, // Devanagari
+    bengali_order, // Bengali
+    gurmukhi_order, // Gurmukhi
+    devanagari_order, // Gujarati
+    bengali_order, // Oriya
+    tamil_order, // Tamil
+    telugu_order, // Telugu
+    kannada_order, // Kannada
+    malayalam_order, // Malayalam
+    sinhala_order // Sinhala
+};
+
+
+
+// vowel matras that have to be split into two parts.
+static const unsigned short split_matras[]  = {
+    //  matra, split1, split2, split3
+
+    // bengalis
+    0x9cb, 0x9c7, 0x9be, 0x0,
+    0x9cc, 0x9c7, 0x9d7, 0x0,
+    // oriya
+    0xb48, 0xb47, 0xb56, 0x0,
+    0xb4b, 0xb47, 0xb3e, 0x0,
+    0xb4c, 0xb47, 0xb57, 0x0,
+    // tamil
+    0xbca, 0xbc6, 0xbbe, 0x0,
+    0xbcb, 0xbc7, 0xbbe, 0x0,
+    0xbcc, 0xbc6, 0xbd7, 0x0,
+    // telugu
+    0xc48, 0xc46, 0xc56, 0x0,
+    // kannada
+    0xcc0, 0xcbf, 0xcd5, 0x0,
+    0xcc7, 0xcc6, 0xcd5, 0x0,
+    0xcc8, 0xcc6, 0xcd6, 0x0,
+    0xcca, 0xcc6, 0xcc2, 0x0,
+    0xccb, 0xcc6, 0xcc2, 0xcd5,
+    // malayalam
+    0xd4a, 0xd46, 0xd3e, 0x0,
+    0xd4b, 0xd47, 0xd3e, 0x0,
+    0xd4c, 0xd46, 0xd57, 0x0,
+    // sinhala
+    0xdda, 0xdd9, 0xdca, 0x0,
+    0xddc, 0xdd9, 0xdcf, 0x0,
+    0xddd, 0xdd9, 0xdcf, 0xdca,
+    0xdde, 0xdd9, 0xddf, 0x0,
+    0xffff
+};
+
+static void splitMatra(unsigned short *reordered, int matra, int *len)
+{
+    unsigned short matra_uc = reordered[matra];
+    //qDebug("matra=%d, reordered[matra]=%x", matra, reordered[matra]);
+
+    const unsigned short *split = split_matras;
+    while (split[0] < matra_uc)
+        split += 4;
+
+    assert(*split == matra_uc);
+    ++split;
+
+    int added_chars = split[2] == 0x0 ? 1 : 2;
+
+    memmove(reordered + matra + added_chars, reordered + matra, (*len-matra)*sizeof(unsigned short));
+    reordered[matra] = split[0];
+    reordered[matra+1] = split[1];
+    if(added_chars == 2)
+        reordered[matra+2] = split[2];
+    *len += added_chars;
+}
+
+#ifndef NO_OPENTYPE
+static const HB_OpenTypeFeature indic_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
+    { HB_MAKE_TAG('n', 'u', 'k', 't'), NuktaProperty },
+    { HB_MAKE_TAG('a', 'k', 'h', 'n'), AkhantProperty },
+    { HB_MAKE_TAG('r', 'p', 'h', 'f'), RephProperty },
+    { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },
+    { HB_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty },
+    { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },
+    { HB_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty },
+    { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },
+    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },
+    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },
+    { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },
+    { HB_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty },
+    { 0, 0 }
+};
+#endif
+
+// #define INDIC_DEBUG
+#ifdef INDIC_DEBUG
+#define IDEBUG hb_debug
+#include <stdarg.h>
+
+static void hb_debug(const char *msg, ...)
+{
+    va_list ap;
+    va_start(ap, msg); // use variable arg list
+    vfprintf(stderr, msg, ap);
+    va_end(ap);
+    fprintf(stderr, "\n");
+}
+
+#else
+#define IDEBUG if(0) printf
+#endif
+
+#if 0 //def INDIC_DEBUG
+static QString propertiesToString(int properties)
+{
+    QString res;
+    properties = ~properties;
+    if (properties & CcmpProperty)
+        res += "Ccmp ";
+    if (properties & InitProperty)
+        res += "Init ";
+    if (properties & NuktaProperty)
+        res += "Nukta ";
+    if (properties & AkhantProperty)
+        res += "Akhant ";
+    if (properties & RephProperty)
+        res += "Reph ";
+    if (properties & PreFormProperty)
+        res += "PreForm ";
+    if (properties & BelowFormProperty)
+        res += "BelowForm ";
+    if (properties & AboveFormProperty)
+        res += "AboveForm ";
+    if (properties & HalfFormProperty)
+        res += "HalfForm ";
+    if (properties & PostFormProperty)
+        res += "PostForm ";
+    if (properties & VattuProperty)
+        res += "Vattu ";
+    if (properties & PreSubstProperty)
+        res += "PreSubst ";
+    if (properties & BelowSubstProperty)
+        res += "BelowSubst ";
+    if (properties & AboveSubstProperty)
+        res += "AboveSubst ";
+    if (properties & PostSubstProperty)
+        res += "PostSubst ";
+    if (properties & HalantProperty)
+        res += "Halant ";
+    if (properties & CligProperty)
+        res += "Clig ";
+    return res;
+}
+#endif
+
+static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool invalid)
+{
+    HB_Script script = item->item.script;
+    assert(script >= HB_Script_Devanagari && script <= HB_Script_Sinhala);
+    const unsigned short script_base = 0x0900 + 0x80*(script-HB_Script_Devanagari);
+    const unsigned short ra = script_base + 0x30;
+    const unsigned short halant = script_base + 0x4d;
+    const unsigned short nukta = script_base + 0x3c;
+    bool control = false;
+
+    int len = (int)item->item.length;
+    IDEBUG(">>>>> indic shape: from=%d, len=%d invalid=%d", item->item.pos, item->item.length, invalid);
+
+    if ((int)item->num_glyphs < len+4) {
+        item->num_glyphs = len+4;
+        return false;
+    }
+
+    HB_STACKARRAY(HB_UChar16, reordered, len + 4);
+    HB_STACKARRAY(hb_uint8, position, len + 4);
+
+    unsigned char properties = scriptProperties[script-HB_Script_Devanagari];
+
+    if (invalid) {
+        *reordered = 0x25cc;
+        memcpy(reordered+1, item->string + item->item.pos, len*sizeof(HB_UChar16));
+        len++;
+    } else {
+        memcpy(reordered, item->string + item->item.pos, len*sizeof(HB_UChar16));
+    }
+    if (reordered[len-1] == 0x200c) // zero width non joiner
+        len--;
+
+    int i;
+    int base = 0;
+    int reph = -1;
+
+#ifdef INDIC_DEBUG
+    IDEBUG("original:");
+    for (i = 0; i < len; i++) {
+        IDEBUG("    %d: %4x", i, reordered[i]);
+    }
+#endif
+
+    if (len != 1) {
+        HB_UChar16 *uc = reordered;
+        bool beginsWithRa = false;
+
+        // Rule 1: find base consonant
+        //
+        // The shaping engine finds the base consonant of the
+        // syllable, using the following algorithm: starting from the
+        // end of the syllable, move backwards until a consonant is
+        // found that does not have a below-base or post-base form
+        // (post-base forms have to follow below-base forms), or
+        // arrive at the first consonant. The consonant stopped at
+        // will be the base.
+        //
+        //  * If the syllable starts with Ra + H (in a script that has
+        //    'Reph'), Ra is excluded from candidates for base
+        //    consonants.
+        //
+        // * In Kannada and Telugu, the base consonant cannot be
+        //   farther than 3 consonants from the end of the syllable.
+        // #### replace the HasReph property by testing if the feature exists in the font!
+        if (form(*uc) == Consonant || (script == HB_Script_Bengali && form(*uc) == IndependentVowel)) {
+            if ((properties & HasReph) && (len > 2) &&
+                (*uc == ra || *uc == 0x9f0) && *(uc+1) == halant)
+                beginsWithRa = true;
+
+            if (beginsWithRa && form(*(uc+2)) == Control)
+                beginsWithRa = false;
+
+            base = (beginsWithRa ? 2 : 0);
+            IDEBUG("    length = %d, beginsWithRa = %d, base=%d", len, beginsWithRa, base);
+
+            int lastConsonant = 0;
+            int matra = -1;
+            // we remember:
+            // * the last consonant since we need it for rule 2
+            // * the matras position for rule 3 and 4
+
+            // figure out possible base glyphs
+            memset(position, 0, len);
+            if (script == HB_Script_Devanagari || script == HB_Script_Gujarati) {
+                bool vattu = false;
+                for (i = base; i < len; ++i) {
+                    position[i] = form(uc[i]);
+                    if (position[i] == Consonant) {
+                        lastConsonant = i;
+                        vattu = (!vattu && uc[i] == ra);
+                        if (vattu) {
+                            IDEBUG("excluding vattu glyph at %d from base candidates", i);
+                            position[i] = Vattu;
+                        }
+                    } else if (position[i] == Matra) {
+                        matra = i;
+                    }
+                }
+            } else {
+                for (i = base; i < len; ++i) {
+                    position[i] = form(uc[i]);
+                    if (position[i] == Consonant)
+                        lastConsonant = i;
+                    else if (matra < 0 && position[i] == Matra)
+                        matra = i;
+                }
+            }
+            int skipped = 0;
+            Position pos = Post;
+            for (i = len-1; i > base; i--) {
+                if (position[i] != Consonant && (position[i] != Control || script == HB_Script_Kannada))
+                    continue;
+
+                Position charPosition = indic_position(uc[i]);
+                if (pos == Post && charPosition == Post) {
+                    pos = Post;
+                } else if ((pos == Post || pos == Below) && charPosition == Below) {
+                    if (script == HB_Script_Devanagari || script == HB_Script_Gujarati)
+                        base = i;
+                    pos = Below;
+                } else {
+                    base = i;
+                    break;
+                }
+                if (skipped == 2 && (script == HB_Script_Kannada || script == HB_Script_Telugu)) {
+                    base = i;
+                    break;
+                }
+                ++skipped;
+            }
+
+            IDEBUG("    base consonant at %d skipped=%d, lastConsonant=%d", base, skipped, lastConsonant);
+
+            // Rule 2:
+            //
+            // If the base consonant is not the last one, Uniscribe
+            // moves the halant from the base consonant to the last
+            // one.
+            if (lastConsonant > base) {
+                int halantPos = 0;
+                if (uc[base+1] == halant)
+                    halantPos = base + 1;
+                else if (uc[base+1] == nukta && uc[base+2] == halant)
+                    halantPos = base + 2;
+                if (halantPos > 0) {
+                    IDEBUG("    moving halant from %d to %d!", base+1, lastConsonant);
+                    for (i = halantPos; i < lastConsonant; i++)
+                        uc[i] = uc[i+1];
+                    uc[lastConsonant] = halant;
+                }
+            }
+
+            // Rule 3:
+            //
+            // If the syllable starts with Ra + H, Uniscribe moves
+            // this combination so that it follows either:
+
+            // * the post-base 'matra' (if any) or the base consonant
+            //   (in scripts that show similarity to Devanagari, i.e.,
+            //   Devanagari, Gujarati, Bengali)
+            // * the base consonant (other scripts)
+            // * the end of the syllable (Kannada)
+
+            Position matra_position = None;
+            if (matra > 0)
+                matra_position = indic_position(uc[matra]);
+            IDEBUG("    matra at %d with form %d, base=%d", matra, matra_position, base);
+
+            if (beginsWithRa && base != 0) {
+                int toPos = base+1;
+                if (toPos < len && uc[toPos] == nukta)
+                    toPos++;
+                if (toPos < len && uc[toPos] == halant)
+                    toPos++;
+                if (toPos < len && uc[toPos] == 0x200d)
+                    toPos++;
+                if (toPos < len-1 && uc[toPos] == ra && uc[toPos+1] == halant)
+                    toPos += 2;
+                if (script == HB_Script_Devanagari || script == HB_Script_Gujarati || script == HB_Script_Bengali) {
+                    if (matra_position == Post || matra_position == Split) {
+                        toPos = matra+1;
+                        matra -= 2;
+                    }
+                } else if (script == HB_Script_Kannada) {
+                    toPos = len;
+                    matra -= 2;
+                }
+
+                IDEBUG("moving leading ra+halant to position %d", toPos);
+                for (i = 2; i < toPos; i++)
+                    uc[i-2] = uc[i];
+                uc[toPos-2] = ra;
+                uc[toPos-1] = halant;
+                base -= 2;
+                if (properties & HasReph)
+                    reph = toPos-2;
+            }
+
+            // Rule 4:
+
+            // Uniscribe splits two- or three-part matras into their
+            // parts. This splitting is a character-to-character
+            // operation).
+            //
+            //      Uniscribe describes some moving operations for these
+            //      matras here. For shaping however all pre matras need
+            //      to be at the beginning of the syllable, so we just move
+            //      them there now.
+            if (matra_position == Split) {
+                splitMatra(uc, matra, &len);
+                // Handle three-part matras (0xccb in Kannada)
+                matra_position = indic_position(uc[matra]);
+            }
+
+            if (matra_position == Pre) {
+                unsigned short m = uc[matra];
+                while (matra--)
+                    uc[matra+1] = uc[matra];
+                uc[0] = m;
+                base++;
+            }
+        }
+
+        // Rule 5:
+        //
+        // Uniscribe classifies consonants and 'matra' parts as
+        // pre-base, above-base (Reph), below-base or post-base. This
+        // classification exists on the character code level and is
+        // language-dependent, not font-dependent.
+        for (i = 0; i < base; ++i)
+            position[i] = Pre;
+        position[base] = Base;
+        for (i = base+1; i < len; ++i) {
+            position[i] = indic_position(uc[i]);
+            // #### replace by adjusting table
+            if (uc[i] == nukta || uc[i] == halant)
+                position[i] = Inherit;
+        }
+        if (reph > 0) {
+            // recalculate reph, it might have changed.
+            for (i = base+1; i < len; ++i)
+                if (uc[i] == ra)
+                    reph = i;
+            position[reph] = Reph;
+            position[reph+1] = Inherit;
+        }
+
+        // all reordering happens now to the chars after the base
+        int fixed = base+1;
+        if (fixed < len && uc[fixed] == nukta)
+            fixed++;
+        if (fixed < len && uc[fixed] == halant)
+            fixed++;
+        if (fixed < len && uc[fixed] == 0x200d)
+            fixed++;
+
+#ifdef INDIC_DEBUG
+        for (i = fixed; i < len; ++i)
+            IDEBUG("position[%d] = %d, form=%d uc=%x", i, position[i], form(uc[i]), uc[i]);
+#endif
+        // we continuosly position the matras and vowel marks and increase the fixed
+        // until we reached the end.
+        const IndicOrdering *finalOrder = indic_order[script-HB_Script_Devanagari];
+
+        IDEBUG("    reordering pass:");
+        IDEBUG("        base=%d fixed=%d", base, fixed);
+        int toMove = 0;
+        while (finalOrder[toMove].form && fixed < len-1) {
+            IDEBUG("        fixed = %d, toMove=%d, moving form %d with pos %d", fixed, toMove, finalOrder[toMove].form, finalOrder[toMove].position);
+            for (i = fixed; i < len; i++) {
+//                IDEBUG() << "           i=" << i << "uc=" << hex << uc[i] << "form=" << form(uc[i])
+//                         << "position=" << position[i];
+                if (form(uc[i]) == finalOrder[toMove].form &&
+                     position[i] == finalOrder[toMove].position) {
+                     int j=0;
+                    // need to move this glyph
+                    int to = fixed;
+                    if (i < len-1 && position[i+1] == Inherit) {
+                        IDEBUG("         moving two chars from %d to %d", i, to);
+                        unsigned short ch = uc[i];
+                        unsigned short ch2 = uc[i+1];
+                        unsigned char pos = position[i];
+                        for (j = i+1; j > to+1; j--) {
+                            uc[j] = uc[j-2];
+                            position[j] = position[j-2];
+                        }
+                        uc[to] = ch;
+                        uc[to+1] = ch2;
+                        position[to] = pos;
+                        position[to+1] = pos;
+                        fixed += 2;
+                    } else {
+                        IDEBUG("         moving one char from %d to %d", i, to);
+                        unsigned short ch = uc[i];
+                        unsigned char pos = position[i];
+                        for (j = i; j > to; j--) {
+                            uc[j] = uc[j-1];
+                            position[j] = position[j-1];
+                        }
+                        uc[to] = ch;
+                        position[to] = pos;
+                        fixed++;
+                    }
+                }
+            }
+            toMove++;
+        }
+
+    }
+
+    if (reph > 0) {
+        // recalculate reph, it might have changed.
+        for (i = base+1; i < len; ++i)
+            if (reordered[i] == ra)
+                reph = i;
+    }
+
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = item->num_glyphs;
+#endif
+    if (!item->font->klass->convertStringToGlyphIndices(item->font,
+                                                        reordered, len,
+                                                        item->glyphs, &item->num_glyphs,
+                                                        item->item.bidiLevel % 2))
+        goto error;
+
+
+    IDEBUG("  base=%d, reph=%d", base, reph);
+    IDEBUG("reordered:");
+    for (i = 0; i < len; i++) {
+        item->attributes[i].mark = false;
+        item->attributes[i].clusterStart = false;
+        item->attributes[i].justification = 0;
+        item->attributes[i].zeroWidth = false;
+        IDEBUG("    %d: %4x", i, reordered[i]);
+    }
+
+    // now we have the syllable in the right order, and can start running it through open type.
+
+    for (i = 0; i < len; ++i)
+        control |= (form(reordered[i]) == Control);
+
+#ifndef NO_OPENTYPE
+    if (openType) {
+
+        // we need to keep track of where the base glyph is for some
+        // scripts and use the cluster feature for this.  This
+        // also means we have to correct the logCluster output from
+        // the open type engine manually afterwards.  for indic this
+        // is rather simple, as all chars just point to the first
+        // glyph in the syllable.
+        HB_STACKARRAY(unsigned short, clusters, len);
+        HB_STACKARRAY(unsigned int, properties, len);
+
+        for (i = 0; i < len; ++i)
+            clusters[i] = i;
+
+        // features we should always apply
+        for (i = 0; i < len; ++i)
+            properties[i] = ~(CcmpProperty
+                              | NuktaProperty
+                              | VattuProperty
+                              | PreSubstProperty
+                              | BelowSubstProperty
+                              | AboveSubstProperty
+                              | HalantProperty
+                              | PositioningProperties);
+
+        // Ccmp always applies
+        // Init
+        if (item->item.pos == 0
+            || !(isLetter(item->string[item->item.pos-1]) || isMark(item->string[item->item.pos-1])))
+            properties[0] &= ~InitProperty;
+
+        // Nukta always applies
+        // Akhant
+        for (i = 0; i <= base; ++i)
+            properties[i] &= ~AkhantProperty;
+        // Reph
+        if (reph >= 0) {
+            properties[reph] &= ~RephProperty;
+            properties[reph+1] &= ~RephProperty;
+        }
+        // BelowForm
+        for (i = base+1; i < len; ++i)
+            properties[i] &= ~BelowFormProperty;
+
+        if (script == HB_Script_Devanagari || script == HB_Script_Gujarati) {
+            // vattu glyphs need this aswell
+            bool vattu = false;
+            for (i = base-2; i > 1; --i) {
+                if (form(reordered[i]) == Consonant) {
+                    vattu = (!vattu && reordered[i] == ra);
+                    if (vattu) {
+                        IDEBUG("forming vattu ligature at %d", i);
+                        properties[i] &= ~BelowFormProperty;
+                        properties[i+1] &= ~BelowFormProperty;
+                    }
+                }
+            }
+        }
+        // HalfFormProperty
+        for (i = 0; i < base; ++i)
+            properties[i] &= ~HalfFormProperty;
+        if (control) {
+            for (i = 2; i < len; ++i) {
+                if (reordered[i] == 0x200d /* ZWJ */) {
+                    properties[i-1] &= ~HalfFormProperty;
+                    properties[i-2] &= ~HalfFormProperty;
+                } else if (reordered[i] == 0x200c /* ZWNJ */) {
+                    properties[i-1] &= ~HalfFormProperty;
+                    properties[i-2] &= ~HalfFormProperty;
+                }
+            }
+        }
+        // PostFormProperty
+        for (i = base+1; i < len; ++i)
+            properties[i] &= ~PostFormProperty;
+        // vattu always applies
+        // pres always applies
+        // blws always applies
+        // abvs always applies
+
+        // psts
+        // ### this looks slightly different from before, but I believe it's correct
+        if (reordered[len-1] != halant || base != len-2)
+            properties[base] &= ~PostSubstProperty;
+        for (i = base+1; i < len; ++i)
+            properties[i] &= ~PostSubstProperty;
+
+        // halant always applies
+
+#ifdef INDIC_DEBUG
+//        {
+//            IDEBUG("OT properties:");
+//            for (int i = 0; i < len; ++i)
+//                qDebug("    i: %s", ::propertiesToString(properties[i]).toLatin1().data());
+//        }
+#endif
+
+        // initialize
+        item->log_clusters = clusters;
+        HB_OpenTypeShape(item, properties);
+
+        int newLen = item->face->buffer->in_length;
+        HB_GlyphItem otl_glyphs = item->face->buffer->in_string;
+
+        // move the left matra back to its correct position in malayalam and tamil
+        if ((script == HB_Script_Malayalam || script == HB_Script_Tamil) && (form(reordered[0]) == Matra)) {
+//             qDebug("reordering matra, len=%d", newLen);
+            // need to find the base in the shaped string and move the matra there
+            int basePos = 0;
+            while (basePos < newLen && (int)otl_glyphs[basePos].cluster <= base)
+                basePos++;
+            --basePos;
+            if (basePos < newLen && basePos > 1) {
+//                 qDebug("moving prebase matra to position %d in syllable newlen=%d", basePos, newLen);
+                HB_GlyphItemRec m = otl_glyphs[0];
+                --basePos;
+                for (i = 0; i < basePos; ++i)
+                    otl_glyphs[i] = otl_glyphs[i+1];
+                otl_glyphs[basePos] = m;
+            }
+        }
+
+        HB_Bool positioned = HB_OpenTypePosition(item, availableGlyphs, false);
+
+        HB_FREE_STACKARRAY(clusters);
+        HB_FREE_STACKARRAY(properties);
+
+        if (!positioned)
+            goto error;
+
+        if (control) {
+            IDEBUG("found a control char in the syllable");
+            hb_uint32 i = 0, j = 0;
+            while (i < item->num_glyphs) {
+                if (form(reordered[otl_glyphs[i].cluster]) == Control) {
+                    ++i;
+                    if (i >= item->num_glyphs)
+                        break;
+                }
+                item->glyphs[j] = item->glyphs[i];
+                item->attributes[j] = item->attributes[i];
+                ++i;
+                ++j;
+            }
+            item->num_glyphs = j;
+        }
+
+    } else {
+        HB_HeuristicPosition(item);
+    }
+#endif // NO_OPENTYPE
+    item->attributes[0].clusterStart = true;
+
+    HB_FREE_STACKARRAY(reordered);
+    HB_FREE_STACKARRAY(position);
+
+    IDEBUG("<<<<<<");
+    return true;
+
+error:
+    HB_FREE_STACKARRAY(reordered);
+    HB_FREE_STACKARRAY(position);
+    return false;
+}
+
+/* syllables are of the form:
+
+   (Consonant Nukta? Halant)* Consonant Matra? VowelMark? StressMark?
+   (Consonant Nukta? Halant)* Consonant Halant
+   IndependentVowel VowelMark? StressMark?
+
+   We return syllable boundaries on invalid combinations aswell
+*/
+/* SAMSUNG - Kaja Changes -Start */
+int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+//static int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+/* SAMSUNG - Kaja Changes -End */
+{
+    *invalid = false;
+    IDEBUG("indic_nextSyllableBoundary: start=%d, end=%d", start, end);
+    const HB_UChar16 *uc = s+start ;
+
+    int pos = 0;
+    Form state = form(uc[pos]);
+    IDEBUG("state[%d]=%d (uc=%4x)", pos, state, uc[pos]);
+    pos++;
+
+    if (state != Consonant && state != IndependentVowel) {
+        if (state != Other)
+            *invalid = true;
+        goto finish;
+    }
+
+    while (pos < end - start) {
+        Form newState = form(uc[pos]);
+        IDEBUG("state[%d]=%d (uc=%4x)", pos, newState, uc[pos]);
+        switch(newState) {
+        case Control:
+            newState = state;
+           if (state == Halant && uc[pos] == 0x200d /* ZWJ */)
+               break;
+            // the control character should be the last char in the item
+            ++pos;
+            goto finish;
+        case Consonant:
+           if (state == Halant && (script != HB_Script_Sinhala || uc[pos-1] == 0x200d /* ZWJ */))
+                break;
+            goto finish;
+        case Halant:
+            if (state == Nukta || state == Consonant)
+                break;
+            // Bengali has a special exception allowing the combination Vowel_A/E + Halant + Ya
+            if (script == HB_Script_Bengali && pos == 1 &&
+                 (uc[0] == 0x0985 || uc[0] == 0x098f))
+                break;
+            // Sinhala uses the Halant as a component of certain matras. Allow these, but keep the state on Matra.
+            if (script == HB_Script_Sinhala && state == Matra) {
+                ++pos;
+                continue;
+            }
+            if (script == HB_Script_Malayalam && state == Matra && uc[pos-1] == 0x0d41) {
+                ++pos;
+                continue;
+            }
+            goto finish;
+        case Nukta:
+            if (state == Consonant)
+                break;
+            goto finish;
+        case StressMark:
+            if (state == VowelMark)
+                break;
+            // fall through
+        case VowelMark:
+            if (state == Matra || state == LengthMark || state == IndependentVowel)
+                break;
+            // fall through
+        case Matra:
+            if (state == Consonant || state == Nukta)
+                break;
+            if (state == Matra) {
+                // ### needs proper testing for correct two/three part matras
+                break;
+            }
+            // ### not sure if this is correct. If it is, does it apply only to Bengali or should
+            // it work for all Indic languages?
+            // the combination Independent_A + Vowel Sign AA is allowed.
+            if (script == HB_Script_Bengali && uc[pos] == 0x9be && uc[pos-1] == 0x985)
+                break;
+            if (script == HB_Script_Tamil && state == Matra) {
+                if (uc[pos-1] == 0x0bc6 &&
+                     (uc[pos] == 0xbbe || uc[pos] == 0xbd7))
+                    break;
+                if (uc[pos-1] == 0x0bc7 && uc[pos] == 0xbbe)
+                    break;
+            }
+            goto finish;
+
+        case LengthMark:
+            if (state == Matra) {
+                // ### needs proper testing for correct two/three part matras
+                break;
+            }
+        case IndependentVowel:
+        case Invalid:
+        case Other:
+            goto finish;
+        }
+        state = newState;
+        pos++;
+    }
+ finish:
+    return pos+start;
+}
+
+HB_Bool HB_IndicShape(HB_ShaperItem *item)
+{
+    assert(item->item.script >= HB_Script_Devanagari && item->item.script <= HB_Script_Sinhala);
+
+    HB_Bool openType = false;
+#ifndef NO_OPENTYPE
+    openType = HB_SelectScript(item, indic_features);
+#endif
+    unsigned short *logClusters = item->log_clusters;
+
+    HB_ShaperItem syllable = *item;
+    int first_glyph = 0;
+
+    int sstart = item->item.pos;
+    int end = sstart + item->item.length;
+    IDEBUG("indic_shape: from %d length %d", item->item.pos, item->item.length);
+    while (sstart < end) {
+        HB_Bool invalid;
+        int send = indic_nextSyllableBoundary(item->item.script, item->string, sstart, end, &invalid);
+        IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,
+               invalid ? "true" : "false");
+        syllable.item.pos = sstart;
+        syllable.item.length = send-sstart;
+        syllable.glyphs = item->glyphs + first_glyph;
+        syllable.attributes = item->attributes + first_glyph;
+        syllable.offsets = item->offsets + first_glyph;
+        syllable.advances = item->advances + first_glyph;
+        syllable.num_glyphs = item->num_glyphs - first_glyph;
+        if (!indic_shape_syllable(openType, &syllable, invalid)) {
+            IDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);
+            item->num_glyphs += syllable.num_glyphs;
+            return false;
+        }
+        // fix logcluster array
+        IDEBUG("syllable:");
+        hb_uint32 g;
+        for (g = first_glyph; g < first_glyph + syllable.num_glyphs; ++g)
+            IDEBUG("        %d -> glyph %x", g, item->glyphs[g]);
+        IDEBUG("    logclusters:");
+        int i;
+        for (i = sstart; i < send; ++i) {
+            IDEBUG("        %d -> glyph %d", i, first_glyph);
+            logClusters[i-item->item.pos] = first_glyph;
+        }
+        sstart = send;
+        first_glyph += syllable.num_glyphs;
+    }
+    item->num_glyphs = first_glyph;
+    return true;
+}
+
+void HB_IndicAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    int end = from + len;
+    const HB_UChar16 *uc = text + from;
+    attributes += from;
+    hb_uint32 i = 0;
+    while (i < len) {
+        HB_Bool invalid;
+        hb_uint32 boundary = indic_nextSyllableBoundary(script, text, from+i, end, &invalid) - from;
+         attributes[i].charStop = true;
+
+        if (boundary > len-1) boundary = len;
+        i++;
+        while (i < boundary) {
+            attributes[i].charStop = false;
+            ++uc;
+            ++i;
+        }
+        assert(i == boundary);
+    }
+
+
+}
+
+
index 6faa22b..d9bc795 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-#include <stdio.h>\r
-\r
-/*\r
-//  Vocabulary\r
-//      Base ->         A consonant or an independent vowel in its full (not subscript) form. It is the\r
-//                      center of the syllable, it can be surrounded by coeng (subscript) consonants, vowels,\r
-//                      split vowels, signs... but there is only one base in a syllable, it has to be coded as\r
-//                      the first character of the syllable.\r
-//      split vowel --> vowel that has two parts placed separately (e.g. Before and after the consonant).\r
-//                      Khmer language has five of them. Khmer split vowels either have one part before the\r
-//                      base and one after the base or they have a part before the base and a part above the base.\r
-//                      The first part of all Khmer split vowels is the same character, identical to\r
-//                      the glyph of Khmer dependent vowel SRA EI\r
-//      coeng -->  modifier used in Khmer to construct coeng (subscript) consonants\r
-//                 Differently than indian languages, the coeng modifies the consonant that follows it,\r
-//                 not the one preceding it  Each consonant has two forms, the base form and the subscript form\r
-//                 the base form is the normal one (using the consonants code-point), the subscript form is\r
-//                 displayed when the combination coeng + consonant is encountered.\r
-//      Consonant of type 1 -> A consonant which has subscript for that only occupies space under a base consonant\r
-//      Consonant of type 2.-> Its subscript form occupies space under and before the base (only one, RO)\r
-//      Consonant of Type 3 -> Its subscript form occupies space under and after the base (KHO, CHHO, THHO, BA, YO, SA)\r
-//      Consonant shifter -> Khmer has to series of consonants. The same dependent vowel has different sounds\r
-//                           if it is attached to a consonant of the first series or a consonant of the second series\r
-//                           Most consonants have an equivalent in the other series, but some of theme exist only in\r
-//                           one series (for example SA). If we want to use the consonant SA with a vowel sound that\r
-//                           can only be done with a vowel sound that corresponds to a vowel accompanying a consonant\r
-//                           of the other series, then we need to use a consonant shifter: TRIISAP or MUSIKATOAN\r
-//                           x17C9 y x17CA. TRIISAP changes a first series consonant to second series sound and\r
-//                           MUSIKATOAN a second series consonant to have a first series vowel sound.\r
-//                           Consonant shifter are both normally supercript marks, but, when they are followed by a\r
-//                           superscript, they change shape and take the form of subscript dependent vowel SRA U.\r
-//                           If they are in the same syllable as a coeng consonant, Unicode 3.0 says that they\r
-//                           should be typed before the coeng. Unicode 4.0 breaks the standard and says that it should\r
-//                           be placed after the coeng consonant.\r
-//      Dependent vowel ->   In khmer dependent vowels can be placed above, below, before or after the base\r
-//                           Each vowel has its own position. Only one vowel per syllable is allowed.\r
-//      Signs            ->  Khmer has above signs and post signs. Only one above sign and/or one post sign are\r
-//                           Allowed in a syllable.\r
-//\r
-//\r
-//   order is important here! This order must be the same that is found in each horizontal\r
-//   line in the statetable for Khmer (see khmerStateTable) .\r
-*/\r
-enum KhmerCharClassValues {\r
-    CC_RESERVED             =  0,\r
-    CC_CONSONANT            =  1, /* Consonant of type 1 or independent vowel */\r
-    CC_CONSONANT2           =  2, /* Consonant of type 2 */\r
-    CC_CONSONANT3           =  3, /* Consonant of type 3 */\r
-    CC_ZERO_WIDTH_NJ_MARK   =  4, /* Zero Width non joiner character (0x200C) */\r
-    CC_CONSONANT_SHIFTER    =  5,\r
-    CC_ROBAT                =  6, /* Khmer special diacritic accent -treated differently in state table */\r
-    CC_COENG                =  7, /* Subscript consonant combining character */\r
-    CC_DEPENDENT_VOWEL      =  8,\r
-    CC_SIGN_ABOVE           =  9,\r
-    CC_SIGN_AFTER           = 10,\r
-    CC_ZERO_WIDTH_J_MARK    = 11, /* Zero width joiner character */\r
-    CC_COUNT                = 12  /* This is the number of character classes */\r
-};\r
-\r
-\r
-enum KhmerCharClassFlags {\r
-    CF_CLASS_MASK    = 0x0000FFFF,\r
-\r
-    CF_CONSONANT     = 0x01000000,  /* flag to speed up comparing */\r
-    CF_SPLIT_VOWEL   = 0x02000000,  /* flag for a split vowel -> the first part is added in front of the syllable */\r
-    CF_DOTTED_CIRCLE = 0x04000000,  /* add a dotted circle if a character with this flag is the first in a syllable */\r
-    CF_COENG         = 0x08000000,  /* flag to speed up comparing */\r
-    CF_SHIFTER       = 0x10000000,  /* flag to speed up comparing */\r
-    CF_ABOVE_VOWEL   = 0x20000000,  /* flag to speed up comparing */\r
-\r
-    /* position flags */\r
-    CF_POS_BEFORE    = 0x00080000,\r
-    CF_POS_BELOW     = 0x00040000,\r
-    CF_POS_ABOVE     = 0x00020000,\r
-    CF_POS_AFTER     = 0x00010000,\r
-    CF_POS_MASK      = 0x000f0000\r
-};\r
-\r
-\r
-/* Characters that get referred to by name */\r
-enum KhmerChar {\r
-    C_SIGN_ZWNJ     = 0x200C,\r
-    C_SIGN_ZWJ      = 0x200D,\r
-    C_RO            = 0x179A,\r
-    C_VOWEL_AA      = 0x17B6,\r
-    C_SIGN_NIKAHIT  = 0x17C6,\r
-    C_VOWEL_E       = 0x17C1,\r
-    C_COENG         = 0x17D2\r
-};\r
-\r
-\r
-/*\r
-//  simple classes, they are used in the statetable (in this file) to control the length of a syllable\r
-//  they are also used to know where a character should be placed (location in reference to the base character)\r
-//  and also to know if a character, when independently displayed, should be displayed with a dotted-circle to\r
-//  indicate error in syllable construction\r
-*/\r
-enum {\r
-    _xx = CC_RESERVED,\r
-    _sa = CC_SIGN_ABOVE | CF_DOTTED_CIRCLE | CF_POS_ABOVE,\r
-    _sp = CC_SIGN_AFTER | CF_DOTTED_CIRCLE| CF_POS_AFTER,\r
-    _c1 = CC_CONSONANT | CF_CONSONANT,\r
-    _c2 = CC_CONSONANT2 | CF_CONSONANT,\r
-    _c3 = CC_CONSONANT3 | CF_CONSONANT,\r
-    _rb = CC_ROBAT | CF_POS_ABOVE | CF_DOTTED_CIRCLE,\r
-    _cs = CC_CONSONANT_SHIFTER | CF_DOTTED_CIRCLE | CF_SHIFTER,\r
-    _dl = CC_DEPENDENT_VOWEL | CF_POS_BEFORE | CF_DOTTED_CIRCLE,\r
-    _db = CC_DEPENDENT_VOWEL | CF_POS_BELOW | CF_DOTTED_CIRCLE,\r
-    _da = CC_DEPENDENT_VOWEL | CF_POS_ABOVE | CF_DOTTED_CIRCLE | CF_ABOVE_VOWEL,\r
-    _dr = CC_DEPENDENT_VOWEL | CF_POS_AFTER | CF_DOTTED_CIRCLE,\r
-    _co = CC_COENG | CF_COENG | CF_DOTTED_CIRCLE,\r
-\r
-    /* split vowel */\r
-    _va = _da | CF_SPLIT_VOWEL,\r
-    _vr = _dr | CF_SPLIT_VOWEL\r
-};\r
-\r
-\r
-/*\r
-//   Character class: a character class value\r
-//   ORed with character class flags.\r
-*/\r
-typedef unsigned long KhmerCharClass;\r
-\r
-\r
-/*\r
-//  Character class tables\r
-//  _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs...\r
-//  _sa Sign placed above the base\r
-//  _sp Sign placed after the base\r
-//  _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants)\r
-//  _c2 Consonant of type 2 (only RO)\r
-//  _c3 Consonant of type 3\r
-//  _rb Khmer sign robat u17CC. combining mark for subscript consonants\r
-//  _cd Consonant-shifter\r
-//  _dl Dependent vowel placed before the base (left of the base)\r
-//  _db Dependent vowel placed below the base\r
-//  _da Dependent vowel placed above the base\r
-//  _dr Dependent vowel placed behind the base (right of the base)\r
-//  _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following\r
-//      it to create a subscript consonant or independent vowel\r
-//  _va Khmer split vowel in which the first part is before the base and the second one above the base\r
-//  _vr Khmer split vowel in which the first part is before the base and the second one behind (right of) the base\r
-*/\r
-static const KhmerCharClass khmerCharClasses[] = {\r
-    _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, /* 1780 - 178F */\r
-    _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c2, _c1, _c1, _c1, _c3, _c3, /* 1790 - 179F */\r
-    _c1, _c3, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, /* 17A0 - 17AF */\r
-    _c1, _c1, _c1, _c1, _dr, _dr, _dr, _da, _da, _da, _da, _db, _db, _db, _va, _vr, /* 17B0 - 17BF */\r
-    _vr, _dl, _dl, _dl, _vr, _vr, _sa, _sp, _sp, _cs, _cs, _sa, _rb, _sa, _sa, _sa, /* 17C0 - 17CF */\r
-    _sa, _sa, _co, _sa, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _sa, _xx, _xx  /* 17D0 - 17DF */\r
-};\r
-\r
-/* this enum must reflect the range of khmerCharClasses */\r
-enum KhmerCharClassesRange {\r
-    KhmerFirstChar = 0x1780,\r
-    KhmerLastChar  = 0x17df\r
-};\r
-\r
-/*\r
-//  Below we define how a character in the input string is either in the khmerCharClasses table\r
-//  (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear\r
-//  within the syllable, but are not in the table) we also get their type back, or an unknown object\r
-//  in which case we get _xx (CC_RESERVED) back\r
-*/\r
-static KhmerCharClass getKhmerCharClass(HB_UChar16 uc)\r
-{\r
-    if (uc == C_SIGN_ZWJ) {\r
-        return CC_ZERO_WIDTH_J_MARK;\r
-    }\r
-\r
-    if (uc == C_SIGN_ZWNJ) {\r
-        return CC_ZERO_WIDTH_NJ_MARK;\r
-    }\r
-\r
-    if (uc < KhmerFirstChar || uc > KhmerLastChar) {\r
-        return CC_RESERVED;\r
-    }\r
-\r
-    return khmerCharClasses[uc - KhmerFirstChar];\r
-}\r
-\r
-\r
-/*\r
-//  The stateTable is used to calculate the end (the length) of a well\r
-//  formed Khmer Syllable.\r
-//\r
-//  Each horizontal line is ordered exactly the same way as the values in KhmerClassTable\r
-//  CharClassValues. This coincidence of values allows the follow up of the table.\r
-//\r
-//  Each line corresponds to a state, which does not necessarily need to be a type\r
-//  of component... for example, state 2 is a base, with is always a first character\r
-//  in the syllable, but the state could be produced a consonant of any type when\r
-//  it is the first character that is analysed (in ground state).\r
-//\r
-//  Differentiating 3 types of consonants is necessary in order to\r
-//  forbid the use of certain combinations, such as having a second\r
-//  coeng after a coeng RO,\r
-//  The inexistent possibility of having a type 3 after another type 3 is permitted,\r
-//  eliminating it would very much complicate the table, and it does not create typing\r
-//  problems, as the case above.\r
-//\r
-//  The table is quite complex, in order to limit the number of coeng consonants\r
-//  to 2 (by means of the table).\r
-//\r
-//  There a peculiarity, as far as Unicode is concerned:\r
-//  - The consonant-shifter is considered in two possible different\r
-//    locations, the one considered in Unicode 3.0 and the one considered in\r
-//    Unicode 4.0. (there is a backwards compatibility problem in this standard).\r
-//\r
-//\r
-//  xx    independent character, such as a number, punctuation sign or non-khmer char\r
-//\r
-//  c1    Khmer consonant of type 1 or an independent vowel\r
-//        that is, a letter in which the subscript for is only under the\r
-//        base, not taking any space to the right or to the left\r
-//\r
-//  c2    Khmer consonant of type 2, the coeng form takes space under\r
-//        and to the left of the base (only RO is of this type)\r
-//\r
-//  c3    Khmer consonant of type 3. Its subscript form takes space under\r
-//        and to the right of the base.\r
-//\r
-//  cs    Khmer consonant shifter\r
-//\r
-//  rb    Khmer robat\r
-//\r
-//  co    coeng character (u17D2)\r
-//\r
-//  dv    dependent vowel (including split vowels, they are treated in the same way).\r
-//        even if dv is not defined above, the component that is really tested for is\r
-//        KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels\r
-//\r
-//  zwj   Zero Width joiner\r
-//\r
-//  zwnj  Zero width non joiner\r
-//\r
-//  sa    above sign\r
-//\r
-//  sp    post sign\r
-//\r
-//  there are lines with equal content but for an easier understanding\r
-//  (and maybe change in the future) we did not join them\r
-*/\r
-static const signed char khmerStateTable[][CC_COUNT] =\r
-{\r
-    /* xx  c1  c2  c3 zwnj cs  rb  co  dv  sa  sp zwj */\r
-    { 1,  2,  2,  2,  1,  1,  1,  6,  1,  1,  1,  2}, /*  0 - ground state */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  1 - exit state (or sign to the right of the syllable) */\r
-    {-1, -1, -1, -1,  3,  4,  5,  6, 16, 17,  1, -1}, /*  2 - Base consonant */\r
-    {-1, -1, -1, -1, -1,  4, -1, -1, 16, -1, -1, -1}, /*  3 - First ZWNJ before a register shifter It can only be followed by a shifter or a vowel */\r
-    {-1, -1, -1, -1, 15, -1, -1,  6, 16, 17,  1, 14}, /*  4 - First register shifter */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, 20, -1,  1, -1}, /*  5 - Robat */\r
-    {-1,  7,  8,  9, -1, -1, -1, -1, -1, -1, -1, -1}, /*  6 - First Coeng */\r
-    {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17,  1, 14}, /*  7 - First consonant of type 1 after coeng */\r
-    {-1, -1, -1, -1, 12, 13, -1, -1, 16, 17,  1, 14}, /*  8 - First consonant of type 2 after coeng */\r
-    {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17,  1, 14}, /*  9 - First consonant or type 3 after ceong */\r
-    {-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, /* 10 - Second Coeng (no register shifter before) */\r
-    {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17,  1, 14}, /* 11 - Second coeng consonant (or ind. vowel) no register shifter before */\r
-    {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, /* 12 - Second ZWNJ before a register shifter */\r
-    {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17,  1, 14}, /* 13 - Second register shifter */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 14 - ZWJ before vowel */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 15 - ZWNJ before vowel */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17,  1, 18}, /* 16 - dependent vowel */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, 18}, /* 17 - sign above */\r
-    {-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, /* 18 - ZWJ after vowel */\r
-    {-1,  1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 19 - Third coeng */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, -1}, /* 20 - dependent vowel after a Robat */\r
-};\r
-\r
-\r
-/*  #define KHMER_DEBUG */\r
-#ifdef KHMER_DEBUG\r
-#define KHDEBUG qDebug\r
-#else\r
-#define KHDEBUG if(0) printf\r
-#endif\r
-\r
-/*\r
-//  Given an input string of characters and a location in which to start looking\r
-//  calculate, using the state table, which one is the last character of the syllable\r
-//  that starts in the starting position.\r
-*/\r
-/* SAMSUNG - Kaja Changes -Start */\r
-//static int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-/* SAMSUNG - Kaja Changes -End */\r
-{\r
-    const HB_UChar16 *uc = s + start;\r
-    int state = 0;\r
-    int pos = start;\r
-    *invalid = FALSE;\r
-\r
-    while (pos < end) {\r
-        KhmerCharClass charClass = getKhmerCharClass(*uc);\r
-        if (pos == start) {\r
-            *invalid = (charClass > 0) && ! (charClass & CF_CONSONANT);\r
-        }\r
-        state = khmerStateTable[state][charClass & CF_CLASS_MASK];\r
-\r
-        KHDEBUG("state[%d]=%d class=%8lx (uc=%4x)", pos - start, state,\r
-                charClass, *uc );\r
-\r
-        if (state < 0) {\r
-            break;\r
-        }\r
-        ++uc;\r
-        ++pos;\r
-    }\r
-    return pos;\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-static const HB_OpenTypeFeature khmer_features[] = {\r
-    { HB_MAKE_TAG( 'p', 'r', 'e', 'f' ), PreFormProperty },\r
-    { HB_MAKE_TAG( 'b', 'l', 'w', 'f' ), BelowFormProperty },\r
-    { HB_MAKE_TAG( 'a', 'b', 'v', 'f' ), AboveFormProperty },\r
-    { HB_MAKE_TAG( 'p', 's', 't', 'f' ), PostFormProperty },\r
-    { HB_MAKE_TAG( 'p', 'r', 'e', 's' ), PreSubstProperty },\r
-    { HB_MAKE_TAG( 'b', 'l', 'w', 's' ), BelowSubstProperty },\r
-    { HB_MAKE_TAG( 'a', 'b', 'v', 's' ), AboveSubstProperty },\r
-    { HB_MAKE_TAG( 'p', 's', 't', 's' ), PostSubstProperty },\r
-    { HB_MAKE_TAG( 'c', 'l', 'i', 'g' ), CligProperty },\r
-    { 0, 0 }\r
-};\r
-#endif\r
-\r
-\r
-static HB_Bool khmer_shape_syllable(HB_Bool openType, HB_ShaperItem *item)\r
-{\r
-/*    KHDEBUG("syllable from %d len %d, str='%s'", item->from, item->length,\r
-           item->string->mid(item->from, item->length).toUtf8().data()); */\r
-\r
-    int len = 0;\r
-    int syllableEnd = item->item.pos + item->item.length;\r
-    unsigned short reordered[16];\r
-    unsigned char properties[16];\r
-    enum {\r
-       AboveForm = 0x01,\r
-       PreForm = 0x02,\r
-       PostForm = 0x04,\r
-       BelowForm = 0x08\r
-    };\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = item->num_glyphs;\r
-#endif\r
-    int coengRo;\r
-    int i;\r
-\r
-    /* according to the specs this is the max length one can get\r
-       ### the real value should be smaller */\r
-    assert(item->item.length < 13);\r
-\r
-    memset(properties, 0, 16*sizeof(unsigned char));\r
-\r
-#ifdef KHMER_DEBUG\r
-    qDebug("original:");\r
-    for (int i = from; i < syllableEnd; i++) {\r
-        qDebug("    %d: %4x", i, string[i]);\r
-    }\r
-#endif\r
-\r
-    /*\r
-    // write a pre vowel or the pre part of a split vowel first\r
-    // and look out for coeng + ro. RO is the only vowel of type 2, and\r
-    // therefore the only one that requires saving space before the base.\r
-    */\r
-    coengRo = -1;  /* There is no Coeng Ro, if found this value will change */\r
-    for (i = item->item.pos; i < syllableEnd; i += 1) {\r
-        KhmerCharClass charClass = getKhmerCharClass(item->string[i]);\r
-\r
-        /* if a split vowel, write the pre part. In Khmer the pre part\r
-           is the same for all split vowels, same glyph as pre vowel C_VOWEL_E */\r
-        if (charClass & CF_SPLIT_VOWEL) {\r
-            reordered[len] = C_VOWEL_E;\r
-            properties[len] = PreForm;\r
-            ++len;\r
-            break; /* there can be only one vowel */\r
-        }\r
-        /* if a vowel with pos before write it out */\r
-        if (charClass & CF_POS_BEFORE) {\r
-            reordered[len] = item->string[i];\r
-            properties[len] = PreForm;\r
-            ++len;\r
-            break; /* there can be only one vowel */\r
-        }\r
-        /* look for coeng + ro and remember position\r
-           works because coeng + ro is always in front of a vowel (if there is a vowel)\r
-           and because CC_CONSONANT2 is enough to identify it, as it is the only consonant\r
-           with this flag */\r
-        if ( (charClass & CF_COENG) && (i + 1 < syllableEnd) &&\r
-              ( (getKhmerCharClass(item->string[i+1]) & CF_CLASS_MASK) == CC_CONSONANT2) ) {\r
-            coengRo = i;\r
-        }\r
-    }\r
-\r
-    /* write coeng + ro if found */\r
-    if (coengRo > -1) {\r
-        reordered[len] = C_COENG;\r
-        properties[len] = PreForm;\r
-        ++len;\r
-        reordered[len] = C_RO;\r
-        properties[len] = PreForm;\r
-        ++len;\r
-    }\r
-\r
-    /*\r
-       shall we add a dotted circle?\r
-       If in the position in which the base should be (first char in the string) there is\r
-       a character that has the Dotted circle flag (a character that cannot be a base)\r
-       then write a dotted circle */\r
-    if (getKhmerCharClass(item->string[item->item.pos]) & CF_DOTTED_CIRCLE) {\r
-        reordered[len] = C_DOTTED_CIRCLE;\r
-        ++len;\r
-    }\r
-\r
-    /* copy what is left to the output, skipping before vowels and\r
-       coeng Ro if they are present */\r
-    for (i = item->item.pos; i < syllableEnd; i += 1) {\r
-        HB_UChar16 uc = item->string[i];\r
-        KhmerCharClass charClass = getKhmerCharClass(uc);\r
-\r
-        /* skip a before vowel, it was already processed */\r
-        if (charClass & CF_POS_BEFORE) {\r
-            continue;\r
-        }\r
-\r
-        /* skip coeng + ro, it was already processed */\r
-        if (i == coengRo) {\r
-            i += 1;\r
-            continue;\r
-        }\r
-\r
-        switch (charClass & CF_POS_MASK)\r
-        {\r
-            case CF_POS_ABOVE :\r
-                reordered[len] = uc;\r
-                properties[len] = AboveForm;\r
-                ++len;\r
-                break;\r
-\r
-            case CF_POS_AFTER :\r
-                reordered[len] = uc;\r
-                properties[len] = PostForm;\r
-                ++len;\r
-                break;\r
-\r
-            case CF_POS_BELOW :\r
-                reordered[len] = uc;\r
-                properties[len] = BelowForm;\r
-                ++len;\r
-                break;\r
-\r
-            default:\r
-                /* assign the correct flags to a coeng consonant\r
-                   Consonants of type 3 are taged as Post forms and those type 1 as below forms */\r
-                if ( (charClass & CF_COENG) && i + 1 < syllableEnd ) {\r
-                    unsigned char property = (getKhmerCharClass(item->string[i+1]) & CF_CLASS_MASK) == CC_CONSONANT3 ?\r
-                                              PostForm : BelowForm;\r
-                    reordered[len] = uc;\r
-                    properties[len] = property;\r
-                    ++len;\r
-                    i += 1;\r
-                    reordered[len] = item->string[i];\r
-                    properties[len] = property;\r
-                    ++len;\r
-                    break;\r
-                }\r
-\r
-                /* if a shifter is followed by an above vowel change the shifter to below form,\r
-                   an above vowel can have two possible positions i + 1 or i + 3\r
-                   (position i+1 corresponds to unicode 3, position i+3 to Unicode 4)\r
-                   and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two\r
-                   different positions, right after the shifter or after a vowel (Unicode 4) */\r
-                if ( (charClass & CF_SHIFTER) && (i + 1 < syllableEnd) ) {\r
-                    if (getKhmerCharClass(item->string[i+1]) & CF_ABOVE_VOWEL ) {\r
-                        reordered[len] = uc;\r
-                        properties[len] = BelowForm;\r
-                        ++len;\r
-                        break;\r
-                    }\r
-                    if (i + 2 < syllableEnd &&\r
-                        (item->string[i+1] == C_VOWEL_AA) &&\r
-                        (item->string[i+2] == C_SIGN_NIKAHIT) )\r
-                    {\r
-                        reordered[len] = uc;\r
-                        properties[len] = BelowForm;\r
-                        ++len;\r
-                        break;\r
-                    }\r
-                    if (i + 3 < syllableEnd && (getKhmerCharClass(item->string[i+3]) & CF_ABOVE_VOWEL) ) {\r
-                        reordered[len] = uc;\r
-                        properties[len] = BelowForm;\r
-                        ++len;\r
-                        break;\r
-                    }\r
-                    if (i + 4 < syllableEnd &&\r
-                        (item->string[i+3] == C_VOWEL_AA) &&\r
-                        (item->string[i+4] == C_SIGN_NIKAHIT) )\r
-                    {\r
-                        reordered[len] = uc;\r
-                        properties[len] = BelowForm;\r
-                        ++len;\r
-                        break;\r
-                    }\r
-                }\r
-\r
-                /* default - any other characters */\r
-                reordered[len] = uc;\r
-                ++len;\r
-                break;\r
-        } /* switch */\r
-    } /* for */\r
-\r
-    if (!item->font->klass->convertStringToGlyphIndices(item->font,\r
-                                                        reordered, len,\r
-                                                        item->glyphs, &item->num_glyphs,\r
-                                                        item->item.bidiLevel % 2))\r
-        return FALSE;\r
-\r
-\r
-    KHDEBUG("after shaping: len=%d", len);\r
-    for (i = 0; i < len; i++) {\r
-       item->attributes[i].mark = FALSE;\r
-       item->attributes[i].clusterStart = FALSE;\r
-       item->attributes[i].justification = 0;\r
-       item->attributes[i].zeroWidth = FALSE;\r
-       KHDEBUG("    %d: %4x property=%x", i, reordered[i], properties[i]);\r
-    }\r
-\r
-    /* now we have the syllable in the right order, and can start running it through open type. */\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (openType) {\r
-       hb_uint32 where[16];\r
-        for (i = 0; i < len; ++i) {\r
-            where[i] = ~(PreSubstProperty\r
-                         | BelowSubstProperty\r
-                         | AboveSubstProperty\r
-                         | PostSubstProperty\r
-                         | CligProperty\r
-                         | PositioningProperties);\r
-            if (properties[i] == PreForm)\r
-                where[i] &= ~PreFormProperty;\r
-            else if (properties[i] == BelowForm)\r
-                where[i] &= ~BelowFormProperty;\r
-            else if (properties[i] == AboveForm)\r
-                where[i] &= ~AboveFormProperty;\r
-            else if (properties[i] == PostForm)\r
-                where[i] &= ~PostFormProperty;\r
-        }\r
-\r
-        HB_OpenTypeShape(item, where);\r
-        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))\r
-            return FALSE;\r
-    } else\r
-#endif\r
-    {\r
-       KHDEBUG("Not using openType");\r
-        HB_HeuristicPosition(item);\r
-    }\r
-\r
-    item->attributes[0].clusterStart = TRUE;\r
-    return TRUE;\r
-}\r
-\r
-HB_Bool HB_KhmerShape(HB_ShaperItem *item)\r
-{\r
-    HB_Bool openType = FALSE;\r
-    unsigned short *logClusters = item->log_clusters;\r
-    int i;\r
-\r
-    HB_ShaperItem syllable = *item;\r
-    int first_glyph = 0;\r
-\r
-    int sstart = item->item.pos;\r
-    int end = sstart + item->item.length;\r
-\r
-    assert(item->item.script == HB_Script_Khmer);\r
-\r
-#ifndef NO_OPENTYPE\r
-    openType = HB_SelectScript(item, khmer_features);\r
-#endif\r
-\r
-    KHDEBUG("khmer_shape: from %d length %d", item->item.pos, item->item.length);\r
-    while (sstart < end) {\r
-        HB_Bool invalid;\r
-        int send = khmer_nextSyllableBoundary(item->string, sstart, end, &invalid);\r
-        KHDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,\r
-               invalid ? "TRUE" : "FALSE");\r
-        syllable.item.pos = sstart;\r
-        syllable.item.length = send-sstart;\r
-        syllable.glyphs = item->glyphs + first_glyph;\r
-        syllable.attributes = item->attributes + first_glyph;\r
-        syllable.offsets = item->offsets + first_glyph;\r
-        syllable.advances = item->advances + first_glyph;\r
-        syllable.num_glyphs = item->num_glyphs - first_glyph;\r
-        if (!khmer_shape_syllable(openType, &syllable)) {\r
-            KHDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);\r
-            item->num_glyphs += syllable.num_glyphs;\r
-            return FALSE;\r
-        }\r
-        /* fix logcluster array */\r
-        KHDEBUG("syllable:");\r
-        for (i = first_glyph; i < first_glyph + (int)syllable.num_glyphs; ++i)\r
-            KHDEBUG("        %d -> glyph %x", i, item->glyphs[i]);\r
-        KHDEBUG("    logclusters:");\r
-        for (i = sstart; i < send; ++i) {\r
-            KHDEBUG("        %d -> glyph %d", i, first_glyph);\r
-            logClusters[i-item->item.pos] = first_glyph;\r
-        }\r
-        sstart = send;\r
-        first_glyph += syllable.num_glyphs;\r
-    }\r
-    item->num_glyphs = first_glyph;\r
-    return TRUE;\r
-}\r
-\r
-void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    int end = from + len;\r
-    const HB_UChar16 *uc = text + from;\r
-    hb_uint32 i = 0;\r
-    HB_UNUSED(script);\r
-    attributes += from;\r
-    while ( i < len ) {\r
-       HB_Bool invalid;\r
-       hb_uint32 boundary = khmer_nextSyllableBoundary( text, from+i, end, &invalid ) - from;\r
-\r
-       attributes[i].charStop = TRUE;\r
-\r
-       if ( boundary > len-1 ) boundary = len;\r
-       i++;\r
-       while ( i < boundary ) {\r
-           attributes[i].charStop = FALSE;\r
-           ++uc;\r
-           ++i;\r
-       }\r
-       assert( i == boundary );\r
-    }\r
-}\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+#include <stdio.h>
+
+/*
+//  Vocabulary
+//      Base ->         A consonant or an independent vowel in its full (not subscript) form. It is the
+//                      center of the syllable, it can be surrounded by coeng (subscript) consonants, vowels,
+//                      split vowels, signs... but there is only one base in a syllable, it has to be coded as
+//                      the first character of the syllable.
+//      split vowel --> vowel that has two parts placed separately (e.g. Before and after the consonant).
+//                      Khmer language has five of them. Khmer split vowels either have one part before the
+//                      base and one after the base or they have a part before the base and a part above the base.
+//                      The first part of all Khmer split vowels is the same character, identical to
+//                      the glyph of Khmer dependent vowel SRA EI
+//      coeng -->  modifier used in Khmer to construct coeng (subscript) consonants
+//                 Differently than indian languages, the coeng modifies the consonant that follows it,
+//                 not the one preceding it  Each consonant has two forms, the base form and the subscript form
+//                 the base form is the normal one (using the consonants code-point), the subscript form is
+//                 displayed when the combination coeng + consonant is encountered.
+//      Consonant of type 1 -> A consonant which has subscript for that only occupies space under a base consonant
+//      Consonant of type 2.-> Its subscript form occupies space under and before the base (only one, RO)
+//      Consonant of Type 3 -> Its subscript form occupies space under and after the base (KHO, CHHO, THHO, BA, YO, SA)
+//      Consonant shifter -> Khmer has to series of consonants. The same dependent vowel has different sounds
+//                           if it is attached to a consonant of the first series or a consonant of the second series
+//                           Most consonants have an equivalent in the other series, but some of theme exist only in
+//                           one series (for example SA). If we want to use the consonant SA with a vowel sound that
+//                           can only be done with a vowel sound that corresponds to a vowel accompanying a consonant
+//                           of the other series, then we need to use a consonant shifter: TRIISAP or MUSIKATOAN
+//                           x17C9 y x17CA. TRIISAP changes a first series consonant to second series sound and
+//                           MUSIKATOAN a second series consonant to have a first series vowel sound.
+//                           Consonant shifter are both normally supercript marks, but, when they are followed by a
+//                           superscript, they change shape and take the form of subscript dependent vowel SRA U.
+//                           If they are in the same syllable as a coeng consonant, Unicode 3.0 says that they
+//                           should be typed before the coeng. Unicode 4.0 breaks the standard and says that it should
+//                           be placed after the coeng consonant.
+//      Dependent vowel ->   In khmer dependent vowels can be placed above, below, before or after the base
+//                           Each vowel has its own position. Only one vowel per syllable is allowed.
+//      Signs            ->  Khmer has above signs and post signs. Only one above sign and/or one post sign are
+//                           Allowed in a syllable.
+//
+//
+//   order is important here! This order must be the same that is found in each horizontal
+//   line in the statetable for Khmer (see khmerStateTable) .
+*/
+enum KhmerCharClassValues {
+    CC_RESERVED             =  0,
+    CC_CONSONANT            =  1, /* Consonant of type 1 or independent vowel */
+    CC_CONSONANT2           =  2, /* Consonant of type 2 */
+    CC_CONSONANT3           =  3, /* Consonant of type 3 */
+    CC_ZERO_WIDTH_NJ_MARK   =  4, /* Zero Width non joiner character (0x200C) */
+    CC_CONSONANT_SHIFTER    =  5,
+    CC_ROBAT                =  6, /* Khmer special diacritic accent -treated differently in state table */
+    CC_COENG                =  7, /* Subscript consonant combining character */
+    CC_DEPENDENT_VOWEL      =  8,
+    CC_SIGN_ABOVE           =  9,
+    CC_SIGN_AFTER           = 10,
+    CC_ZERO_WIDTH_J_MARK    = 11, /* Zero width joiner character */
+    CC_COUNT                = 12  /* This is the number of character classes */
+};
+
+
+enum KhmerCharClassFlags {
+    CF_CLASS_MASK    = 0x0000FFFF,
+
+    CF_CONSONANT     = 0x01000000,  /* flag to speed up comparing */
+    CF_SPLIT_VOWEL   = 0x02000000,  /* flag for a split vowel -> the first part is added in front of the syllable */
+    CF_DOTTED_CIRCLE = 0x04000000,  /* add a dotted circle if a character with this flag is the first in a syllable */
+    CF_COENG         = 0x08000000,  /* flag to speed up comparing */
+    CF_SHIFTER       = 0x10000000,  /* flag to speed up comparing */
+    CF_ABOVE_VOWEL   = 0x20000000,  /* flag to speed up comparing */
+
+    /* position flags */
+    CF_POS_BEFORE    = 0x00080000,
+    CF_POS_BELOW     = 0x00040000,
+    CF_POS_ABOVE     = 0x00020000,
+    CF_POS_AFTER     = 0x00010000,
+    CF_POS_MASK      = 0x000f0000
+};
+
+
+/* Characters that get referred to by name */
+enum KhmerChar {
+    C_SIGN_ZWNJ     = 0x200C,
+    C_SIGN_ZWJ      = 0x200D,
+    C_RO            = 0x179A,
+    C_VOWEL_AA      = 0x17B6,
+    C_SIGN_NIKAHIT  = 0x17C6,
+    C_VOWEL_E       = 0x17C1,
+    C_COENG         = 0x17D2
+};
+
+
+/*
+//  simple classes, they are used in the statetable (in this file) to control the length of a syllable
+//  they are also used to know where a character should be placed (location in reference to the base character)
+//  and also to know if a character, when independently displayed, should be displayed with a dotted-circle to
+//  indicate error in syllable construction
+*/
+enum {
+    _xx = CC_RESERVED,
+    _sa = CC_SIGN_ABOVE | CF_DOTTED_CIRCLE | CF_POS_ABOVE,
+    _sp = CC_SIGN_AFTER | CF_DOTTED_CIRCLE| CF_POS_AFTER,
+    _c1 = CC_CONSONANT | CF_CONSONANT,
+    _c2 = CC_CONSONANT2 | CF_CONSONANT,
+    _c3 = CC_CONSONANT3 | CF_CONSONANT,
+    _rb = CC_ROBAT | CF_POS_ABOVE | CF_DOTTED_CIRCLE,
+    _cs = CC_CONSONANT_SHIFTER | CF_DOTTED_CIRCLE | CF_SHIFTER,
+    _dl = CC_DEPENDENT_VOWEL | CF_POS_BEFORE | CF_DOTTED_CIRCLE,
+    _db = CC_DEPENDENT_VOWEL | CF_POS_BELOW | CF_DOTTED_CIRCLE,
+    _da = CC_DEPENDENT_VOWEL | CF_POS_ABOVE | CF_DOTTED_CIRCLE | CF_ABOVE_VOWEL,
+    _dr = CC_DEPENDENT_VOWEL | CF_POS_AFTER | CF_DOTTED_CIRCLE,
+    _co = CC_COENG | CF_COENG | CF_DOTTED_CIRCLE,
+
+    /* split vowel */
+    _va = _da | CF_SPLIT_VOWEL,
+    _vr = _dr | CF_SPLIT_VOWEL
+};
+
+
+/*
+//   Character class: a character class value
+//   ORed with character class flags.
+*/
+typedef unsigned long KhmerCharClass;
+
+
+/*
+//  Character class tables
+//  _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs...
+//  _sa Sign placed above the base
+//  _sp Sign placed after the base
+//  _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants)
+//  _c2 Consonant of type 2 (only RO)
+//  _c3 Consonant of type 3
+//  _rb Khmer sign robat u17CC. combining mark for subscript consonants
+//  _cd Consonant-shifter
+//  _dl Dependent vowel placed before the base (left of the base)
+//  _db Dependent vowel placed below the base
+//  _da Dependent vowel placed above the base
+//  _dr Dependent vowel placed behind the base (right of the base)
+//  _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following
+//      it to create a subscript consonant or independent vowel
+//  _va Khmer split vowel in which the first part is before the base and the second one above the base
+//  _vr Khmer split vowel in which the first part is before the base and the second one behind (right of) the base
+*/
+static const KhmerCharClass khmerCharClasses[] = {
+    _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, /* 1780 - 178F */
+    _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c2, _c1, _c1, _c1, _c3, _c3, /* 1790 - 179F */
+    _c1, _c3, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, /* 17A0 - 17AF */
+    _c1, _c1, _c1, _c1, _dr, _dr, _dr, _da, _da, _da, _da, _db, _db, _db, _va, _vr, /* 17B0 - 17BF */
+    _vr, _dl, _dl, _dl, _vr, _vr, _sa, _sp, _sp, _cs, _cs, _sa, _rb, _sa, _sa, _sa, /* 17C0 - 17CF */
+    _sa, _sa, _co, _sa, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _sa, _xx, _xx  /* 17D0 - 17DF */
+};
+
+/* this enum must reflect the range of khmerCharClasses */
+enum KhmerCharClassesRange {
+    KhmerFirstChar = 0x1780,
+    KhmerLastChar  = 0x17df
+};
+
+/*
+//  Below we define how a character in the input string is either in the khmerCharClasses table
+//  (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear
+//  within the syllable, but are not in the table) we also get their type back, or an unknown object
+//  in which case we get _xx (CC_RESERVED) back
+*/
+static KhmerCharClass getKhmerCharClass(HB_UChar16 uc)
+{
+    if (uc == C_SIGN_ZWJ) {
+        return CC_ZERO_WIDTH_J_MARK;
+    }
+
+    if (uc == C_SIGN_ZWNJ) {
+        return CC_ZERO_WIDTH_NJ_MARK;
+    }
+
+    if (uc < KhmerFirstChar || uc > KhmerLastChar) {
+        return CC_RESERVED;
+    }
+
+    return khmerCharClasses[uc - KhmerFirstChar];
+}
+
+
+/*
+//  The stateTable is used to calculate the end (the length) of a well
+//  formed Khmer Syllable.
+//
+//  Each horizontal line is ordered exactly the same way as the values in KhmerClassTable
+//  CharClassValues. This coincidence of values allows the follow up of the table.
+//
+//  Each line corresponds to a state, which does not necessarily need to be a type
+//  of component... for example, state 2 is a base, with is always a first character
+//  in the syllable, but the state could be produced a consonant of any type when
+//  it is the first character that is analysed (in ground state).
+//
+//  Differentiating 3 types of consonants is necessary in order to
+//  forbid the use of certain combinations, such as having a second
+//  coeng after a coeng RO,
+//  The inexistent possibility of having a type 3 after another type 3 is permitted,
+//  eliminating it would very much complicate the table, and it does not create typing
+//  problems, as the case above.
+//
+//  The table is quite complex, in order to limit the number of coeng consonants
+//  to 2 (by means of the table).
+//
+//  There a peculiarity, as far as Unicode is concerned:
+//  - The consonant-shifter is considered in two possible different
+//    locations, the one considered in Unicode 3.0 and the one considered in
+//    Unicode 4.0. (there is a backwards compatibility problem in this standard).
+//
+//
+//  xx    independent character, such as a number, punctuation sign or non-khmer char
+//
+//  c1    Khmer consonant of type 1 or an independent vowel
+//        that is, a letter in which the subscript for is only under the
+//        base, not taking any space to the right or to the left
+//
+//  c2    Khmer consonant of type 2, the coeng form takes space under
+//        and to the left of the base (only RO is of this type)
+//
+//  c3    Khmer consonant of type 3. Its subscript form takes space under
+//        and to the right of the base.
+//
+//  cs    Khmer consonant shifter
+//
+//  rb    Khmer robat
+//
+//  co    coeng character (u17D2)
+//
+//  dv    dependent vowel (including split vowels, they are treated in the same way).
+//        even if dv is not defined above, the component that is really tested for is
+//        KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels
+//
+//  zwj   Zero Width joiner
+//
+//  zwnj  Zero width non joiner
+//
+//  sa    above sign
+//
+//  sp    post sign
+//
+//  there are lines with equal content but for an easier understanding
+//  (and maybe change in the future) we did not join them
+*/
+static const signed char khmerStateTable[][CC_COUNT] =
+{
+    /* xx  c1  c2  c3 zwnj cs  rb  co  dv  sa  sp zwj */
+    { 1,  2,  2,  2,  1,  1,  1,  6,  1,  1,  1,  2}, /*  0 - ground state */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  1 - exit state (or sign to the right of the syllable) */
+    {-1, -1, -1, -1,  3,  4,  5,  6, 16, 17,  1, -1}, /*  2 - Base consonant */
+    {-1, -1, -1, -1, -1,  4, -1, -1, 16, -1, -1, -1}, /*  3 - First ZWNJ before a register shifter It can only be followed by a shifter or a vowel */
+    {-1, -1, -1, -1, 15, -1, -1,  6, 16, 17,  1, 14}, /*  4 - First register shifter */
+    {-1, -1, -1, -1, -1, -1, -1, -1, 20, -1,  1, -1}, /*  5 - Robat */
+    {-1,  7,  8,  9, -1, -1, -1, -1, -1, -1, -1, -1}, /*  6 - First Coeng */
+    {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17,  1, 14}, /*  7 - First consonant of type 1 after coeng */
+    {-1, -1, -1, -1, 12, 13, -1, -1, 16, 17,  1, 14}, /*  8 - First consonant of type 2 after coeng */
+    {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17,  1, 14}, /*  9 - First consonant or type 3 after ceong */
+    {-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, /* 10 - Second Coeng (no register shifter before) */
+    {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17,  1, 14}, /* 11 - Second coeng consonant (or ind. vowel) no register shifter before */
+    {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, /* 12 - Second ZWNJ before a register shifter */
+    {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17,  1, 14}, /* 13 - Second register shifter */
+    {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 14 - ZWJ before vowel */
+    {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 15 - ZWNJ before vowel */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17,  1, 18}, /* 16 - dependent vowel */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, 18}, /* 17 - sign above */
+    {-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, /* 18 - ZWJ after vowel */
+    {-1,  1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 19 - Third coeng */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, -1}, /* 20 - dependent vowel after a Robat */
+};
+
+
+/*  #define KHMER_DEBUG */
+#ifdef KHMER_DEBUG
+#define KHDEBUG qDebug
+#else
+#define KHDEBUG if(0) printf
+#endif
+
+/*
+//  Given an input string of characters and a location in which to start looking
+//  calculate, using the state table, which one is the last character of the syllable
+//  that starts in the starting position.
+*/
+/* SAMSUNG - Kaja Changes -Start */
+//static int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+int khmer_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+/* SAMSUNG - Kaja Changes -End */
+{
+    const HB_UChar16 *uc = s + start;
+    int state = 0;
+    int pos = start;
+    *invalid = FALSE;
+
+    while (pos < end) {
+        KhmerCharClass charClass = getKhmerCharClass(*uc);
+        if (pos == start) {
+            *invalid = (charClass > 0) && ! (charClass & CF_CONSONANT);
+        }
+        state = khmerStateTable[state][charClass & CF_CLASS_MASK];
+
+        KHDEBUG("state[%d]=%d class=%8lx (uc=%4x)", pos - start, state,
+                charClass, *uc );
+
+        if (state < 0) {
+            break;
+        }
+        ++uc;
+        ++pos;
+    }
+    return pos;
+}
+
+#ifndef NO_OPENTYPE
+static const HB_OpenTypeFeature khmer_features[] = {
+    { HB_MAKE_TAG( 'p', 'r', 'e', 'f' ), PreFormProperty },
+    { HB_MAKE_TAG( 'b', 'l', 'w', 'f' ), BelowFormProperty },
+    { HB_MAKE_TAG( 'a', 'b', 'v', 'f' ), AboveFormProperty },
+    { HB_MAKE_TAG( 'p', 's', 't', 'f' ), PostFormProperty },
+    { HB_MAKE_TAG( 'p', 'r', 'e', 's' ), PreSubstProperty },
+    { HB_MAKE_TAG( 'b', 'l', 'w', 's' ), BelowSubstProperty },
+    { HB_MAKE_TAG( 'a', 'b', 'v', 's' ), AboveSubstProperty },
+    { HB_MAKE_TAG( 'p', 's', 't', 's' ), PostSubstProperty },
+    { HB_MAKE_TAG( 'c', 'l', 'i', 'g' ), CligProperty },
+    { 0, 0 }
+};
+#endif
+
+
+static HB_Bool khmer_shape_syllable(HB_Bool openType, HB_ShaperItem *item)
+{
+/*    KHDEBUG("syllable from %d len %d, str='%s'", item->from, item->length,
+           item->string->mid(item->from, item->length).toUtf8().data()); */
+
+    int len = 0;
+    int syllableEnd = item->item.pos + item->item.length;
+    unsigned short reordered[16];
+    unsigned char properties[16];
+    enum {
+       AboveForm = 0x01,
+       PreForm = 0x02,
+       PostForm = 0x04,
+       BelowForm = 0x08
+    };
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = item->num_glyphs;
+#endif
+    int coengRo;
+    int i;
+
+    /* according to the specs this is the max length one can get
+       ### the real value should be smaller */
+    assert(item->item.length < 13);
+
+    memset(properties, 0, 16*sizeof(unsigned char));
+
+#ifdef KHMER_DEBUG
+    qDebug("original:");
+    for (int i = from; i < syllableEnd; i++) {
+        qDebug("    %d: %4x", i, string[i]);
+    }
+#endif
+
+    /*
+    // write a pre vowel or the pre part of a split vowel first
+    // and look out for coeng + ro. RO is the only vowel of type 2, and
+    // therefore the only one that requires saving space before the base.
+    */
+    coengRo = -1;  /* There is no Coeng Ro, if found this value will change */
+    for (i = item->item.pos; i < syllableEnd; i += 1) {
+        KhmerCharClass charClass = getKhmerCharClass(item->string[i]);
+
+        /* if a split vowel, write the pre part. In Khmer the pre part
+           is the same for all split vowels, same glyph as pre vowel C_VOWEL_E */
+        if (charClass & CF_SPLIT_VOWEL) {
+            reordered[len] = C_VOWEL_E;
+            properties[len] = PreForm;
+            ++len;
+            break; /* there can be only one vowel */
+        }
+        /* if a vowel with pos before write it out */
+        if (charClass & CF_POS_BEFORE) {
+            reordered[len] = item->string[i];
+            properties[len] = PreForm;
+            ++len;
+            break; /* there can be only one vowel */
+        }
+        /* look for coeng + ro and remember position
+           works because coeng + ro is always in front of a vowel (if there is a vowel)
+           and because CC_CONSONANT2 is enough to identify it, as it is the only consonant
+           with this flag */
+        if ( (charClass & CF_COENG) && (i + 1 < syllableEnd) &&
+              ( (getKhmerCharClass(item->string[i+1]) & CF_CLASS_MASK) == CC_CONSONANT2) ) {
+            coengRo = i;
+        }
+    }
+
+    /* write coeng + ro if found */
+    if (coengRo > -1) {
+        reordered[len] = C_COENG;
+        properties[len] = PreForm;
+        ++len;
+        reordered[len] = C_RO;
+        properties[len] = PreForm;
+        ++len;
+    }
+
+    /*
+       shall we add a dotted circle?
+       If in the position in which the base should be (first char in the string) there is
+       a character that has the Dotted circle flag (a character that cannot be a base)
+       then write a dotted circle */
+    if (getKhmerCharClass(item->string[item->item.pos]) & CF_DOTTED_CIRCLE) {
+        reordered[len] = C_DOTTED_CIRCLE;
+        ++len;
+    }
+
+    /* copy what is left to the output, skipping before vowels and
+       coeng Ro if they are present */
+    for (i = item->item.pos; i < syllableEnd; i += 1) {
+        HB_UChar16 uc = item->string[i];
+        KhmerCharClass charClass = getKhmerCharClass(uc);
+
+        /* skip a before vowel, it was already processed */
+        if (charClass & CF_POS_BEFORE) {
+            continue;
+        }
+
+        /* skip coeng + ro, it was already processed */
+        if (i == coengRo) {
+            i += 1;
+            continue;
+        }
+
+        switch (charClass & CF_POS_MASK)
+        {
+            case CF_POS_ABOVE :
+                reordered[len] = uc;
+                properties[len] = AboveForm;
+                ++len;
+                break;
+
+            case CF_POS_AFTER :
+                reordered[len] = uc;
+                properties[len] = PostForm;
+                ++len;
+                break;
+
+            case CF_POS_BELOW :
+                reordered[len] = uc;
+                properties[len] = BelowForm;
+                ++len;
+                break;
+
+            default:
+                /* assign the correct flags to a coeng consonant
+                   Consonants of type 3 are taged as Post forms and those type 1 as below forms */
+                if ( (charClass & CF_COENG) && i + 1 < syllableEnd ) {
+                    unsigned char property = (getKhmerCharClass(item->string[i+1]) & CF_CLASS_MASK) == CC_CONSONANT3 ?
+                                              PostForm : BelowForm;
+                    reordered[len] = uc;
+                    properties[len] = property;
+                    ++len;
+                    i += 1;
+                    reordered[len] = item->string[i];
+                    properties[len] = property;
+                    ++len;
+                    break;
+                }
+
+                /* if a shifter is followed by an above vowel change the shifter to below form,
+                   an above vowel can have two possible positions i + 1 or i + 3
+                   (position i+1 corresponds to unicode 3, position i+3 to Unicode 4)
+                   and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two
+                   different positions, right after the shifter or after a vowel (Unicode 4) */
+                if ( (charClass & CF_SHIFTER) && (i + 1 < syllableEnd) ) {
+                    if (getKhmerCharClass(item->string[i+1]) & CF_ABOVE_VOWEL ) {
+                        reordered[len] = uc;
+                        properties[len] = BelowForm;
+                        ++len;
+                        break;
+                    }
+                    if (i + 2 < syllableEnd &&
+                        (item->string[i+1] == C_VOWEL_AA) &&
+                        (item->string[i+2] == C_SIGN_NIKAHIT) )
+                    {
+                        reordered[len] = uc;
+                        properties[len] = BelowForm;
+                        ++len;
+                        break;
+                    }
+                    if (i + 3 < syllableEnd && (getKhmerCharClass(item->string[i+3]) & CF_ABOVE_VOWEL) ) {
+                        reordered[len] = uc;
+                        properties[len] = BelowForm;
+                        ++len;
+                        break;
+                    }
+                    if (i + 4 < syllableEnd &&
+                        (item->string[i+3] == C_VOWEL_AA) &&
+                        (item->string[i+4] == C_SIGN_NIKAHIT) )
+                    {
+                        reordered[len] = uc;
+                        properties[len] = BelowForm;
+                        ++len;
+                        break;
+                    }
+                }
+
+                /* default - any other characters */
+                reordered[len] = uc;
+                ++len;
+                break;
+        } /* switch */
+    } /* for */
+
+    if (!item->font->klass->convertStringToGlyphIndices(item->font,
+                                                        reordered, len,
+                                                        item->glyphs, &item->num_glyphs,
+                                                        item->item.bidiLevel % 2))
+        return FALSE;
+
+
+    KHDEBUG("after shaping: len=%d", len);
+    for (i = 0; i < len; i++) {
+       item->attributes[i].mark = FALSE;
+       item->attributes[i].clusterStart = FALSE;
+       item->attributes[i].justification = 0;
+       item->attributes[i].zeroWidth = FALSE;
+       KHDEBUG("    %d: %4x property=%x", i, reordered[i], properties[i]);
+    }
+
+    /* now we have the syllable in the right order, and can start running it through open type. */
+
+#ifndef NO_OPENTYPE
+    if (openType) {
+       hb_uint32 where[16];
+        for (i = 0; i < len; ++i) {
+            where[i] = ~(PreSubstProperty
+                         | BelowSubstProperty
+                         | AboveSubstProperty
+                         | PostSubstProperty
+                         | CligProperty
+                         | PositioningProperties);
+            if (properties[i] == PreForm)
+                where[i] &= ~PreFormProperty;
+            else if (properties[i] == BelowForm)
+                where[i] &= ~BelowFormProperty;
+            else if (properties[i] == AboveForm)
+                where[i] &= ~AboveFormProperty;
+            else if (properties[i] == PostForm)
+                where[i] &= ~PostFormProperty;
+        }
+
+        HB_OpenTypeShape(item, where);
+        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))
+            return FALSE;
+    } else
+#endif
+    {
+       KHDEBUG("Not using openType");
+        HB_HeuristicPosition(item);
+    }
+
+    item->attributes[0].clusterStart = TRUE;
+    return TRUE;
+}
+
+HB_Bool HB_KhmerShape(HB_ShaperItem *item)
+{
+    HB_Bool openType = FALSE;
+    unsigned short *logClusters = item->log_clusters;
+    int i;
+
+    HB_ShaperItem syllable = *item;
+    int first_glyph = 0;
+
+    int sstart = item->item.pos;
+    int end = sstart + item->item.length;
+
+    assert(item->item.script == HB_Script_Khmer);
+
+#ifndef NO_OPENTYPE
+    openType = HB_SelectScript(item, khmer_features);
+#endif
+
+    KHDEBUG("khmer_shape: from %d length %d", item->item.pos, item->item.length);
+    while (sstart < end) {
+        HB_Bool invalid;
+        int send = khmer_nextSyllableBoundary(item->string, sstart, end, &invalid);
+        KHDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,
+               invalid ? "TRUE" : "FALSE");
+        syllable.item.pos = sstart;
+        syllable.item.length = send-sstart;
+        syllable.glyphs = item->glyphs + first_glyph;
+        syllable.attributes = item->attributes + first_glyph;
+        syllable.offsets = item->offsets + first_glyph;
+        syllable.advances = item->advances + first_glyph;
+        syllable.num_glyphs = item->num_glyphs - first_glyph;
+        if (!khmer_shape_syllable(openType, &syllable)) {
+            KHDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);
+            item->num_glyphs += syllable.num_glyphs;
+            return FALSE;
+        }
+        /* fix logcluster array */
+        KHDEBUG("syllable:");
+        for (i = first_glyph; i < first_glyph + (int)syllable.num_glyphs; ++i)
+            KHDEBUG("        %d -> glyph %x", i, item->glyphs[i]);
+        KHDEBUG("    logclusters:");
+        for (i = sstart; i < send; ++i) {
+            KHDEBUG("        %d -> glyph %d", i, first_glyph);
+            logClusters[i-item->item.pos] = first_glyph;
+        }
+        sstart = send;
+        first_glyph += syllable.num_glyphs;
+    }
+    item->num_glyphs = first_glyph;
+    return TRUE;
+}
+
+void HB_KhmerAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    int end = from + len;
+    const HB_UChar16 *uc = text + from;
+    hb_uint32 i = 0;
+    HB_UNUSED(script);
+    attributes += from;
+    while ( i < len ) {
+       HB_Bool invalid;
+       hb_uint32 boundary = khmer_nextSyllableBoundary( text, from+i, end, &invalid ) - from;
+
+       attributes[i].charStop = TRUE;
+
+       if ( boundary > len-1 ) boundary = len;
+       i++;
+       while ( i < boundary ) {
+           attributes[i].charStop = FALSE;
+           ++uc;
+           ++i;
+       }
+       assert( i == boundary );
+    }
+}
+
index 212a3a0..d204087 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-#include <stdio.h>\r
-\r
-enum MymrCharClassValues\r
-{\r
-    Mymr_CC_RESERVED             =  0,\r
-    Mymr_CC_CONSONANT            =  1, /* Consonant of type 1, that has subscript form */\r
-    Mymr_CC_CONSONANT2           =  2, /* Consonant of type 2, that has no subscript form */\r
-    Mymr_CC_NGA                  =  3, /* Consonant NGA */\r
-    Mymr_CC_YA                   =  4, /* Consonant YA */\r
-    Mymr_CC_RA                   =  5, /* Consonant RA */\r
-    Mymr_CC_WA                   =  6, /* Consonant WA */\r
-    Mymr_CC_HA                   =  7, /* Consonant HA */\r
-    Mymr_CC_IND_VOWEL            =  8, /* Independent vowel */\r
-    Mymr_CC_ZERO_WIDTH_NJ_MARK   =  9, /* Zero Width non joiner character (0x200C) */\r
-    Mymr_CC_VIRAMA               = 10, /* Subscript consonant combining character */\r
-    Mymr_CC_PRE_VOWEL            = 11, /* Dependent vowel, prebase (Vowel e) */\r
-    Mymr_CC_BELOW_VOWEL          = 12, /* Dependent vowel, prebase (Vowel u, uu) */\r
-    Mymr_CC_ABOVE_VOWEL          = 13, /* Dependent vowel, prebase (Vowel i, ii, ai) */\r
-    Mymr_CC_POST_VOWEL           = 14, /* Dependent vowel, prebase (Vowel aa) */\r
-    Mymr_CC_SIGN_ABOVE           = 15,\r
-    Mymr_CC_SIGN_BELOW           = 16,\r
-    Mymr_CC_SIGN_AFTER           = 17,\r
-    Mymr_CC_ZERO_WIDTH_J_MARK    = 18, /* Zero width joiner character */\r
-    Mymr_CC_COUNT                = 19  /* This is the number of character classes */\r
-};\r
-\r
-enum MymrCharClassFlags\r
-{\r
-    Mymr_CF_CLASS_MASK    = 0x0000FFFF,\r
-\r
-    Mymr_CF_CONSONANT     = 0x01000000,  /* flag to speed up comparing */\r
-    Mymr_CF_MEDIAL        = 0x02000000,  /* flag to speed up comparing */\r
-    Mymr_CF_IND_VOWEL     = 0x04000000,  /* flag to speed up comparing */\r
-    Mymr_CF_DEP_VOWEL     = 0x08000000,  /* flag to speed up comparing */\r
-    Mymr_CF_DOTTED_CIRCLE = 0x10000000,  /* add a dotted circle if a character with this flag is the first in a syllable */\r
-    Mymr_CF_VIRAMA        = 0x20000000,  /* flag to speed up comparing */\r
-\r
-    /* position flags */\r
-    Mymr_CF_POS_BEFORE    = 0x00080000,\r
-    Mymr_CF_POS_BELOW     = 0x00040000,\r
-    Mymr_CF_POS_ABOVE     = 0x00020000,\r
-    Mymr_CF_POS_AFTER     = 0x00010000,\r
-    Mymr_CF_POS_MASK      = 0x000f0000,\r
-\r
-    Mymr_CF_AFTER_KINZI   = 0x00100000\r
-};\r
-\r
-/* Characters that get refrered to by name */\r
-enum MymrChar\r
-{\r
-    Mymr_C_SIGN_ZWNJ     = 0x200C,\r
-    Mymr_C_SIGN_ZWJ      = 0x200D,\r
-    Mymr_C_DOTTED_CIRCLE = 0x25CC,\r
-    Mymr_C_RA            = 0x101B,\r
-    Mymr_C_YA            = 0x101A,\r
-    Mymr_C_NGA           = 0x1004,\r
-    Mymr_C_VOWEL_E       = 0x1031,\r
-    Mymr_C_VIRAMA        = 0x1039\r
-};\r
-\r
-enum\r
-{\r
-    Mymr_xx = Mymr_CC_RESERVED,\r
-    Mymr_c1 = Mymr_CC_CONSONANT | Mymr_CF_CONSONANT | Mymr_CF_POS_BELOW,\r
-    Mymr_c2 = Mymr_CC_CONSONANT2 | Mymr_CF_CONSONANT,\r
-    Mymr_ng = Mymr_CC_NGA | Mymr_CF_CONSONANT | Mymr_CF_POS_ABOVE,\r
-    Mymr_ya = Mymr_CC_YA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_AFTER | Mymr_CF_AFTER_KINZI,\r
-    Mymr_ra = Mymr_CC_RA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BEFORE,\r
-    Mymr_wa = Mymr_CC_WA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW,\r
-    Mymr_ha = Mymr_CC_HA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW,\r
-    Mymr_id = Mymr_CC_IND_VOWEL | Mymr_CF_IND_VOWEL,\r
-    Mymr_vi = Mymr_CC_VIRAMA | Mymr_CF_VIRAMA | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE,\r
-    Mymr_dl = Mymr_CC_PRE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BEFORE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,\r
-    Mymr_db = Mymr_CC_BELOW_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,\r
-    Mymr_da = Mymr_CC_ABOVE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,\r
-    Mymr_dr = Mymr_CC_POST_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,\r
-    Mymr_sa = Mymr_CC_SIGN_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_ABOVE | Mymr_CF_AFTER_KINZI,\r
-    Mymr_sb = Mymr_CC_SIGN_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_BELOW | Mymr_CF_AFTER_KINZI,\r
-    Mymr_sp = Mymr_CC_SIGN_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI\r
-};\r
-\r
-\r
-typedef int MymrCharClass;\r
-\r
-\r
-static const MymrCharClass mymrCharClasses[] =\r
-{\r
-    Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_ng, Mymr_c1, Mymr_c1, Mymr_c1,\r
-    Mymr_c1, Mymr_c1, Mymr_c2, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, /* 1000 - 100F */\r
-    Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1,\r
-    Mymr_c1, Mymr_c1, Mymr_ya, Mymr_ra, Mymr_c1, Mymr_wa, Mymr_c1, Mymr_ha, /* 1010 - 101F */\r
-    Mymr_c2, Mymr_c2, Mymr_xx, Mymr_id, Mymr_id, Mymr_id, Mymr_id, Mymr_id,\r
-    Mymr_xx, Mymr_id, Mymr_id, Mymr_xx, Mymr_dr, Mymr_da, Mymr_da, Mymr_db, /* 1020 - 102F */\r
-    Mymr_db, Mymr_dl, Mymr_da, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_sa, Mymr_sb,\r
-    Mymr_sp, Mymr_vi, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1030 - 103F */\r
-    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx,\r
-    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1040 - 104F */\r
-    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx,\r
-    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1050 - 105F */\r
-};\r
-\r
-static MymrCharClass\r
-getMyanmarCharClass (HB_UChar16 ch)\r
-{\r
-    if (ch == Mymr_C_SIGN_ZWJ)\r
-        return Mymr_CC_ZERO_WIDTH_J_MARK;\r
-\r
-    if (ch == Mymr_C_SIGN_ZWNJ)\r
-        return Mymr_CC_ZERO_WIDTH_NJ_MARK;\r
-\r
-    if (ch < 0x1000 || ch > 0x105f)\r
-        return Mymr_CC_RESERVED;\r
-\r
-    return mymrCharClasses[ch - 0x1000];\r
-}\r
-\r
-static const signed char mymrStateTable[][Mymr_CC_COUNT] =\r
-{\r
-/*   xx  c1, c2  ng  ya  ra  wa  ha  id zwnj vi  dl  db  da  dr  sa  sb  sp zwj */\r
-    { 1,  4,  4,  2,  4,  4,  4,  4, 24,  1, 27, 17, 18, 19, 20, 21,  1,  1,  4}, /*  0 - ground state */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  1 - exit state (or sp to the right of the syllable) */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  3, 17, 18, 19, 20, 21, -1, -1,  4}, /*  2 - NGA */\r
-    {-1,  4,  4,  4,  4,  4,  4,  4, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  3 - Virama after NGA */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  5, 17, 18, 19, 20, 21,  1,  1, -1}, /*  4 - Base consonant */\r
-    {-2,  6, -2, -2,  7,  8,  9, 10, -2, 23, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /*  5 - First virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 17, 18, 19, 20, 21, -1, -1, -1}, /*  6 - c1 after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  7 - ya after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  8 - ra after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  9 - wa after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 10 - ha after virama */\r
-    {-1, -1, -1, -1,  7,  8,  9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 11 - Virama after NGA+zwj */\r
-    {-2, -2, -2, -2, -2, -2, 13, 14, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 12 - Second virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 18, 19, 20, 21, -1, -1, -1}, /* 13 - wa after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 14 - ha after virama */\r
-    {-2, -2, -2, -2, -2, -2, -2, 16, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 15 - Third virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 16 - ha after virama */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21,  1,  1, -1}, /* 17 - dl, Dependent vowel e */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, 21,  1,  1, -1}, /* 18 - db, Dependent vowel u,uu */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1,  1, -1}, /* 19 - da, Dependent vowel i,ii,ai */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,  1,  1, -1}, /* 20 - dr, Dependent vowel aa */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1, -1}, /* 21 - sa, Sign anusvara */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 22 - atha */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1, -1}, /* 23 - zwnj for atha */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, -1}, /* 24 - Independent vowel */\r
-    {-2, -2, -2, -2, 26, 26, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 25 - Virama after subscript consonant */\r
-    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1,  1, -1}, /* 26 - ra/ya after subscript consonant + virama */\r
-    {-1,  6, -1, -1,  7,  8,  9, 10, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 - Virama after ground state */\r
-/* exit state -2 is for invalid order of medials and combination of invalids\r
-   with virama where virama should treat as start of next syllable\r
- */\r
-};\r
-\r
-\r
-\r
-/*#define MYANMAR_DEBUG */\r
-#ifdef MYANMAR_DEBUG\r
-#define MMDEBUG qDebug\r
-#else\r
-#define MMDEBUG if(0) printf\r
-#endif\r
-\r
-/*\r
-//  Given an input string of characters and a location in which to start looking\r
-//  calculate, using the state table, which one is the last character of the syllable\r
-//  that starts in the starting position.\r
-*/\r
-/* SAMSUNG - Kaja Changes -Start */\r
-//static int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-/* SAMSUNG - Kaja Changes -End */\r
-{\r
-    const HB_UChar16 *uc = s + start;\r
-    int state = 0;\r
-    int pos = start;\r
-    *invalid = FALSE;\r
-\r
-    while (pos < end) {\r
-        MymrCharClass charClass = getMyanmarCharClass(*uc);\r
-        state = mymrStateTable[state][charClass & Mymr_CF_CLASS_MASK];\r
-        if (pos == start)\r
-            *invalid = (HB_Bool)(charClass & Mymr_CF_DOTTED_CIRCLE);\r
-\r
-        MMDEBUG("state[%d]=%d class=%8x (uc=%4x)", pos - start, state, charClass, *uc);\r
-\r
-        if (state < 0) {\r
-            if (state < -1)\r
-                --pos;\r
-            break;\r
-        }\r
-        ++uc;\r
-        ++pos;\r
-    }\r
-    return pos;\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-/* ###### might have to change order of above and below forms and substitutions,\r
-   but according to Unicode below comes before above */\r
-static const HB_OpenTypeFeature myanmar_features[] = {\r
-    { HB_MAKE_TAG('p', 'r', 'e', 'f'), PreFormProperty },\r
-    { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },\r
-    { HB_MAKE_TAG('a', 'b', 'v', 'f'), AboveFormProperty },\r
-    { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },\r
-    { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },\r
-    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },\r
-    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },\r
-    { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },\r
-    { HB_MAKE_TAG('r', 'l', 'i', 'g'), CligProperty }, /* Myanmar1 uses this instead of the other features */\r
-    { 0, 0 }\r
-};\r
-#endif\r
-\r
-\r
-/*\r
-// Visual order before shaping should be:\r
-//\r
-//    [Vowel Mark E]\r
-//    [Virama + Medial Ra]\r
-//    [Base]\r
-//    [Virama + Consonant]\r
-//    [Nga + Virama] (Kinzi) ### should probably come before post forms (medial ya)\r
-//    [Vowels]\r
-//    [Marks]\r
-//\r
-// This means that we can keep the logical order apart from having to\r
-// move the pre vowel, medial ra and kinzi\r
-*/\r
-\r
-static HB_Bool myanmar_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_Bool invalid)\r
-{\r
-    /*\r
-//    MMDEBUG("\nsyllable from %d len %d, str='%s'", item->item.pos, item->item.length,\r
-//         item->string->mid(item->from, item->length).toUtf8().data());\r
-    */\r
-\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = item->num_glyphs;\r
-#endif\r
-    const HB_UChar16 *uc = item->string + item->item.pos;\r
-    int vowel_e = -1;\r
-    int kinzi = -1;\r
-    int medial_ra = -1;\r
-    int base = -1;\r
-    int i;\r
-    int len = 0;\r
-    unsigned short reordered[32];\r
-    unsigned char properties[32];\r
-    enum {\r
-       AboveForm = 0x01,\r
-       PreForm = 0x02,\r
-       PostForm = 0x04,\r
-       BelowForm = 0x08\r
-    };\r
-    HB_Bool lastWasVirama = FALSE;\r
-    int basePos = -1;\r
-\r
-    memset(properties, 0, 32*sizeof(unsigned char));\r
-\r
-    /* according to the table the max length of a syllable should be around 14 chars */\r
-    assert(item->item.length < 32);\r
-\r
-#ifdef MYANMAR_DEBUG\r
-    printf("original:");\r
-    for (i = 0; i < (int)item->item.length; i++) {\r
-        printf("    %d: %4x", i, uc[i]);\r
-    }\r
-#endif\r
-    for (i = 0; i < (int)item->item.length; ++i) {\r
-        HB_UChar16 chr = uc[i];\r
-\r
-        if (chr == Mymr_C_VOWEL_E) {\r
-            vowel_e = i;\r
-            continue;\r
-        }\r
-        if (i == 0\r
-            && chr == Mymr_C_NGA\r
-            && i + 2 < (int)item->item.length\r
-            && uc[i+1] == Mymr_C_VIRAMA) {\r
-            int mc = getMyanmarCharClass(uc[i+2]);\r
-            /*MMDEBUG("maybe kinzi: mc=%x", mc);*/\r
-            if ((mc & Mymr_CF_CONSONANT) == Mymr_CF_CONSONANT) {\r
-                kinzi = i;\r
-                continue;\r
-            }\r
-        }\r
-        if (base >= 0\r
-            && chr == Mymr_C_VIRAMA\r
-            && i + 1 < (int)item->item.length\r
-            && uc[i+1] == Mymr_C_RA) {\r
-            medial_ra = i;\r
-            continue;\r
-        }\r
-        if (base < 0)\r
-            base = i;\r
-    }\r
-\r
-    MMDEBUG("\n  base=%d, vowel_e=%d, kinzi=%d, medial_ra=%d", base, vowel_e, kinzi, medial_ra);\r
-    /* write vowel_e if found */\r
-    if (vowel_e >= 0) {\r
-        reordered[0] = Mymr_C_VOWEL_E;\r
-        len = 1;\r
-    }\r
-    /* write medial_ra */\r
-    if (medial_ra >= 0) {\r
-        reordered[len] = Mymr_C_VIRAMA;\r
-        reordered[len+1] = Mymr_C_RA;\r
-        properties[len] = PreForm;\r
-        properties[len+1] = PreForm;\r
-        len += 2;\r
-    }\r
-\r
-    /* shall we add a dotted circle?\r
-       If in the position in which the base should be (first char in the string) there is\r
-       a character that has the Dotted circle flag (a character that cannot be a base)\r
-       then write a dotted circle */\r
-    if (invalid) {\r
-        reordered[len] = C_DOTTED_CIRCLE;\r
-        ++len;\r
-    }\r
-\r
-    /* copy the rest of the syllable to the output, inserting the kinzi\r
-       at the correct place */\r
-    for (i = 0; i < (int)item->item.length; ++i) {\r
-        hb_uint16 chr = uc[i];\r
-        MymrCharClass cc;\r
-        if (i == vowel_e)\r
-            continue;\r
-        if (i == medial_ra || i == kinzi) {\r
-            ++i;\r
-            continue;\r
-        }\r
-\r
-        cc = getMyanmarCharClass(uc[i]);\r
-        if (kinzi >= 0 && i > base && (cc & Mymr_CF_AFTER_KINZI)) {\r
-            reordered[len] = Mymr_C_NGA;\r
-            reordered[len+1] = Mymr_C_VIRAMA;\r
-            properties[len-1] = AboveForm;\r
-            properties[len] = AboveForm;\r
-            len += 2;\r
-            kinzi = -1;\r
-        }\r
-\r
-        if (lastWasVirama) {\r
-            int prop = 0;\r
-            switch(cc & Mymr_CF_POS_MASK) {\r
-            case Mymr_CF_POS_BEFORE:\r
-                prop = PreForm;\r
-                break;\r
-            case Mymr_CF_POS_BELOW:\r
-                prop = BelowForm;\r
-                break;\r
-            case Mymr_CF_POS_ABOVE:\r
-                prop = AboveForm;\r
-                break;\r
-            case Mymr_CF_POS_AFTER:\r
-                prop = PostForm;\r
-                break;\r
-            default:\r
-                break;\r
-            }\r
-            properties[len-1] = prop;\r
-            properties[len] = prop;\r
-            if(basePos >= 0 && basePos == len-2)\r
-                properties[len-2] = prop;\r
-        }\r
-        lastWasVirama = (chr == Mymr_C_VIRAMA);\r
-        if(i == base)\r
-            basePos = len;\r
-\r
-        if ((chr != Mymr_C_SIGN_ZWNJ && chr != Mymr_C_SIGN_ZWJ) || !len) {\r
-            reordered[len] = chr;\r
-            ++len;\r
-        }\r
-    }\r
-    if (kinzi >= 0) {\r
-        reordered[len] = Mymr_C_NGA;\r
-        reordered[len+1] = Mymr_C_VIRAMA;\r
-        properties[len] = AboveForm;\r
-        properties[len+1] = AboveForm;\r
-        len += 2;\r
-    }\r
-\r
-    if (!item->font->klass->convertStringToGlyphIndices(item->font,\r
-                                                        reordered, len,\r
-                                                        item->glyphs, &item->num_glyphs,\r
-                                                        item->item.bidiLevel % 2))\r
-        return FALSE;\r
-\r
-    MMDEBUG("after shaping: len=%d", len);\r
-    for (i = 0; i < len; i++) {\r
-       item->attributes[i].mark = FALSE;\r
-       item->attributes[i].clusterStart = FALSE;\r
-       item->attributes[i].justification = 0;\r
-       item->attributes[i].zeroWidth = FALSE;\r
-       MMDEBUG("    %d: %4x property=%x", i, reordered[i], properties[i]);\r
-    }\r
-\r
-    /* now we have the syllable in the right order, and can start running it through open type. */\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (openType) {\r
-       unsigned short logClusters[32];\r
-       hb_uint32 where[32];\r
-\r
-       for (i = 0; i < len; ++i)\r
-           logClusters[i] = i;\r
-\r
-        for (i = 0; i < len; ++i) {\r
-            where[i] = ~(PreSubstProperty\r
-                         | BelowSubstProperty\r
-                         | AboveSubstProperty\r
-                         | PostSubstProperty\r
-                         | CligProperty\r
-                         | PositioningProperties);\r
-            if (properties[i] & PreForm)\r
-                where[i] &= ~PreFormProperty;\r
-            if (properties[i] & BelowForm)\r
-                where[i] &= ~BelowFormProperty;\r
-            if (properties[i] & AboveForm)\r
-                where[i] &= ~AboveFormProperty;\r
-            if (properties[i] & PostForm)\r
-                where[i] &= ~PostFormProperty;\r
-        }\r
-\r
-        HB_OpenTypeShape(item, where);\r
-        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))\r
-            return FALSE;\r
-    } else\r
-#endif\r
-    {\r
-       MMDEBUG("Not using openType");\r
-        HB_HeuristicPosition(item);\r
-    }\r
-\r
-    item->attributes[0].clusterStart = TRUE;\r
-    return TRUE;\r
-}\r
-\r
-HB_Bool HB_MyanmarShape(HB_ShaperItem *item)\r
-{\r
-    HB_Bool openType = FALSE;\r
-    unsigned short *logClusters = item->log_clusters;\r
-\r
-    HB_ShaperItem syllable = *item;\r
-    int first_glyph = 0;\r
-\r
-    int sstart = item->item.pos;\r
-    int end = sstart + item->item.length;\r
-    int i = 0;\r
-\r
-    assert(item->item.script == HB_Script_Myanmar);\r
-#ifndef NO_OPENTYPE\r
-    openType = HB_SelectScript(item, myanmar_features);\r
-#endif\r
-\r
-    MMDEBUG("myanmar_shape: from %d length %d", item->item.pos, item->item.length);\r
-    while (sstart < end) {\r
-        HB_Bool invalid;\r
-        int send = myanmar_nextSyllableBoundary(item->string, sstart, end, &invalid);\r
-        MMDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,\r
-               invalid ? "TRUE" : "FALSE");\r
-        syllable.item.pos = sstart;\r
-        syllable.item.length = send-sstart;\r
-        syllable.glyphs = item->glyphs + first_glyph;\r
-        syllable.attributes = item->attributes + first_glyph;\r
-        syllable.advances = item->advances + first_glyph;\r
-        syllable.offsets = item->offsets + first_glyph;\r
-        syllable.num_glyphs = item->num_glyphs - first_glyph;\r
-        if (!myanmar_shape_syllable(openType, &syllable, invalid)) {\r
-            MMDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);\r
-            item->num_glyphs += syllable.num_glyphs;\r
-            return FALSE;\r
-        }\r
-\r
-        /* fix logcluster array */\r
-        MMDEBUG("syllable:");\r
-        for (i = first_glyph; i < first_glyph + (int)syllable.num_glyphs; ++i)\r
-            MMDEBUG("        %d -> glyph %x", i, item->glyphs[i]);\r
-        MMDEBUG("    logclusters:");\r
-        for (i = sstart; i < send; ++i) {\r
-            MMDEBUG("        %d -> glyph %d", i, first_glyph);\r
-            logClusters[i-item->item.pos] = first_glyph;\r
-        }\r
-        sstart = send;\r
-        first_glyph += syllable.num_glyphs;\r
-    }\r
-    item->num_glyphs = first_glyph;\r
-    return TRUE;\r
-}\r
-\r
-void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    int end = from + len;\r
-    const HB_UChar16 *uc = text + from;\r
-    hb_uint32 i = 0;\r
-    HB_UNUSED(script);\r
-    attributes += from;\r
-    while (i < len) {\r
-       HB_Bool invalid;\r
-       hb_uint32 boundary = myanmar_nextSyllableBoundary(text, from+i, end, &invalid) - from;\r
-\r
-       attributes[i].charStop = TRUE;\r
-        if (i)\r
-            attributes[i-1].lineBreakType = HB_Break;\r
-\r
-       if (boundary > len-1)\r
-            boundary = len;\r
-       i++;\r
-       while (i < boundary) {\r
-           attributes[i].charStop = FALSE;\r
-           ++uc;\r
-           ++i;\r
-       }\r
-       assert(i == boundary);\r
-    }\r
-}\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+#include <stdio.h>
+
+enum MymrCharClassValues
+{
+    Mymr_CC_RESERVED             =  0,
+    Mymr_CC_CONSONANT            =  1, /* Consonant of type 1, that has subscript form */
+    Mymr_CC_CONSONANT2           =  2, /* Consonant of type 2, that has no subscript form */
+    Mymr_CC_NGA                  =  3, /* Consonant NGA */
+    Mymr_CC_YA                   =  4, /* Consonant YA */
+    Mymr_CC_RA                   =  5, /* Consonant RA */
+    Mymr_CC_WA                   =  6, /* Consonant WA */
+    Mymr_CC_HA                   =  7, /* Consonant HA */
+    Mymr_CC_IND_VOWEL            =  8, /* Independent vowel */
+    Mymr_CC_ZERO_WIDTH_NJ_MARK   =  9, /* Zero Width non joiner character (0x200C) */
+    Mymr_CC_VIRAMA               = 10, /* Subscript consonant combining character */
+    Mymr_CC_PRE_VOWEL            = 11, /* Dependent vowel, prebase (Vowel e) */
+    Mymr_CC_BELOW_VOWEL          = 12, /* Dependent vowel, prebase (Vowel u, uu) */
+    Mymr_CC_ABOVE_VOWEL          = 13, /* Dependent vowel, prebase (Vowel i, ii, ai) */
+    Mymr_CC_POST_VOWEL           = 14, /* Dependent vowel, prebase (Vowel aa) */
+    Mymr_CC_SIGN_ABOVE           = 15,
+    Mymr_CC_SIGN_BELOW           = 16,
+    Mymr_CC_SIGN_AFTER           = 17,
+    Mymr_CC_ZERO_WIDTH_J_MARK    = 18, /* Zero width joiner character */
+    Mymr_CC_COUNT                = 19  /* This is the number of character classes */
+};
+
+enum MymrCharClassFlags
+{
+    Mymr_CF_CLASS_MASK    = 0x0000FFFF,
+
+    Mymr_CF_CONSONANT     = 0x01000000,  /* flag to speed up comparing */
+    Mymr_CF_MEDIAL        = 0x02000000,  /* flag to speed up comparing */
+    Mymr_CF_IND_VOWEL     = 0x04000000,  /* flag to speed up comparing */
+    Mymr_CF_DEP_VOWEL     = 0x08000000,  /* flag to speed up comparing */
+    Mymr_CF_DOTTED_CIRCLE = 0x10000000,  /* add a dotted circle if a character with this flag is the first in a syllable */
+    Mymr_CF_VIRAMA        = 0x20000000,  /* flag to speed up comparing */
+
+    /* position flags */
+    Mymr_CF_POS_BEFORE    = 0x00080000,
+    Mymr_CF_POS_BELOW     = 0x00040000,
+    Mymr_CF_POS_ABOVE     = 0x00020000,
+    Mymr_CF_POS_AFTER     = 0x00010000,
+    Mymr_CF_POS_MASK      = 0x000f0000,
+
+    Mymr_CF_AFTER_KINZI   = 0x00100000
+};
+
+/* Characters that get refrered to by name */
+enum MymrChar
+{
+    Mymr_C_SIGN_ZWNJ     = 0x200C,
+    Mymr_C_SIGN_ZWJ      = 0x200D,
+    Mymr_C_DOTTED_CIRCLE = 0x25CC,
+    Mymr_C_RA            = 0x101B,
+    Mymr_C_YA            = 0x101A,
+    Mymr_C_NGA           = 0x1004,
+    Mymr_C_VOWEL_E       = 0x1031,
+    Mymr_C_VIRAMA        = 0x1039
+};
+
+enum
+{
+    Mymr_xx = Mymr_CC_RESERVED,
+    Mymr_c1 = Mymr_CC_CONSONANT | Mymr_CF_CONSONANT | Mymr_CF_POS_BELOW,
+    Mymr_c2 = Mymr_CC_CONSONANT2 | Mymr_CF_CONSONANT,
+    Mymr_ng = Mymr_CC_NGA | Mymr_CF_CONSONANT | Mymr_CF_POS_ABOVE,
+    Mymr_ya = Mymr_CC_YA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_AFTER | Mymr_CF_AFTER_KINZI,
+    Mymr_ra = Mymr_CC_RA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BEFORE,
+    Mymr_wa = Mymr_CC_WA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW,
+    Mymr_ha = Mymr_CC_HA | Mymr_CF_CONSONANT | Mymr_CF_MEDIAL | Mymr_CF_POS_BELOW,
+    Mymr_id = Mymr_CC_IND_VOWEL | Mymr_CF_IND_VOWEL,
+    Mymr_vi = Mymr_CC_VIRAMA | Mymr_CF_VIRAMA | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE,
+    Mymr_dl = Mymr_CC_PRE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BEFORE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,
+    Mymr_db = Mymr_CC_BELOW_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,
+    Mymr_da = Mymr_CC_ABOVE_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,
+    Mymr_dr = Mymr_CC_POST_VOWEL | Mymr_CF_DEP_VOWEL | Mymr_CF_POS_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI,
+    Mymr_sa = Mymr_CC_SIGN_ABOVE | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_ABOVE | Mymr_CF_AFTER_KINZI,
+    Mymr_sb = Mymr_CC_SIGN_BELOW | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_POS_BELOW | Mymr_CF_AFTER_KINZI,
+    Mymr_sp = Mymr_CC_SIGN_AFTER | Mymr_CF_DOTTED_CIRCLE | Mymr_CF_AFTER_KINZI
+};
+
+
+typedef int MymrCharClass;
+
+
+static const MymrCharClass mymrCharClasses[] =
+{
+    Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_ng, Mymr_c1, Mymr_c1, Mymr_c1,
+    Mymr_c1, Mymr_c1, Mymr_c2, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, /* 1000 - 100F */
+    Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1, Mymr_c1,
+    Mymr_c1, Mymr_c1, Mymr_ya, Mymr_ra, Mymr_c1, Mymr_wa, Mymr_c1, Mymr_ha, /* 1010 - 101F */
+    Mymr_c2, Mymr_c2, Mymr_xx, Mymr_id, Mymr_id, Mymr_id, Mymr_id, Mymr_id,
+    Mymr_xx, Mymr_id, Mymr_id, Mymr_xx, Mymr_dr, Mymr_da, Mymr_da, Mymr_db, /* 1020 - 102F */
+    Mymr_db, Mymr_dl, Mymr_da, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_sa, Mymr_sb,
+    Mymr_sp, Mymr_vi, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1030 - 103F */
+    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx,
+    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1040 - 104F */
+    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx,
+    Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, Mymr_xx, /* 1050 - 105F */
+};
+
+static MymrCharClass
+getMyanmarCharClass (HB_UChar16 ch)
+{
+    if (ch == Mymr_C_SIGN_ZWJ)
+        return Mymr_CC_ZERO_WIDTH_J_MARK;
+
+    if (ch == Mymr_C_SIGN_ZWNJ)
+        return Mymr_CC_ZERO_WIDTH_NJ_MARK;
+
+    if (ch < 0x1000 || ch > 0x105f)
+        return Mymr_CC_RESERVED;
+
+    return mymrCharClasses[ch - 0x1000];
+}
+
+static const signed char mymrStateTable[][Mymr_CC_COUNT] =
+{
+/*   xx  c1, c2  ng  ya  ra  wa  ha  id zwnj vi  dl  db  da  dr  sa  sb  sp zwj */
+    { 1,  4,  4,  2,  4,  4,  4,  4, 24,  1, 27, 17, 18, 19, 20, 21,  1,  1,  4}, /*  0 - ground state */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  1 - exit state (or sp to the right of the syllable) */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  3, 17, 18, 19, 20, 21, -1, -1,  4}, /*  2 - NGA */
+    {-1,  4,  4,  4,  4,  4,  4,  4, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /*  3 - Virama after NGA */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  5, 17, 18, 19, 20, 21,  1,  1, -1}, /*  4 - Base consonant */
+    {-2,  6, -2, -2,  7,  8,  9, 10, -2, 23, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /*  5 - First virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 17, 18, 19, 20, 21, -1, -1, -1}, /*  6 - c1 after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  7 - ya after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  8 - ra after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1, -1, -1}, /*  9 - wa after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 10 - ha after virama */
+    {-1, -1, -1, -1,  7,  8,  9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 11 - Virama after NGA+zwj */
+    {-2, -2, -2, -2, -2, -2, 13, 14, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 12 - Second virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 18, 19, 20, 21, -1, -1, -1}, /* 13 - wa after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 14 - ha after virama */
+    {-2, -2, -2, -2, -2, -2, -2, 16, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 15 - Third virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 18, 19, 20, 21, -1, -1, -1}, /* 16 - ha after virama */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21,  1,  1, -1}, /* 17 - dl, Dependent vowel e */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, 21,  1,  1, -1}, /* 18 - db, Dependent vowel u,uu */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1,  1, -1}, /* 19 - da, Dependent vowel i,ii,ai */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1,  1,  1, -1}, /* 20 - dr, Dependent vowel aa */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1, -1}, /* 21 - sa, Sign anusvara */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 22 - atha */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1,  1, -1}, /* 23 - zwnj for atha */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  1, -1}, /* 24 - Independent vowel */
+    {-2, -2, -2, -2, 26, 26, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2}, /* 25 - Virama after subscript consonant */
+    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 17, 18, 19, 20, 21, -1,  1, -1}, /* 26 - ra/ya after subscript consonant + virama */
+    {-1,  6, -1, -1,  7,  8,  9, 10, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 - Virama after ground state */
+/* exit state -2 is for invalid order of medials and combination of invalids
+   with virama where virama should treat as start of next syllable
+ */
+};
+
+
+
+/*#define MYANMAR_DEBUG */
+#ifdef MYANMAR_DEBUG
+#define MMDEBUG qDebug
+#else
+#define MMDEBUG if(0) printf
+#endif
+
+/*
+//  Given an input string of characters and a location in which to start looking
+//  calculate, using the state table, which one is the last character of the syllable
+//  that starts in the starting position.
+*/
+/* SAMSUNG - Kaja Changes -Start */
+//static int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+int myanmar_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+/* SAMSUNG - Kaja Changes -End */
+{
+    const HB_UChar16 *uc = s + start;
+    int state = 0;
+    int pos = start;
+    *invalid = FALSE;
+
+    while (pos < end) {
+        MymrCharClass charClass = getMyanmarCharClass(*uc);
+        state = mymrStateTable[state][charClass & Mymr_CF_CLASS_MASK];
+        if (pos == start)
+            *invalid = (HB_Bool)(charClass & Mymr_CF_DOTTED_CIRCLE);
+
+        MMDEBUG("state[%d]=%d class=%8x (uc=%4x)", pos - start, state, charClass, *uc);
+
+        if (state < 0) {
+            if (state < -1)
+                --pos;
+            break;
+        }
+        ++uc;
+        ++pos;
+    }
+    return pos;
+}
+
+#ifndef NO_OPENTYPE
+/* ###### might have to change order of above and below forms and substitutions,
+   but according to Unicode below comes before above */
+static const HB_OpenTypeFeature myanmar_features[] = {
+    { HB_MAKE_TAG('p', 'r', 'e', 'f'), PreFormProperty },
+    { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },
+    { HB_MAKE_TAG('a', 'b', 'v', 'f'), AboveFormProperty },
+    { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },
+    { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },
+    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },
+    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },
+    { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },
+    { HB_MAKE_TAG('r', 'l', 'i', 'g'), CligProperty }, /* Myanmar1 uses this instead of the other features */
+    { 0, 0 }
+};
+#endif
+
+
+/*
+// Visual order before shaping should be:
+//
+//    [Vowel Mark E]
+//    [Virama + Medial Ra]
+//    [Base]
+//    [Virama + Consonant]
+//    [Nga + Virama] (Kinzi) ### should probably come before post forms (medial ya)
+//    [Vowels]
+//    [Marks]
+//
+// This means that we can keep the logical order apart from having to
+// move the pre vowel, medial ra and kinzi
+*/
+
+static HB_Bool myanmar_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_Bool invalid)
+{
+    /*
+//    MMDEBUG("\nsyllable from %d len %d, str='%s'", item->item.pos, item->item.length,
+//         item->string->mid(item->from, item->length).toUtf8().data());
+    */
+
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = item->num_glyphs;
+#endif
+    const HB_UChar16 *uc = item->string + item->item.pos;
+    int vowel_e = -1;
+    int kinzi = -1;
+    int medial_ra = -1;
+    int base = -1;
+    int i;
+    int len = 0;
+    unsigned short reordered[32];
+    unsigned char properties[32];
+    enum {
+       AboveForm = 0x01,
+       PreForm = 0x02,
+       PostForm = 0x04,
+       BelowForm = 0x08
+    };
+    HB_Bool lastWasVirama = FALSE;
+    int basePos = -1;
+
+    memset(properties, 0, 32*sizeof(unsigned char));
+
+    /* according to the table the max length of a syllable should be around 14 chars */
+    assert(item->item.length < 32);
+
+#ifdef MYANMAR_DEBUG
+    printf("original:");
+    for (i = 0; i < (int)item->item.length; i++) {
+        printf("    %d: %4x", i, uc[i]);
+    }
+#endif
+    for (i = 0; i < (int)item->item.length; ++i) {
+        HB_UChar16 chr = uc[i];
+
+        if (chr == Mymr_C_VOWEL_E) {
+            vowel_e = i;
+            continue;
+        }
+        if (i == 0
+            && chr == Mymr_C_NGA
+            && i + 2 < (int)item->item.length
+            && uc[i+1] == Mymr_C_VIRAMA) {
+            int mc = getMyanmarCharClass(uc[i+2]);
+            /*MMDEBUG("maybe kinzi: mc=%x", mc);*/
+            if ((mc & Mymr_CF_CONSONANT) == Mymr_CF_CONSONANT) {
+                kinzi = i;
+                continue;
+            }
+        }
+        if (base >= 0
+            && chr == Mymr_C_VIRAMA
+            && i + 1 < (int)item->item.length
+            && uc[i+1] == Mymr_C_RA) {
+            medial_ra = i;
+            continue;
+        }
+        if (base < 0)
+            base = i;
+    }
+
+    MMDEBUG("\n  base=%d, vowel_e=%d, kinzi=%d, medial_ra=%d", base, vowel_e, kinzi, medial_ra);
+    /* write vowel_e if found */
+    if (vowel_e >= 0) {
+        reordered[0] = Mymr_C_VOWEL_E;
+        len = 1;
+    }
+    /* write medial_ra */
+    if (medial_ra >= 0) {
+        reordered[len] = Mymr_C_VIRAMA;
+        reordered[len+1] = Mymr_C_RA;
+        properties[len] = PreForm;
+        properties[len+1] = PreForm;
+        len += 2;
+    }
+
+    /* shall we add a dotted circle?
+       If in the position in which the base should be (first char in the string) there is
+       a character that has the Dotted circle flag (a character that cannot be a base)
+       then write a dotted circle */
+    if (invalid) {
+        reordered[len] = C_DOTTED_CIRCLE;
+        ++len;
+    }
+
+    /* copy the rest of the syllable to the output, inserting the kinzi
+       at the correct place */
+    for (i = 0; i < (int)item->item.length; ++i) {
+        hb_uint16 chr = uc[i];
+        MymrCharClass cc;
+        if (i == vowel_e)
+            continue;
+        if (i == medial_ra || i == kinzi) {
+            ++i;
+            continue;
+        }
+
+        cc = getMyanmarCharClass(uc[i]);
+        if (kinzi >= 0 && i > base && (cc & Mymr_CF_AFTER_KINZI)) {
+            reordered[len] = Mymr_C_NGA;
+            reordered[len+1] = Mymr_C_VIRAMA;
+            properties[len-1] = AboveForm;
+            properties[len] = AboveForm;
+            len += 2;
+            kinzi = -1;
+        }
+
+        if (lastWasVirama) {
+            int prop = 0;
+            switch(cc & Mymr_CF_POS_MASK) {
+            case Mymr_CF_POS_BEFORE:
+                prop = PreForm;
+                break;
+            case Mymr_CF_POS_BELOW:
+                prop = BelowForm;
+                break;
+            case Mymr_CF_POS_ABOVE:
+                prop = AboveForm;
+                break;
+            case Mymr_CF_POS_AFTER:
+                prop = PostForm;
+                break;
+            default:
+                break;
+            }
+            properties[len-1] = prop;
+            properties[len] = prop;
+            if(basePos >= 0 && basePos == len-2)
+                properties[len-2] = prop;
+        }
+        lastWasVirama = (chr == Mymr_C_VIRAMA);
+        if(i == base)
+            basePos = len;
+
+        if ((chr != Mymr_C_SIGN_ZWNJ && chr != Mymr_C_SIGN_ZWJ) || !len) {
+            reordered[len] = chr;
+            ++len;
+        }
+    }
+    if (kinzi >= 0) {
+        reordered[len] = Mymr_C_NGA;
+        reordered[len+1] = Mymr_C_VIRAMA;
+        properties[len] = AboveForm;
+        properties[len+1] = AboveForm;
+        len += 2;
+    }
+
+    if (!item->font->klass->convertStringToGlyphIndices(item->font,
+                                                        reordered, len,
+                                                        item->glyphs, &item->num_glyphs,
+                                                        item->item.bidiLevel % 2))
+        return FALSE;
+
+    MMDEBUG("after shaping: len=%d", len);
+    for (i = 0; i < len; i++) {
+       item->attributes[i].mark = FALSE;
+       item->attributes[i].clusterStart = FALSE;
+       item->attributes[i].justification = 0;
+       item->attributes[i].zeroWidth = FALSE;
+       MMDEBUG("    %d: %4x property=%x", i, reordered[i], properties[i]);
+    }
+
+    /* now we have the syllable in the right order, and can start running it through open type. */
+
+#ifndef NO_OPENTYPE
+    if (openType) {
+       unsigned short logClusters[32];
+       hb_uint32 where[32];
+
+       for (i = 0; i < len; ++i)
+           logClusters[i] = i;
+
+        for (i = 0; i < len; ++i) {
+            where[i] = ~(PreSubstProperty
+                         | BelowSubstProperty
+                         | AboveSubstProperty
+                         | PostSubstProperty
+                         | CligProperty
+                         | PositioningProperties);
+            if (properties[i] & PreForm)
+                where[i] &= ~PreFormProperty;
+            if (properties[i] & BelowForm)
+                where[i] &= ~BelowFormProperty;
+            if (properties[i] & AboveForm)
+                where[i] &= ~AboveFormProperty;
+            if (properties[i] & PostForm)
+                where[i] &= ~PostFormProperty;
+        }
+
+        HB_OpenTypeShape(item, where);
+        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))
+            return FALSE;
+    } else
+#endif
+    {
+       MMDEBUG("Not using openType");
+        HB_HeuristicPosition(item);
+    }
+
+    item->attributes[0].clusterStart = TRUE;
+    return TRUE;
+}
+
+HB_Bool HB_MyanmarShape(HB_ShaperItem *item)
+{
+    HB_Bool openType = FALSE;
+    unsigned short *logClusters = item->log_clusters;
+
+    HB_ShaperItem syllable = *item;
+    int first_glyph = 0;
+
+    int sstart = item->item.pos;
+    int end = sstart + item->item.length;
+    int i = 0;
+
+    assert(item->item.script == HB_Script_Myanmar);
+#ifndef NO_OPENTYPE
+    openType = HB_SelectScript(item, myanmar_features);
+#endif
+
+    MMDEBUG("myanmar_shape: from %d length %d", item->item.pos, item->item.length);
+    while (sstart < end) {
+        HB_Bool invalid;
+        int send = myanmar_nextSyllableBoundary(item->string, sstart, end, &invalid);
+        MMDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,
+               invalid ? "TRUE" : "FALSE");
+        syllable.item.pos = sstart;
+        syllable.item.length = send-sstart;
+        syllable.glyphs = item->glyphs + first_glyph;
+        syllable.attributes = item->attributes + first_glyph;
+        syllable.advances = item->advances + first_glyph;
+        syllable.offsets = item->offsets + first_glyph;
+        syllable.num_glyphs = item->num_glyphs - first_glyph;
+        if (!myanmar_shape_syllable(openType, &syllable, invalid)) {
+            MMDEBUG("syllable shaping failed, syllable requests %d glyphs", syllable.num_glyphs);
+            item->num_glyphs += syllable.num_glyphs;
+            return FALSE;
+        }
+
+        /* fix logcluster array */
+        MMDEBUG("syllable:");
+        for (i = first_glyph; i < first_glyph + (int)syllable.num_glyphs; ++i)
+            MMDEBUG("        %d -> glyph %x", i, item->glyphs[i]);
+        MMDEBUG("    logclusters:");
+        for (i = sstart; i < send; ++i) {
+            MMDEBUG("        %d -> glyph %d", i, first_glyph);
+            logClusters[i-item->item.pos] = first_glyph;
+        }
+        sstart = send;
+        first_glyph += syllable.num_glyphs;
+    }
+    item->num_glyphs = first_glyph;
+    return TRUE;
+}
+
+void HB_MyanmarAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    int end = from + len;
+    const HB_UChar16 *uc = text + from;
+    hb_uint32 i = 0;
+    HB_UNUSED(script);
+    attributes += from;
+    while (i < len) {
+       HB_Bool invalid;
+       hb_uint32 boundary = myanmar_nextSyllableBoundary(text, from+i, end, &invalid) - from;
+
+       attributes[i].charStop = TRUE;
+        if (i)
+            attributes[i-1].lineBreakType = HB_Break;
+
+       if (boundary > len-1)
+            boundary = len;
+       i++;
+       while (i < boundary) {
+           attributes[i].charStop = FALSE;
+           ++uc;
+           ++i;
+       }
+       assert(i == boundary);
+    }
+}
+
index eda41a2..c786ebb 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-open-private.h"\r
-\r
-\r
-/***************************\r
- * Script related functions\r
- ***************************/\r
-\r
-\r
-/* LangSys */\r
-\r
-static HB_Error  Load_LangSys( HB_LangSys*  ls,\r
-                              HB_Stream     stream )\r
-{\r
-  HB_Error   error;\r
-  HB_UShort  n, count;\r
-  HB_UShort* fi;\r
-\r
-\r
-  if ( ACCESS_Frame( 6L ) )\r
-    return error;\r
-\r
-  ls->LookupOrderOffset    = GET_UShort();    /* should be 0 */\r
-  ls->ReqFeatureIndex      = GET_UShort();\r
-  count = ls->FeatureCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ls->FeatureIndex = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ls->FeatureIndex, count, HB_UShort ) )\r
-    return error;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( ls->FeatureIndex );\r
-    return error;\r
-  }\r
-\r
-  fi = ls->FeatureIndex;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    fi[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_LangSys( HB_LangSys*  ls )\r
-{\r
-  FREE( ls->FeatureIndex );\r
-}\r
-\r
-\r
-/* Script */\r
-\r
-static HB_Error  Load_Script( HB_ScriptTable*  s,\r
-                             HB_Stream    stream )\r
-{\r
-  HB_Error   error;\r
-  HB_UShort  n, m, count;\r
-  HB_UInt   cur_offset, new_offset, base_offset;\r
-\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  new_offset = GET_UShort() + base_offset;\r
-\r
-  FORGET_Frame();\r
-\r
-  if ( new_offset != base_offset )        /* not a NULL offset */\r
-  {\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LangSys( &s->DefaultLangSys,\r
-                                stream ) ) != HB_Err_Ok )\r
-      return error;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-  else\r
-  {\r
-    /* we create a DefaultLangSys table with no entries */\r
-\r
-    s->DefaultLangSys.LookupOrderOffset = 0;\r
-    s->DefaultLangSys.ReqFeatureIndex   = 0xFFFF;\r
-    s->DefaultLangSys.FeatureCount      = 0;\r
-    s->DefaultLangSys.FeatureIndex      = NULL;\r
-  }\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    goto Fail2;\r
-\r
-  count = s->LangSysCount = GET_UShort();\r
-\r
-  /* safety check; otherwise the official handling of TrueType Open\r
-     fonts won't work */\r
-\r
-  if ( s->LangSysCount == 0 && s->DefaultLangSys.FeatureCount == 0 )\r
-  {\r
-    error = HB_Err_Not_Covered;\r
-    goto Fail2;\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  s->LangSysRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( s->LangSysRecord, count, HB_LangSysRecord ) )\r
-    goto Fail2;\r
-\r
-  lsr = s->LangSysRecord;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 6L ) )\r
-      goto Fail1;\r
-\r
-    lsr[n].LangSysTag = GET_ULong();\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_LangSys( &lsr[n].LangSys, stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_LangSys( &lsr[m].LangSys );\r
-\r
-  FREE( s->LangSysRecord );\r
-\r
-Fail2:\r
-  Free_LangSys( &s->DefaultLangSys );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_Script( HB_ScriptTable*  s )\r
-{\r
-  HB_UShort           n, count;\r
-\r
-  HB_LangSysRecord*  lsr;\r
-\r
-\r
-  Free_LangSys( &s->DefaultLangSys );\r
-\r
-  if ( s->LangSysRecord )\r
-  {\r
-    count = s->LangSysCount;\r
-    lsr   = s->LangSysRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_LangSys( &lsr[n].LangSys );\r
-\r
-    FREE( lsr );\r
-  }\r
-}\r
-\r
-\r
-/* ScriptList */\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,\r
-                          HB_Stream        stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort          n, script_count;\r
-  HB_UInt           cur_offset, new_offset, base_offset;\r
-\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  script_count = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  sl->ScriptRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( sl->ScriptRecord, script_count, HB_ScriptRecord ) )\r
-    return error;\r
-\r
-  sr = sl->ScriptRecord;\r
-\r
-  sl->ScriptCount= 0;\r
-  for ( n = 0; n < script_count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 6L ) )\r
-      goto Fail;\r
-\r
-    sr[sl->ScriptCount].ScriptTag = GET_ULong();\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-\r
-    if ( FILE_Seek( new_offset ) )\r
-      goto Fail;\r
-\r
-    error = Load_Script( &sr[sl->ScriptCount].Script, stream );\r
-    if ( error == HB_Err_Ok )\r
-      sl->ScriptCount += 1;\r
-    else if ( error != HB_Err_Not_Covered )\r
-      goto Fail;\r
-\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  /* Empty tables are harmless and generated by fontforge.\r
-   * See http://bugzilla.gnome.org/show_bug.cgi?id=347073\r
-   */\r
-#if 0\r
-  if ( sl->ScriptCount == 0 )\r
-  {\r
-    error = ERR_HB(HB_Err_Invalid_SubTable);\r
-    goto Fail;\r
-  }\r
-#endif\r
-  \r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( n = 0; n < sl->ScriptCount; n++ )\r
-    Free_Script( &sr[n].Script );\r
-\r
-  FREE( sl->ScriptRecord );\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_ScriptList( HB_ScriptList* sl )\r
-{\r
-  HB_UShort          n, count;\r
-\r
-  HB_ScriptRecord*  sr;\r
-\r
-\r
-  if ( sl->ScriptRecord )\r
-  {\r
-    count = sl->ScriptCount;\r
-    sr    = sl->ScriptRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Script( &sr[n].Script );\r
-\r
-    FREE( sr );\r
-  }\r
-}\r
-\r
-\r
-\r
-/*********************************\r
- * Feature List related functions\r
- *********************************/\r
-\r
-\r
-/* Feature */\r
-\r
-static HB_Error  Load_Feature( HB_Feature*  f,\r
-                              HB_Stream     stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort   n, count;\r
-\r
-  HB_UShort*  lli;\r
-\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  f->FeatureParams           = GET_UShort();    /* should be 0 */\r
-  count = f->LookupListCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  f->LookupListIndex = NULL;\r
-\r
-  if ( ALLOC_ARRAY( f->LookupListIndex, count, HB_UShort ) )\r
-    return error;\r
-\r
-  lli = f->LookupListIndex;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( f->LookupListIndex );\r
-    return error;\r
-  }\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    lli[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_Feature( HB_Feature*  f )\r
-{\r
-  FREE( f->LookupListIndex );\r
-}\r
-\r
-\r
-/* FeatureList */\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,\r
-                           HB_Stream         stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort           n, m, count;\r
-  HB_UInt            cur_offset, new_offset, base_offset;\r
-\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = fl->FeatureCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  fl->FeatureRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( fl->FeatureRecord, count, HB_FeatureRecord ) )\r
-    return error;\r
-  if ( ALLOC_ARRAY( fl->ApplyOrder, count, HB_UShort ) )\r
-    goto Fail2;\r
-  \r
-  fl->ApplyCount = 0;\r
-\r
-  fr = fl->FeatureRecord;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 6L ) )\r
-      goto Fail1;\r
-\r
-    fr[n].FeatureTag = GET_ULong();\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_Feature( &fr[n].Feature, stream ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_Feature( &fr[m].Feature );\r
-\r
-  FREE( fl->ApplyOrder );\r
-\r
-Fail2:\r
-  FREE( fl->FeatureRecord );\r
-\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_FeatureList( HB_FeatureList*  fl )\r
-{\r
-  HB_UShort           n, count;\r
-\r
-  HB_FeatureRecord*  fr;\r
-\r
-\r
-  if ( fl->FeatureRecord )\r
-  {\r
-    count = fl->FeatureCount;\r
-    fr    = fl->FeatureRecord;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Feature( &fr[n].Feature );\r
-\r
-    FREE( fr );\r
-  }\r
-  \r
-  FREE( fl->ApplyOrder );\r
-}\r
-\r
-\r
-\r
-/********************************\r
- * Lookup List related functions\r
- ********************************/\r
-\r
-/* the subroutines of the following two functions are defined in\r
-   ftxgsub.c and ftxgpos.c respectively                          */\r
-\r
-\r
-/* SubTable */\r
-\r
-static HB_Error  Load_SubTable( HB_SubTable*  st,\r
-                               HB_Stream     stream,\r
-                               HB_Type       table_type,\r
-                               HB_UShort     lookup_type )\r
-{\r
-  if ( table_type == HB_Type_GSUB )\r
-    return _HB_GSUB_Load_SubTable ( &st->st.gsub, stream, lookup_type );\r
-  else\r
-    return _HB_GPOS_Load_SubTable ( &st->st.gpos, stream, lookup_type );\r
-}\r
-\r
-\r
-static void  Free_SubTable( HB_SubTable*  st,\r
-                           HB_Type       table_type,\r
-                           HB_UShort      lookup_type )\r
-{\r
-  if ( table_type == HB_Type_GSUB )\r
-    _HB_GSUB_Free_SubTable ( &st->st.gsub, lookup_type );\r
-  else\r
-    _HB_GPOS_Free_SubTable ( &st->st.gpos, lookup_type );\r
-}\r
-\r
-\r
-/* Lookup */\r
-\r
-static HB_Error  Load_Lookup( HB_Lookup*   l,\r
-                             HB_Stream     stream,\r
-                             HB_Type      type )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort      n, m, count;\r
-  HB_UInt       cur_offset, new_offset, base_offset;\r
-\r
-  HB_SubTable*  st;\r
-\r
-  HB_Bool        is_extension = FALSE;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 6L ) )\r
-    return error;\r
-\r
-  l->LookupType            = GET_UShort();\r
-  l->LookupFlag            = GET_UShort();\r
-  count = l->SubTableCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  l->SubTable = NULL;\r
-\r
-  if ( ALLOC_ARRAY( l->SubTable, count, HB_SubTable ) )\r
-    return error;\r
-\r
-  st = l->SubTable;\r
-\r
-  if ( ( type == HB_Type_GSUB && l->LookupType == HB_GSUB_LOOKUP_EXTENSION ) ||\r
-       ( type == HB_Type_GPOS && l->LookupType == HB_GPOS_LOOKUP_EXTENSION ) )\r
-    is_extension = TRUE;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-\r
-    if ( is_extension )\r
-    {\r
-      if ( FILE_Seek( new_offset ) || ACCESS_Frame( 8L ) )\r
-       goto Fail;\r
-\r
-      if (GET_UShort() != 1) /* format should be 1 */\r
-       goto Fail;\r
-\r
-      l->LookupType = GET_UShort();\r
-      new_offset += GET_ULong();\r
-\r
-      FORGET_Frame();\r
-    }\r
-\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_SubTable( &st[n], stream,\r
-                                 type, l->LookupType ) ) != HB_Err_Ok )\r
-      goto Fail;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  for ( m = 0; m < n; m++ )\r
-    Free_SubTable( &st[m], type, l->LookupType );\r
-\r
-  FREE( l->SubTable );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_Lookup( HB_Lookup*   l,\r
-                         HB_Type      type)\r
-{\r
-  HB_UShort      n, count;\r
-\r
-  HB_SubTable*  st;\r
-\r
-\r
-  if ( l->SubTable )\r
-  {\r
-    count = l->SubTableCount;\r
-    st    = l->SubTable;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_SubTable( &st[n], type, l->LookupType );\r
-\r
-    FREE( st );\r
-  }\r
-}\r
-\r
-\r
-/* LookupList */\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_LookupList( HB_LookupList* ll,\r
-                          HB_Stream        stream,\r
-                          HB_Type         type )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort    n, m, count;\r
-  HB_UInt     cur_offset, new_offset, base_offset;\r
-\r
-  HB_Lookup*  l;\r
-\r
-\r
-  base_offset = FILE_Pos();\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = ll->LookupCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  ll->Lookup = NULL;\r
-\r
-  if ( ALLOC_ARRAY( ll->Lookup, count, HB_Lookup ) )\r
-    return error;\r
-  if ( ALLOC_ARRAY( ll->Properties, count, HB_UInt ) )\r
-    goto Fail2;\r
-\r
-  l = ll->Lookup;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    if ( ACCESS_Frame( 2L ) )\r
-      goto Fail1;\r
-\r
-    new_offset = GET_UShort() + base_offset;\r
-\r
-    FORGET_Frame();\r
-\r
-    cur_offset = FILE_Pos();\r
-    if ( FILE_Seek( new_offset ) ||\r
-        ( error = Load_Lookup( &l[n], stream, type ) ) != HB_Err_Ok )\r
-      goto Fail1;\r
-    (void)FILE_Seek( cur_offset );\r
-  }\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail1:\r
-  FREE( ll->Properties );\r
-\r
-  for ( m = 0; m < n; m++ )\r
-    Free_Lookup( &l[m], type );\r
-\r
-Fail2:\r
-  FREE( ll->Lookup );\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_LookupList( HB_LookupList* ll,\r
-                      HB_Type         type )\r
-{\r
-  HB_UShort    n, count;\r
-\r
-  HB_Lookup*  l;\r
-\r
-\r
-  FREE( ll->Properties );\r
-\r
-  if ( ll->Lookup )\r
-  {\r
-    count = ll->LookupCount;\r
-    l     = ll->Lookup;\r
-\r
-    for ( n = 0; n < count; n++ )\r
-      Free_Lookup( &l[n], type );\r
-\r
-    FREE( l );\r
-  }\r
-}\r
-\r
-\r
-\r
-/*****************************\r
- * Coverage related functions\r
- *****************************/\r
-\r
-\r
-/* CoverageFormat1 */\r
-\r
-static HB_Error  Load_Coverage1( HB_CoverageFormat1*  cf1,\r
-                                HB_Stream             stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort  n, count;\r
-\r
-  HB_UShort* ga;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = cf1->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cf1->GlyphArray = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cf1->GlyphArray, count, HB_UShort ) )\r
-    return error;\r
-\r
-  ga = cf1->GlyphArray;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( cf1->GlyphArray );\r
-    return error;\r
-  }\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    ga[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static void  Free_Coverage1( HB_CoverageFormat1*  cf1)\r
-{\r
-  FREE( cf1->GlyphArray );\r
-}\r
-\r
-\r
-/* CoverageFormat2 */\r
-\r
-static HB_Error  Load_Coverage2( HB_CoverageFormat2*  cf2,\r
-                                HB_Stream             stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort         n, count;\r
-\r
-  HB_RangeRecord*  rr;\r
-\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = cf2->RangeCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  cf2->RangeRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cf2->RangeRecord, count, HB_RangeRecord ) )\r
-    return error;\r
-\r
-  rr = cf2->RangeRecord;\r
-\r
-  if ( ACCESS_Frame( count * 6L ) )\r
-    goto Fail;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    rr[n].Start              = GET_UShort();\r
-    rr[n].End                = GET_UShort();\r
-    rr[n].StartCoverageIndex = GET_UShort();\r
-\r
-    /* sanity check; we are limited to 16bit integers */\r
-    if ( rr[n].Start > rr[n].End ||\r
-        ( rr[n].End - rr[n].Start + (long)rr[n].StartCoverageIndex ) >=\r
-          0x10000L )\r
-    {\r
-      error = ERR_HB(HB_Err_Invalid_SubTable);\r
-      goto Fail;\r
-    }\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  FREE( cf2->RangeRecord );\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_Coverage2( HB_CoverageFormat2*  cf2 )\r
-{\r
-  FREE( cf2->RangeRecord );\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Coverage( HB_Coverage* c,\r
-                        HB_Stream      stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  c->CoverageFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( c->CoverageFormat )\r
-  {\r
-  case 1:  return Load_Coverage1( &c->cf.cf1, stream );\r
-  case 2:  return Load_Coverage2( &c->cf.cf2, stream );\r
-  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_Coverage( HB_Coverage* c )\r
-{\r
-  switch ( c->CoverageFormat )\r
-  {\r
-  case 1:  Free_Coverage1( &c->cf.cf1 ); break;\r
-  case 2:  Free_Coverage2( &c->cf.cf2 ); break;\r
-  default:                                      break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Coverage_Index1( HB_CoverageFormat1*  cf1,\r
-                                 HB_UShort             glyphID,\r
-                                 HB_UShort*            index )\r
-{\r
-  HB_UShort min, max, new_min, new_max, middle;\r
-\r
-  HB_UShort*  array = cf1->GlyphArray;\r
-\r
-\r
-  /* binary search */\r
-\r
-  if ( cf1->GlyphCount == 0 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  new_min = 0;\r
-  new_max = cf1->GlyphCount - 1;\r
-\r
-  do\r
-  {\r
-    min = new_min;\r
-    max = new_max;\r
-\r
-    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid\r
-       overflow and rounding errors                             */\r
-\r
-    middle = max - ( ( max - min ) >> 1 );\r
-\r
-    if ( glyphID == array[middle] )\r
-    {\r
-      *index = middle;\r
-      return HB_Err_Ok;\r
-    }\r
-    else if ( glyphID < array[middle] )\r
-    {\r
-      if ( middle == min )\r
-       break;\r
-      new_max = middle - 1;\r
-    }\r
-    else\r
-    {\r
-      if ( middle == max )\r
-       break;\r
-      new_min = middle + 1;\r
-    }\r
-  } while ( min < max );\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-static HB_Error  Coverage_Index2( HB_CoverageFormat2*  cf2,\r
-                                 HB_UShort             glyphID,\r
-                                 HB_UShort*            index )\r
-{\r
-  HB_UShort         min, max, new_min, new_max, middle;\r
-\r
-  HB_RangeRecord*  rr = cf2->RangeRecord;\r
-\r
-\r
-  /* binary search */\r
-\r
-  if ( cf2->RangeCount == 0 )\r
-    return HB_Err_Not_Covered;\r
-\r
-  new_min = 0;\r
-  new_max = cf2->RangeCount - 1;\r
-\r
-  do\r
-  {\r
-    min = new_min;\r
-    max = new_max;\r
-\r
-    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid\r
-       overflow and rounding errors                             */\r
-\r
-    middle = max - ( ( max - min ) >> 1 );\r
-\r
-    if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End )\r
-    {\r
-      *index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start;\r
-      return HB_Err_Ok;\r
-    }\r
-    else if ( glyphID < rr[middle].Start )\r
-    {\r
-      if ( middle == min )\r
-       break;\r
-      new_max = middle - 1;\r
-    }\r
-    else\r
-    {\r
-      if ( middle == max )\r
-       break;\r
-      new_min = middle + 1;\r
-    }\r
-  } while ( min < max );\r
-\r
-  return HB_Err_Not_Covered;\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Coverage_Index( HB_Coverage* c,\r
-                         HB_UShort      glyphID,\r
-                         HB_UShort*     index )\r
-{\r
-  switch ( c->CoverageFormat )\r
-  {\r
-  case 1:  return Coverage_Index1( &c->cf.cf1, glyphID, index );\r
-  case 2:  return Coverage_Index2( &c->cf.cf2, glyphID, index );\r
-  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-\r
-/*************************************\r
- * Class Definition related functions\r
- *************************************/\r
-\r
-\r
-/* ClassDefFormat1 */\r
-\r
-static HB_Error  Load_ClassDef1( HB_ClassDefinition*  cd,\r
-                                HB_UShort             limit,\r
-                                HB_Stream             stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort             n, count;\r
-\r
-  HB_UShort*            cva;\r
-\r
-  HB_ClassDefFormat1*  cdf1;\r
-\r
-\r
-  cdf1 = &cd->cd.cd1;\r
-\r
-  if ( ACCESS_Frame( 4L ) )\r
-    return error;\r
-\r
-  cdf1->StartGlyph         = GET_UShort();\r
-  count = cdf1->GlyphCount = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  /* sanity check; we are limited to 16bit integers */\r
-\r
-  if ( cdf1->StartGlyph + (long)count >= 0x10000L )\r
-    return ERR_HB(HB_Err_Invalid_SubTable);\r
-\r
-  cdf1->ClassValueArray = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cdf1->ClassValueArray, count, HB_UShort ) )\r
-    return error;\r
-\r
-  cva = cdf1->ClassValueArray;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-    goto Fail;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    cva[n] = GET_UShort();\r
-    if ( cva[n] >= limit )\r
-    {\r
-      error = ERR_HB(HB_Err_Invalid_SubTable);\r
-      goto Fail;\r
-    }\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  FREE( cva );\r
-\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ClassDef1( HB_ClassDefFormat1*  cdf1 )\r
-{\r
-  FREE( cdf1->ClassValueArray );\r
-}\r
-\r
-\r
-/* ClassDefFormat2 */\r
-\r
-static HB_Error  Load_ClassDef2( HB_ClassDefinition*  cd,\r
-                                HB_UShort             limit,\r
-                                HB_Stream             stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort              n, count;\r
-\r
-  HB_ClassRangeRecord*  crr;\r
-\r
-  HB_ClassDefFormat2*   cdf2;\r
-\r
-\r
-  cdf2 = &cd->cd.cd2;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  count = GET_UShort();\r
-  cdf2->ClassRangeCount = 0; /* zero for now.  we fill with the number of good entries later */\r
-\r
-  FORGET_Frame();\r
-\r
-  cdf2->ClassRangeRecord = NULL;\r
-\r
-  if ( ALLOC_ARRAY( cdf2->ClassRangeRecord, count, HB_ClassRangeRecord ) )\r
-    return error;\r
-\r
-  crr = cdf2->ClassRangeRecord;\r
-\r
-  if ( ACCESS_Frame( count * 6L ) )\r
-    goto Fail;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-  {\r
-    crr[n].Start = GET_UShort();\r
-    crr[n].End   = GET_UShort();\r
-    crr[n].Class = GET_UShort();\r
-\r
-    /* sanity check */\r
-\r
-    if ( crr[n].Start > crr[n].End ||\r
-        crr[n].Class >= limit )\r
-    {\r
-      /* XXX\r
-       * Corrupt entry.  Skip it.\r
-       * This is hit by Nafees Nastaliq font for example\r
-       */\r
-       n--;\r
-       count--;\r
-    }\r
-  }\r
-\r
-  FORGET_Frame();\r
-\r
-  cdf2->ClassRangeCount = count;\r
-\r
-  return HB_Err_Ok;\r
-\r
-Fail:\r
-  FREE( crr );\r
-\r
-  return error;\r
-}\r
-\r
-\r
-static void  Free_ClassDef2( HB_ClassDefFormat2*  cdf2 )\r
-{\r
-  FREE( cdf2->ClassRangeRecord );\r
-}\r
-\r
-\r
-/* ClassDefinition */\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,\r
-                               HB_UShort             limit,\r
-                               HB_Stream             stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  if ( ACCESS_Frame( 2L ) )\r
-    return error;\r
-\r
-  cd->ClassFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  switch ( cd->ClassFormat )\r
-  {\r
-  case 1:  error = Load_ClassDef1( cd, limit, stream ); break;\r
-  case 2:  error = Load_ClassDef2( cd, limit, stream ); break;\r
-  default: error = ERR_HB(HB_Err_Invalid_SubTable_Format);     break;\r
-  }\r
-\r
-  if ( error )\r
-    return error;\r
-\r
-  cd->loaded = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-static HB_Error\r
-_HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition*  cd )\r
-{\r
-  HB_Error   error;\r
-\r
-  cd->ClassFormat = 1; /* Meaningless */\r
-\r
-  if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, HB_UShort ) )\r
-    return error;\r
-\r
-  cd->loaded = TRUE;\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,\r
-                                              HB_UShort             limit,\r
-                                              HB_UInt              class_offset,\r
-                                              HB_UInt              base_offset,\r
-                                              HB_Stream             stream )\r
-{\r
-  HB_Error error;\r
-  HB_UInt               cur_offset;\r
-\r
-  cur_offset = FILE_Pos();\r
-\r
-  if ( class_offset )\r
-    {\r
-      if ( !FILE_Seek( class_offset + base_offset ) )\r
-       error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream );\r
-    }\r
-  else\r
-     error = _HB_OPEN_Load_EmptyClassDefinition ( cd );\r
-\r
-  if (error == HB_Err_Ok)\r
-    (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */\r
-\r
-  return error;\r
-}\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd )\r
-{\r
-  if ( !cd->loaded )\r
-    return;\r
-\r
-  switch ( cd->ClassFormat )\r
-  {\r
-  case 1:  Free_ClassDef1( &cd->cd.cd1 ); break;\r
-  case 2:  Free_ClassDef2( &cd->cd.cd2 ); break;\r
-  default:                               break;\r
-  }\r
-}\r
-\r
-\r
-static HB_Error  Get_Class1( HB_ClassDefFormat1*  cdf1,\r
-                            HB_UShort             glyphID,\r
-                            HB_UShort*            klass,\r
-                            HB_UShort*            index )\r
-{\r
-  HB_UShort*  cva = cdf1->ClassValueArray;\r
-\r
-\r
-  if ( index )\r
-    *index = 0;\r
-\r
-  if ( glyphID >= cdf1->StartGlyph &&\r
-       glyphID < cdf1->StartGlyph + cdf1->GlyphCount )\r
-  {\r
-    *klass = cva[glyphID - cdf1->StartGlyph];\r
-    return HB_Err_Ok;\r
-  }\r
-  else\r
-  {\r
-    *klass = 0;\r
-    return HB_Err_Not_Covered;\r
-  }\r
-}\r
-\r
-\r
-/* we need the index value of the last searched class range record\r
-   in case of failure for constructed GDEF tables                  */\r
-\r
-static HB_Error  Get_Class2( HB_ClassDefFormat2*  cdf2,\r
-                            HB_UShort             glyphID,\r
-                            HB_UShort*            klass,\r
-                            HB_UShort*            index )\r
-{\r
-  HB_Error               error = HB_Err_Ok;\r
-  HB_UShort              min, max, new_min, new_max, middle;\r
-\r
-  HB_ClassRangeRecord*  crr = cdf2->ClassRangeRecord;\r
-\r
-\r
-  /* binary search */\r
-\r
-  if ( cdf2->ClassRangeCount == 0 )\r
-    {\r
-      *klass = 0;\r
-      if ( index )\r
-       *index = 0;\r
-      \r
-      return HB_Err_Not_Covered;\r
-    }\r
-\r
-  new_min = 0;\r
-  new_max = cdf2->ClassRangeCount - 1;\r
-\r
-  do\r
-  {\r
-    min = new_min;\r
-    max = new_max;\r
-\r
-    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid\r
-       overflow and rounding errors                             */\r
-\r
-    middle = max - ( ( max - min ) >> 1 );\r
-\r
-    if ( glyphID >= crr[middle].Start && glyphID <= crr[middle].End )\r
-    {\r
-      *klass = crr[middle].Class;\r
-      error  = HB_Err_Ok;\r
-      break;\r
-    }\r
-    else if ( glyphID < crr[middle].Start )\r
-    {\r
-      if ( middle == min )\r
-      {\r
-       *klass = 0;\r
-       error  = HB_Err_Not_Covered;\r
-       break;\r
-      }\r
-      new_max = middle - 1;\r
-    }\r
-    else\r
-    {\r
-      if ( middle == max )\r
-      {\r
-       *klass = 0;\r
-       error  = HB_Err_Not_Covered;\r
-       break;\r
-      }\r
-      new_min = middle + 1;\r
-    }\r
-  } while ( min < max );\r
-\r
-  if ( index )\r
-    *index = middle;\r
-\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Class( HB_ClassDefinition* cd,\r
-                    HB_UShort             glyphID,\r
-                   HB_UShort*          klass,\r
-                    HB_UShort*            index )\r
-{\r
-  switch ( cd->ClassFormat )\r
-  {\r
-  case 1:  return Get_Class1( &cd->cd.cd1, glyphID, klass, index );\r
-  case 2:  return Get_Class2( &cd->cd.cd2, glyphID, klass, index );\r
-  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);\r
-  }\r
-\r
-  return HB_Err_Ok;               /* never reached */\r
-}\r
-\r
-\r
-\r
-/***************************\r
- * Device related functions\r
- ***************************/\r
-\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Load_Device( HB_Device* d,\r
-                      HB_Stream    stream )\r
-{\r
-  HB_Error   error;\r
-\r
-  HB_UShort   n, count;\r
-\r
-  HB_UShort*  dv;\r
-\r
-\r
-  if ( ACCESS_Frame( 6L ) )\r
-    return error;\r
-\r
-  d->StartSize   = GET_UShort();\r
-  d->EndSize     = GET_UShort();\r
-  d->DeltaFormat = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  d->DeltaValue = NULL;\r
-\r
-  if ( d->StartSize > d->EndSize ||\r
-       d->DeltaFormat == 0 || d->DeltaFormat > 3 )\r
-    {\r
-      /* XXX\r
-       * I've seen fontforge generate DeltaFormat == 0.\r
-       * Just return Ok and let the NULL DeltaValue disable\r
-       * this table.\r
-       */\r
-      return HB_Err_Ok;\r
-    }\r
-\r
-  count = ( ( d->EndSize - d->StartSize + 1 ) >>\r
-             ( 4 - d->DeltaFormat ) ) + 1;\r
-\r
-  if ( ALLOC_ARRAY( d->DeltaValue, count, HB_UShort ) )\r
-    return error;\r
-\r
-  if ( ACCESS_Frame( count * 2L ) )\r
-  {\r
-    FREE( d->DeltaValue );\r
-    return error;\r
-  }\r
-\r
-  dv = d->DeltaValue;\r
-\r
-  for ( n = 0; n < count; n++ )\r
-    dv[n] = GET_UShort();\r
-\r
-  FORGET_Frame();\r
-\r
-  return HB_Err_Ok;\r
-}\r
-\r
-\r
-HB_INTERNAL void\r
-_HB_OPEN_Free_Device( HB_Device* d )\r
-{\r
-  FREE( d->DeltaValue );\r
-}\r
-\r
-\r
-/* Since we have the delta values stored in compressed form, we must\r
-   uncompress it now.  To simplify the interface, the function always\r
-   returns a meaningful value in `value'; the error is just for\r
-   information.\r
-                              |                |\r
-   format = 1: 0011223344556677|8899101112131415|...\r
-                              |                |\r
-                   byte 1           byte 2\r
-\r
-     00: (byte >> 14) & mask\r
-     11: (byte >> 12) & mask\r
-     ...\r
-\r
-     mask = 0x0003\r
-                              |                |\r
-   format = 2: 0000111122223333|4444555566667777|...\r
-                              |                |\r
-                   byte 1           byte 2\r
-\r
-     0000: (byte >> 12) & mask\r
-     1111: (byte >>  8) & mask\r
-     ...\r
-\r
-     mask = 0x000F\r
-                              |                |\r
-   format = 3: 0000000011111111|2222222233333333|...\r
-                              |                |\r
-                   byte 1           byte 2\r
-\r
-     00000000: (byte >> 8) & mask\r
-     11111111: (byte >> 0) & mask\r
-     ....\r
-\r
-     mask = 0x00FF                                    */\r
-\r
-HB_INTERNAL HB_Error\r
-_HB_OPEN_Get_Device( HB_Device* d,\r
-                     HB_UShort    size,\r
-                     HB_Short*    value )\r
-{\r
-  HB_UShort  byte, bits, mask, f, s;\r
-\r
-\r
-  f = d->DeltaFormat;\r
-\r
-  if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize )\r
-  {\r
-    s    = size - d->StartSize;\r
-    byte = d->DeltaValue[s >> ( 4 - f )];\r
-    bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) );\r
-    mask = 0xFFFF >> ( 16 - ( 1 << f ) );\r
-\r
-    *value = (HB_Short)( bits & mask );\r
-\r
-    /* conversion to a signed value */\r
-\r
-    if ( *value >= ( ( mask + 1 ) >> 1 ) )\r
-      *value -= mask + 1;\r
-\r
-    return HB_Err_Ok;\r
-  }\r
-  else\r
-  {\r
-    *value = 0;\r
-    return HB_Err_Not_Covered;\r
-  }\r
-}\r
-\r
-\r
-/* END */\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-open-private.h"
+
+
+/***************************
+ * Script related functions
+ ***************************/
+
+
+/* LangSys */
+
+static HB_Error  Load_LangSys( HB_LangSys*  ls,
+                              HB_Stream     stream )
+{
+  HB_Error   error;
+  HB_UShort  n, count;
+  HB_UShort* fi;
+
+
+  if ( ACCESS_Frame( 6L ) )
+    return error;
+
+  ls->LookupOrderOffset    = GET_UShort();    /* should be 0 */
+  ls->ReqFeatureIndex      = GET_UShort();
+  count = ls->FeatureCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ls->FeatureIndex = NULL;
+
+  if ( ALLOC_ARRAY( ls->FeatureIndex, count, HB_UShort ) )
+    return error;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( ls->FeatureIndex );
+    return error;
+  }
+
+  fi = ls->FeatureIndex;
+
+  for ( n = 0; n < count; n++ )
+    fi[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_LangSys( HB_LangSys*  ls )
+{
+  FREE( ls->FeatureIndex );
+}
+
+
+/* Script */
+
+static HB_Error  Load_Script( HB_ScriptTable*  s,
+                             HB_Stream    stream )
+{
+  HB_Error   error;
+  HB_UShort  n, m, count;
+  HB_UInt   cur_offset, new_offset, base_offset;
+
+  HB_LangSysRecord*  lsr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  new_offset = GET_UShort() + base_offset;
+
+  FORGET_Frame();
+
+  if ( new_offset != base_offset )        /* not a NULL offset */
+  {
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LangSys( &s->DefaultLangSys,
+                                stream ) ) != HB_Err_Ok )
+      return error;
+    (void)FILE_Seek( cur_offset );
+  }
+  else
+  {
+    /* we create a DefaultLangSys table with no entries */
+
+    s->DefaultLangSys.LookupOrderOffset = 0;
+    s->DefaultLangSys.ReqFeatureIndex   = 0xFFFF;
+    s->DefaultLangSys.FeatureCount      = 0;
+    s->DefaultLangSys.FeatureIndex      = NULL;
+  }
+
+  if ( ACCESS_Frame( 2L ) )
+    goto Fail2;
+
+  count = s->LangSysCount = GET_UShort();
+
+  /* safety check; otherwise the official handling of TrueType Open
+     fonts won't work */
+
+  if ( s->LangSysCount == 0 && s->DefaultLangSys.FeatureCount == 0 )
+  {
+    error = HB_Err_Not_Covered;
+    goto Fail2;
+  }
+
+  FORGET_Frame();
+
+  s->LangSysRecord = NULL;
+
+  if ( ALLOC_ARRAY( s->LangSysRecord, count, HB_LangSysRecord ) )
+    goto Fail2;
+
+  lsr = s->LangSysRecord;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 6L ) )
+      goto Fail1;
+
+    lsr[n].LangSysTag = GET_ULong();
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_LangSys( &lsr[n].LangSys, stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_LangSys( &lsr[m].LangSys );
+
+  FREE( s->LangSysRecord );
+
+Fail2:
+  Free_LangSys( &s->DefaultLangSys );
+  return error;
+}
+
+
+static void  Free_Script( HB_ScriptTable*  s )
+{
+  HB_UShort           n, count;
+
+  HB_LangSysRecord*  lsr;
+
+
+  Free_LangSys( &s->DefaultLangSys );
+
+  if ( s->LangSysRecord )
+  {
+    count = s->LangSysCount;
+    lsr   = s->LangSysRecord;
+
+    for ( n = 0; n < count; n++ )
+      Free_LangSys( &lsr[n].LangSys );
+
+    FREE( lsr );
+  }
+}
+
+
+/* ScriptList */
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+                          HB_Stream        stream )
+{
+  HB_Error   error;
+
+  HB_UShort          n, script_count;
+  HB_UInt           cur_offset, new_offset, base_offset;
+
+  HB_ScriptRecord*  sr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  script_count = GET_UShort();
+
+  FORGET_Frame();
+
+  sl->ScriptRecord = NULL;
+
+  if ( ALLOC_ARRAY( sl->ScriptRecord, script_count, HB_ScriptRecord ) )
+    return error;
+
+  sr = sl->ScriptRecord;
+
+  sl->ScriptCount= 0;
+  for ( n = 0; n < script_count; n++ )
+  {
+    if ( ACCESS_Frame( 6L ) )
+      goto Fail;
+
+    sr[sl->ScriptCount].ScriptTag = GET_ULong();
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+
+    if ( FILE_Seek( new_offset ) )
+      goto Fail;
+
+    error = Load_Script( &sr[sl->ScriptCount].Script, stream );
+    if ( error == HB_Err_Ok )
+      sl->ScriptCount += 1;
+    else if ( error != HB_Err_Not_Covered )
+      goto Fail;
+
+    (void)FILE_Seek( cur_offset );
+  }
+
+  /* Empty tables are harmless and generated by fontforge.
+   * See http://bugzilla.gnome.org/show_bug.cgi?id=347073
+   */
+#if 0
+  if ( sl->ScriptCount == 0 )
+  {
+    error = ERR_HB(HB_Err_Invalid_SubTable);
+    goto Fail;
+  }
+#endif
+  
+  return HB_Err_Ok;
+
+Fail:
+  for ( n = 0; n < sl->ScriptCount; n++ )
+    Free_Script( &sr[n].Script );
+
+  FREE( sl->ScriptRecord );
+  return error;
+}
+
+
+HB_INTERNAL void
+_HB_OPEN_Free_ScriptList( HB_ScriptList* sl )
+{
+  HB_UShort          n, count;
+
+  HB_ScriptRecord*  sr;
+
+
+  if ( sl->ScriptRecord )
+  {
+    count = sl->ScriptCount;
+    sr    = sl->ScriptRecord;
+
+    for ( n = 0; n < count; n++ )
+      Free_Script( &sr[n].Script );
+
+    FREE( sr );
+  }
+}
+
+
+
+/*********************************
+ * Feature List related functions
+ *********************************/
+
+
+/* Feature */
+
+static HB_Error  Load_Feature( HB_Feature*  f,
+                              HB_Stream     stream )
+{
+  HB_Error   error;
+
+  HB_UShort   n, count;
+
+  HB_UShort*  lli;
+
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  f->FeatureParams           = GET_UShort();    /* should be 0 */
+  count = f->LookupListCount = GET_UShort();
+
+  FORGET_Frame();
+
+  f->LookupListIndex = NULL;
+
+  if ( ALLOC_ARRAY( f->LookupListIndex, count, HB_UShort ) )
+    return error;
+
+  lli = f->LookupListIndex;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( f->LookupListIndex );
+    return error;
+  }
+
+  for ( n = 0; n < count; n++ )
+    lli[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_Feature( HB_Feature*  f )
+{
+  FREE( f->LookupListIndex );
+}
+
+
+/* FeatureList */
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+                           HB_Stream         stream )
+{
+  HB_Error   error;
+
+  HB_UShort           n, m, count;
+  HB_UInt            cur_offset, new_offset, base_offset;
+
+  HB_FeatureRecord*  fr;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = fl->FeatureCount = GET_UShort();
+
+  FORGET_Frame();
+
+  fl->FeatureRecord = NULL;
+
+  if ( ALLOC_ARRAY( fl->FeatureRecord, count, HB_FeatureRecord ) )
+    return error;
+  if ( ALLOC_ARRAY( fl->ApplyOrder, count, HB_UShort ) )
+    goto Fail2;
+  
+  fl->ApplyCount = 0;
+
+  fr = fl->FeatureRecord;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 6L ) )
+      goto Fail1;
+
+    fr[n].FeatureTag = GET_ULong();
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_Feature( &fr[n].Feature, stream ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  for ( m = 0; m < n; m++ )
+    Free_Feature( &fr[m].Feature );
+
+  FREE( fl->ApplyOrder );
+
+Fail2:
+  FREE( fl->FeatureRecord );
+
+  return error;
+}
+
+
+HB_INTERNAL void
+_HB_OPEN_Free_FeatureList( HB_FeatureList*  fl )
+{
+  HB_UShort           n, count;
+
+  HB_FeatureRecord*  fr;
+
+
+  if ( fl->FeatureRecord )
+  {
+    count = fl->FeatureCount;
+    fr    = fl->FeatureRecord;
+
+    for ( n = 0; n < count; n++ )
+      Free_Feature( &fr[n].Feature );
+
+    FREE( fr );
+  }
+  
+  FREE( fl->ApplyOrder );
+}
+
+
+
+/********************************
+ * Lookup List related functions
+ ********************************/
+
+/* the subroutines of the following two functions are defined in
+   ftxgsub.c and ftxgpos.c respectively                          */
+
+
+/* SubTable */
+
+static HB_Error  Load_SubTable( HB_SubTable*  st,
+                               HB_Stream     stream,
+                               HB_Type       table_type,
+                               HB_UShort     lookup_type )
+{
+  if ( table_type == HB_Type_GSUB )
+    return _HB_GSUB_Load_SubTable ( &st->st.gsub, stream, lookup_type );
+  else
+    return _HB_GPOS_Load_SubTable ( &st->st.gpos, stream, lookup_type );
+}
+
+
+static void  Free_SubTable( HB_SubTable*  st,
+                           HB_Type       table_type,
+                           HB_UShort      lookup_type )
+{
+  if ( table_type == HB_Type_GSUB )
+    _HB_GSUB_Free_SubTable ( &st->st.gsub, lookup_type );
+  else
+    _HB_GPOS_Free_SubTable ( &st->st.gpos, lookup_type );
+}
+
+
+/* Lookup */
+
+static HB_Error  Load_Lookup( HB_Lookup*   l,
+                             HB_Stream     stream,
+                             HB_Type      type )
+{
+  HB_Error   error;
+
+  HB_UShort      n, m, count;
+  HB_UInt       cur_offset, new_offset, base_offset;
+
+  HB_SubTable*  st;
+
+  HB_Bool        is_extension = FALSE;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 6L ) )
+    return error;
+
+  l->LookupType            = GET_UShort();
+  l->LookupFlag            = GET_UShort();
+  count = l->SubTableCount = GET_UShort();
+
+  FORGET_Frame();
+
+  l->SubTable = NULL;
+
+  if ( ALLOC_ARRAY( l->SubTable, count, HB_SubTable ) )
+    return error;
+
+  st = l->SubTable;
+
+  if ( ( type == HB_Type_GSUB && l->LookupType == HB_GSUB_LOOKUP_EXTENSION ) ||
+       ( type == HB_Type_GPOS && l->LookupType == HB_GPOS_LOOKUP_EXTENSION ) )
+    is_extension = TRUE;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+
+    if ( is_extension )
+    {
+      if ( FILE_Seek( new_offset ) || ACCESS_Frame( 8L ) )
+       goto Fail;
+
+      if (GET_UShort() != 1) /* format should be 1 */
+       goto Fail;
+
+      l->LookupType = GET_UShort();
+      new_offset += GET_ULong();
+
+      FORGET_Frame();
+    }
+
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_SubTable( &st[n], stream,
+                                 type, l->LookupType ) ) != HB_Err_Ok )
+      goto Fail;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail:
+  for ( m = 0; m < n; m++ )
+    Free_SubTable( &st[m], type, l->LookupType );
+
+  FREE( l->SubTable );
+  return error;
+}
+
+
+static void  Free_Lookup( HB_Lookup*   l,
+                         HB_Type      type)
+{
+  HB_UShort      n, count;
+
+  HB_SubTable*  st;
+
+
+  if ( l->SubTable )
+  {
+    count = l->SubTableCount;
+    st    = l->SubTable;
+
+    for ( n = 0; n < count; n++ )
+      Free_SubTable( &st[n], type, l->LookupType );
+
+    FREE( st );
+  }
+}
+
+
+/* LookupList */
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_LookupList( HB_LookupList* ll,
+                          HB_Stream        stream,
+                          HB_Type         type )
+{
+  HB_Error   error;
+
+  HB_UShort    n, m, count;
+  HB_UInt     cur_offset, new_offset, base_offset;
+
+  HB_Lookup*  l;
+
+
+  base_offset = FILE_Pos();
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = ll->LookupCount = GET_UShort();
+
+  FORGET_Frame();
+
+  ll->Lookup = NULL;
+
+  if ( ALLOC_ARRAY( ll->Lookup, count, HB_Lookup ) )
+    return error;
+  if ( ALLOC_ARRAY( ll->Properties, count, HB_UInt ) )
+    goto Fail2;
+
+  l = ll->Lookup;
+
+  for ( n = 0; n < count; n++ )
+  {
+    if ( ACCESS_Frame( 2L ) )
+      goto Fail1;
+
+    new_offset = GET_UShort() + base_offset;
+
+    FORGET_Frame();
+
+    cur_offset = FILE_Pos();
+    if ( FILE_Seek( new_offset ) ||
+        ( error = Load_Lookup( &l[n], stream, type ) ) != HB_Err_Ok )
+      goto Fail1;
+    (void)FILE_Seek( cur_offset );
+  }
+
+  return HB_Err_Ok;
+
+Fail1:
+  FREE( ll->Properties );
+
+  for ( m = 0; m < n; m++ )
+    Free_Lookup( &l[m], type );
+
+Fail2:
+  FREE( ll->Lookup );
+  return error;
+}
+
+
+HB_INTERNAL void
+_HB_OPEN_Free_LookupList( HB_LookupList* ll,
+                      HB_Type         type )
+{
+  HB_UShort    n, count;
+
+  HB_Lookup*  l;
+
+
+  FREE( ll->Properties );
+
+  if ( ll->Lookup )
+  {
+    count = ll->LookupCount;
+    l     = ll->Lookup;
+
+    for ( n = 0; n < count; n++ )
+      Free_Lookup( &l[n], type );
+
+    FREE( l );
+  }
+}
+
+
+
+/*****************************
+ * Coverage related functions
+ *****************************/
+
+
+/* CoverageFormat1 */
+
+static HB_Error  Load_Coverage1( HB_CoverageFormat1*  cf1,
+                                HB_Stream             stream )
+{
+  HB_Error   error;
+
+  HB_UShort  n, count;
+
+  HB_UShort* ga;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = cf1->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cf1->GlyphArray = NULL;
+
+  if ( ALLOC_ARRAY( cf1->GlyphArray, count, HB_UShort ) )
+    return error;
+
+  ga = cf1->GlyphArray;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( cf1->GlyphArray );
+    return error;
+  }
+
+  for ( n = 0; n < count; n++ )
+    ga[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+static void  Free_Coverage1( HB_CoverageFormat1*  cf1)
+{
+  FREE( cf1->GlyphArray );
+}
+
+
+/* CoverageFormat2 */
+
+static HB_Error  Load_Coverage2( HB_CoverageFormat2*  cf2,
+                                HB_Stream             stream )
+{
+  HB_Error   error;
+
+  HB_UShort         n, count;
+
+  HB_RangeRecord*  rr;
+
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = cf2->RangeCount = GET_UShort();
+
+  FORGET_Frame();
+
+  cf2->RangeRecord = NULL;
+
+  if ( ALLOC_ARRAY( cf2->RangeRecord, count, HB_RangeRecord ) )
+    return error;
+
+  rr = cf2->RangeRecord;
+
+  if ( ACCESS_Frame( count * 6L ) )
+    goto Fail;
+
+  for ( n = 0; n < count; n++ )
+  {
+    rr[n].Start              = GET_UShort();
+    rr[n].End                = GET_UShort();
+    rr[n].StartCoverageIndex = GET_UShort();
+
+    /* sanity check; we are limited to 16bit integers */
+    if ( rr[n].Start > rr[n].End ||
+        ( rr[n].End - rr[n].Start + (long)rr[n].StartCoverageIndex ) >=
+          0x10000L )
+    {
+      error = ERR_HB(HB_Err_Invalid_SubTable);
+      goto Fail;
+    }
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail:
+  FREE( cf2->RangeRecord );
+  return error;
+}
+
+
+static void  Free_Coverage2( HB_CoverageFormat2*  cf2 )
+{
+  FREE( cf2->RangeRecord );
+}
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Coverage( HB_Coverage* c,
+                        HB_Stream      stream )
+{
+  HB_Error   error;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  c->CoverageFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( c->CoverageFormat )
+  {
+  case 1:  return Load_Coverage1( &c->cf.cf1, stream );
+  case 2:  return Load_Coverage2( &c->cf.cf2, stream );
+  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+HB_INTERNAL void
+_HB_OPEN_Free_Coverage( HB_Coverage* c )
+{
+  switch ( c->CoverageFormat )
+  {
+  case 1:  Free_Coverage1( &c->cf.cf1 ); break;
+  case 2:  Free_Coverage2( &c->cf.cf2 ); break;
+  default:                                      break;
+  }
+}
+
+
+static HB_Error  Coverage_Index1( HB_CoverageFormat1*  cf1,
+                                 HB_UShort             glyphID,
+                                 HB_UShort*            index )
+{
+  HB_UShort min, max, new_min, new_max, middle;
+
+  HB_UShort*  array = cf1->GlyphArray;
+
+
+  /* binary search */
+
+  if ( cf1->GlyphCount == 0 )
+    return HB_Err_Not_Covered;
+
+  new_min = 0;
+  new_max = cf1->GlyphCount - 1;
+
+  do
+  {
+    min = new_min;
+    max = new_max;
+
+    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid
+       overflow and rounding errors                             */
+
+    middle = max - ( ( max - min ) >> 1 );
+
+    if ( glyphID == array[middle] )
+    {
+      *index = middle;
+      return HB_Err_Ok;
+    }
+    else if ( glyphID < array[middle] )
+    {
+      if ( middle == min )
+       break;
+      new_max = middle - 1;
+    }
+    else
+    {
+      if ( middle == max )
+       break;
+      new_min = middle + 1;
+    }
+  } while ( min < max );
+
+  return HB_Err_Not_Covered;
+}
+
+
+static HB_Error  Coverage_Index2( HB_CoverageFormat2*  cf2,
+                                 HB_UShort             glyphID,
+                                 HB_UShort*            index )
+{
+  HB_UShort         min, max, new_min, new_max, middle;
+
+  HB_RangeRecord*  rr = cf2->RangeRecord;
+
+
+  /* binary search */
+
+  if ( cf2->RangeCount == 0 )
+    return HB_Err_Not_Covered;
+
+  new_min = 0;
+  new_max = cf2->RangeCount - 1;
+
+  do
+  {
+    min = new_min;
+    max = new_max;
+
+    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid
+       overflow and rounding errors                             */
+
+    middle = max - ( ( max - min ) >> 1 );
+
+    if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End )
+    {
+      *index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start;
+      return HB_Err_Ok;
+    }
+    else if ( glyphID < rr[middle].Start )
+    {
+      if ( middle == min )
+       break;
+      new_max = middle - 1;
+    }
+    else
+    {
+      if ( middle == max )
+       break;
+      new_min = middle + 1;
+    }
+  } while ( min < max );
+
+  return HB_Err_Not_Covered;
+}
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Coverage_Index( HB_Coverage* c,
+                         HB_UShort      glyphID,
+                         HB_UShort*     index )
+{
+  switch ( c->CoverageFormat )
+  {
+  case 1:  return Coverage_Index1( &c->cf.cf1, glyphID, index );
+  case 2:  return Coverage_Index2( &c->cf.cf2, glyphID, index );
+  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+
+/*************************************
+ * Class Definition related functions
+ *************************************/
+
+
+/* ClassDefFormat1 */
+
+static HB_Error  Load_ClassDef1( HB_ClassDefinition*  cd,
+                                HB_UShort             limit,
+                                HB_Stream             stream )
+{
+  HB_Error   error;
+
+  HB_UShort             n, count;
+
+  HB_UShort*            cva;
+
+  HB_ClassDefFormat1*  cdf1;
+
+
+  cdf1 = &cd->cd.cd1;
+
+  if ( ACCESS_Frame( 4L ) )
+    return error;
+
+  cdf1->StartGlyph         = GET_UShort();
+  count = cdf1->GlyphCount = GET_UShort();
+
+  FORGET_Frame();
+
+  /* sanity check; we are limited to 16bit integers */
+
+  if ( cdf1->StartGlyph + (long)count >= 0x10000L )
+    return ERR_HB(HB_Err_Invalid_SubTable);
+
+  cdf1->ClassValueArray = NULL;
+
+  if ( ALLOC_ARRAY( cdf1->ClassValueArray, count, HB_UShort ) )
+    return error;
+
+  cva = cdf1->ClassValueArray;
+
+  if ( ACCESS_Frame( count * 2L ) )
+    goto Fail;
+
+  for ( n = 0; n < count; n++ )
+  {
+    cva[n] = GET_UShort();
+    if ( cva[n] >= limit )
+    {
+      error = ERR_HB(HB_Err_Invalid_SubTable);
+      goto Fail;
+    }
+  }
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+
+Fail:
+  FREE( cva );
+
+  return error;
+}
+
+
+static void  Free_ClassDef1( HB_ClassDefFormat1*  cdf1 )
+{
+  FREE( cdf1->ClassValueArray );
+}
+
+
+/* ClassDefFormat2 */
+
+static HB_Error  Load_ClassDef2( HB_ClassDefinition*  cd,
+                                HB_UShort             limit,
+                                HB_Stream             stream )
+{
+  HB_Error   error;
+
+  HB_UShort              n, count;
+
+  HB_ClassRangeRecord*  crr;
+
+  HB_ClassDefFormat2*   cdf2;
+
+
+  cdf2 = &cd->cd.cd2;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  count = GET_UShort();
+  cdf2->ClassRangeCount = 0; /* zero for now.  we fill with the number of good entries later */
+
+  FORGET_Frame();
+
+  cdf2->ClassRangeRecord = NULL;
+
+  if ( ALLOC_ARRAY( cdf2->ClassRangeRecord, count, HB_ClassRangeRecord ) )
+    return error;
+
+  crr = cdf2->ClassRangeRecord;
+
+  if ( ACCESS_Frame( count * 6L ) )
+    goto Fail;
+
+  for ( n = 0; n < count; n++ )
+  {
+    crr[n].Start = GET_UShort();
+    crr[n].End   = GET_UShort();
+    crr[n].Class = GET_UShort();
+
+    /* sanity check */
+
+    if ( crr[n].Start > crr[n].End ||
+        crr[n].Class >= limit )
+    {
+      /* XXX
+       * Corrupt entry.  Skip it.
+       * This is hit by Nafees Nastaliq font for example
+       */
+       n--;
+       count--;
+    }
+  }
+
+  FORGET_Frame();
+
+  cdf2->ClassRangeCount = count;
+
+  return HB_Err_Ok;
+
+Fail:
+  FREE( crr );
+
+  return error;
+}
+
+
+static void  Free_ClassDef2( HB_ClassDefFormat2*  cdf2 )
+{
+  FREE( cdf2->ClassRangeRecord );
+}
+
+
+/* ClassDefinition */
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+                               HB_UShort             limit,
+                               HB_Stream             stream )
+{
+  HB_Error   error;
+
+  if ( ACCESS_Frame( 2L ) )
+    return error;
+
+  cd->ClassFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  switch ( cd->ClassFormat )
+  {
+  case 1:  error = Load_ClassDef1( cd, limit, stream ); break;
+  case 2:  error = Load_ClassDef2( cd, limit, stream ); break;
+  default: error = ERR_HB(HB_Err_Invalid_SubTable_Format);     break;
+  }
+
+  if ( error )
+    return error;
+
+  cd->loaded = TRUE;
+
+  return HB_Err_Ok;
+}
+
+
+static HB_Error
+_HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition*  cd )
+{
+  HB_Error   error;
+
+  cd->ClassFormat = 1; /* Meaningless */
+
+  if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, HB_UShort ) )
+    return error;
+
+  cd->loaded = TRUE;
+
+  return HB_Err_Ok;
+}
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+                                              HB_UShort             limit,
+                                              HB_UInt              class_offset,
+                                              HB_UInt              base_offset,
+                                              HB_Stream             stream )
+{
+  HB_Error error;
+  HB_UInt               cur_offset;
+
+  cur_offset = FILE_Pos();
+
+  if ( class_offset )
+    {
+      if ( !FILE_Seek( class_offset + base_offset ) )
+       error = _HB_OPEN_Load_ClassDefinition( cd, limit, stream );
+    }
+  else
+     error = _HB_OPEN_Load_EmptyClassDefinition ( cd );
+
+  if (error == HB_Err_Ok)
+    (void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */
+
+  return error;
+}
+
+HB_INTERNAL void
+_HB_OPEN_Free_ClassDefinition( HB_ClassDefinition*  cd )
+{
+  if ( !cd->loaded )
+    return;
+
+  switch ( cd->ClassFormat )
+  {
+  case 1:  Free_ClassDef1( &cd->cd.cd1 ); break;
+  case 2:  Free_ClassDef2( &cd->cd.cd2 ); break;
+  default:                               break;
+  }
+}
+
+
+static HB_Error  Get_Class1( HB_ClassDefFormat1*  cdf1,
+                            HB_UShort             glyphID,
+                            HB_UShort*            klass,
+                            HB_UShort*            index )
+{
+  HB_UShort*  cva = cdf1->ClassValueArray;
+
+
+  if ( index )
+    *index = 0;
+
+  if ( glyphID >= cdf1->StartGlyph &&
+       glyphID < cdf1->StartGlyph + cdf1->GlyphCount )
+  {
+    *klass = cva[glyphID - cdf1->StartGlyph];
+    return HB_Err_Ok;
+  }
+  else
+  {
+    *klass = 0;
+    return HB_Err_Not_Covered;
+  }
+}
+
+
+/* we need the index value of the last searched class range record
+   in case of failure for constructed GDEF tables                  */
+
+static HB_Error  Get_Class2( HB_ClassDefFormat2*  cdf2,
+                            HB_UShort             glyphID,
+                            HB_UShort*            klass,
+                            HB_UShort*            index )
+{
+  HB_Error               error = HB_Err_Ok;
+  HB_UShort              min, max, new_min, new_max, middle;
+
+  HB_ClassRangeRecord*  crr = cdf2->ClassRangeRecord;
+
+
+  /* binary search */
+
+  if ( cdf2->ClassRangeCount == 0 )
+    {
+      *klass = 0;
+      if ( index )
+       *index = 0;
+      
+      return HB_Err_Not_Covered;
+    }
+
+  new_min = 0;
+  new_max = cdf2->ClassRangeCount - 1;
+
+  do
+  {
+    min = new_min;
+    max = new_max;
+
+    /* we use (min + max) / 2 = max - (max - min) / 2  to avoid
+       overflow and rounding errors                             */
+
+    middle = max - ( ( max - min ) >> 1 );
+
+    if ( glyphID >= crr[middle].Start && glyphID <= crr[middle].End )
+    {
+      *klass = crr[middle].Class;
+      error  = HB_Err_Ok;
+      break;
+    }
+    else if ( glyphID < crr[middle].Start )
+    {
+      if ( middle == min )
+      {
+       *klass = 0;
+       error  = HB_Err_Not_Covered;
+       break;
+      }
+      new_max = middle - 1;
+    }
+    else
+    {
+      if ( middle == max )
+      {
+       *klass = 0;
+       error  = HB_Err_Not_Covered;
+       break;
+      }
+      new_min = middle + 1;
+    }
+  } while ( min < max );
+
+  if ( index )
+    *index = middle;
+
+  return error;
+}
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+                    HB_UShort             glyphID,
+                   HB_UShort*          klass,
+                    HB_UShort*            index )
+{
+  switch ( cd->ClassFormat )
+  {
+  case 1:  return Get_Class1( &cd->cd.cd1, glyphID, klass, index );
+  case 2:  return Get_Class2( &cd->cd.cd2, glyphID, klass, index );
+  default: return ERR_HB(HB_Err_Invalid_SubTable_Format);
+  }
+
+  return HB_Err_Ok;               /* never reached */
+}
+
+
+
+/***************************
+ * Device related functions
+ ***************************/
+
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Load_Device( HB_Device* d,
+                      HB_Stream    stream )
+{
+  HB_Error   error;
+
+  HB_UShort   n, count;
+
+  HB_UShort*  dv;
+
+
+  if ( ACCESS_Frame( 6L ) )
+    return error;
+
+  d->StartSize   = GET_UShort();
+  d->EndSize     = GET_UShort();
+  d->DeltaFormat = GET_UShort();
+
+  FORGET_Frame();
+
+  d->DeltaValue = NULL;
+
+  if ( d->StartSize > d->EndSize ||
+       d->DeltaFormat == 0 || d->DeltaFormat > 3 )
+    {
+      /* XXX
+       * I've seen fontforge generate DeltaFormat == 0.
+       * Just return Ok and let the NULL DeltaValue disable
+       * this table.
+       */
+      return HB_Err_Ok;
+    }
+
+  count = ( ( d->EndSize - d->StartSize + 1 ) >>
+             ( 4 - d->DeltaFormat ) ) + 1;
+
+  if ( ALLOC_ARRAY( d->DeltaValue, count, HB_UShort ) )
+    return error;
+
+  if ( ACCESS_Frame( count * 2L ) )
+  {
+    FREE( d->DeltaValue );
+    return error;
+  }
+
+  dv = d->DeltaValue;
+
+  for ( n = 0; n < count; n++ )
+    dv[n] = GET_UShort();
+
+  FORGET_Frame();
+
+  return HB_Err_Ok;
+}
+
+
+HB_INTERNAL void
+_HB_OPEN_Free_Device( HB_Device* d )
+{
+  FREE( d->DeltaValue );
+}
+
+
+/* Since we have the delta values stored in compressed form, we must
+   uncompress it now.  To simplify the interface, the function always
+   returns a meaningful value in `value'; the error is just for
+   information.
+                              |                |
+   format = 1: 0011223344556677|8899101112131415|...
+                              |                |
+                   byte 1           byte 2
+
+     00: (byte >> 14) & mask
+     11: (byte >> 12) & mask
+     ...
+
+     mask = 0x0003
+                              |                |
+   format = 2: 0000111122223333|4444555566667777|...
+                              |                |
+                   byte 1           byte 2
+
+     0000: (byte >> 12) & mask
+     1111: (byte >>  8) & mask
+     ...
+
+     mask = 0x000F
+                              |                |
+   format = 3: 0000000011111111|2222222233333333|...
+                              |                |
+                   byte 1           byte 2
+
+     00000000: (byte >> 8) & mask
+     11111111: (byte >> 0) & mask
+     ....
+
+     mask = 0x00FF                                    */
+
+HB_INTERNAL HB_Error
+_HB_OPEN_Get_Device( HB_Device* d,
+                     HB_UShort    size,
+                     HB_Short*    value )
+{
+  HB_UShort  byte, bits, mask, f, s;
+
+
+  f = d->DeltaFormat;
+
+  if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize )
+  {
+    s    = size - d->StartSize;
+    byte = d->DeltaValue[s >> ( 4 - f )];
+    bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) );
+    mask = 0xFFFF >> ( 16 - ( 1 << f ) );
+
+    *value = (HB_Short)( bits & mask );
+
+    /* conversion to a signed value */
+
+    if ( *value >= ( ( mask + 1 ) >> 1 ) )
+      *value -= mask + 1;
+
+    return HB_Err_Ok;
+  }
+  else
+  {
+    *value = 0;
+    return HB_Err_Not_Covered;
+  }
+}
+
+
+/* END */
index ab09358..0e15094 100755 (executable)
@@ -1,34 +1,34 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.c"\r
-#include "harfbuzz-indic.c"\r
-\r
-#include "harfbuzz-tibetan.c"\r
-#include "harfbuzz-khmer.c"\r
-#include "harfbuzz-hebrew.c"\r
-#include "harfbuzz-arabic.c"\r
-#include "harfbuzz-hangul.c"\r
-#include "harfbuzz-myanmar.c"\r
-#include "harfbuzz-thai.c"\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.c"
+#include "harfbuzz-indic.c"
+
+#include "harfbuzz-tibetan.c"
+#include "harfbuzz-khmer.c"
+#include "harfbuzz-hebrew.c"
+#include "harfbuzz-arabic.c"
+#include "harfbuzz-hangul.c"
+#include "harfbuzz-myanmar.c"
+#include "harfbuzz-thai.c"
+
+
index d743a2c..b310156 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include "harfbuzz-stream-private.h"\r
-#include <assert.h>\r
-#include <stdio.h>\r
-\r
-#define HB_MIN(a, b) ((a) < (b) ? (a) : (b))\r
-#define HB_MAX(a, b) ((a) > (b) ? (a) : (b))\r
-\r
-// -----------------------------------------------------------------------------------------------------\r
-//\r
-// The line break algorithm. See http://www.unicode.org/reports/tr14/tr14-13.html\r
-//\r
-// -----------------------------------------------------------------------------------------------------\r
-\r
-/* The Unicode algorithm does in our opinion allow line breaks at some\r
-   places they shouldn't be allowed. The following changes were thus\r
-   made in comparison to the Unicode reference:\r
-\r
-   EX->AL from DB to IB\r
-   SY->AL from DB to IB\r
-   SY->PO from DB to IB\r
-   SY->PR from DB to IB\r
-   SY->OP from DB to IB\r
-   AL->PR from DB to IB\r
-   AL->PO from DB to IB\r
-   PR->PR from DB to IB\r
-   PO->PO from DB to IB\r
-   PR->PO from DB to IB\r
-   PO->PR from DB to IB\r
-   HY->PO from DB to IB\r
-   HY->PR from DB to IB\r
-   HY->OP from DB to IB\r
-   NU->EX from PB to IB\r
-   EX->PO from DB to IB\r
-*/\r
-\r
-// The following line break classes are not treated by the table:\r
-//  AI, BK, CB, CR, LF, NL, SA, SG, SP, XX\r
-\r
-enum break_class {\r
-    // the first 4 values have to agree with the enum in QCharAttributes\r
-    ProhibitedBreak,            // PB in table\r
-    DirectBreak,                // DB in table\r
-    IndirectBreak,              // IB in table\r
-    CombiningIndirectBreak,     // CI in table\r
-    CombiningProhibitedBreak    // CP in table\r
-};\r
-#define DB DirectBreak\r
-#define IB IndirectBreak\r
-#define CI CombiningIndirectBreak\r
-#define CP CombiningProhibitedBreak\r
-#define PB ProhibitedBreak\r
-\r
-static const hb_uint8 breakTable[HB_LineBreak_JT+1][HB_LineBreak_JT+1] =\r
-{\r
-/*          OP  CL  QU  GL  NS  EX  SY  IS  PR  PO  NU  AL  ID  IN  HY  BA  BB  B2  ZW  CM  WJ  H2  H3  JL  JV  JT */\r
-/* OP */ { PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, CP, PB, PB, PB, PB, PB, PB },\r
-/* CL */ { DB, PB, IB, IB, PB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* QU */ { PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },\r
-/* GL */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },\r
-/* NS */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* EX */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* SY */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* IS */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* PR */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, DB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, IB },\r
-/* PO */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* NU */ { IB, PB, IB, IB, IB, IB, PB, PB, IB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* AL */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* ID */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* IN */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* HY */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* BA */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* BB */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },\r
-/* B2 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, PB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* ZW */ { DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, PB, DB, DB, DB, DB, DB, DB, DB },\r
-/* CM */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },\r
-/* WJ */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },\r
-/* H2 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB },\r
-/* H3 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB },\r
-/* JL */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, DB },\r
-/* JV */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB },\r
-/* JT */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB }\r
-};\r
-#undef DB\r
-#undef IB\r
-#undef CI\r
-#undef CP\r
-#undef PB\r
-\r
-static const hb_uint8 graphemeTable[HB_Grapheme_LVT + 1][HB_Grapheme_LVT + 1] =\r
-{\r
-//      Other, CR,    LF,    Control,Extend,L,    V,     T,     LV,    LVT\r
-    { true , true , true , true , true , true , true , true , true , true  }, // Other, \r
-    { true , true , true , true , true , true , true , true , true , true  }, // CR,\r
-    { true , false, true , true , true , true , true , true , true , true  }, // LF,\r
-    { true , true , true , true , true , true , true , true , true , true  }, // Control,\r
-    { false, true , true , true , false, false, false, false, false, false }, // Extend,\r
-    { true , true , true , true , true , false, true , true , true , true  }, // L, \r
-    { true , true , true , true , true , false, false, true , false, true  }, // V, \r
-    { true , true , true , true , true , true , false, false, false, false }, // T, \r
-    { true , true , true , true , true , false, true , true , true , true  }, // LV, \r
-    { true , true , true , true , true , false, true , true , true , true  }, // LVT\r
-};\r
-    \r
-static void calcLineBreaks(const HB_UChar16 *uc, hb_uint32 len, HB_CharAttributes *charAttributes)\r
-{\r
-       hb_uint32 i ;\r
-       \r
-    if (!len)\r
-        return;\r
-\r
-    // ##### can this fail if the first char is a surrogate?\r
-    HB_LineBreakClass cls;\r
-    HB_GraphemeClass grapheme;\r
-    HB_GetGraphemeAndLineBreakClass(*uc, &grapheme, &cls);\r
-    // handle case where input starts with an LF\r
-    if (cls == HB_LineBreak_LF)\r
-        cls = HB_LineBreak_BK;\r
-\r
-    charAttributes[0].whiteSpace = (cls == HB_LineBreak_SP || cls == HB_LineBreak_BK);\r
-    charAttributes[0].charStop = true;\r
-\r
-    int lcls = cls;\r
-    for (i = 1; i < len; ++i) {\r
-        HB_UChar32 code = uc[i];\r
-        HB_GraphemeClass ngrapheme;\r
-        HB_LineBreakClass ncls;\r
-               \r
-        charAttributes[i].whiteSpace = false;\r
-        charAttributes[i].charStop = true;\r
-               \r
-        HB_GetGraphemeAndLineBreakClass(code, &ngrapheme, &ncls);\r
-        charAttributes[i].charStop = graphemeTable[ngrapheme][grapheme];\r
-        // handle surrogates\r
-        if (ncls == HB_LineBreak_SG) {\r
-            if (HB_IsHighSurrogate(uc[i]) && i < len - 1 && HB_IsLowSurrogate(uc[i+1])) {\r
-                continue;\r
-            } else if (HB_IsLowSurrogate(uc[i]) && HB_IsHighSurrogate(uc[i-1])) {\r
-                code = HB_SurrogateToUcs4(uc[i-1], uc[i]);\r
-                HB_GetGraphemeAndLineBreakClass(code, &ngrapheme, &ncls);\r
-                charAttributes[i].charStop = false;\r
-            } else {\r
-                ncls = HB_LineBreak_AL;\r
-            }\r
-        }\r
-\r
-        // set white space and char stop flag\r
-        if (ncls >= HB_LineBreak_SP)\r
-            charAttributes[i].whiteSpace = true;\r
-\r
-        HB_LineBreakType lineBreakType = HB_NoBreak;\r
-        if (cls >= HB_LineBreak_LF) {\r
-            lineBreakType = HB_ForcedBreak;\r
-        } else if(cls == HB_LineBreak_CR) {\r
-            lineBreakType = (ncls == HB_LineBreak_LF) ? HB_NoBreak : HB_ForcedBreak;\r
-        }\r
-\r
-        if (ncls == HB_LineBreak_SP)\r
-            goto next_no_cls_update;\r
-        if (ncls >= HB_LineBreak_CR)\r
-            goto next;\r
-\r
-        // two complex chars (thai or lao), thai_attributes might override, but here we do a best guess\r
-       if (cls == HB_LineBreak_SA && ncls == HB_LineBreak_SA) {\r
-            lineBreakType = HB_Break;\r
-            goto next;\r
-        }\r
-\r
-        {\r
-            int tcls = ncls;\r
-            if (tcls >= HB_LineBreak_SA)\r
-                tcls = HB_LineBreak_ID;\r
-            if (cls >= HB_LineBreak_SA)\r
-                cls = HB_LineBreak_ID;\r
-\r
-            int brk = breakTable[cls][tcls];\r
-            switch (brk) {\r
-            case DirectBreak:\r
-                lineBreakType = HB_Break;\r
-                if (uc[i-1] == 0xad) // soft hyphen\r
-                    lineBreakType = HB_SoftHyphen;\r
-                break;\r
-            case IndirectBreak:\r
-                lineBreakType = (lcls == HB_LineBreak_SP) ? HB_Break : HB_NoBreak;\r
-                break;\r
-            case CombiningIndirectBreak:\r
-                lineBreakType = HB_NoBreak;\r
-                if (lcls == HB_LineBreak_SP){\r
-                    if (i > 1)\r
-                        charAttributes[i-2].lineBreakType = HB_Break;\r
-                } else {\r
-                    goto next_no_cls_update;\r
-                }\r
-                break;\r
-            case CombiningProhibitedBreak:\r
-                lineBreakType = HB_NoBreak;\r
-                if (lcls != HB_LineBreak_SP)\r
-                    goto next_no_cls_update;\r
-            case ProhibitedBreak:\r
-            default:\r
-                break;\r
-            }\r
-        }\r
-    next:\r
-        cls = ncls;\r
-    next_no_cls_update:\r
-        lcls = ncls;\r
-        grapheme = ngrapheme;\r
-        charAttributes[i-1].lineBreakType = lineBreakType;\r
-    }\r
-    charAttributes[len-1].lineBreakType = HB_ForcedBreak;\r
-}\r
-\r
-// --------------------------------------------------------------------------------------------------------------------------------------------\r
-//\r
-// Basic processing\r
-//\r
-// --------------------------------------------------------------------------------------------------------------------------------------------\r
-\r
-static inline void positionCluster(HB_ShaperItem *item, int gfrom,  int glast)\r
-{\r
-    int nmarks = glast - gfrom;\r
-    HB_Bool rightToLeft = item->item.bidiLevel % 2;\r
-    int i;\r
-    unsigned char lastCmb = 0;\r
-    HB_GlyphMetrics attachmentRect;\r
-       \r
-    assert(nmarks > 0);\r
-\r
-    HB_Glyph *glyphs = item->glyphs;\r
-    HB_GlyphAttributes *attributes = item->attributes;\r
-\r
-    HB_GlyphMetrics baseMetrics;\r
-    item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom], &baseMetrics);\r
-\r
-    if (item->item.script == HB_Script_Hebrew\r
-        && (-baseMetrics.y) > baseMetrics.height)\r
-        // we need to attach below the baseline, because of the hebrew iud.\r
-        baseMetrics.height = -baseMetrics.y;\r
-\r
-//     qDebug("---> positionCluster: cluster from %d to %d", gfrom, glast);\r
-//     qDebug("baseInfo: %f/%f (%f/%f) off=%f/%f", baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height, baseInfo.xoff, baseInfo.yoff);\r
-\r
-    HB_Fixed size = item->font->klass->getFontMetric(item->font, HB_FontAscent) / 10;\r
-    HB_Fixed offsetBase = HB_FIXED_CONSTANT(1) + (size - HB_FIXED_CONSTANT(4)) / 4;\r
-    if (size > HB_FIXED_CONSTANT(4))\r
-        offsetBase += HB_FIXED_CONSTANT(4);\r
-    else\r
-        offsetBase += size;\r
-    //qreal offsetBase = (size - 4) / 4 + qMin<qreal>(size, 4) + 1;\r
-//     qDebug("offset = %f", offsetBase);\r
-\r
-    memset(&attachmentRect, 0, sizeof(attachmentRect));\r
-\r
-    for(i = 1; i <= nmarks; i++) {\r
-        HB_Glyph mark = glyphs[gfrom+i];\r
-        HB_GlyphMetrics markMetrics;\r
-       HB_GlyphMetrics unitedAttachmentRect = attachmentRect;\r
-        \r
-        item->font->klass->getGlyphMetrics(item->font, mark, &markMetrics);\r
-        HB_FixedPoint p;\r
-        p.x = p.y = 0;\r
-//          qDebug("markInfo: %f/%f (%f/%f) off=%f/%f", markInfo.x, markInfo.y, markInfo.width, markInfo.height, markInfo.xoff, markInfo.yoff);\r
-\r
-        HB_Fixed offset = offsetBase;\r
-        unsigned char cmb = attributes[gfrom+i].combiningClass;\r
-\r
-        // ### maybe the whole position determination should move down to heuristicSetGlyphAttributes. Would save some\r
-        // bits  in the glyphAttributes structure.\r
-        if (cmb < 200) {\r
-            // fixed position classes. We approximate by mapping to one of the others.\r
-            // currently I added only the ones for arabic, hebrew, lao and thai.\r
-\r
-            // for Lao and Thai marks with class 0, see below (heuristicSetGlyphAttributes)\r
-\r
-            // add a bit more offset to arabic, a bit hacky\r
-            if (cmb >= 27 && cmb <= 36 && offset < 3)\r
-                offset +=1;\r
-            // below\r
-            if ((cmb >= 10 && cmb <= 18) ||\r
-                 cmb == 20 || cmb == 22 ||\r
-                 cmb == 29 || cmb == 32)\r
-                cmb = HB_Combining_Below;\r
-            // above\r
-            else if (cmb == 23 || cmb == 27 || cmb == 28 ||\r
-                      cmb == 30 || cmb == 31 || (cmb >= 33 && cmb <= 36))\r
-                cmb = HB_Combining_Above;\r
-            //below-right\r
-            else if (cmb == 9 || cmb == 103 || cmb == 118)\r
-                cmb = HB_Combining_BelowRight;\r
-            // above-right\r
-            else if (cmb == 24 || cmb == 107 || cmb == 122)\r
-                cmb = HB_Combining_AboveRight;\r
-            else if (cmb == 25)\r
-                cmb = HB_Combining_AboveLeft;\r
-            // fixed:\r
-            //  19 21\r
-\r
-        }\r
-\r
-        // combining marks of different class don't interact. Reset the rectangle.\r
-        if (cmb != lastCmb) {\r
-            //qDebug("resetting rect");\r
-            attachmentRect = baseMetrics;\r
-        }\r
-\r
-        switch(cmb) {\r
-        case HB_Combining_DoubleBelow:\r
-                // ### wrong in rtl context!\r
-        case HB_Combining_BelowLeft:\r
-            p.y += offset;\r
-        case HB_Combining_BelowLeftAttached:\r
-            p.x += attachmentRect.x - markMetrics.x;\r
-            p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;\r
-            break;\r
-        case HB_Combining_Below:\r
-            p.y += offset;\r
-        case HB_Combining_BelowAttached:\r
-            p.x += attachmentRect.x - markMetrics.x;\r
-            p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;\r
-\r
-            p.x += (attachmentRect.width - markMetrics.width) / 2;\r
-            break;\r
-        case HB_Combining_BelowRight:\r
-            p.y += offset;\r
-        case HB_Combining_BelowRightAttached:\r
-            p.x += attachmentRect.x + attachmentRect.width - markMetrics.width - markMetrics.x;\r
-            p.y += attachmentRect.y + attachmentRect.height - markMetrics.y;\r
-            break;\r
-        case HB_Combining_Left:\r
-            p.x -= offset;\r
-        case HB_Combining_LeftAttached:\r
-            break;\r
-        case HB_Combining_Right:\r
-            p.x += offset;\r
-        case HB_Combining_RightAttached:\r
-            break;\r
-        case HB_Combining_DoubleAbove:\r
-            // ### wrong in RTL context!\r
-        case HB_Combining_AboveLeft:\r
-            p.y -= offset;\r
-        case HB_Combining_AboveLeftAttached:\r
-            p.x += attachmentRect.x - markMetrics.x;\r
-            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;\r
-            break;\r
-        case HB_Combining_Above:\r
-            p.y -= offset;\r
-        case HB_Combining_AboveAttached:\r
-            p.x += attachmentRect.x - markMetrics.x;\r
-            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;\r
-\r
-            p.x += (attachmentRect.width - markMetrics.width) / 2;\r
-            break;\r
-        case HB_Combining_AboveRight:\r
-            p.y -= offset;\r
-        case HB_Combining_AboveRightAttached:\r
-            p.x += attachmentRect.x + attachmentRect.width - markMetrics.x - markMetrics.width;\r
-            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;\r
-            break;\r
-\r
-        case HB_Combining_IotaSubscript:\r
-            default:\r
-                break;\r
-        }\r
-//          qDebug("char=%x combiningClass = %d offset=%f/%f", mark, cmb, p.x(), p.y());\r
-        markMetrics.x += p.x;\r
-        markMetrics.y += p.y;\r
-\r
-        unitedAttachmentRect.x = HB_MIN(attachmentRect.x, markMetrics.x);\r
-        unitedAttachmentRect.y = HB_MIN(attachmentRect.y, markMetrics.y);\r
-        unitedAttachmentRect.width = HB_MAX(attachmentRect.x + attachmentRect.width, markMetrics.x + markMetrics.width) - unitedAttachmentRect.x;\r
-        unitedAttachmentRect.height = HB_MAX(attachmentRect.y + attachmentRect.height, markMetrics.y + markMetrics.height) - unitedAttachmentRect.y;\r
-        attachmentRect = unitedAttachmentRect;\r
-\r
-        lastCmb = cmb;\r
-        if (rightToLeft) {\r
-            item->offsets[gfrom+i].x = p.x;\r
-            item->offsets[gfrom+i].y = p.y;\r
-        } else {\r
-            item->offsets[gfrom+i].x = p.x - baseMetrics.xOffset;\r
-            item->offsets[gfrom+i].y = p.y - baseMetrics.yOffset;\r
-        }\r
-        item->advances[gfrom+i] = 0;\r
-    }\r
-}\r
-\r
-void HB_HeuristicPosition(HB_ShaperItem *item)\r
-{\r
-    HB_GetGlyphAdvances(item);\r
-    HB_GlyphAttributes *attributes = item->attributes;\r
-\r
-    int cEnd = -1;\r
-    int i = item->num_glyphs;\r
-    while (i--) {\r
-        if (cEnd == -1 && attributes[i].mark) {\r
-            cEnd = i;\r
-        } else if (cEnd != -1 && !attributes[i].mark) {\r
-            positionCluster(item, i, cEnd);\r
-            cEnd = -1;\r
-        }\r
-    }\r
-}\r
-\r
-// set the glyph attributes heuristically. Assumes a 1 to 1 relationship between chars and glyphs\r
-// and no reordering.\r
-// also computes logClusters heuristically\r
-void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item)\r
-{\r
-    const HB_UChar16 *uc = item->string + item->item.pos;\r
-    hb_uint32 length = item->item.length;\r
-\r
-    // ### zeroWidth and justification are missing here!!!!!\r
-\r
-    assert(item->num_glyphs <= length);\r
-\r
-//     qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item->num_glyphs);\r
-    HB_GlyphAttributes *attributes = item->attributes;\r
-    unsigned short *logClusters = item->log_clusters;\r
-\r
-    hb_uint32 glyph_pos = 0;\r
-    hb_uint32 i;\r
-    int cStart = 0;\r
-    const bool symbolFont = item->face->isSymbolFont;\r
-       \r
-    for (i = 0; i < length; i++) {\r
-        if (HB_IsHighSurrogate(uc[i]) && i < length - 1\r
-            && HB_IsLowSurrogate(uc[i + 1])) {\r
-            logClusters[i] = glyph_pos;\r
-            logClusters[++i] = glyph_pos;\r
-        } else {\r
-            logClusters[i] = glyph_pos;\r
-        }\r
-        ++glyph_pos;\r
-    }\r
-    assert(glyph_pos == item->num_glyphs);\r
-\r
-    // first char in a run is never (treated as) a mark\r
-    attributes[0].mark = false;\r
-    attributes[0].clusterStart = true;\r
-    attributes[0].dontPrint = (!symbolFont && uc[0] == 0x00ad) || HB_IsControlChar(uc[0]);\r
-\r
-    int pos = 0;\r
-    HB_CharCategory lastCat;\r
-    int dummy;\r
-    HB_GetUnicodeCharProperties(uc[0], &lastCat, &dummy);\r
-    for (i = 1; i < length; ++i) {\r
-        if (logClusters[i] == pos)\r
-            // same glyph\r
-            continue;\r
-        ++pos;\r
-        while (pos < logClusters[i]) {\r
-            attributes[pos] = attributes[pos-1];\r
-            ++pos;\r
-        }\r
-        // hide soft-hyphens by default\r
-        if ((!symbolFont && uc[i] == 0x00ad) || HB_IsControlChar(uc[i]))\r
-            attributes[pos].dontPrint = true;\r
-        HB_CharCategory cat;\r
-        int cmb;\r
-        HB_GetUnicodeCharProperties(uc[i], &cat, &cmb);\r
-        if (cat != HB_Mark_NonSpacing) {\r
-            attributes[pos].mark = false;\r
-            attributes[pos].clusterStart = true;\r
-            attributes[pos].combiningClass = 0;\r
-            cStart = logClusters[i];\r
-        } else {\r
-            if (cmb == 0) {\r
-                // Fix 0 combining classes\r
-                if ((uc[pos] & 0xff00) == 0x0e00) {\r
-                    // thai or lao\r
-                    if (uc[pos] == 0xe31 ||\r
-                         uc[pos] == 0xe34 ||\r
-                         uc[pos] == 0xe35 ||\r
-                         uc[pos] == 0xe36 ||\r
-                         uc[pos] == 0xe37 ||\r
-                         uc[pos] == 0xe47 ||\r
-                         uc[pos] == 0xe4c ||\r
-                         uc[pos] == 0xe4d ||\r
-                         uc[pos] == 0xe4e) {\r
-                        cmb = HB_Combining_AboveRight;\r
-                    } else if (uc[pos] == 0xeb1 ||\r
-                                uc[pos] == 0xeb4 ||\r
-                                uc[pos] == 0xeb5 ||\r
-                                uc[pos] == 0xeb6 ||\r
-                                uc[pos] == 0xeb7 ||\r
-                                uc[pos] == 0xebb ||\r
-                                uc[pos] == 0xecc ||\r
-                                uc[pos] == 0xecd) {\r
-                        cmb = HB_Combining_Above;\r
-                    } else if (uc[pos] == 0xebc) {\r
-                        cmb = HB_Combining_Below;\r
-                    }\r
-                }\r
-            }\r
-\r
-            attributes[pos].mark = true;\r
-            attributes[pos].clusterStart = false;\r
-            attributes[pos].combiningClass = cmb;\r
-            logClusters[i] = cStart;\r
-        }\r
-        // one gets an inter character justification point if the current char is not a non spacing mark.\r
-        // as then the current char belongs to the last one and one gets a space justification point\r
-        // after the space char.\r
-        if (lastCat == HB_Separator_Space)\r
-            attributes[pos-1].justification = HB_Space;\r
-        else if (cat != HB_Mark_NonSpacing)\r
-            attributes[pos-1].justification = HB_Character;\r
-        else\r
-            attributes[pos-1].justification = HB_NoJustification;\r
-\r
-        lastCat = cat;\r
-    }\r
-    pos = logClusters[length-1];\r
-    if (lastCat == HB_Separator_Space)\r
-        attributes[pos].justification = HB_Space;\r
-    else\r
-        attributes[pos].justification = HB_Character;\r
-}\r
-\r
-#ifndef NO_OPENTYPE\r
-static const HB_OpenTypeFeature basic_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('l', 'i', 'g', 'a'), CcmpProperty },\r
-    { HB_MAKE_TAG('c', 'l', 'i', 'g'), CcmpProperty },\r
-    {0, 0}\r
-};\r
-#endif\r
-\r
-HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item)\r
-{\r
-    if (shaper_item->glyphIndicesPresent) {\r
-        shaper_item->num_glyphs = shaper_item->initialGlyphCount;\r
-        shaper_item->glyphIndicesPresent = false;\r
-        return true;\r
-    }\r
-    return shaper_item->font->klass\r
-           ->convertStringToGlyphIndices(shaper_item->font,\r
-                                         shaper_item->string + shaper_item->item.pos, shaper_item->item.length,\r
-                                         shaper_item->glyphs, &shaper_item->num_glyphs,\r
-                                         shaper_item->item.bidiLevel % 2);\r
-}\r
-\r
-HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item)\r
-{\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = shaper_item->num_glyphs;\r
-#endif\r
-\r
-    if (!HB_ConvertStringToGlyphIndices(shaper_item))\r
-        return false;\r
-\r
-    HB_HeuristicSetGlyphAttributes(shaper_item);\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (HB_SelectScript(shaper_item, basic_features)) {\r
-        HB_OpenTypeShape(shaper_item, /*properties*/0);\r
-        return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/true);\r
-    }\r
-#endif\r
-\r
-    HB_HeuristicPosition(shaper_item);\r
-    return true;\r
-}\r
-\r
-const HB_ScriptEngine HB_ScriptEngines[] = {\r
-    // Common\r
-    { HB_BasicShape, 0},\r
-    // Greek\r
-    { HB_BasicShape, 0},\r
-    // Cyrillic\r
-    { HB_BasicShape, 0},\r
-    // Armenian\r
-    { HB_BasicShape, 0},\r
-    // Hebrew\r
-    { HB_HebrewShape, 0 },\r
-    // Arabic\r
-    { HB_ArabicShape, 0},\r
-    // Syriac\r
-    { HB_ArabicShape, 0},\r
-    // Thaana\r
-    { HB_BasicShape, 0 },\r
-    // Devanagari\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Bengali\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Gurmukhi\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Gujarati\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Oriya\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Tamil\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Telugu\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Kannada\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Malayalam\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Sinhala\r
-    { HB_IndicShape, HB_IndicAttributes },\r
-    // Thai\r
-    { HB_BasicShape, HB_ThaiAttributes },\r
-    // Lao\r
-    { HB_BasicShape, 0 },\r
-    // Tibetan\r
-    { HB_TibetanShape, HB_TibetanAttributes },\r
-    // Myanmar\r
-    { HB_MyanmarShape, HB_MyanmarAttributes },\r
-    // Georgian\r
-    { HB_BasicShape, 0 },\r
-    // Hangul\r
-    { HB_HangulShape, 0 },\r
-    // Ogham\r
-    { HB_BasicShape, 0 },\r
-    // Runic\r
-    { HB_BasicShape, 0 },\r
-    // Khmer\r
-    { HB_KhmerShape, HB_KhmerAttributes },\r
-    // N'Ko\r
-    { HB_ArabicShape, 0}\r
-};\r
-\r
-void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem *items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes)\r
-{\r
-       hb_uint32 i ;\r
-    calcLineBreaks(string, stringLength, attributes);\r
-\r
-    for (i = 0; i < numItems; ++i) {\r
-        HB_Script script = items[i].script;\r
-               HB_AttributeFunction attributeFunction = NULL ;\r
-        if (script == HB_Script_Inherited)\r
-            script = HB_Script_Common;\r
-        attributeFunction = HB_ScriptEngines[script].charAttributes;\r
-        if (!attributeFunction)\r
-            continue;\r
-        attributeFunction(script, string, items[i].pos, items[i].length, attributes);\r
-    }\r
-}\r
-\r
-\r
-enum _BreakRule { NoBreak = 0, Break = 1, Middle = 2 };\r
-typedef enum _BreakRule BreakRule ;\r
-\r
-static const hb_uint8 wordbreakTable[HB_Word_ExtendNumLet + 1][HB_Word_ExtendNumLet + 1] = {\r
-//        Other    Format   Katakana ALetter  MidLetter MidNum  Numeric  ExtendNumLet\r
-    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // Other\r
-    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // Format \r
-    {   Break,   Break, NoBreak,   Break,   Break,   Break,   Break, NoBreak }, // Katakana\r
-    {   Break,   Break,   Break, NoBreak,  Middle,   Break, NoBreak, NoBreak }, // ALetter\r
-    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // MidLetter\r
-    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // MidNum\r
-    {   Break,   Break,   Break, NoBreak,   Break,  Middle, NoBreak, NoBreak }, // Numeric\r
-    {   Break,   Break, NoBreak, NoBreak,   Break,   Break, NoBreak, NoBreak }, // ExtendNumLet\r
-};\r
-\r
-void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                          const HB_ScriptItem * items, hb_uint32 numItems,\r
-                          HB_CharAttributes *attributes)\r
-{\r
-       hb_uint32 i;\r
-    if (stringLength == 0)\r
-        return;\r
-    unsigned int brk = HB_GetWordClass(string[0]);\r
-    attributes[0].wordBoundary = true;\r
-    for ( i = 1; i < stringLength; ++i) {\r
-               hb_uint32 nbrk=0;\r
-               BreakRule rule;\r
-        if (!attributes[i].charStop) {\r
-            attributes[i].wordBoundary = false;\r
-            continue;\r
-        }\r
-        nbrk = HB_GetWordClass(string[i]);\r
-        if (nbrk == HB_Word_Format) {\r
-            attributes[i].wordBoundary = (HB_GetSentenceClass(string[i-1]) == HB_Sentence_Sep);\r
-            continue;\r
-        }\r
-        rule = (BreakRule)wordbreakTable[brk][nbrk];\r
-        if (rule == Middle) {\r
-            rule = Break;\r
-            hb_uint32 lookahead = i + 1;\r
-            while (lookahead < stringLength) {\r
-                hb_uint32 testbrk = HB_GetWordClass(string[lookahead]);\r
-                if (testbrk == HB_Word_Format && HB_GetSentenceClass(string[lookahead]) != HB_Sentence_Sep) {\r
-                    ++lookahead;\r
-                    continue;\r
-                }\r
-                if (testbrk == brk) {\r
-                    rule = NoBreak;\r
-                    while (i < lookahead)\r
-                        attributes[i++].wordBoundary = false;\r
-                    nbrk = testbrk;\r
-                }\r
-                break;\r
-            }\r
-        }\r
-        attributes[i].wordBoundary = (rule == Break);\r
-        brk = nbrk;\r
-    }\r
-}\r
-\r
-\r
-enum SentenceBreakStates {\r
-    SB_Initial,\r
-    SB_Upper,\r
-    SB_UpATerm, \r
-    SB_ATerm,\r
-    SB_ATermC, \r
-    SB_ACS, \r
-    SB_STerm, \r
-    SB_STermC, \r
-    SB_SCS,\r
-    SB_BAfter, \r
-    SB_Break,\r
-    SB_Look\r
-};\r
-\r
-static const hb_uint8 sentenceBreakTable[HB_Sentence_Close + 1][HB_Sentence_Close + 1] = {\r
-//        Other       Sep         Format      Sp          Lower       Upper       OLetter     Numeric     ATerm       STerm       Close\r
-      { SB_Initial, SB_BAfter , SB_Initial, SB_Initial, SB_Initial, SB_Upper  , SB_Initial, SB_Initial, SB_ATerm  , SB_STerm  , SB_Initial }, // SB_Initial,\r
-      { SB_Initial, SB_BAfter , SB_Upper  , SB_Initial, SB_Initial, SB_Upper  , SB_Initial, SB_Initial, SB_UpATerm, SB_STerm  , SB_Initial }, // SB_Upper\r
-      \r
-      { SB_Look   , SB_BAfter , SB_UpATerm, SB_ACS    , SB_Initial, SB_Upper  , SB_Break  , SB_Initial, SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_UpATerm\r
-      { SB_Look   , SB_BAfter , SB_ATerm  , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Initial, SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_ATerm\r
-      { SB_Look   , SB_BAfter , SB_ATermC , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Look   , SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_ATermC,\r
-      { SB_Look   , SB_BAfter , SB_ACS    , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Look   , SB_ATerm  , SB_STerm  , SB_Look    }, // SB_ACS,\r
-      \r
-      { SB_Break  , SB_BAfter , SB_STerm  , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_STermC  }, // SB_STerm,\r
-      { SB_Break  , SB_BAfter , SB_STermC , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_STermC  }, // SB_STermC,\r
-      { SB_Break  , SB_BAfter , SB_SCS    , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_Break   }, // SB_SCS,\r
-      { SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break   }, // SB_BAfter,\r
-};\r
-\r
-void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,\r
-                              const HB_ScriptItem * items, hb_uint32 numItems,\r
-                              HB_CharAttributes *attributes)\r
-{\r
-       hb_uint32 i;\r
-    if (stringLength == 0)\r
-        return;\r
-    hb_uint32 brk = sentenceBreakTable[SB_Initial][HB_GetSentenceClass(string[0])];\r
-    attributes[0].sentenceBoundary = true;\r
-    for (i = 1; i < stringLength; ++i) {\r
-        if (!attributes[i].charStop) {\r
-            attributes[i].sentenceBoundary = false;\r
-            continue;\r
-        }\r
-        brk = sentenceBreakTable[brk][HB_GetSentenceClass(string[i])];\r
-        if (brk == SB_Look) {\r
-            hb_uint32 lookahead = i + 1;\r
-            brk = SB_Break;\r
-            while (lookahead < stringLength) {\r
-                hb_uint32 sbrk = HB_GetSentenceClass(string[lookahead]);\r
-                if (sbrk != HB_Sentence_Other && sbrk != HB_Sentence_Numeric && sbrk != HB_Sentence_Close) {\r
-                    break;\r
-                } else if (sbrk == HB_Sentence_Lower) {\r
-                    brk = SB_Initial;\r
-                    break;\r
-                }\r
-                ++lookahead;\r
-            }\r
-            if (brk == SB_Initial) {\r
-                while (i < lookahead)\r
-                    attributes[i++].sentenceBoundary = false;\r
-            }\r
-        }\r
-        if (brk == SB_Break) {\r
-            attributes[i].sentenceBoundary = true;\r
-            brk = sentenceBreakTable[SB_Initial][HB_GetSentenceClass(string[i])];\r
-        } else {\r
-            attributes[i].sentenceBoundary = false;\r
-        }\r
-    }\r
-}\r
-\r
-\r
-static inline char *tag_to_string(HB_UInt tag)\r
-{\r
-    static char string[5];\r
-    string[0] = (tag >> 24)&0xff;\r
-    string[1] = (tag >> 16)&0xff;\r
-    string[2] = (tag >> 8)&0xff;\r
-    string[3] = tag&0xff;\r
-    string[4] = 0;\r
-    return string;\r
-}\r
-\r
-#ifdef OT_DEBUG\r
-static void dump_string(HB_Buffer buffer)\r
-{\r
-    for (uint i = 0; i < buffer->in_length; ++i) {\r
-        qDebug("    %x: cluster=%d", buffer->in_string[i].gindex, buffer->in_string[i].cluster);\r
-    }\r
-}\r
-#define DEBUG printf\r
-#else\r
-#define DEBUG if (1) ; else printf\r
-#endif\r
-\r
-#define DefaultLangSys 0xffff\r
-#define DefaultScript HB_MAKE_TAG('D', 'F', 'L', 'T')\r
-\r
-enum {\r
-    RequiresGsub = 1,\r
-    RequiresGpos = 2\r
-};\r
-\r
-struct _OTScripts {\r
-    unsigned int tag;\r
-    int flags;\r
-};\r
-\r
-typedef struct _OTScripts OTScripts;\r
-\r
-static const OTScripts ot_scripts [] = {\r
-    // Common\r
-    { HB_MAKE_TAG('l', 'a', 't', 'n'), 0 },\r
-    // Greek\r
-    { HB_MAKE_TAG('g', 'r', 'e', 'k'), 0 },\r
-    // Cyrillic\r
-    { HB_MAKE_TAG('c', 'y', 'r', 'l'), 0 },\r
-    // Armenian\r
-    { HB_MAKE_TAG('a', 'r', 'm', 'n'), 0 },\r
-    // Hebrew\r
-    { HB_MAKE_TAG('h', 'e', 'b', 'r'), 1 },\r
-    // Arabic\r
-    { HB_MAKE_TAG('a', 'r', 'a', 'b'), 1 },\r
-    // Syriac\r
-    { HB_MAKE_TAG('s', 'y', 'r', 'c'), 1 },\r
-    // Thaana\r
-    { HB_MAKE_TAG('t', 'h', 'a', 'a'), 1 },\r
-    // Devanagari\r
-    { HB_MAKE_TAG('d', 'e', 'v', 'a'), 1 },\r
-    // Bengali\r
-    { HB_MAKE_TAG('b', 'e', 'n', 'g'), 1 },\r
-    // Gurmukhi\r
-    { HB_MAKE_TAG('g', 'u', 'r', 'u'), 1 },\r
-    // Gujarati\r
-    { HB_MAKE_TAG('g', 'u', 'j', 'r'), 1 },\r
-    // Oriya\r
-    { HB_MAKE_TAG('o', 'r', 'y', 'a'), 1 },\r
-    // Tamil\r
-    { HB_MAKE_TAG('t', 'a', 'm', 'l'), 1 },\r
-    // Telugu\r
-    { HB_MAKE_TAG('t', 'e', 'l', 'u'), 1 },\r
-    // Kannada\r
-    { HB_MAKE_TAG('k', 'n', 'd', 'a'), 1 },\r
-    // Malayalam\r
-    { HB_MAKE_TAG('m', 'l', 'y', 'm'), 1 },\r
-    // Sinhala\r
-    { HB_MAKE_TAG('s', 'i', 'n', 'h'), 1 },\r
-    // Thai\r
-    { HB_MAKE_TAG('t', 'h', 'a', 'i'), 1 },\r
-    // Lao\r
-    { HB_MAKE_TAG('l', 'a', 'o', ' '), 1 },\r
-    // Tibetan\r
-    { HB_MAKE_TAG('t', 'i', 'b', 't'), 1 },\r
-    // Myanmar\r
-    { HB_MAKE_TAG('m', 'y', 'm', 'r'), 1 },\r
-    // Georgian\r
-    { HB_MAKE_TAG('g', 'e', 'o', 'r'), 0 },\r
-    // Hangul\r
-    { HB_MAKE_TAG('h', 'a', 'n', 'g'), 1 },\r
-    // Ogham\r
-    { HB_MAKE_TAG('o', 'g', 'a', 'm'), 0 },\r
-    // Runic\r
-    { HB_MAKE_TAG('r', 'u', 'n', 'r'), 0 },\r
-    // Khmer\r
-    { HB_MAKE_TAG('k', 'h', 'm', 'r'), 1 },\r
-    // N'Ko\r
-    { HB_MAKE_TAG('n', 'k', 'o', ' '), 1 }\r
-};\r
-enum { NumOTScripts = sizeof(ot_scripts)/sizeof(OTScripts) };\r
-\r
-static HB_Bool checkScript(HB_Face face, int script)\r
-{\r
-    assert(script < HB_ScriptCount);\r
-\r
-    if (!face->gsub && !face->gpos)\r
-        return false;\r
-\r
-    unsigned int tag = ot_scripts[script].tag;\r
-    int requirements = ot_scripts[script].flags;\r
-\r
-    if (requirements & RequiresGsub) {\r
-        if (!face->gsub)\r
-            return false;\r
-\r
-        HB_UShort script_index;\r
-        HB_Error error = HB_GSUB_Select_Script(face->gsub, tag, &script_index);\r
-        if (error) {\r
-            DEBUG("could not select script %d in GSub table: %d", (int)script, error);\r
-            error = HB_GSUB_Select_Script(face->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &script_index);\r
-            if (error)\r
-                return false;\r
-        }\r
-    }\r
-\r
-    if (requirements & RequiresGpos) {\r
-        if (!face->gpos)\r
-            return false;\r
-\r
-        HB_UShort script_index;\r
-        HB_Error error = HB_GPOS_Select_Script(face->gpos, script, &script_index);\r
-        if (error) {\r
-            DEBUG("could not select script in gpos table: %d", error);\r
-            error = HB_GPOS_Select_Script(face->gpos, HB_MAKE_TAG('D', 'F', 'L', 'T'), &script_index);\r
-            if (error)\r
-                return false;\r
-        }\r
-\r
-    }\r
-    return true;\r
-}\r
-\r
-static HB_Stream getTableStream(void *font, HB_GetFontTableFunc tableFunc, HB_Tag tag)\r
-{\r
-    HB_Error error;\r
-    HB_UInt length = 0;\r
-    HB_Stream stream = 0;\r
-\r
-    if (!font)\r
-        return 0;\r
-\r
-    error = tableFunc(font, tag, 0, &length);\r
-    if (error)\r
-        return 0;\r
-    stream = (HB_Stream)malloc(sizeof(HB_StreamRec));\r
-    if (!stream)\r
-        return 0;\r
-    stream->base = (HB_Byte*)malloc(length);\r
-    if (!stream->base) {\r
-        free(stream);\r
-        return 0;\r
-    }\r
-    error = tableFunc(font, tag, stream->base, &length);\r
-    if (error) {\r
-        _hb_close_stream(stream);\r
-        return 0;\r
-    }\r
-    stream->size = length;\r
-    stream->pos = 0;\r
-    stream->cursor = NULL;\r
-    return stream;\r
-}\r
-\r
-HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)\r
-{\r
-    unsigned int i;\r
-    HB_Face face = (HB_Face )malloc(sizeof(HB_FaceRec));\r
-    HB_Error error;\r
-    HB_Stream stream;\r
-    HB_Stream gdefStream;\r
-       \r
-    if (!face)\r
-        return 0;\r
-\r
-    face->isSymbolFont = false;\r
-    face->gdef = 0;\r
-    face->gpos = 0;\r
-    face->gsub = 0;\r
-    face->current_script = HB_ScriptCount;\r
-    face->current_flags = HB_ShaperFlag_Default;\r
-    face->has_opentype_kerning = false;\r
-    face->tmpAttributes = 0;\r
-    face->tmpLogClusters = 0;\r
-    face->glyphs_substituted = false;\r
-    face->buffer = 0;\r
-\r
-    gdefStream = getTableStream(font, tableFunc, TTAG_GDEF);\r
-    if (!gdefStream || (error = HB_Load_GDEF_Table(gdefStream, &face->gdef))) {\r
-        //DEBUG("error loading gdef table: %d", error);\r
-        face->gdef = 0;\r
-    }\r
-\r
-    //DEBUG() << "trying to load gsub table";\r
-    stream = getTableStream(font, tableFunc, TTAG_GSUB);\r
-    if (!stream || (error = HB_Load_GSUB_Table(stream, &face->gsub, face->gdef, gdefStream))) {\r
-        face->gsub = 0;\r
-        if (error != HB_Err_Not_Covered) {\r
-            //DEBUG("error loading gsub table: %d", error);\r
-        } else {\r
-            //DEBUG("face doesn't have a gsub table");\r
-        }\r
-    }\r
-    _hb_close_stream(stream);\r
-\r
-    stream = getTableStream(font, tableFunc, TTAG_GPOS);\r
-    if (!stream || (error = HB_Load_GPOS_Table(stream, &face->gpos, face->gdef, gdefStream))) {\r
-        face->gpos = 0;\r
-        DEBUG("error loading gpos table: %d", error);\r
-    }\r
-    _hb_close_stream(stream);\r
-\r
-    _hb_close_stream(gdefStream);\r
-\r
-    for (i = 0; i < HB_ScriptCount; ++i)\r
-        face->supported_scripts[i] = checkScript(face, i);\r
-\r
-    if (hb_buffer_new(&face->buffer) != HB_Err_Ok) {\r
-        HB_FreeFace(face);\r
-        return 0;\r
-    }\r
-\r
-    return face;\r
-}\r
-\r
-void HB_FreeFace(HB_Face face)\r
-{\r
-    if (!face)\r
-        return;\r
-    if (face->gpos)\r
-        HB_Done_GPOS_Table(face->gpos);\r
-    if (face->gsub)\r
-        HB_Done_GSUB_Table(face->gsub);\r
-    if (face->gdef)\r
-        HB_Done_GDEF_Table(face->gdef);\r
-    if (face->buffer)\r
-        hb_buffer_free(face->buffer);\r
-    if (face->tmpAttributes)\r
-        free(face->tmpAttributes);\r
-    if (face->tmpLogClusters)\r
-        free(face->tmpLogClusters);\r
-    free(face);\r
-}\r
-\r
-HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *features)\r
-{\r
-    HB_Script script = shaper_item->item.script;\r
-\r
-    if (!shaper_item->face->supported_scripts[script])\r
-        return false;\r
-\r
-    HB_Face face = shaper_item->face;\r
-    if (face->current_script == script && face->current_flags == shaper_item->shaperFlags)\r
-        return true;\r
-\r
-    face->current_script = script;\r
-    face->current_flags = shaper_item->shaperFlags;\r
-\r
-    assert(script < HB_ScriptCount);\r
-    // find script in our list of supported scripts.\r
-    unsigned int tag = ot_scripts[script].tag;\r
-\r
-    if (face->gsub && features) {\r
-#ifdef OT_DEBUG\r
-        {\r
-            HB_FeatureList featurelist = face->gsub->FeatureList;\r
-            int numfeatures = featurelist.FeatureCount;\r
-            DEBUG("gsub table has %d features", numfeatures);\r
-            for (int i = 0; i < numfeatures; i++) {\r
-                HB_FeatureRecord *r = featurelist.FeatureRecord + i;\r
-                DEBUG("   feature '%s'", tag_to_string(r->FeatureTag));\r
-            }\r
-        }\r
-#endif\r
-        HB_GSUB_Clear_Features(face->gsub);\r
-        HB_UShort script_index;\r
-        HB_Error error = HB_GSUB_Select_Script(face->gsub, tag, &script_index);\r
-        if (!error) {\r
-            DEBUG("script %s has script index %d", tag_to_string(script), script_index);\r
-            while (features->tag) {\r
-                HB_UShort feature_index;\r
-                error = HB_GSUB_Select_Feature(face->gsub, features->tag, script_index, 0xffff, &feature_index);\r
-                if (!error) {\r
-                    DEBUG("  adding feature %s", tag_to_string(features->tag));\r
-                    HB_GSUB_Add_Feature(face->gsub, feature_index, features->property);\r
-                }\r
-                ++features;\r
-            }\r
-        }\r
-    }\r
-\r
-    // reset\r
-    face->has_opentype_kerning = false;\r
-\r
-    if (face->gpos) {\r
-        HB_GPOS_Clear_Features(face->gpos);\r
-        HB_UShort script_index;\r
-        HB_Error error = HB_GPOS_Select_Script(face->gpos, tag, &script_index);\r
-        if (!error) {\r
-#ifdef OT_DEBUG\r
-            {\r
-                HB_FeatureList featurelist = face->gpos->FeatureList;\r
-                int numfeatures = featurelist.FeatureCount;\r
-                DEBUG("gpos table has %d features", numfeatures);\r
-                for(int i = 0; i < numfeatures; i++) {\r
-                    HB_FeatureRecord *r = featurelist.FeatureRecord + i;\r
-                    HB_UShort feature_index;\r
-                    HB_GPOS_Select_Feature(face->gpos, r->FeatureTag, script_index, 0xffff, &feature_index);\r
-                    DEBUG("   feature '%s'", tag_to_string(r->FeatureTag));\r
-                }\r
-            }\r
-#endif\r
-            HB_UInt *feature_tag_list_buffer;\r
-            error = HB_GPOS_Query_Features(face->gpos, script_index, 0xffff, &feature_tag_list_buffer);\r
-            if (!error) {\r
-                HB_UInt *feature_tag_list = feature_tag_list_buffer;\r
-                while (*feature_tag_list) {\r
-                    HB_UShort feature_index;\r
-                    if (*feature_tag_list == HB_MAKE_TAG('k', 'e', 'r', 'n')) {\r
-                        if (face->current_flags & HB_ShaperFlag_NoKerning) {\r
-                            ++feature_tag_list;\r
-                            continue;\r
-                        }\r
-                        face->has_opentype_kerning = true;\r
-                    }\r
-                    error = HB_GPOS_Select_Feature(face->gpos, *feature_tag_list, script_index, 0xffff, &feature_index);\r
-                    if (!error)\r
-                        HB_GPOS_Add_Feature(face->gpos, feature_index, PositioningProperties);\r
-                    ++feature_tag_list;\r
-                }\r
-                FREE(feature_tag_list_buffer);\r
-            }\r
-        }\r
-    }\r
-\r
-    return true;\r
-}\r
-\r
-HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties)\r
-{\r
-    HB_GlyphAttributes *tmpAttributes;\r
-    unsigned int *tmpLogClusters;\r
-       int i ;\r
-\r
-    HB_Face face = item->face;\r
-\r
-    face->length = item->num_glyphs;\r
-\r
-    hb_buffer_clear(face->buffer);\r
-\r
-    tmpAttributes = (HB_GlyphAttributes *) realloc(face->tmpAttributes, face->length*sizeof(HB_GlyphAttributes));\r
-    if (!tmpAttributes)\r
-        return false;\r
-    face->tmpAttributes = tmpAttributes;\r
-\r
-    tmpLogClusters = (unsigned int *) realloc(face->tmpLogClusters, face->length*sizeof(unsigned int));\r
-    if (!tmpLogClusters)\r
-        return false;\r
-    face->tmpLogClusters = tmpLogClusters;\r
-\r
-    for (i = 0; i < face->length; ++i) {\r
-        hb_buffer_add_glyph(face->buffer, item->glyphs[i], properties ? properties[i] : 0, i);\r
-        face->tmpAttributes[i] = item->attributes[i];\r
-        face->tmpLogClusters[i] = item->log_clusters[i];\r
-    }\r
-\r
-#ifdef OT_DEBUG\r
-    DEBUG("-----------------------------------------");\r
-//     DEBUG("log clusters before shaping:");\r
-//     for (int j = 0; j < length; j++)\r
-//         DEBUG("    log[%d] = %d", j, item->log_clusters[j]);\r
-    DEBUG("original glyphs: %p", item->glyphs);\r
-    for (int i = 0; i < length; ++i)\r
-        DEBUG("   glyph=%4x", hb_buffer->in_string[i].gindex);\r
-//     dump_string(hb_buffer);\r
-#endif\r
-\r
-    face->glyphs_substituted = false;\r
-    if (face->gsub) {\r
-        unsigned int error = HB_GSUB_Apply_String(face->gsub, face->buffer);\r
-        if (error && error != HB_Err_Not_Covered)\r
-            return false;\r
-        face->glyphs_substituted = (error != HB_Err_Not_Covered);\r
-    }\r
-\r
-#ifdef OT_DEBUG\r
-//     DEBUG("log clusters before shaping:");\r
-//     for (int j = 0; j < length; j++)\r
-//         DEBUG("    log[%d] = %d", j, item->log_clusters[j]);\r
-    DEBUG("shaped glyphs:");\r
-    for (int i = 0; i < length; ++i)\r
-        DEBUG("   glyph=%4x", hb_buffer->in_string[i].gindex);\r
-    DEBUG("-----------------------------------------");\r
-//     dump_string(hb_buffer);\r
-#endif\r
-\r
-    return true;\r
-}\r
-\r
-HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters)\r
-{\r
-    HB_Face face = item->face;\r
-       unsigned int i;\r
-       \r
-    HB_Glyph *glyphs = item->glyphs;\r
-    HB_GlyphAttributes *attributes = item->attributes;\r
-\r
-    bool glyphs_positioned = false;\r
-    if (face->gpos) {\r
-        if (face->buffer->positions)\r
-            memset(face->buffer->positions, 0, face->buffer->in_length*sizeof(HB_PositionRec));\r
-        // #### check that passing "false,false" is correct\r
-        glyphs_positioned = HB_GPOS_Apply_String(item->font, face->gpos, face->current_flags, face->buffer, false, false) != HB_Err_Not_Covered;\r
-    }\r
-\r
-    if (!face->glyphs_substituted && !glyphs_positioned) {\r
-        HB_GetGlyphAdvances(item);\r
-        return true; // nothing to do for us\r
-    }\r
-\r
-    // make sure we have enough space to write everything back\r
-    if (availableGlyphs < (int)face->buffer->in_length) {\r
-        item->num_glyphs = face->buffer->in_length;\r
-        return false;\r
-    }\r
-\r
-\r
-    for (i = 0; i < face->buffer->in_length; ++i) {\r
-        glyphs[i] = face->buffer->in_string[i].gindex;\r
-        attributes[i] = face->tmpAttributes[face->buffer->in_string[i].cluster];\r
-        if (i && face->buffer->in_string[i].cluster == face->buffer->in_string[i-1].cluster)\r
-            attributes[i].clusterStart = false;\r
-    }\r
-    item->num_glyphs = face->buffer->in_length;\r
-\r
-    if (doLogClusters && face->glyphs_substituted) {\r
-               unsigned int i;\r
-               int j;\r
-        // we can't do this for indic, as we pass the stuf in syllables and it's easier to do it in the shaper.\r
-        unsigned short *logClusters = item->log_clusters;\r
-        int clusterStart = 0;\r
-        int oldCi = 0;\r
-        // #### the reconstruction of the logclusters currently does not work if the original string\r
-        // contains surrogate pairs\r
-        for (i = 0; i < face->buffer->in_length; ++i) {\r
-            int ci = face->buffer->in_string[i].cluster;\r
-            //         DEBUG("   ci[%d] = %d mark=%d, cmb=%d, cs=%d",\r
-            //                i, ci, glyphAttributes[i].mark, glyphAttributes[i].combiningClass, glyphAttributes[i].clusterStart);\r
-            if (!attributes[i].mark && attributes[i].clusterStart && ci != oldCi) {\r
-                for ( j = oldCi; j < ci; j++)\r
-                    logClusters[j] = clusterStart;\r
-                clusterStart = i;\r
-                oldCi = ci;\r
-            }\r
-        }\r
-        for (j = oldCi; j < face->length; j++)\r
-            logClusters[j] = clusterStart;\r
-    }\r
-\r
-    // calulate the advances for the shaped glyphs\r
-//     DEBUG("unpositioned: ");\r
-\r
-    // positioning code:\r
-    if (glyphs_positioned) {\r
-               unsigned int i;\r
-        HB_Position positions = face->buffer->positions;\r
-        HB_Fixed *advances = item->advances;\r
-        HB_GetGlyphAdvances(item);\r
-\r
-//         DEBUG("positioned glyphs:");\r
-        for (i = 0; i < face->buffer->in_length; i++) {\r
-//             DEBUG("    %d:\t orig advance: (%d/%d)\tadv=(%d/%d)\tpos=(%d/%d)\tback=%d\tnew_advance=%d", i,\r
-//                    glyphs[i].advance.x.toInt(), glyphs[i].advance.y.toInt(),\r
-//                    (int)(positions[i].x_advance >> 6), (int)(positions[i].y_advance >> 6),\r
-//                    (int)(positions[i].x_pos >> 6), (int)(positions[i].y_pos >> 6),\r
-//                    positions[i].back, positions[i].new_advance);\r
-\r
-            HB_Fixed adjustment = (item->item.bidiLevel % 2) ? -positions[i].x_advance : positions[i].x_advance;\r
-\r
-            if (!(face->current_flags & HB_ShaperFlag_UseDesignMetrics))\r
-                adjustment = HB_FIXED_ROUND(adjustment);\r
-\r
-            if (positions[i].new_advance) {\r
-                advances[i] = adjustment;\r
-            } else {\r
-                advances[i] += adjustment;\r
-            }\r
-\r
-            int back = 0;\r
-            HB_FixedPoint *offsets = item->offsets;\r
-            offsets[i].x = positions[i].x_pos;\r
-            offsets[i].y = positions[i].y_pos;\r
-            while (positions[i - back].back) {\r
-                back += positions[i - back].back;\r
-                offsets[i].x += positions[i - back].x_pos;\r
-                offsets[i].y += positions[i - back].y_pos;\r
-            }\r
-            offsets[i].y = -offsets[i].y;\r
-\r
-            if (item->item.bidiLevel % 2) {\r
-                // ### may need to go back multiple glyphs like in ltr\r
-                back = positions[i].back;\r
-                while (back--)\r
-                    offsets[i].x -= advances[i-back];\r
-            } else {\r
-                back = 0;\r
-                while (positions[i - back].back) {\r
-                    back += positions[i - back].back;\r
-                    offsets[i].x -= advances[i-back];\r
-                }\r
-            }\r
-//             DEBUG("   ->\tadv=%d\tpos=(%d/%d)",\r
-//                    glyphs[i].advance.x.toInt(), glyphs[i].offset.x.toInt(), glyphs[i].offset.y.toInt());\r
-        }\r
-        item->kerning_applied = face->has_opentype_kerning;\r
-    } else {\r
-        HB_HeuristicPosition(item);\r
-    }\r
-\r
-#ifdef OT_DEBUG\r
-    if (doLogClusters) {\r
-        DEBUG("log clusters after shaping:");\r
-        for (int j = 0; j < length; j++)\r
-            DEBUG("    log[%d] = %d", j, item->log_clusters[j]);\r
-    }\r
-    DEBUG("final glyphs:");\r
-    for (int i = 0; i < (int)hb_buffer->in_length; ++i)\r
-        DEBUG("   glyph=%4x char_index=%d mark: %d cmp: %d, clusterStart: %d advance=%d/%d offset=%d/%d",\r
-               glyphs[i].glyph, hb_buffer->in_string[i].cluster, glyphs[i].attributes.mark,\r
-               glyphs[i].attributes.combiningClass, glyphs[i].attributes.clusterStart,\r
-               glyphs[i].advance.x.toInt(), glyphs[i].advance.y.toInt(),\r
-               glyphs[i].offset.x.toInt(), glyphs[i].offset.y.toInt());\r
-    DEBUG("-----------------------------------------");\r
-#endif\r
-    return true;\r
-}\r
-\r
-HB_Bool HB_ShapeItem(HB_ShaperItem *shaper_item)\r
-{\r
-    HB_Bool result = false;\r
-    if (shaper_item->num_glyphs < shaper_item->item.length) {\r
-        shaper_item->num_glyphs = shaper_item->item.length;\r
-        return false;\r
-    }\r
-    assert(shaper_item->item.script < HB_ScriptCount);\r
-    result = HB_ScriptEngines[shaper_item->item.script].shape(shaper_item);\r
-    shaper_item->glyphIndicesPresent = false;\r
-    return result;\r
-}\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include "harfbuzz-stream-private.h"
+#include <assert.h>
+#include <stdio.h>
+
+#define HB_MIN(a, b) ((a) < (b) ? (a) : (b))
+#define HB_MAX(a, b) ((a) > (b) ? (a) : (b))
+
+// -----------------------------------------------------------------------------------------------------
+//
+// The line break algorithm. See http://www.unicode.org/reports/tr14/tr14-13.html
+//
+// -----------------------------------------------------------------------------------------------------
+
+/* The Unicode algorithm does in our opinion allow line breaks at some
+   places they shouldn't be allowed. The following changes were thus
+   made in comparison to the Unicode reference:
+
+   EX->AL from DB to IB
+   SY->AL from DB to IB
+   SY->PO from DB to IB
+   SY->PR from DB to IB
+   SY->OP from DB to IB
+   AL->PR from DB to IB
+   AL->PO from DB to IB
+   PR->PR from DB to IB
+   PO->PO from DB to IB
+   PR->PO from DB to IB
+   PO->PR from DB to IB
+   HY->PO from DB to IB
+   HY->PR from DB to IB
+   HY->OP from DB to IB
+   NU->EX from PB to IB
+   EX->PO from DB to IB
+*/
+
+// The following line break classes are not treated by the table:
+//  AI, BK, CB, CR, LF, NL, SA, SG, SP, XX
+
+enum break_class {
+    // the first 4 values have to agree with the enum in QCharAttributes
+    ProhibitedBreak,            // PB in table
+    DirectBreak,                // DB in table
+    IndirectBreak,              // IB in table
+    CombiningIndirectBreak,     // CI in table
+    CombiningProhibitedBreak    // CP in table
+};
+#define DB DirectBreak
+#define IB IndirectBreak
+#define CI CombiningIndirectBreak
+#define CP CombiningProhibitedBreak
+#define PB ProhibitedBreak
+
+static const hb_uint8 breakTable[HB_LineBreak_JT+1][HB_LineBreak_JT+1] =
+{
+/*          OP  CL  QU  GL  NS  EX  SY  IS  PR  PO  NU  AL  ID  IN  HY  BA  BB  B2  ZW  CM  WJ  H2  H3  JL  JV  JT */
+/* OP */ { PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, PB, CP, PB, PB, PB, PB, PB, PB },
+/* CL */ { DB, PB, IB, IB, PB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* QU */ { PB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },
+/* GL */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },
+/* NS */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* EX */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* SY */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* IS */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* PR */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, DB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, IB },
+/* PO */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* NU */ { IB, PB, IB, IB, IB, IB, PB, PB, IB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* AL */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* ID */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* IN */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* HY */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* BA */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* BB */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },
+/* B2 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, DB, DB, DB, DB, IB, IB, DB, PB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* ZW */ { DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, DB, PB, DB, DB, DB, DB, DB, DB, DB },
+/* CM */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, DB, IB, IB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, DB },
+/* WJ */ { IB, PB, IB, IB, IB, PB, PB, PB, IB, IB, IB, IB, IB, IB, IB, IB, IB, IB, PB, CI, PB, IB, IB, IB, IB, IB },
+/* H2 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB },
+/* H3 */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB },
+/* JL */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, IB, IB, IB, IB, DB },
+/* JV */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, IB, IB },
+/* JT */ { DB, PB, IB, IB, IB, PB, PB, PB, DB, IB, DB, DB, DB, IB, IB, IB, DB, DB, PB, CI, PB, DB, DB, DB, DB, IB }
+};
+#undef DB
+#undef IB
+#undef CI
+#undef CP
+#undef PB
+
+static const hb_uint8 graphemeTable[HB_Grapheme_LVT + 1][HB_Grapheme_LVT + 1] =
+{
+//      Other, CR,    LF,    Control,Extend,L,    V,     T,     LV,    LVT
+    { true , true , true , true , true , true , true , true , true , true  }, // Other, 
+    { true , true , true , true , true , true , true , true , true , true  }, // CR,
+    { true , false, true , true , true , true , true , true , true , true  }, // LF,
+    { true , true , true , true , true , true , true , true , true , true  }, // Control,
+    { false, true , true , true , false, false, false, false, false, false }, // Extend,
+    { true , true , true , true , true , false, true , true , true , true  }, // L, 
+    { true , true , true , true , true , false, false, true , false, true  }, // V, 
+    { true , true , true , true , true , true , false, false, false, false }, // T, 
+    { true , true , true , true , true , false, true , true , true , true  }, // LV, 
+    { true , true , true , true , true , false, true , true , true , true  }, // LVT
+};
+    
+static void calcLineBreaks(const HB_UChar16 *uc, hb_uint32 len, HB_CharAttributes *charAttributes)
+{
+       hb_uint32 i ;
+       
+    if (!len)
+        return;
+
+    // ##### can this fail if the first char is a surrogate?
+    HB_LineBreakClass cls;
+    HB_GraphemeClass grapheme;
+    HB_GetGraphemeAndLineBreakClass(*uc, &grapheme, &cls);
+    // handle case where input starts with an LF
+    if (cls == HB_LineBreak_LF)
+        cls = HB_LineBreak_BK;
+
+    charAttributes[0].whiteSpace = (cls == HB_LineBreak_SP || cls == HB_LineBreak_BK);
+    charAttributes[0].charStop = true;
+
+    int lcls = cls;
+    for (i = 1; i < len; ++i) {
+        HB_UChar32 code = uc[i];
+        HB_GraphemeClass ngrapheme;
+        HB_LineBreakClass ncls;
+               
+        charAttributes[i].whiteSpace = false;
+        charAttributes[i].charStop = true;
+               
+        HB_GetGraphemeAndLineBreakClass(code, &ngrapheme, &ncls);
+        charAttributes[i].charStop = graphemeTable[ngrapheme][grapheme];
+        // handle surrogates
+        if (ncls == HB_LineBreak_SG) {
+            if (HB_IsHighSurrogate(uc[i]) && i < len - 1 && HB_IsLowSurrogate(uc[i+1])) {
+                continue;
+            } else if (HB_IsLowSurrogate(uc[i]) && HB_IsHighSurrogate(uc[i-1])) {
+                code = HB_SurrogateToUcs4(uc[i-1], uc[i]);
+                HB_GetGraphemeAndLineBreakClass(code, &ngrapheme, &ncls);
+                charAttributes[i].charStop = false;
+            } else {
+                ncls = HB_LineBreak_AL;
+            }
+        }
+
+        // set white space and char stop flag
+        if (ncls >= HB_LineBreak_SP)
+            charAttributes[i].whiteSpace = true;
+
+        HB_LineBreakType lineBreakType = HB_NoBreak;
+        if (cls >= HB_LineBreak_LF) {
+            lineBreakType = HB_ForcedBreak;
+        } else if(cls == HB_LineBreak_CR) {
+            lineBreakType = (ncls == HB_LineBreak_LF) ? HB_NoBreak : HB_ForcedBreak;
+        }
+
+        if (ncls == HB_LineBreak_SP)
+            goto next_no_cls_update;
+        if (ncls >= HB_LineBreak_CR)
+            goto next;
+
+        // two complex chars (thai or lao), thai_attributes might override, but here we do a best guess
+       if (cls == HB_LineBreak_SA && ncls == HB_LineBreak_SA) {
+            lineBreakType = HB_Break;
+            goto next;
+        }
+
+        {
+            int tcls = ncls;
+            if (tcls >= HB_LineBreak_SA)
+                tcls = HB_LineBreak_ID;
+            if (cls >= HB_LineBreak_SA)
+                cls = HB_LineBreak_ID;
+
+            int brk = breakTable[cls][tcls];
+            switch (brk) {
+            case DirectBreak:
+                lineBreakType = HB_Break;
+                if (uc[i-1] == 0xad) // soft hyphen
+                    lineBreakType = HB_SoftHyphen;
+                break;
+            case IndirectBreak:
+                lineBreakType = (lcls == HB_LineBreak_SP) ? HB_Break : HB_NoBreak;
+                break;
+            case CombiningIndirectBreak:
+                lineBreakType = HB_NoBreak;
+                if (lcls == HB_LineBreak_SP){
+                    if (i > 1)
+                        charAttributes[i-2].lineBreakType = HB_Break;
+                } else {
+                    goto next_no_cls_update;
+                }
+                break;
+            case CombiningProhibitedBreak:
+                lineBreakType = HB_NoBreak;
+                if (lcls != HB_LineBreak_SP)
+                    goto next_no_cls_update;
+            case ProhibitedBreak:
+            default:
+                break;
+            }
+        }
+    next:
+        cls = ncls;
+    next_no_cls_update:
+        lcls = ncls;
+        grapheme = ngrapheme;
+        charAttributes[i-1].lineBreakType = lineBreakType;
+    }
+    charAttributes[len-1].lineBreakType = HB_ForcedBreak;
+}
+
+// --------------------------------------------------------------------------------------------------------------------------------------------
+//
+// Basic processing
+//
+// --------------------------------------------------------------------------------------------------------------------------------------------
+
+static inline void positionCluster(HB_ShaperItem *item, int gfrom,  int glast)
+{
+    int nmarks = glast - gfrom;
+    HB_Bool rightToLeft = item->item.bidiLevel % 2;
+    int i;
+    unsigned char lastCmb = 0;
+    HB_GlyphMetrics attachmentRect;
+       
+    assert(nmarks > 0);
+
+    HB_Glyph *glyphs = item->glyphs;
+    HB_GlyphAttributes *attributes = item->attributes;
+
+    HB_GlyphMetrics baseMetrics;
+    item->font->klass->getGlyphMetrics(item->font, glyphs[gfrom], &baseMetrics);
+
+    if (item->item.script == HB_Script_Hebrew
+        && (-baseMetrics.y) > baseMetrics.height)
+        // we need to attach below the baseline, because of the hebrew iud.
+        baseMetrics.height = -baseMetrics.y;
+
+//     qDebug("---> positionCluster: cluster from %d to %d", gfrom, glast);
+//     qDebug("baseInfo: %f/%f (%f/%f) off=%f/%f", baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height, baseInfo.xoff, baseInfo.yoff);
+
+    HB_Fixed size = item->font->klass->getFontMetric(item->font, HB_FontAscent) / 10;
+    HB_Fixed offsetBase = HB_FIXED_CONSTANT(1) + (size - HB_FIXED_CONSTANT(4)) / 4;
+    if (size > HB_FIXED_CONSTANT(4))
+        offsetBase += HB_FIXED_CONSTANT(4);
+    else
+        offsetBase += size;
+    //qreal offsetBase = (size - 4) / 4 + qMin<qreal>(size, 4) + 1;
+//     qDebug("offset = %f", offsetBase);
+
+    memset(&attachmentRect, 0, sizeof(attachmentRect));
+
+    for(i = 1; i <= nmarks; i++) {
+        HB_Glyph mark = glyphs[gfrom+i];
+        HB_GlyphMetrics markMetrics;
+       HB_GlyphMetrics unitedAttachmentRect = attachmentRect;
+        
+        item->font->klass->getGlyphMetrics(item->font, mark, &markMetrics);
+        HB_FixedPoint p;
+        p.x = p.y = 0;
+//          qDebug("markInfo: %f/%f (%f/%f) off=%f/%f", markInfo.x, markInfo.y, markInfo.width, markInfo.height, markInfo.xoff, markInfo.yoff);
+
+        HB_Fixed offset = offsetBase;
+        unsigned char cmb = attributes[gfrom+i].combiningClass;
+
+        // ### maybe the whole position determination should move down to heuristicSetGlyphAttributes. Would save some
+        // bits  in the glyphAttributes structure.
+        if (cmb < 200) {
+            // fixed position classes. We approximate by mapping to one of the others.
+            // currently I added only the ones for arabic, hebrew, lao and thai.
+
+            // for Lao and Thai marks with class 0, see below (heuristicSetGlyphAttributes)
+
+            // add a bit more offset to arabic, a bit hacky
+            if (cmb >= 27 && cmb <= 36 && offset < 3)
+                offset +=1;
+            // below
+            if ((cmb >= 10 && cmb <= 18) ||
+                 cmb == 20 || cmb == 22 ||
+                 cmb == 29 || cmb == 32)
+                cmb = HB_Combining_Below;
+            // above
+            else if (cmb == 23 || cmb == 27 || cmb == 28 ||
+                      cmb == 30 || cmb == 31 || (cmb >= 33 && cmb <= 36))
+                cmb = HB_Combining_Above;
+            //below-right
+            else if (cmb == 9 || cmb == 103 || cmb == 118)
+                cmb = HB_Combining_BelowRight;
+            // above-right
+            else if (cmb == 24 || cmb == 107 || cmb == 122)
+                cmb = HB_Combining_AboveRight;
+            else if (cmb == 25)
+                cmb = HB_Combining_AboveLeft;
+            // fixed:
+            //  19 21
+
+        }
+
+        // combining marks of different class don't interact. Reset the rectangle.
+        if (cmb != lastCmb) {
+            //qDebug("resetting rect");
+            attachmentRect = baseMetrics;
+        }
+
+        switch(cmb) {
+        case HB_Combining_DoubleBelow:
+                // ### wrong in rtl context!
+        case HB_Combining_BelowLeft:
+            p.y += offset;
+        case HB_Combining_BelowLeftAttached:
+            p.x += attachmentRect.x - markMetrics.x;
+            p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;
+            break;
+        case HB_Combining_Below:
+            p.y += offset;
+        case HB_Combining_BelowAttached:
+            p.x += attachmentRect.x - markMetrics.x;
+            p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;
+
+            p.x += (attachmentRect.width - markMetrics.width) / 2;
+            break;
+        case HB_Combining_BelowRight:
+            p.y += offset;
+        case HB_Combining_BelowRightAttached:
+            p.x += attachmentRect.x + attachmentRect.width - markMetrics.width - markMetrics.x;
+            p.y += attachmentRect.y + attachmentRect.height - markMetrics.y;
+            break;
+        case HB_Combining_Left:
+            p.x -= offset;
+        case HB_Combining_LeftAttached:
+            break;
+        case HB_Combining_Right:
+            p.x += offset;
+        case HB_Combining_RightAttached:
+            break;
+        case HB_Combining_DoubleAbove:
+            // ### wrong in RTL context!
+        case HB_Combining_AboveLeft:
+            p.y -= offset;
+        case HB_Combining_AboveLeftAttached:
+            p.x += attachmentRect.x - markMetrics.x;
+            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;
+            break;
+        case HB_Combining_Above:
+            p.y -= offset;
+        case HB_Combining_AboveAttached:
+            p.x += attachmentRect.x - markMetrics.x;
+            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;
+
+            p.x += (attachmentRect.width - markMetrics.width) / 2;
+            break;
+        case HB_Combining_AboveRight:
+            p.y -= offset;
+        case HB_Combining_AboveRightAttached:
+            p.x += attachmentRect.x + attachmentRect.width - markMetrics.x - markMetrics.width;
+            p.y += attachmentRect.y - markMetrics.y - markMetrics.height;
+            break;
+
+        case HB_Combining_IotaSubscript:
+            default:
+                break;
+        }
+//          qDebug("char=%x combiningClass = %d offset=%f/%f", mark, cmb, p.x(), p.y());
+        markMetrics.x += p.x;
+        markMetrics.y += p.y;
+
+        unitedAttachmentRect.x = HB_MIN(attachmentRect.x, markMetrics.x);
+        unitedAttachmentRect.y = HB_MIN(attachmentRect.y, markMetrics.y);
+        unitedAttachmentRect.width = HB_MAX(attachmentRect.x + attachmentRect.width, markMetrics.x + markMetrics.width) - unitedAttachmentRect.x;
+        unitedAttachmentRect.height = HB_MAX(attachmentRect.y + attachmentRect.height, markMetrics.y + markMetrics.height) - unitedAttachmentRect.y;
+        attachmentRect = unitedAttachmentRect;
+
+        lastCmb = cmb;
+        if (rightToLeft) {
+            item->offsets[gfrom+i].x = p.x;
+            item->offsets[gfrom+i].y = p.y;
+        } else {
+            item->offsets[gfrom+i].x = p.x - baseMetrics.xOffset;
+            item->offsets[gfrom+i].y = p.y - baseMetrics.yOffset;
+        }
+        item->advances[gfrom+i] = 0;
+    }
+}
+
+void HB_HeuristicPosition(HB_ShaperItem *item)
+{
+    HB_GetGlyphAdvances(item);
+    HB_GlyphAttributes *attributes = item->attributes;
+
+    int cEnd = -1;
+    int i = item->num_glyphs;
+    while (i--) {
+        if (cEnd == -1 && attributes[i].mark) {
+            cEnd = i;
+        } else if (cEnd != -1 && !attributes[i].mark) {
+            positionCluster(item, i, cEnd);
+            cEnd = -1;
+        }
+    }
+}
+
+// set the glyph attributes heuristically. Assumes a 1 to 1 relationship between chars and glyphs
+// and no reordering.
+// also computes logClusters heuristically
+void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item)
+{
+    const HB_UChar16 *uc = item->string + item->item.pos;
+    hb_uint32 length = item->item.length;
+
+    // ### zeroWidth and justification are missing here!!!!!
+
+    assert(item->num_glyphs <= length);
+
+//     qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item->num_glyphs);
+    HB_GlyphAttributes *attributes = item->attributes;
+    unsigned short *logClusters = item->log_clusters;
+
+    hb_uint32 glyph_pos = 0;
+    hb_uint32 i;
+    int cStart = 0;
+    const bool symbolFont = item->face->isSymbolFont;
+       
+    for (i = 0; i < length; i++) {
+        if (HB_IsHighSurrogate(uc[i]) && i < length - 1
+            && HB_IsLowSurrogate(uc[i + 1])) {
+            logClusters[i] = glyph_pos;
+            logClusters[++i] = glyph_pos;
+        } else {
+            logClusters[i] = glyph_pos;
+        }
+        ++glyph_pos;
+    }
+    assert(glyph_pos == item->num_glyphs);
+
+    // first char in a run is never (treated as) a mark
+    attributes[0].mark = false;
+    attributes[0].clusterStart = true;
+    attributes[0].dontPrint = (!symbolFont && uc[0] == 0x00ad) || HB_IsControlChar(uc[0]);
+
+    int pos = 0;
+    HB_CharCategory lastCat;
+    int dummy;
+    HB_GetUnicodeCharProperties(uc[0], &lastCat, &dummy);
+    for (i = 1; i < length; ++i) {
+        if (logClusters[i] == pos)
+            // same glyph
+            continue;
+        ++pos;
+        while (pos < logClusters[i]) {
+            attributes[pos] = attributes[pos-1];
+            ++pos;
+        }
+        // hide soft-hyphens by default
+        if ((!symbolFont && uc[i] == 0x00ad) || HB_IsControlChar(uc[i]))
+            attributes[pos].dontPrint = true;
+        HB_CharCategory cat;
+        int cmb;
+        HB_GetUnicodeCharProperties(uc[i], &cat, &cmb);
+        if (cat != HB_Mark_NonSpacing) {
+            attributes[pos].mark = false;
+            attributes[pos].clusterStart = true;
+            attributes[pos].combiningClass = 0;
+            cStart = logClusters[i];
+        } else {
+            if (cmb == 0) {
+                // Fix 0 combining classes
+                if ((uc[pos] & 0xff00) == 0x0e00) {
+                    // thai or lao
+                    if (uc[pos] == 0xe31 ||
+                         uc[pos] == 0xe34 ||
+                         uc[pos] == 0xe35 ||
+                         uc[pos] == 0xe36 ||
+                         uc[pos] == 0xe37 ||
+                         uc[pos] == 0xe47 ||
+                         uc[pos] == 0xe4c ||
+                         uc[pos] == 0xe4d ||
+                         uc[pos] == 0xe4e) {
+                        cmb = HB_Combining_AboveRight;
+                    } else if (uc[pos] == 0xeb1 ||
+                                uc[pos] == 0xeb4 ||
+                                uc[pos] == 0xeb5 ||
+                                uc[pos] == 0xeb6 ||
+                                uc[pos] == 0xeb7 ||
+                                uc[pos] == 0xebb ||
+                                uc[pos] == 0xecc ||
+                                uc[pos] == 0xecd) {
+                        cmb = HB_Combining_Above;
+                    } else if (uc[pos] == 0xebc) {
+                        cmb = HB_Combining_Below;
+                    }
+                }
+            }
+
+            attributes[pos].mark = true;
+            attributes[pos].clusterStart = false;
+            attributes[pos].combiningClass = cmb;
+            logClusters[i] = cStart;
+        }
+        // one gets an inter character justification point if the current char is not a non spacing mark.
+        // as then the current char belongs to the last one and one gets a space justification point
+        // after the space char.
+        if (lastCat == HB_Separator_Space)
+            attributes[pos-1].justification = HB_Space;
+        else if (cat != HB_Mark_NonSpacing)
+            attributes[pos-1].justification = HB_Character;
+        else
+            attributes[pos-1].justification = HB_NoJustification;
+
+        lastCat = cat;
+    }
+    pos = logClusters[length-1];
+    if (lastCat == HB_Separator_Space)
+        attributes[pos].justification = HB_Space;
+    else
+        attributes[pos].justification = HB_Character;
+}
+
+#ifndef NO_OPENTYPE
+static const HB_OpenTypeFeature basic_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('l', 'i', 'g', 'a'), CcmpProperty },
+    { HB_MAKE_TAG('c', 'l', 'i', 'g'), CcmpProperty },
+    {0, 0}
+};
+#endif
+
+HB_Bool HB_ConvertStringToGlyphIndices(HB_ShaperItem *shaper_item)
+{
+    if (shaper_item->glyphIndicesPresent) {
+        shaper_item->num_glyphs = shaper_item->initialGlyphCount;
+        shaper_item->glyphIndicesPresent = false;
+        return true;
+    }
+    return shaper_item->font->klass
+           ->convertStringToGlyphIndices(shaper_item->font,
+                                         shaper_item->string + shaper_item->item.pos, shaper_item->item.length,
+                                         shaper_item->glyphs, &shaper_item->num_glyphs,
+                                         shaper_item->item.bidiLevel % 2);
+}
+
+HB_Bool HB_BasicShape(HB_ShaperItem *shaper_item)
+{
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = shaper_item->num_glyphs;
+#endif
+
+    if (!HB_ConvertStringToGlyphIndices(shaper_item))
+        return false;
+
+    HB_HeuristicSetGlyphAttributes(shaper_item);
+
+#ifndef NO_OPENTYPE
+    if (HB_SelectScript(shaper_item, basic_features)) {
+        HB_OpenTypeShape(shaper_item, /*properties*/0);
+        return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/true);
+    }
+#endif
+
+    HB_HeuristicPosition(shaper_item);
+    return true;
+}
+
+const HB_ScriptEngine HB_ScriptEngines[] = {
+    // Common
+    { HB_BasicShape, 0},
+    // Greek
+    { HB_BasicShape, 0},
+    // Cyrillic
+    { HB_BasicShape, 0},
+    // Armenian
+    { HB_BasicShape, 0},
+    // Hebrew
+    { HB_HebrewShape, 0 },
+    // Arabic
+    { HB_ArabicShape, 0},
+    // Syriac
+    { HB_ArabicShape, 0},
+    // Thaana
+    { HB_BasicShape, 0 },
+    // Devanagari
+    { HB_IndicShape, HB_IndicAttributes },
+    // Bengali
+    { HB_IndicShape, HB_IndicAttributes },
+    // Gurmukhi
+    { HB_IndicShape, HB_IndicAttributes },
+    // Gujarati
+    { HB_IndicShape, HB_IndicAttributes },
+    // Oriya
+    { HB_IndicShape, HB_IndicAttributes },
+    // Tamil
+    { HB_IndicShape, HB_IndicAttributes },
+    // Telugu
+    { HB_IndicShape, HB_IndicAttributes },
+    // Kannada
+    { HB_IndicShape, HB_IndicAttributes },
+    // Malayalam
+    { HB_IndicShape, HB_IndicAttributes },
+    // Sinhala
+    { HB_IndicShape, HB_IndicAttributes },
+    // Thai
+    { HB_BasicShape, HB_ThaiAttributes },
+    // Lao
+    { HB_BasicShape, 0 },
+    // Tibetan
+    { HB_TibetanShape, HB_TibetanAttributes },
+    // Myanmar
+    { HB_MyanmarShape, HB_MyanmarAttributes },
+    // Georgian
+    { HB_BasicShape, 0 },
+    // Hangul
+    { HB_HangulShape, 0 },
+    // Ogham
+    { HB_BasicShape, 0 },
+    // Runic
+    { HB_BasicShape, 0 },
+    // Khmer
+    { HB_KhmerShape, HB_KhmerAttributes },
+    // N'Ko
+    { HB_ArabicShape, 0}
+};
+
+void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem *items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes)
+{
+       hb_uint32 i ;
+    calcLineBreaks(string, stringLength, attributes);
+
+    for (i = 0; i < numItems; ++i) {
+        HB_Script script = items[i].script;
+               HB_AttributeFunction attributeFunction = NULL ;
+        if (script == HB_Script_Inherited)
+            script = HB_Script_Common;
+        attributeFunction = HB_ScriptEngines[script].charAttributes;
+        if (!attributeFunction)
+            continue;
+        attributeFunction(script, string, items[i].pos, items[i].length, attributes);
+    }
+}
+
+
+enum _BreakRule { NoBreak = 0, Break = 1, Middle = 2 };
+typedef enum _BreakRule BreakRule ;
+
+static const hb_uint8 wordbreakTable[HB_Word_ExtendNumLet + 1][HB_Word_ExtendNumLet + 1] = {
+//        Other    Format   Katakana ALetter  MidLetter MidNum  Numeric  ExtendNumLet
+    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // Other
+    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // Format 
+    {   Break,   Break, NoBreak,   Break,   Break,   Break,   Break, NoBreak }, // Katakana
+    {   Break,   Break,   Break, NoBreak,  Middle,   Break, NoBreak, NoBreak }, // ALetter
+    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // MidLetter
+    {   Break,   Break,   Break,   Break,   Break,   Break,   Break,   Break }, // MidNum
+    {   Break,   Break,   Break, NoBreak,   Break,  Middle, NoBreak, NoBreak }, // Numeric
+    {   Break,   Break, NoBreak, NoBreak,   Break,   Break, NoBreak, NoBreak }, // ExtendNumLet
+};
+
+void HB_GetWordBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                          const HB_ScriptItem * items, hb_uint32 numItems,
+                          HB_CharAttributes *attributes)
+{
+       hb_uint32 i;
+    if (stringLength == 0)
+        return;
+    unsigned int brk = HB_GetWordClass(string[0]);
+    attributes[0].wordBoundary = true;
+    for ( i = 1; i < stringLength; ++i) {
+               hb_uint32 nbrk=0;
+               BreakRule rule;
+        if (!attributes[i].charStop) {
+            attributes[i].wordBoundary = false;
+            continue;
+        }
+        nbrk = HB_GetWordClass(string[i]);
+        if (nbrk == HB_Word_Format) {
+            attributes[i].wordBoundary = (HB_GetSentenceClass(string[i-1]) == HB_Sentence_Sep);
+            continue;
+        }
+        rule = (BreakRule)wordbreakTable[brk][nbrk];
+        if (rule == Middle) {
+            rule = Break;
+            hb_uint32 lookahead = i + 1;
+            while (lookahead < stringLength) {
+                hb_uint32 testbrk = HB_GetWordClass(string[lookahead]);
+                if (testbrk == HB_Word_Format && HB_GetSentenceClass(string[lookahead]) != HB_Sentence_Sep) {
+                    ++lookahead;
+                    continue;
+                }
+                if (testbrk == brk) {
+                    rule = NoBreak;
+                    while (i < lookahead)
+                        attributes[i++].wordBoundary = false;
+                    nbrk = testbrk;
+                }
+                break;
+            }
+        }
+        attributes[i].wordBoundary = (rule == Break);
+        brk = nbrk;
+    }
+}
+
+
+enum SentenceBreakStates {
+    SB_Initial,
+    SB_Upper,
+    SB_UpATerm, 
+    SB_ATerm,
+    SB_ATermC, 
+    SB_ACS, 
+    SB_STerm, 
+    SB_STermC, 
+    SB_SCS,
+    SB_BAfter, 
+    SB_Break,
+    SB_Look
+};
+
+static const hb_uint8 sentenceBreakTable[HB_Sentence_Close + 1][HB_Sentence_Close + 1] = {
+//        Other       Sep         Format      Sp          Lower       Upper       OLetter     Numeric     ATerm       STerm       Close
+      { SB_Initial, SB_BAfter , SB_Initial, SB_Initial, SB_Initial, SB_Upper  , SB_Initial, SB_Initial, SB_ATerm  , SB_STerm  , SB_Initial }, // SB_Initial,
+      { SB_Initial, SB_BAfter , SB_Upper  , SB_Initial, SB_Initial, SB_Upper  , SB_Initial, SB_Initial, SB_UpATerm, SB_STerm  , SB_Initial }, // SB_Upper
+      
+      { SB_Look   , SB_BAfter , SB_UpATerm, SB_ACS    , SB_Initial, SB_Upper  , SB_Break  , SB_Initial, SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_UpATerm
+      { SB_Look   , SB_BAfter , SB_ATerm  , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Initial, SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_ATerm
+      { SB_Look   , SB_BAfter , SB_ATermC , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Look   , SB_ATerm  , SB_STerm  , SB_ATermC  }, // SB_ATermC,
+      { SB_Look   , SB_BAfter , SB_ACS    , SB_ACS    , SB_Initial, SB_Break  , SB_Break  , SB_Look   , SB_ATerm  , SB_STerm  , SB_Look    }, // SB_ACS,
+      
+      { SB_Break  , SB_BAfter , SB_STerm  , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_STermC  }, // SB_STerm,
+      { SB_Break  , SB_BAfter , SB_STermC , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_STermC  }, // SB_STermC,
+      { SB_Break  , SB_BAfter , SB_SCS    , SB_SCS    , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_ATerm  , SB_STerm  , SB_Break   }, // SB_SCS,
+      { SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break  , SB_Break   }, // SB_BAfter,
+};
+
+void HB_GetSentenceBoundaries(const HB_UChar16 *string, hb_uint32 stringLength,
+                              const HB_ScriptItem * items, hb_uint32 numItems,
+                              HB_CharAttributes *attributes)
+{
+       hb_uint32 i;
+    if (stringLength == 0)
+        return;
+    hb_uint32 brk = sentenceBreakTable[SB_Initial][HB_GetSentenceClass(string[0])];
+    attributes[0].sentenceBoundary = true;
+    for (i = 1; i < stringLength; ++i) {
+        if (!attributes[i].charStop) {
+            attributes[i].sentenceBoundary = false;
+            continue;
+        }
+        brk = sentenceBreakTable[brk][HB_GetSentenceClass(string[i])];
+        if (brk == SB_Look) {
+            hb_uint32 lookahead = i + 1;
+            brk = SB_Break;
+            while (lookahead < stringLength) {
+                hb_uint32 sbrk = HB_GetSentenceClass(string[lookahead]);
+                if (sbrk != HB_Sentence_Other && sbrk != HB_Sentence_Numeric && sbrk != HB_Sentence_Close) {
+                    break;
+                } else if (sbrk == HB_Sentence_Lower) {
+                    brk = SB_Initial;
+                    break;
+                }
+                ++lookahead;
+            }
+            if (brk == SB_Initial) {
+                while (i < lookahead)
+                    attributes[i++].sentenceBoundary = false;
+            }
+        }
+        if (brk == SB_Break) {
+            attributes[i].sentenceBoundary = true;
+            brk = sentenceBreakTable[SB_Initial][HB_GetSentenceClass(string[i])];
+        } else {
+            attributes[i].sentenceBoundary = false;
+        }
+    }
+}
+
+
+static inline char *tag_to_string(HB_UInt tag)
+{
+    static char string[5];
+    string[0] = (tag >> 24)&0xff;
+    string[1] = (tag >> 16)&0xff;
+    string[2] = (tag >> 8)&0xff;
+    string[3] = tag&0xff;
+    string[4] = 0;
+    return string;
+}
+
+#ifdef OT_DEBUG
+static void dump_string(HB_Buffer buffer)
+{
+    for (uint i = 0; i < buffer->in_length; ++i) {
+        qDebug("    %x: cluster=%d", buffer->in_string[i].gindex, buffer->in_string[i].cluster);
+    }
+}
+#define DEBUG printf
+#else
+#define DEBUG if (1) ; else printf
+#endif
+
+#define DefaultLangSys 0xffff
+#define DefaultScript HB_MAKE_TAG('D', 'F', 'L', 'T')
+
+enum {
+    RequiresGsub = 1,
+    RequiresGpos = 2
+};
+
+struct _OTScripts {
+    unsigned int tag;
+    int flags;
+};
+
+typedef struct _OTScripts OTScripts;
+
+static const OTScripts ot_scripts [] = {
+    // Common
+    { HB_MAKE_TAG('l', 'a', 't', 'n'), 0 },
+    // Greek
+    { HB_MAKE_TAG('g', 'r', 'e', 'k'), 0 },
+    // Cyrillic
+    { HB_MAKE_TAG('c', 'y', 'r', 'l'), 0 },
+    // Armenian
+    { HB_MAKE_TAG('a', 'r', 'm', 'n'), 0 },
+    // Hebrew
+    { HB_MAKE_TAG('h', 'e', 'b', 'r'), 1 },
+    // Arabic
+    { HB_MAKE_TAG('a', 'r', 'a', 'b'), 1 },
+    // Syriac
+    { HB_MAKE_TAG('s', 'y', 'r', 'c'), 1 },
+    // Thaana
+    { HB_MAKE_TAG('t', 'h', 'a', 'a'), 1 },
+    // Devanagari
+    { HB_MAKE_TAG('d', 'e', 'v', 'a'), 1 },
+    // Bengali
+    { HB_MAKE_TAG('b', 'e', 'n', 'g'), 1 },
+    // Gurmukhi
+    { HB_MAKE_TAG('g', 'u', 'r', 'u'), 1 },
+    // Gujarati
+    { HB_MAKE_TAG('g', 'u', 'j', 'r'), 1 },
+    // Oriya
+    { HB_MAKE_TAG('o', 'r', 'y', 'a'), 1 },
+    // Tamil
+    { HB_MAKE_TAG('t', 'a', 'm', 'l'), 1 },
+    // Telugu
+    { HB_MAKE_TAG('t', 'e', 'l', 'u'), 1 },
+    // Kannada
+    { HB_MAKE_TAG('k', 'n', 'd', 'a'), 1 },
+    // Malayalam
+    { HB_MAKE_TAG('m', 'l', 'y', 'm'), 1 },
+    // Sinhala
+    { HB_MAKE_TAG('s', 'i', 'n', 'h'), 1 },
+    // Thai
+    { HB_MAKE_TAG('t', 'h', 'a', 'i'), 1 },
+    // Lao
+    { HB_MAKE_TAG('l', 'a', 'o', ' '), 1 },
+    // Tibetan
+    { HB_MAKE_TAG('t', 'i', 'b', 't'), 1 },
+    // Myanmar
+    { HB_MAKE_TAG('m', 'y', 'm', 'r'), 1 },
+    // Georgian
+    { HB_MAKE_TAG('g', 'e', 'o', 'r'), 0 },
+    // Hangul
+    { HB_MAKE_TAG('h', 'a', 'n', 'g'), 1 },
+    // Ogham
+    { HB_MAKE_TAG('o', 'g', 'a', 'm'), 0 },
+    // Runic
+    { HB_MAKE_TAG('r', 'u', 'n', 'r'), 0 },
+    // Khmer
+    { HB_MAKE_TAG('k', 'h', 'm', 'r'), 1 },
+    // N'Ko
+    { HB_MAKE_TAG('n', 'k', 'o', ' '), 1 }
+};
+enum { NumOTScripts = sizeof(ot_scripts)/sizeof(OTScripts) };
+
+static HB_Bool checkScript(HB_Face face, int script)
+{
+    assert(script < HB_ScriptCount);
+
+    if (!face->gsub && !face->gpos)
+        return false;
+
+    unsigned int tag = ot_scripts[script].tag;
+    int requirements = ot_scripts[script].flags;
+
+    if (requirements & RequiresGsub) {
+        if (!face->gsub)
+            return false;
+
+        HB_UShort script_index;
+        HB_Error error = HB_GSUB_Select_Script(face->gsub, tag, &script_index);
+        if (error) {
+            DEBUG("could not select script %d in GSub table: %d", (int)script, error);
+            error = HB_GSUB_Select_Script(face->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &script_index);
+            if (error)
+                return false;
+        }
+    }
+
+    if (requirements & RequiresGpos) {
+        if (!face->gpos)
+            return false;
+
+        HB_UShort script_index;
+        HB_Error error = HB_GPOS_Select_Script(face->gpos, script, &script_index);
+        if (error) {
+            DEBUG("could not select script in gpos table: %d", error);
+            error = HB_GPOS_Select_Script(face->gpos, HB_MAKE_TAG('D', 'F', 'L', 'T'), &script_index);
+            if (error)
+                return false;
+        }
+
+    }
+    return true;
+}
+
+static HB_Stream getTableStream(void *font, HB_GetFontTableFunc tableFunc, HB_Tag tag)
+{
+    HB_Error error;
+    HB_UInt length = 0;
+    HB_Stream stream = 0;
+
+    if (!font)
+        return 0;
+
+    error = tableFunc(font, tag, 0, &length);
+    if (error)
+        return 0;
+    stream = (HB_Stream)malloc(sizeof(HB_StreamRec));
+    if (!stream)
+        return 0;
+    stream->base = (HB_Byte*)malloc(length);
+    if (!stream->base) {
+        free(stream);
+        return 0;
+    }
+    error = tableFunc(font, tag, stream->base, &length);
+    if (error) {
+        _hb_close_stream(stream);
+        return 0;
+    }
+    stream->size = length;
+    stream->pos = 0;
+    stream->cursor = NULL;
+    return stream;
+}
+
+HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)
+{
+    unsigned int i;
+    HB_Face face = (HB_Face )malloc(sizeof(HB_FaceRec));
+    HB_Error error;
+    HB_Stream stream;
+    HB_Stream gdefStream;
+       
+    if (!face)
+        return 0;
+
+    face->isSymbolFont = false;
+    face->gdef = 0;
+    face->gpos = 0;
+    face->gsub = 0;
+    face->current_script = HB_ScriptCount;
+    face->current_flags = HB_ShaperFlag_Default;
+    face->has_opentype_kerning = false;
+    face->tmpAttributes = 0;
+    face->tmpLogClusters = 0;
+    face->glyphs_substituted = false;
+    face->buffer = 0;
+
+    gdefStream = getTableStream(font, tableFunc, TTAG_GDEF);
+    if (!gdefStream || (error = HB_Load_GDEF_Table(gdefStream, &face->gdef))) {
+        //DEBUG("error loading gdef table: %d", error);
+        face->gdef = 0;
+    }
+
+    //DEBUG() << "trying to load gsub table";
+    stream = getTableStream(font, tableFunc, TTAG_GSUB);
+    if (!stream || (error = HB_Load_GSUB_Table(stream, &face->gsub, face->gdef, gdefStream))) {
+        face->gsub = 0;
+        if (error != HB_Err_Not_Covered) {
+            //DEBUG("error loading gsub table: %d", error);
+        } else {
+            //DEBUG("face doesn't have a gsub table");
+        }
+    }
+    _hb_close_stream(stream);
+
+    stream = getTableStream(font, tableFunc, TTAG_GPOS);
+    if (!stream || (error = HB_Load_GPOS_Table(stream, &face->gpos, face->gdef, gdefStream))) {
+        face->gpos = 0;
+        DEBUG("error loading gpos table: %d", error);
+    }
+    _hb_close_stream(stream);
+
+    _hb_close_stream(gdefStream);
+
+    for (i = 0; i < HB_ScriptCount; ++i)
+        face->supported_scripts[i] = checkScript(face, i);
+
+    if (hb_buffer_new(&face->buffer) != HB_Err_Ok) {
+        HB_FreeFace(face);
+        return 0;
+    }
+
+    return face;
+}
+
+void HB_FreeFace(HB_Face face)
+{
+    if (!face)
+        return;
+    if (face->gpos)
+        HB_Done_GPOS_Table(face->gpos);
+    if (face->gsub)
+        HB_Done_GSUB_Table(face->gsub);
+    if (face->gdef)
+        HB_Done_GDEF_Table(face->gdef);
+    if (face->buffer)
+        hb_buffer_free(face->buffer);
+    if (face->tmpAttributes)
+        free(face->tmpAttributes);
+    if (face->tmpLogClusters)
+        free(face->tmpLogClusters);
+    free(face);
+}
+
+HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *features)
+{
+    HB_Script script = shaper_item->item.script;
+
+    if (!shaper_item->face->supported_scripts[script])
+        return false;
+
+    HB_Face face = shaper_item->face;
+    if (face->current_script == script && face->current_flags == shaper_item->shaperFlags)
+        return true;
+
+    face->current_script = script;
+    face->current_flags = shaper_item->shaperFlags;
+
+    assert(script < HB_ScriptCount);
+    // find script in our list of supported scripts.
+    unsigned int tag = ot_scripts[script].tag;
+
+    if (face->gsub && features) {
+#ifdef OT_DEBUG
+        {
+            HB_FeatureList featurelist = face->gsub->FeatureList;
+            int numfeatures = featurelist.FeatureCount;
+            DEBUG("gsub table has %d features", numfeatures);
+            for (int i = 0; i < numfeatures; i++) {
+                HB_FeatureRecord *r = featurelist.FeatureRecord + i;
+                DEBUG("   feature '%s'", tag_to_string(r->FeatureTag));
+            }
+        }
+#endif
+        HB_GSUB_Clear_Features(face->gsub);
+        HB_UShort script_index;
+        HB_Error error = HB_GSUB_Select_Script(face->gsub, tag, &script_index);
+        if (!error) {
+            DEBUG("script %s has script index %d", tag_to_string(script), script_index);
+            while (features->tag) {
+                HB_UShort feature_index;
+                error = HB_GSUB_Select_Feature(face->gsub, features->tag, script_index, 0xffff, &feature_index);
+                if (!error) {
+                    DEBUG("  adding feature %s", tag_to_string(features->tag));
+                    HB_GSUB_Add_Feature(face->gsub, feature_index, features->property);
+                }
+                ++features;
+            }
+        }
+    }
+
+    // reset
+    face->has_opentype_kerning = false;
+
+    if (face->gpos) {
+        HB_GPOS_Clear_Features(face->gpos);
+        HB_UShort script_index;
+        HB_Error error = HB_GPOS_Select_Script(face->gpos, tag, &script_index);
+        if (!error) {
+#ifdef OT_DEBUG
+            {
+                HB_FeatureList featurelist = face->gpos->FeatureList;
+                int numfeatures = featurelist.FeatureCount;
+                DEBUG("gpos table has %d features", numfeatures);
+                for(int i = 0; i < numfeatures; i++) {
+                    HB_FeatureRecord *r = featurelist.FeatureRecord + i;
+                    HB_UShort feature_index;
+                    HB_GPOS_Select_Feature(face->gpos, r->FeatureTag, script_index, 0xffff, &feature_index);
+                    DEBUG("   feature '%s'", tag_to_string(r->FeatureTag));
+                }
+            }
+#endif
+            HB_UInt *feature_tag_list_buffer;
+            error = HB_GPOS_Query_Features(face->gpos, script_index, 0xffff, &feature_tag_list_buffer);
+            if (!error) {
+                HB_UInt *feature_tag_list = feature_tag_list_buffer;
+                while (*feature_tag_list) {
+                    HB_UShort feature_index;
+                    if (*feature_tag_list == HB_MAKE_TAG('k', 'e', 'r', 'n')) {
+                        if (face->current_flags & HB_ShaperFlag_NoKerning) {
+                            ++feature_tag_list;
+                            continue;
+                        }
+                        face->has_opentype_kerning = true;
+                    }
+                    error = HB_GPOS_Select_Feature(face->gpos, *feature_tag_list, script_index, 0xffff, &feature_index);
+                    if (!error)
+                        HB_GPOS_Add_Feature(face->gpos, feature_index, PositioningProperties);
+                    ++feature_tag_list;
+                }
+                FREE(feature_tag_list_buffer);
+            }
+        }
+    }
+
+    return true;
+}
+
+HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties)
+{
+    HB_GlyphAttributes *tmpAttributes;
+    unsigned int *tmpLogClusters;
+       int i ;
+
+    HB_Face face = item->face;
+
+    face->length = item->num_glyphs;
+
+    hb_buffer_clear(face->buffer);
+
+    tmpAttributes = (HB_GlyphAttributes *) realloc(face->tmpAttributes, face->length*sizeof(HB_GlyphAttributes));
+    if (!tmpAttributes)
+        return false;
+    face->tmpAttributes = tmpAttributes;
+
+    tmpLogClusters = (unsigned int *) realloc(face->tmpLogClusters, face->length*sizeof(unsigned int));
+    if (!tmpLogClusters)
+        return false;
+    face->tmpLogClusters = tmpLogClusters;
+
+    for (i = 0; i < face->length; ++i) {
+        hb_buffer_add_glyph(face->buffer, item->glyphs[i], properties ? properties[i] : 0, i);
+        face->tmpAttributes[i] = item->attributes[i];
+        face->tmpLogClusters[i] = item->log_clusters[i];
+    }
+
+#ifdef OT_DEBUG
+    DEBUG("-----------------------------------------");
+//     DEBUG("log clusters before shaping:");
+//     for (int j = 0; j < length; j++)
+//         DEBUG("    log[%d] = %d", j, item->log_clusters[j]);
+    DEBUG("original glyphs: %p", item->glyphs);
+    for (int i = 0; i < length; ++i)
+        DEBUG("   glyph=%4x", hb_buffer->in_string[i].gindex);
+//     dump_string(hb_buffer);
+#endif
+
+    face->glyphs_substituted = false;
+    if (face->gsub) {
+        unsigned int error = HB_GSUB_Apply_String(face->gsub, face->buffer);
+        if (error && error != HB_Err_Not_Covered)
+            return false;
+        face->glyphs_substituted = (error != HB_Err_Not_Covered);
+    }
+
+#ifdef OT_DEBUG
+//     DEBUG("log clusters before shaping:");
+//     for (int j = 0; j < length; j++)
+//         DEBUG("    log[%d] = %d", j, item->log_clusters[j]);
+    DEBUG("shaped glyphs:");
+    for (int i = 0; i < length; ++i)
+        DEBUG("   glyph=%4x", hb_buffer->in_string[i].gindex);
+    DEBUG("-----------------------------------------");
+//     dump_string(hb_buffer);
+#endif
+
+    return true;
+}
+
+HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters)
+{
+    HB_Face face = item->face;
+       unsigned int i;
+       
+    HB_Glyph *glyphs = item->glyphs;
+    HB_GlyphAttributes *attributes = item->attributes;
+
+    bool glyphs_positioned = false;
+    if (face->gpos) {
+        if (face->buffer->positions)
+            memset(face->buffer->positions, 0, face->buffer->in_length*sizeof(HB_PositionRec));
+        // #### check that passing "false,false" is correct
+        glyphs_positioned = HB_GPOS_Apply_String(item->font, face->gpos, face->current_flags, face->buffer, false, false) != HB_Err_Not_Covered;
+    }
+
+    if (!face->glyphs_substituted && !glyphs_positioned) {
+        HB_GetGlyphAdvances(item);
+        return true; // nothing to do for us
+    }
+
+    // make sure we have enough space to write everything back
+    if (availableGlyphs < (int)face->buffer->in_length) {
+        item->num_glyphs = face->buffer->in_length;
+        return false;
+    }
+
+
+    for (i = 0; i < face->buffer->in_length; ++i) {
+        glyphs[i] = face->buffer->in_string[i].gindex;
+        attributes[i] = face->tmpAttributes[face->buffer->in_string[i].cluster];
+        if (i && face->buffer->in_string[i].cluster == face->buffer->in_string[i-1].cluster)
+            attributes[i].clusterStart = false;
+    }
+    item->num_glyphs = face->buffer->in_length;
+
+    if (doLogClusters && face->glyphs_substituted) {
+               unsigned int i;
+               int j;
+        // we can't do this for indic, as we pass the stuf in syllables and it's easier to do it in the shaper.
+        unsigned short *logClusters = item->log_clusters;
+        int clusterStart = 0;
+        int oldCi = 0;
+        // #### the reconstruction of the logclusters currently does not work if the original string
+        // contains surrogate pairs
+        for (i = 0; i < face->buffer->in_length; ++i) {
+            int ci = face->buffer->in_string[i].cluster;
+            //         DEBUG("   ci[%d] = %d mark=%d, cmb=%d, cs=%d",
+            //                i, ci, glyphAttributes[i].mark, glyphAttributes[i].combiningClass, glyphAttributes[i].clusterStart);
+            if (!attributes[i].mark && attributes[i].clusterStart && ci != oldCi) {
+                for ( j = oldCi; j < ci; j++)
+                    logClusters[j] = clusterStart;
+                clusterStart = i;
+                oldCi = ci;
+            }
+        }
+        for (j = oldCi; j < face->length; j++)
+            logClusters[j] = clusterStart;
+    }
+
+    // calulate the advances for the shaped glyphs
+//     DEBUG("unpositioned: ");
+
+    // positioning code:
+    if (glyphs_positioned) {
+               unsigned int i;
+        HB_Position positions = face->buffer->positions;
+        HB_Fixed *advances = item->advances;
+        HB_GetGlyphAdvances(item);
+
+//         DEBUG("positioned glyphs:");
+        for (i = 0; i < face->buffer->in_length; i++) {
+//             DEBUG("    %d:\t orig advance: (%d/%d)\tadv=(%d/%d)\tpos=(%d/%d)\tback=%d\tnew_advance=%d", i,
+//                    glyphs[i].advance.x.toInt(), glyphs[i].advance.y.toInt(),
+//                    (int)(positions[i].x_advance >> 6), (int)(positions[i].y_advance >> 6),
+//                    (int)(positions[i].x_pos >> 6), (int)(positions[i].y_pos >> 6),
+//                    positions[i].back, positions[i].new_advance);
+
+            HB_Fixed adjustment = (item->item.bidiLevel % 2) ? -positions[i].x_advance : positions[i].x_advance;
+
+            if (!(face->current_flags & HB_ShaperFlag_UseDesignMetrics))
+                adjustment = HB_FIXED_ROUND(adjustment);
+
+            if (positions[i].new_advance) {
+                advances[i] = adjustment;
+            } else {
+                advances[i] += adjustment;
+            }
+
+            int back = 0;
+            HB_FixedPoint *offsets = item->offsets;
+            offsets[i].x = positions[i].x_pos;
+            offsets[i].y = positions[i].y_pos;
+            while (positions[i - back].back) {
+                back += positions[i - back].back;
+                offsets[i].x += positions[i - back].x_pos;
+                offsets[i].y += positions[i - back].y_pos;
+            }
+            offsets[i].y = -offsets[i].y;
+
+            if (item->item.bidiLevel % 2) {
+                // ### may need to go back multiple glyphs like in ltr
+                back = positions[i].back;
+                while (back--)
+                    offsets[i].x -= advances[i-back];
+            } else {
+                back = 0;
+                while (positions[i - back].back) {
+                    back += positions[i - back].back;
+                    offsets[i].x -= advances[i-back];
+                }
+            }
+//             DEBUG("   ->\tadv=%d\tpos=(%d/%d)",
+//                    glyphs[i].advance.x.toInt(), glyphs[i].offset.x.toInt(), glyphs[i].offset.y.toInt());
+        }
+        item->kerning_applied = face->has_opentype_kerning;
+    } else {
+        HB_HeuristicPosition(item);
+    }
+
+#ifdef OT_DEBUG
+    if (doLogClusters) {
+        DEBUG("log clusters after shaping:");
+        for (int j = 0; j < length; j++)
+            DEBUG("    log[%d] = %d", j, item->log_clusters[j]);
+    }
+    DEBUG("final glyphs:");
+    for (int i = 0; i < (int)hb_buffer->in_length; ++i)
+        DEBUG("   glyph=%4x char_index=%d mark: %d cmp: %d, clusterStart: %d advance=%d/%d offset=%d/%d",
+               glyphs[i].glyph, hb_buffer->in_string[i].cluster, glyphs[i].attributes.mark,
+               glyphs[i].attributes.combiningClass, glyphs[i].attributes.clusterStart,
+               glyphs[i].advance.x.toInt(), glyphs[i].advance.y.toInt(),
+               glyphs[i].offset.x.toInt(), glyphs[i].offset.y.toInt());
+    DEBUG("-----------------------------------------");
+#endif
+    return true;
+}
+
+HB_Bool HB_ShapeItem(HB_ShaperItem *shaper_item)
+{
+    HB_Bool result = false;
+    if (shaper_item->num_glyphs < shaper_item->item.length) {
+        shaper_item->num_glyphs = shaper_item->item.length;
+        return false;
+    }
+    assert(shaper_item->item.script < HB_ScriptCount);
+    result = HB_ScriptEngines[shaper_item->item.script].shape(shaper_item);
+    shaper_item->glyphIndicesPresent = false;
+    return result;
+}
+
index 7ec457c..46389e9 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- *\r
- * Red Hat Author(s): Behdad Esfahbod\r
- */\r
-\r
-#include "harfbuzz-impl.h"\r
-#include "harfbuzz-stream-private.h"\r
-#include <stdlib.h>\r
-\r
-#if 0\r
-#include <stdio.h>\r
-#define  LOG(x)  _hb_log x\r
-\r
-static void\r
-_hb_log( const char*   format, ... )\r
-{\r
-  va_list  ap;\r
\r
-  va_start( ap, format );\r
-  vfprintf( stderr, format, ap );\r
-  va_end( ap );\r
-}\r
-\r
-#else\r
-#define  LOG(x)  do {} while (0)\r
-#endif\r
-\r
-HB_INTERNAL void\r
-_hb_close_stream( HB_Stream stream )\r
-{\r
-  if (!stream)\r
-      return;\r
-  free(stream->base);\r
-  free(stream);\r
-}\r
-\r
-\r
-HB_INTERNAL    HB_Int\r
-_hb_stream_pos( HB_Stream stream )\r
-{\r
-  LOG(( "_hb_stream_pos() -> %ld\n", stream->pos ));\r
-  return stream->pos;\r
-}\r
-\r
-\r
-HB_INTERNAL  HB_Error\r
-_hb_stream_seek( HB_Stream stream,\r
-                HB_UInt pos )\r
-{\r
-  HB_Error  error = (HB_Error)0;\r
-\r
-  stream->pos = pos;\r
-  if (pos > stream->size)\r
-      error = ERR_HB(HB_Err_Read_Error);\r
-\r
-  LOG(( "_hb_stream_seek(%ld) -> 0x%04X\n", pos, error ));\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL    HB_Error\r
-_hb_stream_frame_enter( HB_Stream stream,\r
-                       HB_UInt count )\r
-{\r
-  HB_Error  error = HB_Err_Ok;\r
-\r
-  /* check new position, watch for overflow */\r
-  if (HB_UNLIKELY (stream->pos + count > stream->size ||\r
-                  stream->pos + count < stream->pos))\r
-  {\r
-    error = ERR_HB(HB_Err_Read_Error);\r
-    goto Exit;\r
-  }\r
-\r
-  /* set cursor */\r
-  stream->cursor = stream->base + stream->pos;\r
-  stream->pos   += count;\r
-\r
-Exit:\r
-  LOG(( "_hb_stream_frame_enter(%ld) -> 0x%04X\n", count, error ));\r
-  return error;\r
-}\r
-\r
-\r
-HB_INTERNAL    void\r
-_hb_stream_frame_exit( HB_Stream stream )\r
-{\r
-  stream->cursor = NULL;\r
-\r
-  LOG(( "_hb_stream_frame_exit()\n" ));\r
-}\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#include "harfbuzz-impl.h"
+#include "harfbuzz-stream-private.h"
+#include <stdlib.h>
+
+#if 0
+#include <stdio.h>
+#define  LOG(x)  _hb_log x
+
+static void
+_hb_log( const char*   format, ... )
+{
+  va_list  ap;
+  va_start( ap, format );
+  vfprintf( stderr, format, ap );
+  va_end( ap );
+}
+
+#else
+#define  LOG(x)  do {} while (0)
+#endif
+
+HB_INTERNAL void
+_hb_close_stream( HB_Stream stream )
+{
+  if (!stream)
+      return;
+  free(stream->base);
+  free(stream);
+}
+
+
+HB_INTERNAL    HB_Int
+_hb_stream_pos( HB_Stream stream )
+{
+  LOG(( "_hb_stream_pos() -> %ld\n", stream->pos ));
+  return stream->pos;
+}
+
+
+HB_INTERNAL  HB_Error
+_hb_stream_seek( HB_Stream stream,
+                HB_UInt pos )
+{
+  HB_Error  error = (HB_Error)0;
+
+  stream->pos = pos;
+  if (pos > stream->size)
+      error = ERR_HB(HB_Err_Read_Error);
+
+  LOG(( "_hb_stream_seek(%ld) -> 0x%04X\n", pos, error ));
+  return error;
+}
+
+
+HB_INTERNAL    HB_Error
+_hb_stream_frame_enter( HB_Stream stream,
+                       HB_UInt count )
+{
+  HB_Error  error = HB_Err_Ok;
+
+  /* check new position, watch for overflow */
+  if (HB_UNLIKELY (stream->pos + count > stream->size ||
+                  stream->pos + count < stream->pos))
+  {
+    error = ERR_HB(HB_Err_Read_Error);
+    goto Exit;
+  }
+
+  /* set cursor */
+  stream->cursor = stream->base + stream->pos;
+  stream->pos   += count;
+
+Exit:
+  LOG(( "_hb_stream_frame_enter(%ld) -> 0x%04X\n", count, error ));
+  return error;
+}
+
+
+HB_INTERNAL    void
+_hb_stream_frame_exit( HB_Stream stream )
+{
+  stream->cursor = NULL;
+
+  LOG(( "_hb_stream_frame_exit()\n" ));
+}
index 3447812..bb48bb2 100755 (executable)
@@ -1,85 +1,85 @@
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-#include "harfbuzz-external.h"\r
-\r
-#include <assert.h>\r
-\r
-static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    typedef int (*th_brk_def)(const char*, int[], int);\r
-    static void *thaiCodec = 0;\r
-    static th_brk_def th_brk = 0;\r
-    char *cstr = 0;\r
-    int brp[128];\r
-    int *break_positions = brp;\r
-    hb_uint32 numbreaks;\r
-    hb_uint32 i;\r
-\r
-    if (!thaiCodec)\r
-        thaiCodec = HB_TextCodecForMib(2259);\r
-\r
-    /* load libthai dynamically */\r
-    if (!th_brk && thaiCodec) {\r
-        th_brk = (th_brk_def)HB_Library_Resolve("thai", "th_brk");\r
-        if (!th_brk)\r
-            thaiCodec = 0;\r
-    }\r
-\r
-    if (!th_brk)\r
-        return;\r
-\r
-    cstr = HB_TextCodec_ConvertFromUnicode(thaiCodec, string, len, 0);\r
-    if (!cstr)\r
-        return;\r
-\r
-    break_positions = brp;\r
-    numbreaks = th_brk(cstr, break_positions, 128);\r
-    if (numbreaks > 128) {\r
-        break_positions = (int *)malloc(numbreaks * sizeof(int));\r
-        numbreaks = th_brk(cstr, break_positions, numbreaks);\r
-    }\r
-\r
-    for (i = 0; i < len; ++i)\r
-        attributes[i].lineBreakType = HB_NoBreak;\r
-\r
-    for (i = 0; i < numbreaks; ++i) {\r
-        if (break_positions[i] > 0)\r
-            attributes[break_positions[i]-1].lineBreakType = HB_Break;\r
-    }\r
-\r
-    if (break_positions != brp)\r
-        free(break_positions);\r
-\r
-    HB_TextCodec_FreeResult(cstr);\r
-}\r
-\r
-\r
-void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    assert(script == HB_Script_Thai);\r
-    attributes += from;\r
-    thaiWordBreaks(text + from, len, attributes);\r
-}\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+#include "harfbuzz-external.h"
+
+#include <assert.h>
+
+static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    typedef int (*th_brk_def)(const char*, int[], int);
+    static void *thaiCodec = 0;
+    static th_brk_def th_brk = 0;
+    char *cstr = 0;
+    int brp[128];
+    int *break_positions = brp;
+    hb_uint32 numbreaks;
+    hb_uint32 i;
+
+    if (!thaiCodec)
+        thaiCodec = HB_TextCodecForMib(2259);
+
+    /* load libthai dynamically */
+    if (!th_brk && thaiCodec) {
+        th_brk = (th_brk_def)HB_Library_Resolve("thai", "th_brk");
+        if (!th_brk)
+            thaiCodec = 0;
+    }
+
+    if (!th_brk)
+        return;
+
+    cstr = HB_TextCodec_ConvertFromUnicode(thaiCodec, string, len, 0);
+    if (!cstr)
+        return;
+
+    break_positions = brp;
+    numbreaks = th_brk(cstr, break_positions, 128);
+    if (numbreaks > 128) {
+        break_positions = (int *)malloc(numbreaks * sizeof(int));
+        numbreaks = th_brk(cstr, break_positions, numbreaks);
+    }
+
+    for (i = 0; i < len; ++i)
+        attributes[i].lineBreakType = HB_NoBreak;
+
+    for (i = 0; i < numbreaks; ++i) {
+        if (break_positions[i] > 0)
+            attributes[break_positions[i]-1].lineBreakType = HB_Break;
+    }
+
+    if (break_positions != brp)
+        free(break_positions);
+
+    HB_TextCodec_FreeResult(cstr);
+}
+
+
+void HB_ThaiAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    assert(script == HB_Script_Thai);
+    attributes += from;
+    thaiWordBreaks(text + from, len, attributes);
+}
+
index 94eea0a..bed4fbb 100755 (executable)
-/*\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz-shaper.h"\r
-#include "harfbuzz-shaper-private.h"\r
-\r
-#include <assert.h>\r
-\r
-/*\r
- tibetan syllables are of the form:\r
-    head position consonant\r
-    first sub-joined consonant\r
-    ....intermediate sub-joined consonants (if any)\r
-    last sub-joined consonant\r
-    sub-joined vowel (a-chung U+0F71)\r
-    standard or compound vowel sign (or 'virama' for devanagari transliteration)\r
-*/\r
-\r
-typedef enum {\r
-    TibetanOther,\r
-    TibetanHeadConsonant,\r
-    TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedVowel,\r
-    TibetanVowel\r
-} TibetanForm;\r
-\r
-/* this table starts at U+0f40 */\r
-static const unsigned char tibetanForm[0x80] = {\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,\r
-    TibetanOther, TibetanOther, TibetanOther, TibetanOther,\r
-\r
-    TibetanOther, TibetanVowel, TibetanVowel, TibetanVowel,\r
-    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,\r
-    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,\r
-    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,\r
-\r
-    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,\r
-    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,\r
-    TibetanOther, TibetanOther, TibetanOther, TibetanOther,\r
-    TibetanOther, TibetanOther, TibetanOther, TibetanOther,\r
-\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,\r
-    TibetanSubjoinedConsonant, TibetanOther, TibetanOther, TibetanOther\r
-};\r
-\r
-\r
-#define tibetan_form(c) \\r
-    (TibetanForm)tibetanForm[c - 0x0f40]\r
-\r
-static const HB_OpenTypeFeature tibetan_features[] = {\r
-    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },\r
-    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },\r
-    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },\r
-    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },\r
-    {0, 0}\r
-};\r
-\r
-static HB_Bool tibetan_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_Bool invalid)\r
-{\r
-    hb_uint32 i;\r
-    const HB_UChar16 *str = item->string + item->item.pos;\r
-    int len = item->item.length;\r
-#ifndef NO_OPENTYPE\r
-    const int availableGlyphs = item->num_glyphs;\r
-#endif\r
-    HB_Bool haveGlyphs;\r
-    HB_STACKARRAY(HB_UChar16, reordered, len + 4);\r
-\r
-    if (item->num_glyphs < item->item.length + 4) {\r
-        item->num_glyphs = item->item.length + 4;\r
-        return FALSE;\r
-    }\r
-\r
-    if (invalid) {\r
-        *reordered = 0x25cc;\r
-        memcpy(reordered+1, str, len*sizeof(HB_UChar16));\r
-        len++;\r
-        str = reordered;\r
-    }\r
-\r
-    haveGlyphs = item->font->klass->convertStringToGlyphIndices(item->font,\r
-                                                                str, len,\r
-                                                                item->glyphs, &item->num_glyphs,\r
-                                                                item->item.bidiLevel % 2);\r
-\r
-    HB_FREE_STACKARRAY(reordered);\r
-\r
-    if (!haveGlyphs)\r
-        return FALSE;\r
-\r
-    for (i = 0; i < item->item.length; i++) {\r
-        item->attributes[i].mark = FALSE;\r
-        item->attributes[i].clusterStart = FALSE;\r
-        item->attributes[i].justification = 0;\r
-        item->attributes[i].zeroWidth = FALSE;\r
-/*        IDEBUG("    %d: %4x", i, str[i]); */\r
-    }\r
-\r
-    /* now we have the syllable in the right order, and can start running it through open type. */\r
-\r
-#ifndef NO_OPENTYPE\r
-    if (openType) {\r
-        HB_OpenTypeShape(item, /*properties*/0);\r
-        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))\r
-            return FALSE;\r
-    } else {\r
-        HB_HeuristicPosition(item);\r
-    }\r
-#endif\r
-\r
-    item->attributes[0].clusterStart = TRUE;\r
-    return TRUE;\r
-}\r
-\r
-/* SAMSUNG - Kaja Changes -Start */\r
-//static int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)\r
-/* SAMSUNG - Kaja Changes -End */\r
-{\r
-    const HB_UChar16 *uc = s + start;\r
-\r
-    int pos = 0;\r
-    TibetanForm state = tibetan_form(*uc);\r
-\r
-/*     qDebug("state[%d]=%d (uc=%4x)", pos, state, uc[pos]);*/\r
-    pos++;\r
-\r
-    if (state != TibetanHeadConsonant) {\r
-        if (state != TibetanOther)\r
-            *invalid = TRUE;\r
-        goto finish;\r
-    }\r
-\r
-    while (pos < end - start) {\r
-        TibetanForm newState = tibetan_form(uc[pos]);\r
-        switch(newState) {\r
-        case TibetanSubjoinedConsonant:\r
-        case TibetanSubjoinedVowel:\r
-            if (state != TibetanHeadConsonant &&\r
-                 state != TibetanSubjoinedConsonant)\r
-                goto finish;\r
-            state = newState;\r
-            break;\r
-        case TibetanVowel:\r
-            if (state != TibetanHeadConsonant &&\r
-                 state != TibetanSubjoinedConsonant &&\r
-                 state != TibetanSubjoinedVowel)\r
-                goto finish;\r
-            break;\r
-        case TibetanOther:\r
-        case TibetanHeadConsonant:\r
-            goto finish;\r
-        }\r
-        pos++;\r
-    }\r
-\r
-finish:\r
-    *invalid = FALSE;\r
-    return start+pos;\r
-}\r
-\r
-HB_Bool HB_TibetanShape(HB_ShaperItem *item)\r
-{\r
-\r
-    HB_Bool openType = FALSE;\r
-    unsigned short *logClusters = item->log_clusters;\r
-\r
-    HB_ShaperItem syllable = *item;\r
-    int first_glyph = 0;\r
-\r
-    int sstart = item->item.pos;\r
-    int end = sstart + item->item.length;\r
-\r
-    assert(item->item.script == HB_Script_Tibetan);\r
-\r
-#ifndef QT_NO_OPENTYPE\r
-    openType = HB_SelectScript(item, tibetan_features);\r
-#endif\r
-\r
-    while (sstart < end) {\r
-        HB_Bool invalid;\r
-        int i;\r
-        int send = tibetan_nextSyllableBoundary(item->string, sstart, end, &invalid);\r
-/*        IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,\r
-                 invalid ? "TRUE" : "FALSE"); */\r
-        syllable.item.pos = sstart;\r
-        syllable.item.length = send-sstart;\r
-        syllable.glyphs = item->glyphs + first_glyph;\r
-        syllable.attributes = item->attributes + first_glyph;\r
-        syllable.offsets = item->offsets + first_glyph;\r
-        syllable.advances = item->advances + first_glyph;\r
-        syllable.num_glyphs = item->num_glyphs - first_glyph;\r
-        if (!tibetan_shape_syllable(openType, &syllable, invalid)) {\r
-            item->num_glyphs += syllable.num_glyphs;\r
-            return FALSE;\r
-        }\r
-        /* fix logcluster array */\r
-        for (i = sstart; i < send; ++i)\r
-            logClusters[i-item->item.pos] = first_glyph;\r
-        sstart = send;\r
-        first_glyph += syllable.num_glyphs;\r
-    }\r
-    item->num_glyphs = first_glyph;\r
-    return TRUE;\r
-}\r
-\r
-void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)\r
-{\r
-    int end = from + len;\r
-    const HB_UChar16 *uc = text + from;\r
-    hb_uint32 i = 0;\r
-    HB_UNUSED(script);\r
-    attributes += from;\r
-    while (i < len) {\r
-        HB_Bool invalid;\r
-        hb_uint32 boundary = tibetan_nextSyllableBoundary(text, from+i, end, &invalid) - from;\r
-\r
-        attributes[i].charStop = TRUE;\r
-\r
-        if (boundary > len-1) boundary = len;\r
-        i++;\r
-        while (i < boundary) {\r
-            attributes[i].charStop = FALSE;\r
-            ++uc;\r
-            ++i;\r
-        }\r
-        assert(i == boundary);\r
-    }\r
-}\r
-\r
-\r
+/*
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz-shaper.h"
+#include "harfbuzz-shaper-private.h"
+
+#include <assert.h>
+
+/*
+ tibetan syllables are of the form:
+    head position consonant
+    first sub-joined consonant
+    ....intermediate sub-joined consonants (if any)
+    last sub-joined consonant
+    sub-joined vowel (a-chung U+0F71)
+    standard or compound vowel sign (or 'virama' for devanagari transliteration)
+*/
+
+typedef enum {
+    TibetanOther,
+    TibetanHeadConsonant,
+    TibetanSubjoinedConsonant,
+    TibetanSubjoinedVowel,
+    TibetanVowel
+} TibetanForm;
+
+/* this table starts at U+0f40 */
+static const unsigned char tibetanForm[0x80] = {
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant, TibetanHeadConsonant,
+    TibetanOther, TibetanOther, TibetanOther, TibetanOther,
+
+    TibetanOther, TibetanVowel, TibetanVowel, TibetanVowel,
+    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,
+    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,
+    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,
+
+    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,
+    TibetanVowel, TibetanVowel, TibetanVowel, TibetanVowel,
+    TibetanOther, TibetanOther, TibetanOther, TibetanOther,
+    TibetanOther, TibetanOther, TibetanOther, TibetanOther,
+
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant, TibetanSubjoinedConsonant,
+    TibetanSubjoinedConsonant, TibetanOther, TibetanOther, TibetanOther
+};
+
+
+#define tibetan_form(c) \
+    (TibetanForm)tibetanForm[c - 0x0f40]
+
+static const HB_OpenTypeFeature tibetan_features[] = {
+    { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
+    { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },
+    { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },
+    { HB_MAKE_TAG('c', 'a', 'l', 't'), CaltProperty },
+    {0, 0}
+};
+
+static HB_Bool tibetan_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_Bool invalid)
+{
+    hb_uint32 i;
+    const HB_UChar16 *str = item->string + item->item.pos;
+    int len = item->item.length;
+#ifndef NO_OPENTYPE
+    const int availableGlyphs = item->num_glyphs;
+#endif
+    HB_Bool haveGlyphs;
+    HB_STACKARRAY(HB_UChar16, reordered, len + 4);
+
+    if (item->num_glyphs < item->item.length + 4) {
+        item->num_glyphs = item->item.length + 4;
+        return FALSE;
+    }
+
+    if (invalid) {
+        *reordered = 0x25cc;
+        memcpy(reordered+1, str, len*sizeof(HB_UChar16));
+        len++;
+        str = reordered;
+    }
+
+    haveGlyphs = item->font->klass->convertStringToGlyphIndices(item->font,
+                                                                str, len,
+                                                                item->glyphs, &item->num_glyphs,
+                                                                item->item.bidiLevel % 2);
+
+    HB_FREE_STACKARRAY(reordered);
+
+    if (!haveGlyphs)
+        return FALSE;
+
+    for (i = 0; i < item->item.length; i++) {
+        item->attributes[i].mark = FALSE;
+        item->attributes[i].clusterStart = FALSE;
+        item->attributes[i].justification = 0;
+        item->attributes[i].zeroWidth = FALSE;
+/*        IDEBUG("    %d: %4x", i, str[i]); */
+    }
+
+    /* now we have the syllable in the right order, and can start running it through open type. */
+
+#ifndef NO_OPENTYPE
+    if (openType) {
+        HB_OpenTypeShape(item, /*properties*/0);
+        if (!HB_OpenTypePosition(item, availableGlyphs, /*doLogClusters*/FALSE))
+            return FALSE;
+    } else {
+        HB_HeuristicPosition(item);
+    }
+#endif
+
+    item->attributes[0].clusterStart = TRUE;
+    return TRUE;
+}
+
+/* SAMSUNG - Kaja Changes -Start */
+//static int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+int tibetan_nextSyllableBoundary(const HB_UChar16 *s, int start, int end, HB_Bool *invalid)
+/* SAMSUNG - Kaja Changes -End */
+{
+    const HB_UChar16 *uc = s + start;
+
+    int pos = 0;
+    TibetanForm state = tibetan_form(*uc);
+
+/*     qDebug("state[%d]=%d (uc=%4x)", pos, state, uc[pos]);*/
+    pos++;
+
+    if (state != TibetanHeadConsonant) {
+        if (state != TibetanOther)
+            *invalid = TRUE;
+        goto finish;
+    }
+
+    while (pos < end - start) {
+        TibetanForm newState = tibetan_form(uc[pos]);
+        switch(newState) {
+        case TibetanSubjoinedConsonant:
+        case TibetanSubjoinedVowel:
+            if (state != TibetanHeadConsonant &&
+                 state != TibetanSubjoinedConsonant)
+                goto finish;
+            state = newState;
+            break;
+        case TibetanVowel:
+            if (state != TibetanHeadConsonant &&
+                 state != TibetanSubjoinedConsonant &&
+                 state != TibetanSubjoinedVowel)
+                goto finish;
+            break;
+        case TibetanOther:
+        case TibetanHeadConsonant:
+            goto finish;
+        }
+        pos++;
+    }
+
+finish:
+    *invalid = FALSE;
+    return start+pos;
+}
+
+HB_Bool HB_TibetanShape(HB_ShaperItem *item)
+{
+
+    HB_Bool openType = FALSE;
+    unsigned short *logClusters = item->log_clusters;
+
+    HB_ShaperItem syllable = *item;
+    int first_glyph = 0;
+
+    int sstart = item->item.pos;
+    int end = sstart + item->item.length;
+
+    assert(item->item.script == HB_Script_Tibetan);
+
+#ifndef QT_NO_OPENTYPE
+    openType = HB_SelectScript(item, tibetan_features);
+#endif
+
+    while (sstart < end) {
+        HB_Bool invalid;
+        int i;
+        int send = tibetan_nextSyllableBoundary(item->string, sstart, end, &invalid);
+/*        IDEBUG("syllable from %d, length %d, invalid=%s", sstart, send-sstart,
+                 invalid ? "TRUE" : "FALSE"); */
+        syllable.item.pos = sstart;
+        syllable.item.length = send-sstart;
+        syllable.glyphs = item->glyphs + first_glyph;
+        syllable.attributes = item->attributes + first_glyph;
+        syllable.offsets = item->offsets + first_glyph;
+        syllable.advances = item->advances + first_glyph;
+        syllable.num_glyphs = item->num_glyphs - first_glyph;
+        if (!tibetan_shape_syllable(openType, &syllable, invalid)) {
+            item->num_glyphs += syllable.num_glyphs;
+            return FALSE;
+        }
+        /* fix logcluster array */
+        for (i = sstart; i < send; ++i)
+            logClusters[i-item->item.pos] = first_glyph;
+        sstart = send;
+        first_glyph += syllable.num_glyphs;
+    }
+    item->num_glyphs = first_glyph;
+    return TRUE;
+}
+
+void HB_TibetanAttributes(HB_Script script, const HB_UChar16 *text, hb_uint32 from, hb_uint32 len, HB_CharAttributes *attributes)
+{
+    int end = from + len;
+    const HB_UChar16 *uc = text + from;
+    hb_uint32 i = 0;
+    HB_UNUSED(script);
+    attributes += from;
+    while (i < len) {
+        HB_Bool invalid;
+        hb_uint32 boundary = tibetan_nextSyllableBoundary(text, from+i, end, &invalid) - from;
+
+        attributes[i].charStop = TRUE;
+
+        if (boundary > len-1) boundary = len;
+        i++;
+        while (i < boundary) {
+            attributes[i].charStop = FALSE;
+            ++uc;
+            ++i;
+        }
+        assert(i == boundary);
+    }
+}
+
+
index ea5e4c1..692d00d 100755 (executable)
-/*\r
- * Copyright (C) 2006  Behdad Esfahbod\r
- *\r
- * This is part of HarfBuzz, an OpenType Layout engine library.\r
- *\r
- * Permission is hereby granted, without written agreement and without\r
- * license or royalty fees, to use, copy, modify, and distribute this\r
- * software and its documentation for any purpose, provided that the\r
- * above copyright notice and the following two paragraphs appear in\r
- * all copies of this software.\r
- *\r
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
- * DAMAGE.\r
- *\r
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
- */\r
-\r
-#include "harfbuzz.h"\r
-#include "hb_unicode_tables.h"\r
-\r
-#include "harfbuzz-buffer.c"\r
-#include "harfbuzz-gdef.c"\r
-#include "harfbuzz-gsub.c"\r
-#include "harfbuzz-gpos.c"\r
-#include "harfbuzz-impl.c"\r
-#include "harfbuzz-open.c"\r
-#include "harfbuzz-stream.c"\r
-\r
-\r
-HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID)\r
-{\r
-       HB_Error error = HB_Err_Ok;\r
-       hb_uint8 script = value>>8;\r
-\r
-       *scriptID = HB_Script_Common;\r
-\r
-       if(0 == scriptTableStruct[script].pSubTable)\r
-       {\r
-               *scriptID = (HB_Script)scriptTableStruct[script].scriptID;\r
-       }\r
-       else if(scriptTableStruct[script].pSubTable != 0)\r
-       {\r
-               if((value&0xFF) < scriptTableStruct[script].scriptID)//check the size of the sub table array\r
-               {\r
-                       *scriptID = scriptTableStruct[script].pSubTable[(value&0xFF)];\r
-               }\r
-               else\r
-               {\r
-                       error = HB_Err_Not_Covered;\r
-               }\r
-       }\r
-       else\r
-       {\r
-               error = HB_Err_Invalid_SubTable;\r
-       }\r
-\r
-       return error;\r
-}\r
-\r
-HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen)\r
-{\r
-      HB_Script cur_script_id;\r
-      HB_Error error = HB_Err_Ok;\r
-      HB_UShort *curText = text ; \r
-\r
-      *scriptID = HB_Script_Common;\r
-      *scriptLen = 0 ;\r
\r
-      if((NULL == curText) || (0 == textLen))\r
-      {\r
-            return HB_Err_Invalid_Argument;\r
-      }\r
-\r
-      hb_getScriptID(*curText, scriptID);   \r
-         \r
-      curText++;\r
-      textLen--; \r
-\r
-      while(textLen)\r
-      {\r
-            if(HB_DOTTED_CIRCLE == *curText     || HB_ZWJ == *curText || HB_ZWNJ == *curText)\r
-            {\r
-                  curText++;\r
-                  textLen--;\r
-                  continue;\r
-            } \r
-\r
-            hb_getScriptID(*curText, &cur_script_id); \r
-\r
-            if(*scriptID != cur_script_id)\r
-            {\r
-                  break;\r
-            } \r
-\r
-            curText++;\r
-            textLen--;\r
-      } \r
-\r
-      *scriptLen = curText -text ;\r
-      return error;\r
-\r
-}\r
-\r
-\r
-int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID)\r
-{\r
-       int len = 0 ;\r
-       HB_Bool invalid ;\r
-       switch (*scriptID)\r
-       {\r
-       case HB_Script_Devanagari:\r
-       case HB_Script_Bengali:\r
-       case HB_Script_Gurmukhi:\r
-       case HB_Script_Gujarati:\r
-       case HB_Script_Oriya:\r
-       case HB_Script_Tamil:\r
-       case HB_Script_Telugu:\r
-       case HB_Script_Kannada:\r
-       case HB_Script_Malayalam:\r
-       case HB_Script_Sinhala:\r
-               len = indic_nextSyllableBoundary(*scriptID, (const HB_UChar16*)text, 0, textLen, &invalid); \r
-               break ;\r
-       case HB_Script_Khmer:\r
-               len = khmer_nextSyllableBoundary(text, 0, textLen, &invalid);\r
-               break ;\r
-       case HB_Script_Myanmar:\r
-               len = myanmar_nextSyllableBoundary(text, 0, textLen, &invalid);\r
-               break ;\r
-       case HB_Script_Tibetan:\r
-               len = tibetan_nextSyllableBoundary(text, 0, textLen, &invalid);\r
-               break ;\r
-       default:\r
-               len = 1 ;\r
-       }\r
-\r
-       return len ;\r
-}\r
-\r
+/*
+ * Copyright (C) 2006  Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine 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.
+ */
+
+#include "harfbuzz.h"
+#include "hb_unicode_tables.h"
+
+#include "harfbuzz-buffer.c"
+#include "harfbuzz-gdef.c"
+#include "harfbuzz-gsub.c"
+#include "harfbuzz-gpos.c"
+#include "harfbuzz-impl.c"
+#include "harfbuzz-open.c"
+#include "harfbuzz-stream.c"
+
+
+HB_Error hb_getScriptID(HB_UShort value, HB_Script *scriptID)
+{
+       HB_Error error = HB_Err_Ok;
+       hb_uint8 script = value>>8;
+
+       *scriptID = HB_Script_Common;
+
+       if(0 == scriptTableStruct[script].pSubTable)
+       {
+               *scriptID = (HB_Script)scriptTableStruct[script].scriptID;
+       }
+       else if(scriptTableStruct[script].pSubTable != 0)
+       {
+               if((value&0xFF) < scriptTableStruct[script].scriptID)//check the size of the sub table array
+               {
+                       *scriptID = scriptTableStruct[script].pSubTable[(value&0xFF)];
+               }
+               else
+               {
+                       error = HB_Err_Not_Covered;
+               }
+       }
+       else
+       {
+               error = HB_Err_Invalid_SubTable;
+       }
+
+       return error;
+}
+
+HB_Error hb_getTextWithScriptID(HB_UShort *text, int textLen, HB_Script *scriptID, int *scriptLen)
+{
+      HB_Script cur_script_id;
+      HB_Error error = HB_Err_Ok;
+      HB_UShort *curText = text ; 
+
+      *scriptID = HB_Script_Common;
+      *scriptLen = 0 ;
+      if((NULL == curText) || (0 == textLen))
+      {
+            return HB_Err_Invalid_Argument;
+      }
+
+      hb_getScriptID(*curText, scriptID);   
+         
+      curText++;
+      textLen--; 
+
+      while(textLen)
+      {
+            if(HB_DOTTED_CIRCLE == *curText     || HB_ZWJ == *curText || HB_ZWNJ == *curText)
+            {
+                  curText++;
+                  textLen--;
+                  continue;
+            } 
+
+            hb_getScriptID(*curText, &cur_script_id); 
+
+            if(*scriptID != cur_script_id)
+            {
+                  break;
+            } 
+
+            curText++;
+            textLen--;
+      } 
+
+      *scriptLen = curText -text ;
+      return error;
+
+}
+
+
+int hb_getSyllableLength(HB_UShort *text, int textLen, HB_Script *scriptID)
+{
+       int len = 0 ;
+       HB_Bool invalid ;
+       switch (*scriptID)
+       {
+       case HB_Script_Devanagari:
+       case HB_Script_Bengali:
+       case HB_Script_Gurmukhi:
+       case HB_Script_Gujarati:
+       case HB_Script_Oriya:
+       case HB_Script_Tamil:
+       case HB_Script_Telugu:
+       case HB_Script_Kannada:
+       case HB_Script_Malayalam:
+       case HB_Script_Sinhala:
+               len = indic_nextSyllableBoundary(*scriptID, (const HB_UChar16*)text, 0, textLen, &invalid); 
+               break ;
+       case HB_Script_Khmer:
+               len = khmer_nextSyllableBoundary(text, 0, textLen, &invalid);
+               break ;
+       case HB_Script_Myanmar:
+               len = myanmar_nextSyllableBoundary(text, 0, textLen, &invalid);
+               break ;
+       case HB_Script_Tibetan:
+               len = tibetan_nextSyllableBoundary(text, 0, textLen, &invalid);
+               break ;
+       default:
+               len = 1 ;
+       }
+
+       return len ;
+}
+