I am doing some research on how to "draw" some attributed text on Graphics2D.
So, i am interested is it possible to save content of AttributedString in some format ?
I know it could be Java serialized, but, i don't need that solution here.
Also, if somebody knows some example which shows how to edit AttributedString ?
Here is some Java code, just to get idea:
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
AttributedString as new AttributedString( "Lorem ipsum dolor sit amet..." );
Font font1 = new Font( "SansSerif" , Font.PLAIN , 20 );
as.addAttribute( TextAttribute.FONT , font1 );
as.addAttribute( TextAttribute.FOREGROUND , Color.black );
as.addAttribute( TextAttribute.FOREGROUND , Color.blue , 4 , 9 );
AttributedCharacterIterator aci = as.getIterator();
FontRenderContext frc = g2.getFontRenderContext();
LineBreakMeasurer lbm = new LineBreakMeasurer( aci , frc );
TextLayout textLayout = lbm.nextLayout( wrappingWidth );
int x = 50 , y = 50 ;
textLayout.draw( g2 , x , y );
}
Thanx for any help or advice :)