Font.createFont +抗锯齿
我已将 .ttf 字体捆绑在 JAR 存档中,并使用以下例程加载该字体:
[snip]
is = IdeUiUtil.class.getResourceAsStream(fontName);
font = Font.createFont(Font.TRUETYPE_FONT, is);
font = font.deriveFont(style, size);
[snip]
更新: 该字体用于 TitledBorder
的标题中,并且将最终也可以在几个 JLabels
中使用。
问题是,在 Window 平台上它看起来都是锯齿状的。在Linux 上,它可以很好地消除锯齿。我需要做什么才能在 Windows 上也消除锯齿?
I have bundled a .ttf font inside a JAR archive which I load with a routine along this lines:
[snip]
is = IdeUiUtil.class.getResourceAsStream(fontName);
font = Font.createFont(Font.TRUETYPE_FONT, is);
font = font.deriveFont(style, size);
[snip]
UPDATE: The font is used in the title of a TitledBorder
, and will eventually also be used in a couple of JLabels
.
The problem is, that on a Window platform it looks all jaggy. On linux, it's nicely anti-aliased. What do I have to do so it's anti-aliased on windows as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 Graphics 进行绘图,则应该使用:
...但这并不特定于捆绑字体:它适用于与 Graphics 对象一起使用的所有字体。
有一个 hack 可以将此应用到面板,但我不确定它是否是最新的。
If you are drawing with Graphics, you should use:
... but this is not specific to bundling a font : it applies to all fonts used with the Graphics object.
There is a hack to apply this to a panel, but I'm not sure it's up to date.