Font.createFont + Anti-Aliasing
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 Title开发者_如何学GodBorder
, 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?
If you are drawing with Graphics, you should use:
Graphics2D g2d = (Graphics2D)getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
... 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.
精彩评论