(match_ids_backward): New function.
authorhanda <handa>
Fri, 13 Nov 2009 13:12:00 +0000 (13:12 +0000)
committerhanda <handa>
Fri, 13 Nov 2009 13:12:00 +0000 (13:12 +0000)
(match_chain_ids): Call match_ids_backward for backward matching.

src/otfdrive.c

index 4ae95b8..30081a0 100644 (file)
@@ -286,6 +286,21 @@ match_ids (OTF_GlyphString *gstring, int gidx, int flag,
 }
 
 static int
+match_ids_backward (OTF_GlyphString *gstring, int gidx, int flag,
+                   int count, OTF_GlyphID *ids)
+{
+  OTF_Glyph *gbeg = gstring->glyphs + gidx;
+  OTF_Glyph *gend = gstring->glyphs;
+  OTF_Glyph *g;
+  int i;
+
+  for (g = gbeg, i = 0; g >= gend && i < count; g--)
+    if (! IGNORED_GLYPH (g, flag) && g->glyph_id != ids[i++])
+      return -1;
+  return (i < count ? -1 : gbeg - g);
+}
+
+static int
 match_chain_ids (OTF_GlyphString *gstring, int gidx, int flag,
                 OTF_ChainRule *rule)
 {
@@ -301,7 +316,7 @@ match_chain_ids (OTF_GlyphString *gstring, int gidx, int flag,
          break;
       if (i > 0)
        return -1;
-      if (match_ids (gstring, j, flag,
+      if (match_ids_backward (gstring, j, flag,
                     rule->BacktrackGlyphCount, rule->Backtrack)
          < 0)
        return -1;