Editing Character Data in an IText Object

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."

The exception is that characters inserted with the insert_and_propagate_styles function take on the styles of the text they are inserted into.

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!");

Style Propagation