IText provides a set of functions for character editing: append and operator+=, insert, insert_and_propagate_styles, replace, and erase. The functions that add characters take either styled or unstyled text. The text that is added maintains its character styling information (raw Unicode characters are considered to be unstyled). Paragraph styles are propagated according to the mechanism described in "IText style propagation."
For example, this code demonstrates some simple text editing functions:
IText string("Now is the time for all men to come swiftly to the
aid of the party.");
// Delete "swiftly"
string.erase(36, 8);
// Add "good" before "men"
string.insert(24, IText("good"));
// Change "the party" to "their country"
string.replace(58, 6, IText("ir country"));
// Create a copy of a substring of the text and append more
characters
IText newString = string.substr(0, 15);
newString += IText ("for me to go!");
![]()