void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const { LEGlyphID a, b, c, d; le_int32 ia, ib, ic, id, ix, x; LEErrorCode success = LE_NO_ERROR; switch(verb) { case irvNoAction: break; case irvxA: a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); x = firstGlyph + 1; while (x <= lastGlyph) { glyphStorage[x - 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 1, ix, success); x += 1; } glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDx: d = glyphStorage[lastGlyph]; id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 1; while (x >= firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage.setCharIndex(firstGlyph, id, success); break; case irvDxA: a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDx: c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); break; case irvDCx: c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); break; case irvCDxA: a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxA: a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvCDxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDCxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; default: break; } }
void MPreFixups::apply(LEGlyphStorage &glyphStorage, LEErrorCode& leSuccess) { if (LE_FAILURE(leSuccess)) { return; } for (le_int32 fixup = 0; fixup < fFixupCount; fixup += 1) { le_int32 baseIndex = fFixupData[fixup].fBaseIndex; le_int32 mpreIndex = fFixupData[fixup].fMPreIndex; le_int32 mpreLimit = mpreIndex + 1; while (glyphStorage[baseIndex] == 0xFFFF || glyphStorage[baseIndex] == 0xFFFE) { baseIndex -= 1; } while (glyphStorage[mpreLimit] == 0xFFFF || glyphStorage[mpreLimit] == 0xFFFE) { mpreLimit += 1; } if (mpreLimit == baseIndex) { continue; } LEErrorCode success = LE_NO_ERROR; le_int32 mpreCount = mpreLimit - mpreIndex; le_int32 moveCount = baseIndex - mpreLimit; le_int32 mpreDest = baseIndex - mpreCount; LEGlyphID *mpreSave = LE_NEW_ARRAY(LEGlyphID, mpreCount); le_int32 *indexSave = LE_NEW_ARRAY(le_int32, mpreCount); if (mpreSave == NULL || indexSave == NULL) { LE_DELETE_ARRAY(mpreSave); LE_DELETE_ARRAY(indexSave); success = LE_MEMORY_ALLOCATION_ERROR; return; } le_int32 i; for (i = 0; i < mpreCount; i += 1) { mpreSave[i] = glyphStorage[mpreIndex + i]; indexSave[i] = glyphStorage.getCharIndex(mpreIndex + i, success); //charIndices[mpreIndex + i]; } for (i = 0; i < moveCount; i += 1) { LEGlyphID glyph = glyphStorage[mpreLimit + i]; le_int32 charIndex = glyphStorage.getCharIndex(mpreLimit + i, success); glyphStorage[mpreIndex + i] = glyph; glyphStorage.setCharIndex(mpreIndex + i, charIndex, success); } for (i = 0; i < mpreCount; i += 1) { glyphStorage[mpreDest + i] = mpreSave[i]; glyphStorage.setCharIndex(mpreDest, indexSave[i], success); } LE_DELETE_ARRAY(indexSave); LE_DELETE_ARRAY(mpreSave); } }
void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb, LEErrorCode &success) const { LEGlyphID a, b, c, d; le_int32 ia, ib, ic, id, ix, x; if (LE_FAILURE(success)) return; if (verb == irvNoAction) { return; } if (firstGlyph > lastGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; return; } switch(verb) { case irvxA: if (firstGlyph == lastGlyph) break; if (firstGlyph + 1 < firstGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); x = firstGlyph + 1; while (x <= lastGlyph) { glyphStorage[x - 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 1, ix, success); x += 1; } glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDx: if (firstGlyph == lastGlyph) break; if (lastGlyph - 1 > lastGlyph) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } d = glyphStorage[lastGlyph]; id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 1; while (x >= firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage.setCharIndex(firstGlyph, id, success); break; case irvDxA: a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvxAB: if ((firstGlyph + 2 < firstGlyph) || (lastGlyph - firstGlyph < 1)) { // difference == 1 is a no-op, < 1 is an error. success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvxBA: if ((firstGlyph + 2 < firstGlyph) || (lastGlyph - firstGlyph < 1)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDx: if ((lastGlyph - 2 > lastGlyph) || (lastGlyph - firstGlyph < 1)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); break; case irvDCx: if ((lastGlyph - 2 > lastGlyph) || (lastGlyph - firstGlyph < 1)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); break; case irvCDxA: if ((lastGlyph - 2 > lastGlyph) || (lastGlyph - firstGlyph < 2)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxA: if ((lastGlyph - 2 > lastGlyph) || (lastGlyph - firstGlyph < 2)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDxAB: if ((firstGlyph + 2 < firstGlyph) || (lastGlyph - firstGlyph < 2)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDxBA: if ((firstGlyph + 2 < firstGlyph) || (lastGlyph - firstGlyph < 2)) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDxAB: if (lastGlyph - firstGlyph < 3) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvCDxBA: if (lastGlyph - firstGlyph < 3) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxAB: if (lastGlyph - firstGlyph < 3) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDCxBA: if (lastGlyph - firstGlyph < 3) { success = LE_INDEX_OUT_OF_BOUNDS_ERROR; break; } a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; default: break; } }
U_NAMESPACE_BEGIN void doRearrangementAction(LEGlyphStorage &glyphStorage, le_int32 firstGlyph, le_int32 lastGlyph, IndicRearrangementVerb verb, LEErrorCode &success) { if (LE_FAILURE(success)) return; LEGlyphID a, b, c, d; le_int32 ia, ib, ic, id, ix, x; switch(verb) { case irvNoAction: break; case irvxA: a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); x = firstGlyph + 1; while (x <= lastGlyph) { glyphStorage[x - 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 1, ix, success); x += 1; } glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDx: d = glyphStorage[lastGlyph]; id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 1; while (x >= firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage.setCharIndex(firstGlyph, id, success); break; case irvDxA: a = glyphStorage[firstGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); x = firstGlyph + 2; while (x <= lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDx: c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); break; case irvDCx: c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x >= firstGlyph) { glyphStorage[x + 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 2, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); break; case irvCDxA: a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = c; glyphStorage[firstGlyph + 1] = d; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxA: a = glyphStorage[firstGlyph]; c = glyphStorage[lastGlyph - 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = lastGlyph - 2; while (x > firstGlyph) { glyphStorage[x + 1] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x + 1, ix, success); x -= 1; } glyphStorage[firstGlyph] = d; glyphStorage[firstGlyph + 1] = c; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; d = glyphStorage[lastGlyph]; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); x = firstGlyph + 2; while (x < lastGlyph) { glyphStorage[x - 2] = glyphStorage[x]; ix = glyphStorage.getCharIndex(x, success); glyphStorage.setCharIndex(x - 2, ix, success); x += 1; } glyphStorage[firstGlyph] = d; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvCDxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvCDxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, ic, success); glyphStorage.setCharIndex(firstGlyph + 1, id, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; case irvDCxAB: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = a; glyphStorage[lastGlyph] = b; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ia, success); glyphStorage.setCharIndex(lastGlyph, ib, success); break; case irvDCxBA: a = glyphStorage[firstGlyph]; b = glyphStorage[firstGlyph + 1]; glyphStorage[firstGlyph] = glyphStorage[lastGlyph]; glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1]; glyphStorage[lastGlyph - 1] = b; glyphStorage[lastGlyph] = a; ia = glyphStorage.getCharIndex(firstGlyph, success); ib = glyphStorage.getCharIndex(firstGlyph + 1, success); ic = glyphStorage.getCharIndex(lastGlyph - 1, success); id = glyphStorage.getCharIndex(lastGlyph, success); glyphStorage.setCharIndex(firstGlyph, id, success); glyphStorage.setCharIndex(firstGlyph + 1, ic, success); glyphStorage.setCharIndex(lastGlyph - 1, ib, success); glyphStorage.setCharIndex(lastGlyph, ia, success); break; default: break; } }