The Unicode Text Framework provides
ITextStyleRunIterator for iterating through the style runs in an
IText object. To use ITextStyleRunIterator:
- To create the ITextStyleRunIterator,
pass the constructor the IText object you want to iterate
over.
- Use the iterator operators ++ and -- to
move forward and backward through style runs.
- Extract the styles on the current style
run. The iterator's operator-> lets you call the
ITextStyleSet::extract function for the current style
run's style set.
- Use the ITextStyleRunIterator functions
runStart and runLength to get the extent of the current
style run.
For example, this code shows how to use an
iterator to modify the point size for each style run, or add a
point-size style if there is none:
ITextPointSizeStyle size;
ITextStyleRunIterator iter(someText);
for ( ; iter; ++iter) {
if (iter->extract(size))
size.setPointSize(size.pointSize() + 3);
else
size.setPointSize(6);
someText.addStyles(size, iter.runStart(), iter.runLength());
}