[trak] Fix, and hook up
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 11 Oct 2018 15:10:06 +0000 (11:10 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 11 Oct 2018 15:10:06 +0000 (11:10 -0400)
Works beautifully!  Test coming.

src/hb-aat-layout-common.hh
src/hb-aat-layout-trak-table.hh
src/hb-aat-layout.cc
src/hb-aat-layout.hh
src/hb-ot-shape.cc

index 78de04f..78a27a7 100644 (file)
@@ -540,7 +540,7 @@ struct hb_aat_apply_context_t :
   inline hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_,
                                 hb_font_t *font_,
                                 hb_buffer_t *buffer_,
-                                hb_blob_t *table,
+                                hb_blob_t *blob = const_cast<hb_blob_t *> (&Null(hb_blob_t)),
                                 const ankr &ankr_table_ = Null(ankr),
                                 const char *ankr_end_ = nullptr) :
                plan (plan_), font (font_), face (font->face), buffer (buffer_),
@@ -548,7 +548,7 @@ struct hb_aat_apply_context_t :
                ankr_table (ankr_table_), ankr_end (ankr_end_),
                lookup_index (0), debug_depth (0)
   {
-    sanitizer.init (table);
+    sanitizer.init (blob);
     sanitizer.set_num_glyphs (face->get_num_glyphs ());
     sanitizer.start_processing ();
     sanitizer.set_max_ops (HB_SANITIZE_MAX_OPS_MAX);
index 368c55c..b2d6941 100644 (file)
@@ -125,9 +125,9 @@ struct TrackData
 
     /* TODO bfind() */
     unsigned int size_index;
-    UnsizedArrayOf<Fixed> size_table = base+sizeTable;
+    hb_array_t<Fixed> size_table ((base+sizeTable).arrayZ, sizes);
     for (size_index = 0; size_index < sizes; size_index++)
-      if (size_table[size_index] >= fixed_size)
+      if ((int) size_table[size_index] >= (int) fixed_size)
         break;
 
     // TODO(ebraminio): We don't attempt to extrapolate to larger or
@@ -169,6 +169,8 @@ struct trak
 {
   static const hb_tag_t tableTag = HB_AAT_TAG_trak;
 
+  inline bool has_data (void) const { return version.to_int () != 0; }
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
index 73ab06d..2b86ba8 100644 (file)
@@ -37,7 +37,7 @@
 #include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise.
 
 /*
- * morx/kerx/trak/ankr
+ * morx/kerx/trak
  */
 
 static inline const AAT::morx&
@@ -82,6 +82,12 @@ _get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr)
     *blob = hb_ot_face_data (face)->ankr.get_blob ();
   return ankr;
 }
+static inline const AAT::trak&
+_get_trak (hb_face_t *face)
+{
+  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(AAT::trak);
+  return *(hb_ot_face_data (face)->trak.get ());
+}
 
 
 hb_bool_t
@@ -124,3 +130,20 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
                                 ankr, ankr_blob->data + ankr_blob->length);
   kerx.apply (&c);
 }
+
+hb_bool_t
+hb_aat_layout_has_tracking (hb_face_t *face)
+{
+  return _get_trak (face).has_data ();
+}
+
+void
+hb_aat_layout_track (hb_ot_shape_plan_t *plan,
+                    hb_font_t *font,
+                    hb_buffer_t *buffer)
+{
+  const AAT::trak& trak = _get_trak (font->face);
+
+  AAT::hb_aat_apply_context_t c (plan, font, buffer);
+  trak.apply (&c);
+}
index aafc327..897c26a 100644 (file)
@@ -47,4 +47,12 @@ hb_aat_layout_position (hb_ot_shape_plan_t *plan,
                        hb_font_t *font,
                        hb_buffer_t *buffer);
 
+HB_INTERNAL hb_bool_t
+hb_aat_layout_has_tracking (hb_face_t *face);
+
+HB_INTERNAL void
+hb_aat_layout_track (hb_ot_shape_plan_t *plan,
+                    hb_font_t *font,
+                    hb_buffer_t *buffer);
+
 #endif /* HB_AAT_LAYOUT_HH */
index 75f72ed..3ca54ac 100644 (file)
@@ -838,6 +838,8 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
   else if (c->plan->apply_kerx)
     hb_aat_layout_position (c->plan, c->font, c->buffer);
 
+  hb_aat_layout_track (c->plan, c->font, c->buffer);
+
   if (!c->plan->apply_kerx)
     switch (c->plan->shaper->zero_width_marks)
     {