TextAttribute.TRACKING 和 LineBreakMeasurer
有没有人成功使用java.awt.font.LineBreakMeasurer
来绘制具有java.awt.font.TextAttribute.TRACKING
(也称为字母间距)的自动换行文本)设置字体?
我通过以下方式创建字体:
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object> ();
map.put(TextAttribute.SIZE, 18);
map.put(TextAttribute.TRACKING, .04);
Font f = Font.createFont(Font.TRUETYPE_FONT, new File ("C:/arialbd.ttf"));
f = f.deriveFont(map);
渲染到图像时一切看起来都很好并且跟踪为0
。但是当设置跟踪时> 0
一切都正确绘制,但换行符没有改变。文字就从图像的一侧消失了。
has anyone ever successfully used the java.awt.font.LineBreakMeasurer
to draw word-wrapping text that has java.awt.font.TextAttribute.TRACKING
(also known as letter spacing) set on the font?
i create the font by:
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object> ();
map.put(TextAttribute.SIZE, 18);
map.put(TextAttribute.TRACKING, .04);
Font f = Font.createFont(Font.TRUETYPE_FONT, new File ("C:/arialbd.ttf"));
f = f.deriveFont(map);
everything looks good when rendered to an image and tracking is 0
. but when the tracking is set > 0
everything is drawn correctly but the line breaks do not change. the text just disappears off the side of the image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了默认字体之外,我从未尝试过使用其他字体,但是旧的 多行文本技术提示展示了使用 LineBreakMeasurer 的一种方法。由于您没有发布代码,我无法判断您的代码是否相同或不同。
下次发布您的 SSCCE 将会很有帮助,这样我们就可以看到您在做什么。
I've never tried it with anything but the default Font, but the old Multi Line Text tech tip shows one way to use the LineBreakMeasurer. Since you didn't post your code I can't tell if your code is the same or different.
Next time posting your SSCCE would be helpful so we can see what your are doing.