AttributedCharacterIterator charIterator = myStyledText.getIterator();
LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator,
graphics2d.getFontRenderContext());
float wrappingWidth = (float) format.getImageableWidth();
while (measurer.getPosition() == charIterator.getEndIndex()) {
TextLayout layout = measurer.nextLayout(wrappingWidth);
pen.y += layout.getAscent();
float dx = layout.isLeftToRight() ? 0 : (wrappingWidth - layout
.getAdvance());
layout.draw(graphics2d, pen.x + dx, pen.y);
pen.y += layout.getDescent() + layout.getLeading();