如何为 AWT/Swing 应用程序进行字体平滑?
我需要为 Windows 系统上的 AWT 应用程序进行字体平滑。 在进行谷歌搜索时,我发现我可以在 Eclipse 中设置以下 VM 参数。
-Dawt.useSystemAAFontSettings=gasp
但这并没有产生任何积极的结果。 如果有人对如何实现字体平滑有更好的想法,请告诉我。
编辑在安德鲁回答后,
我在绘制方法中添加了以下代码片段,
public class BottomSubmitButtons extends Canvas {
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
g2.setRenderingHints(rh);
}
}
这似乎改善了其中一个子面板的平滑度。 但在其他面板中执行相同操作不会产生任何平滑效果。另外,默认情况下,文本字段框将不可见,但一旦我单击该区域,它们就会变得可见
I need to do font smoothing for a AWT application on Windows System.
On doing googling I came to know that I can set following VM argument in Eclipse.
-Dawt.useSystemAAFontSettings=gasp
But this is not yielding any positive results.
If anyone is having a better idea on how to achieve Font Smoothing, then kindly let me know.
EDIT After Answer By Andrew
I added the following snippet of code in paint method
public class BottomSubmitButtons extends Canvas {
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
g2.setRenderingHints(rh);
}
}
This seems to have improved the smoothing in one of the sub panel.
But doing the same in other panel is not yielding any smoothing. Also the TextField boxes are going invisible by default, though they becomes visible once I click in that area
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
RenderingHints 的值。 KEY_TEXT_LCD_CONTRAST
。当您找到有效的方法时,请将其用作命令行值。Play with the values for
RenderingHints.KEY_TEXT_LCD_CONTRAST
. When you find something that works, use that as the command line value.