From: handa Date: Fri, 13 Nov 2009 13:12:00 +0000 (+0000) Subject: (match_ids_backward): New function. X-Git-Tag: REL-0-9-11~42 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e0fa2bf25fc79591bf064ba67744da2398eac0e;p=m17n%2Flibotf.git (match_ids_backward): New function. (match_chain_ids): Call match_ids_backward for backward matching. --- 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;