/// <summary> /// Implements <see cref="Transliterator.HandleTransliterate(IReplaceable, Position, bool)"/>. /// </summary> protected override void HandleTransliterate(IReplaceable text, Position pos, bool isIncremental) { int allStart = pos.Start; int allLimit = pos.Limit; ScriptRunIterator it = new ScriptRunIterator(text, pos.ContextStart, pos.ContextLimit); while (it.Next()) { // Ignore runs in the ante context if (it.Limit <= allStart) { continue; } // Try to instantiate transliterator from it.scriptCode to // our target or target/variant Transliterator t = GetTransliterator(it.ScriptCode); if (t == null) { // We have no transliterator. Do nothing, but keep // pos.start up to date. pos.Start = it.Limit; continue; } // If the run end is before the transliteration limit, do // a non-incremental transliteration. Otherwise do an // incremental one. bool incremental = isIncremental && (it.Limit >= allLimit); pos.Start = Math.Max(allStart, it.Start); pos.Limit = Math.Min(allLimit, it.Limit); int limit = pos.Limit; t.FilteredTransliterate(text, pos, incremental); int delta = pos.Limit - limit; allLimit += delta; it.AdjustLimit(delta); // We're done if we enter the post context if (it.Limit >= allLimit) { break; } } // Restore limit. pos.start is fine where the last transliterator // left it, or at the end of the last run. pos.Limit = allLimit; }