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

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon May 14 14:48:55 PDT 2012


 configure.ac                         |    2 
 src/hb-buffer-private.hh             |    9 ++
 src/hb-fallback-shape.cc             |    4 -
 src/hb-font.cc                       |    2 
 src/hb-ot-layout-common-private.hh   |    3 
 src/hb-ot-layout-gpos-table.hh       |   47 +++++++--------
 src/hb-ot-layout-gsub-table.hh       |   36 +++++------
 src/hb-ot-layout-gsubgpos-private.hh |   76 ++++++++++---------------
 src/hb-ot-shape-complex-arabic.cc    |   11 ++-
 src/hb-ot-shape-complex-indic.cc     |   91 +++++++++++++++---------------
 src/hb-ot-shape-complex-misc.cc      |   26 +++++---
 src/hb-ot-shape-normalize.cc         |   29 ++++-----
 src/hb-ot-shape.cc                   |    8 +-
 src/hb-private.hh                    |   54 ++++++++---------
 src/hb-set.cc                        |    2 
 util/ansi-print.cc                   |  106 ++++++++++++++++++-----------------
 util/options.hh                      |    2 
 17 files changed, 259 insertions(+), 249 deletions(-)

New commits:
commit 1d6846db9ebf84561bb30a4e48c6c43184914099
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 18:09:29 2012 +0200

    [Indic] Apply vatu feature after cjct
    
    Testing with old Deva spec this reduces failures.
    Test sequence: U+0915,U+094D,U+0930.

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 05ae161..3712d06 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -101,9 +101,9 @@ indic_basic_features[] =
   {HB_TAG('p','r','e','f'), false},
   {HB_TAG('b','l','w','f'), false},
   {HB_TAG('h','a','l','f'), false},
-  {HB_TAG('v','a','t','u'), true},
   {HB_TAG('p','s','t','f'), false},
   {HB_TAG('c','j','c','t'), false},
+  {HB_TAG('v','a','t','u'), true},
 };
 
 /* Same order as the indic_basic_features array */
@@ -115,9 +115,9 @@ enum {
   PREF,
   BLWF,
   HALF,
-  _VATU,
   PSTF,
-  CJCT
+  CJCT,
+  VATU
 };
 
 static const feature_list_t
commit 8caf5dcd66550351c6038b9ae7ecc5254eed64ff
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 17:10:18 2012 +0200

    Minor

diff --git a/util/ansi-print.cc b/util/ansi-print.cc
index 1451819..fde06f1 100644
--- a/util/ansi-print.cc
+++ b/util/ansi-print.cc
@@ -251,8 +251,6 @@ block_best (const biimage_t &bi, unsigned int *score, bool *inverse)
     col_sum_i[i] += col_sum_i[i - 1];
   }
 
-  *score = (unsigned int) -1;
-  *inverse = false;
   const char *best_c = " ";
 
   /* Maybe empty is better! */
@@ -301,7 +299,6 @@ block_best (const biimage_t &bi, unsigned int *score, bool *inverse)
   }
 
   /* Find best left line */
-  /* Disable this as it looks ugly because of line height issues. */
   if (1) {
     unsigned int best_s = (unsigned int) -1;
     bool best_inv = false;
@@ -333,35 +330,37 @@ block_best (const biimage_t &bi, unsigned int *score, bool *inverse)
     }
   }
 
