From b33aac5e1a4b762dab986756cbb5ba33a82ff228 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 20 Sep 2004 18:04:13 +0000 Subject: Fix various bugs, make more robust. (#151689) Mon Sep 20 13:57:35 2004 Owen Taylor * modules/indic/mprefixups.c (indic_mprefixups_apply): Fix various bugs, make more robust. (#151689) --- modules/indic/mprefixups.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/indic/mprefixups.c b/modules/indic/mprefixups.c index 85ced566..a3a3d018 100644 --- a/modules/indic/mprefixups.c +++ b/modules/indic/mprefixups.c @@ -66,7 +66,10 @@ void indic_mprefixups_apply(MPreFixups *mprefixups, PangoOTBuffer *buffer) for (fixup = 0; fixup < mprefixups->fFixupCount; fixup += 1) { glong baseIndex = mprefixups->fFixupData[fixup].fBaseIndex; glong mpreIndex = mprefixups->fFixupData[fixup].fMPreIndex; - glong mpreLimit, mpreCount, moveCount, mpreDest; + glong baseGlyph = -1; + glong mpreGlyph = -1; + glong mpreLimit = -1; + glong mpreCount, moveCount, mpreDest; glong i; PangoOTGlyph *glyphs; int n_glyphs; @@ -74,48 +77,35 @@ void indic_mprefixups_apply(MPreFixups *mprefixups, PangoOTBuffer *buffer) int *clusterSave; /* determine post GSUB location of baseIndex and mpreIndex */ - gboolean no_base = TRUE; pango_ot_buffer_get_glyphs (buffer, &glyphs, &n_glyphs); for (i = 0; i < n_glyphs; i++) { - if (glyphs[i].cluster == baseIndex) { - baseIndex = i + 1; - no_base = FALSE; - } - if (glyphs[i].cluster == mpreIndex) - mpreIndex = i; + if (baseGlyph < 0 && glyphs[i].cluster == baseIndex) + baseGlyph = i; + if (glyphs[i].cluster == mpreIndex) { + if (mpreGlyph < 0) + mpreGlyph = i; + mpreLimit = i + 1; + } } - if (no_base) - break; - - mpreLimit = mpreIndex + 1; - - while (glyphs[baseIndex].glyph == 0xFFFF || glyphs[baseIndex].glyph == 0xFFFE) { - baseIndex -= 1; - } - - while (glyphs[mpreLimit].glyph == 0xFFFF || glyphs[mpreLimit].glyph == 0xFFFE) { - mpreLimit += 1; - } - - if (mpreLimit == baseIndex) { + if (baseGlyph < 0 || mpreGlyph < 0 || mpreLimit >= baseGlyph) { continue; } - mpreCount = mpreLimit - mpreIndex; - moveCount = baseIndex - mpreLimit; - mpreDest = baseIndex - mpreCount - 1; + mpreCount = mpreLimit - mpreGlyph; + moveCount = baseGlyph - mpreLimit; + mpreDest = baseGlyph - mpreCount; mpreSave = g_new (PangoOTGlyph, mpreCount); clusterSave = g_new (int, mpreCount); for (i = 0; i < mpreCount; i += 1) { - mpreSave[i] = glyphs[mpreIndex + i]; + mpreSave[i] = glyphs[mpreGlyph + i]; } for (i = 0; i < moveCount; i += 1) { - glyphs[mpreIndex + i] = glyphs[mpreLimit + i]; + glyphs[mpreGlyph + i] = glyphs[mpreLimit + i]; } for (i = 0; i < mpreCount; i += 1) { -- cgit v1.2.1