首页 > 其他 > 详细

e655. 混合风格的文本

时间:2018-09-02 22:54:37      阅读:163      评论:0      收藏:0      [点我收藏+]

This example applies a new font and background color to a part of the text. You can apply styles to as many parts of the text as you need. See TextAttributes for available styles.

    // Apply styles to text
    AttributedString astr = new AttributedString("aString");
    astr.addAttribute(TextAttribute.FONT, font, start, end);
    astr.addAttribute(TextAttribute.BACKGROUND, color, start, end);
    
    // Draw mixed-style text
    TextLayout tl = new TextLayout(astr.getIterator(), g2d.getFontRenderContext());
    tl.draw(g2d, x, y);

 

Related Examples

e655. 混合风格的文本

原文:https://www.cnblogs.com/borter/p/9575451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!