Je fais des recherches sur la façon de "dessiner" du texte attribué sur Graphics2D.Le "contenu" de AttributedString peut-il être enregistré dans un fichier?
Donc, je suis intéressé est-il possible d'enregistrer contenu de AttributedString dans un certain format?
Je sais qu'il pourrait être sérialisé Java, mais, je n'ai pas besoin de cette solution ici.
De même, si quelqu'un connaît un exemple qui montre comment modifier AttributedString?
Voici un code Java, pour obtenir une idée:
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 pour toute aide ou des conseils :)