/// <summary> /// Creates a substring of this rich text. /// </summary> public RichText Substring(int offset, int length) { if (offset == 0 && length == this.Length) { return(this); } string newText = text.Substring(offset, length); RichTextModel model = ToRichTextModel(); OffsetChangeMap map = new OffsetChangeMap(2); map.Add(new OffsetChangeMapEntry(offset + length, text.Length - offset - length, 0)); map.Add(new OffsetChangeMapEntry(0, offset, 0)); model.UpdateOffsets(map); return(new RichText(newText, model)); }