src/hb-open-type-private.hh                                             |    4 
 src/hb-ot-kern-table.hh                                                 |   69 
+++++-----
 src/hb-ot-shape-complex-arabic.cc                                       |    1 
 test/shaping/Makefile.am                                                |    1 
 test/shaping/fonts/sha1sum/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf |binary
 test/shaping/tests/arabic-stch.tests                                    |    1 
 6 files changed, 45 insertions(+), 31 deletions(-)

New commits:
commit 625ae08fcee747fbdc33a3a6865fb3aa425662ca
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sat Nov 4 12:01:11 2017 -0400

    [kern] Towards implementing format-2

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index b3169c04..2687ba66 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -1078,9 +1078,7 @@ struct BinSearchHeader
 };
 
 template <typename Type>
-struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader>
-{
-};
+struct BinSearchArrayOf : SortedArrayOf<Type, BinSearchHeader> {};
 
 
 /* Lazy struct and blob loaders. */
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 2cab5cc9..2d355914 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -81,9 +81,6 @@ struct KernSubTableFormat0
     return pairs[i].get_kerning ();
   }
 
-  inline unsigned int get_size (void) const
-  { return pairs.get_size (); }
-
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
@@ -96,46 +93,63 @@ struct KernSubTableFormat0
   DEFINE_SIZE_ARRAY (8, pairs);
 };
 
-struct KernSubTableFormat2
+struct KernClassTable
 {
-  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+  inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - 
firstGlyph]; }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
   {
-    /* XXX */
-    return 0;
+    TRACE_SANITIZE (this);
+    return_trace (firstGlyph.sanitize (c) && classes.sanitize (c));
   }
 
-  inline unsigned int get_size (void) const
+  protected:
+  USHORT               firstGlyph;     /* First glyph in class range. */
+  ArrayOf<USHORT>      classes;        /* Glyph classes. */
+  public:
+  DEFINE_SIZE_ARRAY (4, classes);
+};
+
+struct KernSubTableFormat2
+{
+  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned 
int length) const
   {
-    /* XXX */
-    return 0;
+    unsigned int l = (this+leftClassTable).get_class (left);
+    unsigned int r = (this+leftClassTable).get_class (left);
+    return 0;//(&(this+array))[0/*XXX*/];
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-
-    /* XXX */
-
-    return_trace (true);
+    return_trace (rowWidth.sanitize (c) &&
+                 leftClassTable.sanitize (c, this) &&
+                 rightClassTable.sanitize (c, this) &&
+                 array.sanitize (c, this));
   }
+
+  protected:
+  USHORT       rowWidth;       /* The width, in bytes, of a row in the table. 
*/
+  OffsetTo<KernClassTable>
+               leftClassTable; /* Offset from beginning of this subtable to
+                                * left-hand class table. */
+  OffsetTo<KernClassTable>
+               rightClassTable;/* Offset from beginning of this subtable to
+                                * right-hand class table. */
+  OffsetTo<FWORD>
+               array;          /* Offset from beginning of this subtable to
+                                * the start of the kerning array. */
+  public:
+  DEFINE_SIZE_MIN (8);
 };
 
 struct KernSubTable
 {
-  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned 
int format) const
+  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned 
int length, unsigned int format) const
   {
     switch (format) {
     case 0: return u.format0.get_kerning (left, right);
-    case 2: return u.format2.get_kerning (left, right);
-    default:return 0;
-    }
-  }
-
-  inline unsigned int get_size (unsigned int format) const
-  {
-    switch (format) {
-    case 0: return u.format0.get_size ();
-    case 2: return u.format2.get_size ();
+    case 2: return u.format2.get_kerning (left, right, length);
     default:return 0;
     }
   }
@@ -173,7 +187,7 @@ struct KernSubTableWrapper
   { return bool (thiz()->coverage & T::COVERAGE_OVERRIDE_FLAG); }
 
   inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
-  { return thiz()->subtable.get_kerning (left, right, thiz()->format); }
+  { return thiz()->subtable.get_kerning (left, right, thiz()->length - 
thiz()->min_size, thiz()->format); }
 
   inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
   { return is_horizontal () ? get_kerning (left, right) : 0; }
@@ -186,8 +200,7 @@ struct KernSubTableWrapper
     return_trace (c->check_struct (thiz()) &&
                  thiz()->length >= thiz()->min_size &&
                  c->check_array (thiz(), 1, thiz()->length) &&
-                 thiz()->subtable.sanitize (c, thiz()->format) &&
-                 thiz()->subtable.get_size (thiz()-> format) <= thiz()->length 
- thiz()->min_size);
+                 thiz()->subtable.sanitize (c, thiz()->format));
   }
 };
 
commit 74e82adaea08ced18493e3341823dbd5b6cd493e
Author: David Corbett <corbett....@husky.neu.edu>
Date:   Mon Nov 6 14:41:55 2017 -0500

    Mark glyphs involved in 'stch' as unsafe to break

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index 283f325b..eda20ca1 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -560,6 +560,7 @@ apply_stch (const hb_ot_shape_plan_t *plan,
       }
       else
       {
+       buffer->unsafe_to_break (context, end + 1);
        hb_position_t x_offset = 0;
        for (unsigned int k = end; k > start; k--)
        {
diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index 377c08d0..ca7c1c30 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -45,6 +45,7 @@ TESTS = \
        tests/arabic-feature-order.tests \
        tests/arabic-like-joining.tests \
        tests/arabic-mark-order.tests \
+       tests/arabic-stch.tests \
        tests/automatic-fractions.tests \
        tests/cluster.tests \
        tests/color-fonts.tests \
diff --git 
a/test/shaping/fonts/sha1sum/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf 
b/test/shaping/fonts/sha1sum/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf
new file mode 100644
index 00000000..112146eb
Binary files /dev/null and 
b/test/shaping/fonts/sha1sum/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf differ
diff --git a/test/shaping/tests/arabic-stch.tests 
b/test/shaping/tests/arabic-stch.tests
new file mode 100644
index 00000000..a268d8a7
--- /dev/null
+++ b/test/shaping/tests/arabic-stch.tests
@@ -0,0 +1 @@
+fonts/sha1sum/d9b8bc10985f24796826c29f7ccba3d0ae11ec02.ttf:--no-glyph-names 
--show-flags:U+0718,U+070F,U+0718,U+0718,U+002E:[1=4+168|3=3+502#1|3=2+502#1|4=1@-1004,0+0#1|5=1@-876,0+0#1|5=1@-799,0+0#1|5=1@-722,0+0#1|5=1@-645,0+0#1|4=1@-566,0+0#1|5=1@-438,0+0#1|5=1@-361,0+0#1|5=1@-284,0+0#1|5=1@-207,0+0#1|4=1@-128,0+0#1|3=0+502]
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to