-  /* Quadrant? */
-  unsigned int q = 0;
-  unsigned int qs = 0;
-  for (unsigned int i = 0; i < 2; i++)
-    for (unsigned int j = 0; j < 2; j++)
-      if (quad[i][j] > quad_i[i][j]) {
-        q += 1 << (2 * i + j);
-	qs += quad_i[i][j];
-      } else
-	qs += quad[i][j];
-  if (qs < *score) {
-    const char *c = NULL;
-    bool inv = false;
-    switch (q) {
-      case 1:  c = "â–Ÿ"; inv = true;  break;
-      case 2:  c = "â–™"; inv = true;  break;
-      case 4:  c = "â––"; inv = false; break;
-      case 8:  c = "â–—"; inv = false; break;
-      case 9:  c = "â–š"; inv = false; break;
-      case 6:  c = "â–ž"; inv = false; break;
-      case 7:  c = "▜"; inv = true;  break;
-      case 11: c = "▜"; inv = true;  break;
-      case 13: c = "â–™"; inv = true;  break;
-      case 14: c = "â–Ÿ"; inv = true;  break;
-    }
-    if (c) {
-      *score = qs;
-      *inverse = inv;
-      best_c = c;
+  /* Find best quadrant */
+  if (1) {
+    unsigned int q = 0;
+    unsigned int qs = 0;
+    for (unsigned int i = 0; i < 2; i++)
+      for (unsigned int j = 0; j < 2; j++)
+	if (quad[i][j] > quad_i[i][j]) {
+	  q += 1 << (2 * i + j);
+	  qs += quad_i[i][j];
+	} else
+	  qs += quad[i][j];
+    if (qs < *score) {
+      const char *c = NULL;
+      bool inv = false;
+      switch (q) {
+	case 1:  c = "â–Ÿ"; inv = true;  break;
+	case 2:  c = "â–™"; inv = true;  break;
+	case 4:  c = "â––"; inv = false; break;
+	case 8:  c = "â–—"; inv = false; break;
+	case 9:  c = "â–š"; inv = false; break;
+	case 6:  c = "â–ž"; inv = false; break;
+	case 7:  c = "▜"; inv = true;  break;
+	case 11: c = "▜"; inv = true;  break;
+	case 13: c = "â–™"; inv = true;  break;
+	case 14: c = "â–Ÿ"; inv = true;  break;
+      }
+      if (c) {
+	*score = qs;
+	*inverse = inv;
+	best_c = c;
+      }
     }
   }
 
@@ -377,7 +376,7 @@ ansi_print_image_rgb24 (const uint32_t *data,
   image_t image (width, height, data, stride);
 
   unsigned int rows = (height + CELL_H - 1) / CELL_H;
-  unsigned int cols = (width + CELL_W - 1) / CELL_W;
+  unsigned int cols = (width +  CELL_W - 1) / CELL_W;
   image_t cell (CELL_W, CELL_H);
   biimage_t bi (CELL_W, CELL_H);
   unsigned int last_bg = -1, last_fg = -1;
@@ -394,7 +393,7 @@ ansi_print_image_rgb24 (const uint32_t *data,
       } else {
         /* Figure out the closest character to the biimage */
         unsigned int score = (unsigned int) -1;
-	bool inverse;
+	bool inverse = false;
         const char *c = block_best (bi, &score, &inverse);
 	if (inverse) {
 	  if (last_bg != bi.fg || last_fg != bi.bg) {
commit 617f4ac46f1084859d2034c08760e31e52d3bec3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:48:03 2012 +0200

    Refactor

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 132a697..05ae161 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -250,6 +250,7 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
 {
   hb_glyph_info_t *info = buffer->info;
 
+
   /* 1. Find base consonant:
    *
    * The shaping engine finds the base consonant of the syllable, using the
@@ -267,22 +268,22 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
   unsigned int base = end;
   bool has_reph = false;
 
-  /* -> If the syllable starts with Ra + Halant (in a script that has Reph)
-   *    and has more than one consonant, Ra is excluded from candidates for
-   *    base consonants. */
-  unsigned int limit = start;
-  if (mask_array[RPHF] &&
-      start + 3 <= end &&
-      info[start].indic_category() == OT_Ra &&
-      info[start + 1].indic_category() == OT_H &&
-      !is_joiner (info[start + 2]))
   {
-    limit += 2;
-    base = start;
-    has_reph = true;
-  };
+    /* -> If the syllable starts with Ra + Halant (in a script that has Reph)
+     *    and has more than one consonant, Ra is excluded from candidates for
+     *    base consonants. */
+    unsigned int limit = start;
+    if (mask_array[RPHF] &&
+	start + 3 <= end &&
+	info[start].indic_category() == OT_Ra &&
+	info[start + 1].indic_category() == OT_H &&
+	!is_joiner (info[start + 2]))
+    {
+      limit += 2;
+      base = start;
+      has_reph = true;
+    };
 
-  {
     /* -> starting from the end of the syllable, move backwards */
     unsigned int i = end;
     do {
@@ -314,14 +315,15 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
     } while (i > limit);
     if (base < start)
       base = start; /* Just in case... */
-  }
 
-  /* -> If the syllable starts with Ra + Halant (in a script that has Reph)
-   *    and has more than one consonant, Ra is excluded from candidates for
-   *    base consonants. */
-  if (has_reph && base == start) {
-    /* Have no other consonant, so Reph is not formed and Ra becomes base. */
-    has_reph = false;
+
+    /* -> If the syllable starts with Ra + Halant (in a script that has Reph)
+     *    and has more than one consonant, Ra is excluded from candidates for
+     *    base consonants. */
+    if (has_reph && base == start) {
+      /* Have no other consonant, so Reph is not formed and Ra becomes base. */
+      has_reph = false;
+    }
   }
 
 
commit 5e4e21fce4b548b0b8a5951bc8f35a9f27428192
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:46:08 2012 +0200

    Revert "[Indic] Refactoring"
    
    This reverts commit 0831061efb78983b9c6e1e72574c977e56383c08.

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 8b6d4bb..132a697 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -245,10 +245,6 @@ compare_indic_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
  * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */
 
 static void
-initial_reordering_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
-			     unsigned int start, unsigned int end, unsigned int base);
-
-static void
 initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
 				       unsigned int start, unsigned int end)
 {
@@ -320,17 +316,14 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
       base = start; /* Just in case... */
   }
 
-  /* Continue reading below ------v */
-  initial_reordering_syllable (map, buffer, mask_array, start, end, base);
-}
+  /* -> If the syllable starts with Ra + Halant (in a script that has Reph)
+   *    and has more than one consonant, Ra is excluded from candidates for
+   *    base consonants. */
+  if (has_reph && base == start) {
+    /* Have no other consonant, so Reph is not formed and Ra becomes base. */
+    has_reph = false;
+  }
 
-static void
-initial_reordering_syllable (const hb_ot_map_t *map,
-			     hb_buffer_t *buffer,
-			     hb_mask_t *mask_array,
-			     unsigned int start, unsigned int end, unsigned int base)
-{
-  hb_glyph_info_t *info = buffer->info;
 
   /* 2. Decompose and reorder Matras:
    *
@@ -371,12 +364,7 @@ initial_reordering_syllable (const hb_ot_map_t *map,
   info[base].indic_position() = POS_BASE_C;
 
   /* Handle beginning Ra */
-  if (mask_array[RPHF] &&
-      start != base &&
-      start + 3 <= end &&
-      info[start].indic_category() == OT_Ra &&
-      info[start + 1].indic_category() == OT_H &&
-      !is_joiner (info[start + 2]))
+  if (has_reph)
     info[start].indic_position() = POS_RA_TO_BECOME_REPH;
 
   /* For old-style Indic script tags, move the first post-base Halant after
commit 3f18236a03880c0960f5990dc90685f6146951a6
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:20:10 2012 +0200

    Fix more warnings

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 6ea28bc..2943a7f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -403,7 +403,7 @@ struct CoverageFormat2
     for (i = 0; i < count; i++) {
       const RangeRecord &range = rangeRecord[i];
       if (range.value <= index &&
-	  index < range.value + (range.end - range.start) &&
+	  index < (unsigned int) range.value + (range.end - range.start) &&
 	  range.intersects (glyphs))
         return true;
       else if (index < range.value)
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 2b19fc8..452214a 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1178,7 +1178,7 @@ GSUB::substitute_start (hb_buffer_t *buffer)
 }
 
 void
-GSUB::substitute_finish (hb_buffer_t *buffer)
+GSUB::substitute_finish (hb_buffer_t *buffer HB_UNUSED)
 {
 }
 
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 6607778..8b6d4bb 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -188,7 +188,7 @@ _hb_ot_shape_complex_normalization_preference_indic (void)
 void
 _hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map HB_UNUSED,
 					hb_buffer_t *buffer,
-					hb_font_t *font)
+					hb_font_t *font HB_UNUSED)
 {
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_category);
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_position);
@@ -513,7 +513,7 @@ static void
 initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
 			      hb_buffer_t *buffer HB_UNUSED,
 			      hb_mask_t *mask_array HB_UNUSED,
-			      unsigned int start, unsigned int end)
+			      unsigned int start HB_UNUSED, unsigned int end HB_UNUSED)
 {
   /* Nothing to do right now.  If we ever switch to using the output
    * buffer in the reordering process, we'd need to next_glyph() here. */
@@ -523,7 +523,7 @@ initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
 
 static void
 initial_reordering (const hb_ot_map_t *map,
-		    hb_face_t *face,
+		    hb_face_t *face HB_UNUSED,
 		    hb_buffer_t *buffer,
 		    void *user_data HB_UNUSED)
 {
@@ -824,7 +824,7 @@ final_reordering_syllable (hb_buffer_t *buffer, hb_mask_t *mask_array,
 
 static void
 final_reordering (const hb_ot_map_t *map,
-		  hb_face_t *face,
+		  hb_face_t *face HB_UNUSED,
 		  hb_buffer_t *buffer,
 		  void *user_data HB_UNUSED)
 {
commit 9f377ed3210fe7d9f15e0c4f82020556f9a8f6f0
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:13:44 2012 +0200

    Fix more unused-var warnings

diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 8a590bb..54460f0 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -165,7 +165,8 @@ static const struct arabic_state_table_entry {
 
 
 void
-_hb_ot_shape_complex_collect_features_arabic (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+_hb_ot_shape_complex_collect_features_arabic (hb_ot_map_builder_t *map,
+					      const hb_segment_properties_t *props)
 {
   /* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init together,
    * then rlig and calt each in their own stage.  This makes IranNastaliq's ALLAH
@@ -240,7 +241,9 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
+_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map,
+					 hb_buffer_t *buffer,
+					 hb_font_t *font)
 {
   unsigned int count = buffer->len;
   unsigned int prev = 0, state = 0;
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index e4273c9..6607778 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -153,7 +153,8 @@ final_reordering (const hb_ot_map_t *map,
 		  void *user_data HB_UNUSED);
 
 void
-_hb_ot_shape_complex_collect_features_indic (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+_hb_ot_shape_complex_collect_features_indic (hb_ot_map_builder_t *map,
+					     const hb_segment_properties_t *props HB_UNUSED)
 {
   map->add_bool_feature (HB_TAG('l','o','c','l'));
   /* The Indic specs do not require ccmp, but we apply it here since if
@@ -185,7 +186,9 @@ _hb_ot_shape_complex_normalization_preference_indic (void)
 
 
 void
-_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
+_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map HB_UNUSED,
+					hb_buffer_t *buffer,
+					hb_font_t *font)
 {
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_category);
   HB_BUFFER_ALLOCATE_VAR (buffer, indic_position);
@@ -322,7 +325,9 @@ initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buff
 }
 
 static void
-initial_reordering_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
+initial_reordering_syllable (const hb_ot_map_t *map,
+			     hb_buffer_t *buffer,
+			     hb_mask_t *mask_array,
 			     unsigned int start, unsigned int end, unsigned int base)
 {
   hb_glyph_info_t *info = buffer->info;
@@ -474,7 +479,9 @@ initial_reordering_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mas
 
 
 static void
-initial_reordering_vowel_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
+initial_reordering_vowel_syllable (const hb_ot_map_t *map,
+				   hb_buffer_t *buffer,
+				   hb_mask_t *mask_array,
 				   unsigned int start, unsigned int end)
 {
   /* We made the vowels look like consonants.  So let's call the consonant logic! */
@@ -482,7 +489,9 @@ initial_reordering_vowel_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer,
 }
 
 static void
-initial_reordering_standalone_cluster (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
+initial_reordering_standalone_cluster (const hb_ot_map_t *map,
+				       hb_buffer_t *buffer,
+				       hb_mask_t *mask_array,
 				       unsigned int start, unsigned int end)
 {
   /* We treat NBSP/dotted-circle as if they are consonants, so we should just chain.
@@ -501,8 +510,10 @@ initial_reordering_standalone_cluster (const hb_ot_map_t *map, hb_buffer_t *buff
 }
 
 static void
-initial_reordering_non_indic (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array,
-		 unsigned int start, unsigned int end)
+initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
+			      hb_buffer_t *buffer HB_UNUSED,
+			      hb_mask_t *mask_array HB_UNUSED,
+			      unsigned int start, unsigned int end)
 {
   /* Nothing to do right now.  If we ever switch to using the output
    * buffer in the reordering process, we'd need to next_glyph() here. */
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index 1416a0d..d93d4c6 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -37,7 +37,8 @@
  */
 
 void
-_hb_ot_shape_complex_collect_features_default (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+_hb_ot_shape_complex_collect_features_default (hb_ot_map_builder_t *map HB_UNUSED,
+					       const hb_segment_properties_t *props HB_UNUSED)
 {
 }
 
@@ -48,7 +49,9 @@ _hb_ot_shape_complex_normalization_preference_default (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
+_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map HB_UNUSED,
+					  hb_buffer_t *buffer HB_UNUSED,
+					  hb_font_t *font HB_UNUSED)
 {
 }
 
@@ -64,7 +67,8 @@ static const hb_tag_t hangul_features[] =
 };
 
 void
-_hb_ot_shape_complex_collect_features_hangul (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+_hb_ot_shape_complex_collect_features_hangul (hb_ot_map_builder_t *map,
+					      const hb_segment_properties_t *props HB_UNUSED)
 {
   for (unsigned int i = 0; i < ARRAY_LENGTH (hangul_features); i++)
     map->add_bool_feature (hangul_features[i]);
@@ -77,7 +81,9 @@ _hb_ot_shape_complex_normalization_preference_hangul (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
+_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map HB_UNUSED,
+					 hb_buffer_t *buffer HB_UNUSED,
+					 hb_font_t *font HB_UNUSED)
 {
 }
 
@@ -86,7 +92,8 @@ _hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer,
 /* Thai / Lao shaper */
 
 void
-_hb_ot_shape_complex_collect_features_thai (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props)
+_hb_ot_shape_complex_collect_features_thai (hb_ot_map_builder_t *map HB_UNUSED,
+					    const hb_segment_properties_t *props HB_UNUSED)
 {
 }
 
@@ -97,7 +104,9 @@ _hb_ot_shape_complex_normalization_preference_thai (void)
 }
 
 void
-_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
+_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED,
+				       hb_buffer_t *buffer,
+				       hb_font_t *font HB_UNUSED)
 {
   /* The following is NOT specified in the MS OT Thai spec, however, it seems
    * to be what Uniscribe and other engines implement.  According to Eric Muller:
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index e237800..a9019fb 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -69,8 +69,7 @@
  */
 
 static void
-output_glyph (hb_font_t *font, hb_buffer_t *buffer,
-	      hb_codepoint_t glyph)
+output_glyph (hb_buffer_t *buffer, hb_codepoint_t glyph)
 {
   buffer->output_glyph (glyph);
   _hb_glyph_info_set_unicode_props (&buffer->prev(), buffer->unicode);
@@ -90,22 +89,22 @@ decompose (hb_font_t *font, hb_buffer_t *buffer,
   bool has_a = hb_font_get_glyph (font, a, 0, &glyph);
   if (shortest && has_a) {
     /* Output a and b */
-    output_glyph (font, buffer, a);
+    output_glyph (buffer, a);
     if (b)
-      output_glyph (font, buffer, b);
+      output_glyph (buffer, b);
     return TRUE;
   }
 
   if (decompose (font, buffer, shortest, a)) {
     if (b)
-      output_glyph (font, buffer, b);
+      output_glyph (buffer, b);
     return TRUE;
   }
 
   if (has_a) {
-    output_glyph (font, buffer, a);
+    output_glyph (buffer, a);
     if (b)
-      output_glyph (font, buffer, b);
+      output_glyph (buffer, b);
     return TRUE;
   }
 
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 0a0bc61..9d013a1 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -91,7 +91,7 @@ hb_set_get_user_data (hb_set_t        *set,
 
 
 hb_bool_t
-hb_set_allocation_successful (hb_set_t  *set)
+hb_set_allocation_successful (hb_set_t  *set HB_UNUSED)
 {
   return TRUE;
 }
commit d993e72331c6c4c783b803e01e4d4a02c8e3eb77
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:04:36 2012 +0200

    Fix hb_face_set_index()

diff --git a/src/hb-font.cc b/src/hb-font.cc
index d549455..9800ea7 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -729,7 +729,7 @@ hb_face_set_index (hb_face_t    *face,
   if (hb_object_is_inert (face))
     return;
 
-  face->index = 0;
+  face->index = index;
 }
 
 unsigned int
commit 93345edcbea49bdf0e22f26b5b74a23e601dfab4
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 16:01:08 2012 +0200

    Fix warnings

diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc
index 6822d2e..20ea43e 100644
--- a/src/hb-fallback-shape.cc
+++ b/src/hb-fallback-shape.cc
@@ -31,8 +31,8 @@
 hb_bool_t
 _hb_fallback_shape (hb_font_t          *font,
 		    hb_buffer_t        *buffer,
-		    const hb_feature_t *features,
-		    unsigned int        num_features)
+		    const hb_feature_t *features HB_UNUSED,
+		    unsigned int        num_features HB_UNUSED)
 {
   buffer->guess_properties ();
 
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 0423dd4..aa86072 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -548,14 +548,14 @@ _hb_debug_msg_va (const char *what,
   fprintf (stderr, "\n");
 }
 template <> inline void
-_hb_debug_msg_va<0> (const char *what,
-		     const void *obj,
-		     const char *func,
-		     bool indented,
-		     unsigned int level,
-		     int level_dir,
-		     const char *message,
-		     va_list ap) {}
+_hb_debug_msg_va<0> (const char *what HB_UNUSED,
+		     const void *obj HB_UNUSED,
+		     const char *func HB_UNUSED,
+		     bool indented HB_UNUSED,
+		     unsigned int level HB_UNUSED,
+		     int level_dir HB_UNUSED,
+		     const char *message HB_UNUSED,
+		     va_list ap HB_UNUSED) {}
 
 template <int max_level> inline void
 _hb_debug_msg (const char *what,
@@ -582,22 +582,22 @@ _hb_debug_msg (const char *what,
   va_end (ap);
 }
 template <> inline void
-_hb_debug_msg<0> (const char *what,
-		  const void *obj,
-		  const char *func,
-		  bool indented,
-		  unsigned int level,
-		  int level_dir,
-		  const char *message,
+_hb_debug_msg<0> (const char *what HB_UNUSED,
+		  const void *obj HB_UNUSED,
+		  const char *func HB_UNUSED,
+		  bool indented HB_UNUSED,
+		  unsigned int level HB_UNUSED,
+		  int level_dir HB_UNUSED,
+		  const char *message HB_UNUSED,
 		  ...) HB_PRINTF_FUNC(7, 8);
 template <> inline void
-_hb_debug_msg<0> (const char *what,
-		  const void *obj,
-		  const char *func,
-		  bool indented,
-		  unsigned int level,
-		  int level_dir,
-		  const char *message,
+_hb_debug_msg<0> (const char *what HB_UNUSED,
+		  const void *obj HB_UNUSED,
+		  const char *func HB_UNUSED,
+		  bool indented HB_UNUSED,
+		  unsigned int level HB_UNUSED,
+		  int level_dir HB_UNUSED,
+		  const char *message HB_UNUSED,
 		  ...) {}
 
 #define DEBUG_MSG_LEVEL(WHAT, OBJ, LEVEL, LEVEL_DIR, ...)	_hb_debug_msg<HB_DEBUG_##WHAT> (#WHAT, (OBJ), NULL,    TRUE, (LEVEL), (LEVEL_DIR), __VA_ARGS__)
@@ -658,11 +658,11 @@ struct hb_auto_trace_t {
 };
 template <> /* Optimize when tracing is disabled */
 struct hb_auto_trace_t<0> {
-  explicit inline hb_auto_trace_t (unsigned int *plevel_,
-				   const char *what,
-				   const void *obj,
-				   const char *func,
-				   const char *message,
+  explicit inline hb_auto_trace_t (unsigned int *plevel_ HB_UNUSED,
+				   const char *what HB_UNUSED,
+				   const void *obj HB_UNUSED,
+				   const char *func HB_UNUSED,
+				   const char *message HB_UNUSED,
 				   ...) {}
 
   template <typename T>
commit eace47b173807d94b29a6490d0bc3c9f8f6168d1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 15:54:43 2012 +0200

    Minor

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 81cfd15..e4273c9 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -776,7 +776,7 @@ final_reordering_syllable (hb_buffer_t *buffer, hb_mask_t *mask_array,
   /* Apply 'init' to the Left Matra if it's a word start. */
   if (info[start].indic_position () == POS_PRE_M &&
       (!start ||
-       !(FLAG (_hb_glyph_info_get_general_category (&buffer->info[start - 1])) &
+       !(FLAG (_hb_glyph_info_get_general_category (&info[start - 1])) &
 	 (FLAG (HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) |
 	  FLAG (HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER) |
 	  FLAG (HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER) |
commit 99c2695759a6af855d565f4994bbdf220570bb48
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 15:45:18 2012 +0200

    Add accessort to buffer for current info, current pos, and prev info

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 6296608..e9e0f82 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -70,6 +70,15 @@ struct _hb_buffer_t {
   hb_glyph_info_t     *out_info;
   hb_glyph_position_t *pos;
 
+  inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; }
+  inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; }
+
+  inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; }
+  inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; }
+
+  inline hb_glyph_info_t &prev (void) { return out_info[out_len - 1]; }
+  inline hb_glyph_info_t prev (void) const { return info[out_len - 1]; }
+
   unsigned int serial;
   uint8_t allocated_var_bytes[8];
   const char *allocated_var_owner[8];
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index ecd06c4..71c13a2 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -403,10 +403,10 @@ struct MarkArray : ArrayOf<MarkRecord>	/* Array of MarkRecords--in Coverage orde
 
     hb_position_t mark_x, mark_y, base_x, base_y;
 
-    mark_anchor.get_anchor (c->font, c->buffer->info[c->buffer->idx].codepoint, &mark_x, &mark_y);
+    mark_anchor.get_anchor (c->font, c->buffer->cur().codepoint, &mark_x, &mark_y);
     glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y);
 
-    hb_glyph_position_t &o = c->buffer->pos[c->buffer->idx];
+    hb_glyph_position_t &o = c->buffer->cur_pos();
     o.x_offset = base_x - mark_x;
     o.y_offset = base_y - mark_y;
     o.attach_lookback() = c->buffer->idx - glyph_pos;
@@ -432,11 +432,11 @@ struct SinglePosFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     valueFormat.apply_value (c->font, c->direction, this,
-			     values, c->buffer->pos[c->buffer->idx]);
+			     values, c->buffer->cur_pos());
 
     c->buffer->idx++;
     return TRACE_RETURN (true);
@@ -469,14 +469,14 @@ struct SinglePosFormat2
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     if (likely (index >= valueCount)) return TRACE_RETURN (false);
 
     valueFormat.apply_value (c->font, c->direction, this,
 			     &values[index * valueFormat.get_len ()],
-			     c->buffer->pos[c->buffer->idx]);
+			     c->buffer->cur_pos());
 
     c->buffer->idx++;
     return TRACE_RETURN (true);
@@ -569,7 +569,7 @@ struct PairSet
       if (c->buffer->info[pos].codepoint == record->secondGlyph)
       {
 	valueFormats[0].apply_value (c->font, c->direction, this,
-				     &record->values[0], c->buffer->pos[c->buffer->idx]);
+				     &record->values[0], c->buffer->cur_pos());
 	valueFormats[1].apply_value (c->font, c->direction, this,
 				     &record->values[len1], c->buffer->pos[pos]);
 	if (len2)
@@ -620,7 +620,7 @@ struct PairPosFormat1
     hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
     if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -672,7 +672,7 @@ struct PairPosFormat2
     hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
     if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -681,13 +681,13 @@ struct PairPosFormat2
     unsigned int len2 = valueFormat2.get_len ();
     unsigned int record_len = len1 + len2;
 
-    unsigned int klass1 = (this+classDef1) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int klass1 = (this+classDef1) (c->buffer->cur().codepoint);
     unsigned int klass2 = (this+classDef2) (c->buffer->info[skippy_iter.idx].codepoint);
     if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return TRACE_RETURN (false);
 
     const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
     valueFormat1.apply_value (c->font, c->direction, this,
-			      v, c->buffer->pos[c->buffer->idx]);
+			      v, c->buffer->cur_pos());
     valueFormat2.apply_value (c->font, c->direction, this,
 			      v + len1, c->buffer->pos[skippy_iter.idx]);
 
@@ -816,7 +816,7 @@ struct CursivePosFormat1
     hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
     if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
 
-    const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->info[c->buffer->idx].codepoint)];
+    const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->cur().codepoint)];
     if (!this_record.exitAnchor) return TRACE_RETURN (false);
 
     if (!skippy_iter.next ()) return TRACE_RETURN (false);
@@ -949,7 +949,7 @@ struct MarkBasePosFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
     if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
 
     /* now we search backwards for a non-mark glyph */
@@ -1040,7 +1040,7 @@ struct MarkLigPosFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
     if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
 
     /* now we search backwards for a non-mark glyph */
@@ -1068,10 +1068,10 @@ struct MarkLigPosFormat1
      * can directly use the component index.  If not, we attach the mark
      * glyph to the last component of the ligature. */
     if (get_lig_id (c->buffer->info[j]) &&
-	get_lig_id (c->buffer->info[j]) == get_lig_id (c->buffer->info[c->buffer->idx]) &&
-	get_lig_comp (c->buffer->info[c->buffer->idx]) > 0)
+	get_lig_id (c->buffer->cur()) &&
+	get_lig_comp (c->buffer->cur()) > 0)
     {
-      comp_index = get_lig_comp (c->buffer->info[c->buffer->idx]) - 1;
+      comp_index = get_lig_comp (c->buffer->cur()) - 1;
       if (comp_index >= comp_count)
 	comp_index = comp_count - 1;
     }
@@ -1151,7 +1151,7 @@ struct MarkMarkPosFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    unsigned int mark1_index = (this+mark1Coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int mark1_index = (this+mark1Coverage) (c->buffer->cur().codepoint);
     if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
 
     /* now we search backwards for a suitable mark glyph until a non-mark glyph */
@@ -1166,9 +1166,9 @@ struct MarkMarkPosFormat1
     /* Two marks match only if they belong to the same base, or same component
      * of the same ligature.  That is, the component numbers must match, and
      * if those are non-zero, the ligid number should also match. */
-    if ((get_lig_comp (c->buffer->info[j]) != get_lig_comp (c->buffer->info[c->buffer->idx])) ||
+    if ((get_lig_comp (c->buffer->cur())) ||
 	(get_lig_comp (c->buffer->info[j]) > 0 &&
-	 get_lig_id (c->buffer->info[j]) != get_lig_id (c->buffer->info[c->buffer->idx])))
+	 get_lig_id (c->buffer->cur())))
       return TRACE_RETURN (false);
 
     unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
@@ -1363,7 +1363,7 @@ struct PosLookup : Lookup
   {
     unsigned int lookup_type = get_type ();
 
-    if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
+    if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->cur(), c->lookup_props, &c->property))
       return false;
 
     for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1385,7 +1385,7 @@ struct PosLookup : Lookup
     c->buffer->idx = 0;
     while (c->buffer->idx < c->buffer->len)
     {
-      if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
+      if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
 	ret = true;
       else
 	c->buffer->idx++;
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 8c57f60..2b19fc8 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -58,7 +58,7 @@ struct SingleSubstFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
+    hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
     unsigned int index = (this+coverage) (glyph_id);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
@@ -110,7 +110,7 @@ struct SingleSubstFormat2
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
+    hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
     unsigned int index = (this+coverage) (glyph_id);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
@@ -257,7 +257,7 @@ struct MultipleSubstFormat1
   {
     TRACE_APPLY ();
 
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     return TRACE_RETURN ((this+sequence[index]).apply (c));
@@ -360,7 +360,7 @@ struct AlternateSubstFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
+    hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
 
     unsigned int index = (this+coverage) (glyph_id);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@@ -369,7 +369,7 @@ struct AlternateSubstFormat1
 
     if (unlikely (!alt_set.len)) return TRACE_RETURN (false);
 
-    hb_mask_t glyph_mask = c->buffer->info[c->buffer->idx].mask;
+    hb_mask_t glyph_mask = c->buffer->cur().mask;
     hb_mask_t lookup_mask = c->lookup_mask;
 
     /* Note: This breaks badly if two features enabled this lookup together. */
@@ -500,7 +500,7 @@ struct Ligature
 
     /* Allocate new ligature id */
     unsigned int lig_id = allocate_lig_id (c->buffer);
-    set_lig_props (c->buffer->info[c->buffer->idx], lig_id, 0);
+    set_lig_props (c->buffer->cur(), lig_id, 0);
 
     if (skippy_iter.idx < c->buffer->idx + count) /* No input glyphs skipped */
     {
@@ -521,8 +521,8 @@ struct Ligature
       {
 	while (c->should_mark_skip_current_glyph ())
 	{
-	  set_lig_props (c->buffer->info[c->buffer->idx],  lig_id, i);
-	  c->replace_glyph (c->buffer->info[c->buffer->idx].codepoint);
+	  set_lig_props (c->buffer->cur(),  lig_id, i);
+	  c->replace_glyph (c->buffer->cur().codepoint);
 	}
 
 	/* Skip the base glyph */
@@ -628,7 +628,7 @@ struct LigatureSubstFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
+    hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
 
     unsigned int index = (this+coverage) (glyph_id);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@@ -807,7 +807,7 @@ struct ReverseChainSingleSubstFormat1
     if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL))
       return TRACE_RETURN (false); /* No chaining to this type */
 
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@@ -821,7 +821,7 @@ struct ReverseChainSingleSubstFormat1
 			 match_coverage, this,
 			 1))
     {
-      c->buffer->info[c->buffer->idx].codepoint = substitute[index];
+      c->buffer->cur().codepoint = substitute[index];
       c->buffer->idx--; /* Reverse! */
       return TRACE_RETURN (true);
     }
@@ -1055,7 +1055,7 @@ struct SubstLookup : Lookup
   {
     unsigned int lookup_type = get_type ();
 
-    if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
+    if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->cur(), c->lookup_props, &c->property))
       return false;
 
     if (unlikely (lookup_type == SubstLookupSubTable::Extension))
@@ -1096,7 +1096,7 @@ struct SubstLookup : Lookup
 	c->buffer->idx = 0;
 	while (c->buffer->idx < c->buffer->len)
 	{
-	  if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
+	  if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
 	    ret = true;
 	  else
 	    c->buffer->next_glyph ();
@@ -1111,7 +1111,7 @@ struct SubstLookup : Lookup
 	c->buffer->idx = c->buffer->len - 1;
 	do
 	{
-	  if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
+	  if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
 	    ret = true;
 	  else
 	    c->buffer->idx--;
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 1a92d28..919360f 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -95,7 +95,7 @@ struct hb_closure_context_t
 #endif
 
 #define TRACE_APPLY() \
-	hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->info[c->buffer->idx].codepoint);
+	hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->cur().codepoint);
 
 
 
@@ -137,7 +137,7 @@ struct hb_apply_context_t
       idx = start_index_;
       num_items = num_items_;
       mask = context_match ? -1 : c->lookup_mask;
-      syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable ();
+      syllable = context_match ? 0 : c->buffer->cur().syllable ();
       end = c->buffer->len;
     }
     inline bool has_no_chance (void) const
@@ -183,7 +183,7 @@ struct hb_apply_context_t
       idx = start_index_;
       num_items = num_items_;
       mask = mask_ ? mask_ : c->lookup_mask;
-      syllable = match_syllable_ ? c->buffer->info[c->buffer->idx].syllable () : 0;
+      syllable = match_syllable_ ? c->buffer->cur().syllable () : 0;
     }
     inline bool has_no_chance (void) const
     {
@@ -217,7 +217,7 @@ struct hb_apply_context_t
 
   inline bool should_mark_skip_current_glyph (void) const
   {
-    return _hb_ot_layout_skip_mark (face, &buffer->info[buffer->idx], lookup_props, NULL);
+    return _hb_ot_layout_skip_mark (face, &buffer->cur(), lookup_props, NULL);
   }
 
 
@@ -238,14 +238,14 @@ struct hb_apply_context_t
   inline void guess_glyph_class (unsigned int klass)
   {
     /* XXX if ! has gdef */
-    buffer->info[buffer->idx].props_cache() = klass;
+    buffer->cur().props_cache() = klass;
   }
 
   private:
   inline void clear_property (void) const
   {
     /* XXX if has gdef */
-    buffer->info[buffer->idx].props_cache() = 0;
+    buffer->cur().props_cache() = 0;
   }
 };
 
@@ -625,7 +625,7 @@ struct ContextFormat1
   inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED))
       return TRACE_RETURN (false);
 
@@ -685,11 +685,11 @@ struct ContextFormat2
   inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const ClassDef &class_def = this+classDef;
-    index = class_def (c->buffer->info[c->buffer->idx].codepoint);
+    index = class_def (c->buffer->cur().codepoint);
     const RuleSet &rule_set = this+ruleSet[index];
     struct ContextApplyLookupContext lookup_context = {
       {match_class, apply_func},
@@ -745,7 +745,7 @@ struct ContextFormat3
   inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage[0]) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage[0]) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
@@ -1020,7 +1020,7 @@ struct ChainContextFormat1
   inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const ChainRuleSet &rule_set = this+ruleSet[index];
@@ -1082,14 +1082,14 @@ struct ChainContextFormat2
   inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
   {
     TRACE_APPLY ();
-    unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const ClassDef &backtrack_class_def = this+backtrackClassDef;
     const ClassDef &input_class_def = this+inputClassDef;
     const ClassDef &lookahead_class_def = this+lookaheadClassDef;
 
-    index = input_class_def (c->buffer->info[c->buffer->idx].codepoint);
+    index = input_class_def (c->buffer->cur().codepoint);
     const ChainRuleSet &rule_set = this+ruleSet[index];
     struct ChainContextApplyLookupContext lookup_context = {
       {match_class, apply_func},
@@ -1164,7 +1164,7 @@ struct ChainContextFormat3
     TRACE_APPLY ();
     const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
 
-    unsigned int index = (this+input[0]) (c->buffer->info[c->buffer->idx].codepoint);
+    unsigned int index = (this+input[0]) (c->buffer->cur().codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
 
     const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index ac7457e..8a590bb 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -222,8 +222,8 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
   /* Mandatory ligatures */
   buffer->clear_output ();
   for (buffer->idx = 0; buffer->idx + 1 < count;) {
-    hb_codepoint_t ligature = get_ligature (buffer->info[buffer->idx].codepoint,
-					    buffer->info[buffer->idx + 1].codepoint);
+    hb_codepoint_t ligature = get_ligature (buffer->cur().codepoint,
+					    buffer->cur(+1).codepoint);
     if (likely (!ligature) || !(hb_font_get_glyph (font, ligature, 0, &glyph))) {
       buffer->next_glyph ();
       continue;
diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc
index c95749a..1416a0d 100644
--- a/src/hb-ot-shape-complex-misc.cc
+++ b/src/hb-ot-shape-complex-misc.cc
@@ -141,7 +141,7 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb
   unsigned int count = buffer->len;
   for (buffer->idx = 0; buffer->idx < count;)
   {
-    hb_codepoint_t u = buffer->info[buffer->idx].codepoint;
+    hb_codepoint_t u = buffer->cur().codepoint;
     if (likely (!IS_SARA_AM (u))) {
       buffer->next_glyph ();
       continue;
@@ -167,11 +167,12 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb
 	     sizeof (buffer->out_info[0]) * (end - start - 2));
     buffer->out_info[start] = t;
 
+    /* XXX Make this easier! */
     /* Make cluster */
     for (; start > 0 && buffer->out_info[start - 1].cluster == buffer->out_info[start].cluster; start--)
       ;
     for (; buffer->idx < count;)
-      if (buffer->info[buffer->idx].cluster == buffer->out_info[buffer->out_len - 1].cluster)
+      if (buffer->cur().cluster == buffer->prev().cluster)
         buffer->next_glyph ();
       else
         break;
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 4a378a8..e237800 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -73,7 +73,7 @@ output_glyph (hb_font_t *font, hb_buffer_t *buffer,
 	      hb_codepoint_t glyph)
 {
   buffer->output_glyph (glyph);
-  _hb_glyph_info_set_unicode_props (&buffer->out_info[buffer->out_len - 1], buffer->unicode);
+  _hb_glyph_info_set_unicode_props (&buffer->prev(), buffer->unicode);
 }
 
 static bool
@@ -116,7 +116,7 @@ static void
 decompose_current_glyph (hb_font_t *font, hb_buffer_t *buffer,
 			 bool shortest)
 {
-  if (decompose (font, buffer, shortest, buffer->info[buffer->idx].codepoint))
+  if (decompose (font, buffer, shortest, buffer->cur().codepoint))
     buffer->skip_glyph ();
   else
     buffer->next_glyph ();
@@ -129,7 +129,7 @@ decompose_single_char_cluster (hb_font_t *font, hb_buffer_t *buffer,
   hb_codepoint_t glyph;
 
   /* If recomposing and font supports this, we're good to go */
-  if (will_recompose && hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph)) {
+  if (will_recompose && hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph)) {
     buffer->next_glyph ();
     return;
   }
@@ -185,7 +185,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
   {
     unsigned int end;
     for (end = buffer->idx + 1; end < count; end++)
-      if (buffer->info[buffer->idx].cluster != buffer->info[end].cluster)
+      if (buffer->cur().cluster != buffer->info[end].cluster)
         break;
 
     if (buffer->idx + 1 == end)
@@ -247,15 +247,15 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
     if (/* If mode is NOT COMPOSED_FULL (ie. it's COMPOSED_DIACRITICS), we don't try to
 	 * compose a CCC=0 character with it's preceding starter. */
 	(mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL ||
-	 _hb_glyph_info_get_modified_combining_class (&buffer->info[buffer->idx]) != 0) &&
+	 _hb_glyph_info_get_modified_combining_class (&buffer->cur()) != 0) &&
 	/* If there's anything between the starter and this char, they should have CCC
 	 * smaller than this character's. */
 	(starter == buffer->out_len - 1 ||
-	 _hb_glyph_info_get_modified_combining_class (&buffer->out_info[buffer->out_len - 1]) < _hb_glyph_info_get_modified_combining_class (&buffer->info[buffer->idx])) &&
+	 _hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
 	/* And compose. */
 	hb_unicode_compose (buffer->unicode,
 			    buffer->out_info[starter].codepoint,
-			    buffer->info[buffer->idx].codepoint,
+			    buffer->cur().codepoint,
 			    &composed) &&
 	/* And the font has glyph for the composite. */
 	hb_font_get_glyph (font, composed, 0, &glyph))
@@ -272,7 +272,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
     /* Blocked, or doesn't compose. */
     buffer->next_glyph ();
 
-    if (_hb_glyph_info_get_modified_combining_class (&buffer->out_info[buffer->out_len - 1]) == 0)
+    if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0)
       starter = buffer->out_len - 1;
   }
   buffer->swap_buffers ();
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index dbfcf18..8b1d670 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -244,16 +244,16 @@ hb_map_glyphs (hb_font_t    *font,
 
   unsigned int count = buffer->len - 1;
   for (buffer->idx = 0; buffer->idx < count;) {
-    if (unlikely (_hb_unicode_is_variation_selector (buffer->info[buffer->idx + 1].codepoint))) {
-      hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, buffer->info[buffer->idx + 1].codepoint, &glyph);
+    if (unlikely (_hb_unicode_is_variation_selector (buffer->cur(+1).codepoint))) {
+      hb_font_get_glyph (font, buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
       buffer->replace_glyphs (2, 1, &glyph);
     } else {
-      hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph);
+      hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
       buffer->replace_glyph (glyph);
     }
   }
   if (likely (buffer->idx < buffer->len)) {
-    hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph);
+    hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
     buffer->replace_glyph (glyph);
   }
   buffer->swap_buffers ();
commit 6736f3c5b09af6a71935afc04248b033e171a9b2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 15:21:06 2012 +0200

    Minor

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 2e8b92a..1a92d28 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -115,12 +115,11 @@ struct hb_apply_context_t
   hb_apply_context_t (hb_font_t *font_,
 		      hb_face_t *face_,
 		      hb_buffer_t *buffer_,
-		      hb_mask_t lookup_mask_,
-		      unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
+		      hb_mask_t lookup_mask_) :
 			font (font_), face (face_), buffer (buffer_),
 			direction (buffer_->props.direction),
 			lookup_mask (lookup_mask_),
-			nesting_level_left (nesting_level_left_),
+			nesting_level_left (MAX_NESTING_LEVEL),
 			lookup_props (0), property (0), debug_depth (0) {}
 
   void set_lookup (const Lookup &l) {
@@ -178,7 +177,7 @@ struct hb_apply_context_t
 					      unsigned int start_index_,
 					      unsigned int num_items_,
 					      hb_mask_t mask_ = 0,
-					     bool match_syllable_ = true)
+					      bool match_syllable_ = true)
     {
       c = c_;
       idx = start_index_;
commit 5df809b655bb1318115651fd87d4555cdd9b41cb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 15:17:51 2012 +0200

    [GSUB/GPOS] Remove context_length
    
    The spec doesn't say contextual matching should be done this way,
    and AOTS doesn't do it either.  It was inherited from old HarfBuzz.
    Remove it.

diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 2051000..6ea28bc 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -34,7 +34,6 @@
 #include "hb-set-private.hh"
 
 
-#define NO_CONTEXT		((unsigned int) 0x110000)
 #define NOT_COVERED		((unsigned int) 0x110000)
 #define MAX_NESTING_LEVEL	8
 
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 44ec65f..ecd06c4 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1532,9 +1532,6 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i
   if (unlikely (c->nesting_level_left == 0))
     return false;
 
-  if (unlikely (c->context_length < 1))
-    return false;
-
   hb_apply_context_t new_c (*c);
   new_c.nesting_level_left--;
   new_c.set_lookup (l);
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index bc2b0e1..8c57f60 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -804,7 +804,8 @@ struct ReverseChainSingleSubstFormat1
   inline bool apply (hb_apply_context_t *c) const
   {
     TRACE_APPLY ();
-    if (unlikely (c->context_length != NO_CONTEXT)) return TRACE_RETURN (false); /* No chaining to this type */
+    if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL))
+      return TRACE_RETURN (false); /* No chaining to this type */
 
     unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
     if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@@ -1243,9 +1244,6 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup
   if (unlikely (c->nesting_level_left == 0))
     return false;
 
-  if (unlikely (c->context_length < 1))
-    return false;
-
   hb_apply_context_t new_c (*c);
   new_c.nesting_level_left--;
   new_c.set_lookup (l);
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index a000c15..2e8b92a 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -106,7 +106,6 @@ struct hb_apply_context_t
   hb_buffer_t *buffer;
   hb_direction_t direction;
   hb_mask_t lookup_mask;
-  unsigned int context_length;
   unsigned int nesting_level_left;
   unsigned int lookup_props;
   unsigned int property; /* propety of first glyph */
@@ -117,12 +116,10 @@ struct hb_apply_context_t
 		      hb_face_t *face_,
 		      hb_buffer_t *buffer_,
 		      hb_mask_t lookup_mask_,
-		      unsigned int context_length_ = NO_CONTEXT,
 		      unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
 			font (font_), face (face_), buffer (buffer_),
 			direction (buffer_->props.direction),
 			lookup_mask (lookup_mask_),
-			context_length (context_length_),
 			nesting_level_left (nesting_level_left_),
 			lookup_props (0), property (0), debug_depth (0) {}
 
@@ -142,7 +139,7 @@ struct hb_apply_context_t
       num_items = num_items_;
       mask = context_match ? -1 : c->lookup_mask;
       syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable ();
-      end = MIN (c->buffer->len, c->buffer->idx + c->context_length);
+      end = c->buffer->len;
     }
     inline bool has_no_chance (void) const
     {
@@ -320,7 +317,7 @@ static inline bool match_input (hb_apply_context_t *c,
 				const USHORT input[], /* Array of input values--start with second glyph */
 				match_func_t match_func,
 				const void *match_data,
-				unsigned int *context_length_out)
+				unsigned int *end_offset = NULL)
 {
   hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
   if (skippy_iter.has_no_chance ())
@@ -335,7 +332,8 @@ static inline bool match_input (hb_apply_context_t *c,
       return false;
   }
 
-  *context_length_out = skippy_iter.idx - c->buffer->idx + 1;
+  if (end_offset)
+    *end_offset = skippy_iter.idx - c->buffer->idx + 1;
 
   return true;
 }
@@ -418,7 +416,7 @@ static inline bool apply_lookup (hb_apply_context_t *c,
 				 const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
 				 apply_lookup_func_t apply_func)
 {
-  unsigned int end = MIN (c->buffer->len, c->buffer->idx + c->context_length);
+  unsigned int end = c->buffer->len;
   if (unlikely (count == 0 || c->buffer->idx + count > end))
     return false;
 
@@ -509,12 +507,10 @@ static inline bool context_apply_lookup (hb_apply_context_t *c,
 					 const LookupRecord lookupRecord[],
 					 ContextApplyLookupContext &lookup_context)
 {
-  hb_apply_context_t new_context = *c;
   return match_input (c,
 		      inputCount, input,
-		      lookup_context.funcs.match, lookup_context.match_data,
-		      &new_context.context_length)
-      && apply_lookup (&new_context,
+		      lookup_context.funcs.match, lookup_context.match_data)
+      && apply_lookup (c,
 		       inputCount,
 		       lookupCount, lookupRecord,
 		       lookup_context.funcs.apply);
@@ -883,25 +879,19 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c,
 					       const LookupRecord lookupRecord[],
 					       ChainContextApplyLookupContext &lookup_context)
 {
-  /* First guess */
-  if (unlikely (c->buffer->backtrack_len () < backtrackCount ||
-		c->buffer->idx + inputCount + lookaheadCount > c->buffer->len ||
-		inputCount + lookaheadCount > c->context_length))
-    return false;
-
-  hb_apply_context_t new_context = *c;
+  unsigned int lookahead_offset;
   return match_backtrack (c,
 			  backtrackCount, backtrack,
 			  lookup_context.funcs.match, lookup_context.match_data[0])
       && match_input (c,
 		      inputCount, input,
 		      lookup_context.funcs.match, lookup_context.match_data[1],
-		      &new_context.context_length)
+		      &lookahead_offset)
       && match_lookahead (c,
 			  lookaheadCount, lookahead,
 			  lookup_context.funcs.match, lookup_context.match_data[2],
-			  new_context.context_length)
-      && apply_lookup (&new_context,
+			  lookahead_offset)
+      && apply_lookup (c,
 		       inputCount,
 		       lookupCount, lookupRecord,
 		       lookup_context.funcs.apply);
commit 28b9d502bb69a8045818d5f6113ded9c59a56bd7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 15:04:00 2012 +0200

    Minor

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 96e6ddb..a000c15 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -135,14 +135,13 @@ struct hb_apply_context_t
     inline mark_skipping_forward_iterator_t (hb_apply_context_t *c_,
 					     unsigned int start_index_,
 					     unsigned int num_items_,
-					     hb_mask_t mask_ = 0,
-					     bool match_syllable_ = true)
+					     bool context_match = false)
     {
       c = c_;
       idx = start_index_;
       num_items = num_items_;
-      mask = mask_ ? mask_ : c->lookup_mask;
-      syllable = match_syllable_ ? c->buffer->info[c->buffer->idx].syllable () : 0;
+      mask = context_match ? -1 : c->lookup_mask;
+      syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable ();
       end = MIN (c->buffer->len, c->buffer->idx + c->context_length);
     }
     inline bool has_no_chance (void) const
@@ -347,7 +346,7 @@ static inline bool match_backtrack (hb_apply_context_t *c,
 				    match_func_t match_func,
 				    const void *match_data)
 {
-  hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, (hb_mask_t) -1, false);
+  hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->backtrack_len (), count, true);
   if (skippy_iter.has_no_chance ())
     return false;
 
@@ -370,7 +369,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
 				    const void *match_data,
 				    unsigned int offset)
 {
-  hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, (hb_mask_t) -1, false);
+  hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx + offset - 1, count, true);
   if (skippy_iter.has_no_chance ())
     return false;
 
commit 50f630c17ced1bd59b4da4f27728dcfbb876400a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 13:03:44 2012 +0200

    Remove ioctl checks
    
    Ended up not using terminal size after all.

diff --git a/configure.ac b/configure.ac
index 6c5959a..853d083 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,7 @@ dnl GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
 
 # Functions and headers
 AC_CHECK_FUNCS(mprotect sysconf getpagesize mmap _setmode isatty)
-AC_CHECK_HEADERS(unistd.h sys/mman.h io.h sys/ioctl.h)
+AC_CHECK_HEADERS(unistd.h sys/mman.h io.h)
 
 # Compiler flags
 AC_CANONICAL_HOST
diff --git a/util/ansi-print.cc b/util/ansi-print.cc
index 3e418cf..1451819 100644
--- a/util/ansi-print.cc
+++ b/util/ansi-print.cc
@@ -40,9 +40,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h> /* for isatty() */
 #endif
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 
@@ -377,14 +374,6 @@ ansi_print_image_rgb24 (const uint32_t *data,
 			unsigned int height,
 			unsigned int stride)
 {
-  /* Get screen size */
-   struct winsize w;
-   if (ioctl(1, TIOCGWINSZ, &w)) /* Ought to be stdout, right? */
-   {
-     w.ws_row = 25;
-     w.ws_col = 80;
-   }
-
   image_t image (width, height, data, stride);
 
   unsigned int rows = (height + CELL_H - 1) / CELL_H;
commit db0de7cd616e1e9d6fde6659e52a541477fb0148
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 13:02:38 2012 +0200

    [util] Set ansi color only on color change

diff --git a/util/ansi-print.cc b/util/ansi-print.cc
index 0ad9a7d..3e418cf 100644
--- a/util/ansi-print.cc
+++ b/util/ansi-print.cc
@@ -45,7 +45,6 @@
 #endif
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 #define CELL_W 8
 #define CELL_H (2 * CELL_W)
@@ -392,20 +391,39 @@ ansi_print_image_rgb24 (const uint32_t *data,
   unsigned int cols = (width + CELL_W - 1) / CELL_W;
   image_t cell (CELL_W, CELL_H);
   biimage_t bi (CELL_W, CELL_H);
+  unsigned int last_bg = -1, last_fg = -1;
   for (unsigned int row = 0; row < rows; row++) {
     for (unsigned int col = 0; col < cols; col++) {
       image.copy_sub_image (cell, col * CELL_W, row * CELL_H, CELL_W, CELL_H);
       bi.set (cell);
-      if (bi.unicolor)
-	printf ("\e[%dm ", 40 + bi.bg);
-      else {
+      if (bi.unicolor) {
+        if (last_bg != bi.bg) {
+	  printf ("\e[%dm", 40 + bi.bg);
+	  last_bg = bi.bg;
+	}
+	printf (" ");
+      } else {
         /* Figure out the closest character to the biimage */
         unsigned int score = (unsigned int) -1;
 	bool inverse;
         const char *c = block_best (bi, &score, &inverse);
-	printf ("\e[%d;%dm%s", (inverse ? 30 : 40) + bi.bg, (inverse ? 40 : 30) + bi.fg, c);
+	if (inverse) {
+	  if (last_bg != bi.fg || last_fg != bi.bg) {
+	    printf ("\e[%d;%dm", 30 + bi.bg, 40 + bi.fg);
+	    last_bg = bi.fg;
+	    last_fg = bi.bg;
+	  }
+	} else {
+	  if (last_bg != bi.bg || last_fg != bi.fg) {
+	    printf ("\e[%d;%dm", 40 + bi.bg, 30 + bi.fg);
+	    last_bg = bi.bg;
+	    last_fg = bi.fg;
+	  }
+	}
+	printf ("%s", c);
       }
     }
     printf ("\e[0m\n"); /* Reset */
+    last_bg = last_fg = -1;
   }
 }
commit 912c5ff80a255edb8145b9db69e2ed828f8eab5c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 13 12:51:02 2012 +0200

    Reduce default margin

diff --git a/util/options.hh b/util/options.hh
index 6b2b226..dec165b 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -105,7 +105,7 @@ struct option_parser_t
 };
 
 
-#define DEFAULT_MARGIN 64
+#define DEFAULT_MARGIN 16
 #define DEFAULT_FORE "#000000"
 #define DEFAULT_BACK "#FFFFFF"
 #define DEFAULT_FONT_SIZE 256



More information about the HarfBuzz mailing list