Java Font Rendering

℡╲_俬逩灬. 提交于 2019-11-27 22:22:18

Are the AWT Desktop Properties of any help? In particular, "awt.font.desktophints" - these contain the AA hints that the native components use, but can be applied to any Graphics2D you want.

Just a shot in the dark, having recently read through the AA section in Filthy Rich Clients.

Use would look something like this:

String str = "A quick brown fox jumps over the lazy dog";
Toolkit tk = Toolkit.getDefaultToolkit();
Map desktopHints = (Map)(tk.getDesktopProperty("awt.font.desktophints"));
Graphics2D g2d = (Graphics2D)g;

if(desktopHints != null) {
    g2d.addRenderingHints(desktopHints);
}

g2d.drawString(str, someX, someY);

I was able to get the same results (using your example class and drawChars and drawImage, just typed drawString for simplicity) as the LCD HRGB mode using these hints and no other calls on my machine.

I'm not sure what release of Java this requires, if it's what you're looking for...

trashgod

Don't forget: "Implementations are free to ignore the hints completely." For reference, here's what I see at 24 points:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!