TextAttribute.TRACKING 和 LineBreakMeasurer

发布于 2024-08-06 01:23:36 字数 536 浏览 4 评论 0原文

有没有人成功使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懷念過去 2024-08-13 01:23:36

除了默认字体之外,我从未尝试过使用其他字体,但是旧的 多行文本技术提示展示了使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文