Fix alternate, again
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 20 May 2010 16:47:28 +0000 (17:47 +0100)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 20 May 2010 16:47:28 +0000 (17:47 +0100)
src/hb-ot-layout-gsub-private.hh

index 4c1b168..d64c095 100644 (file)
@@ -287,12 +287,12 @@ struct AlternateSubstFormat1
       return false;
 
     unsigned int shift = _hb_ctz (lookup_mask);
-    unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift) - 1;
+    unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift);
 
-    if (unlikely (alt_index >= alt_set.len))
+    if (unlikely (alt_index > alt_set.len || alt_index == 0))
       return false;
 
-    glyph_id = alt_set[alt_index];
+    glyph_id = alt_set[alt_index - 1];
 
     c->buffer->replace_glyph (glyph_id);