From 1e0fa2bf25fc79591bf064ba67744da2398eac0e Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 13 Nov 2009 13:12:00 +0000 Subject: [PATCH] (match_ids_backward): New function. (match_chain_ids): Call match_ids_backward for backward matching. --- src/otfdrive.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/otfdrive.c b/src/otfdrive.c index 4ae95b8..30081a0 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -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; -- 1.7.10.4