How to smooth font for AWT / Swing application?

I need to perform font smoothing for an AWT application on a Windows system. When doing a googling search, I found out that I can set the next VM argument in Eclipse.

-Dawt.useSystemAAFontSettings=gasp 

But this does not give any positive results. If anyone has a better idea on how to achieve font smoothing, then kindly let me know.

EDIT After Andrew's answer

I added the following code snippet in the 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 anti-aliasing in one of the sub-panels. But to do the same in another panel does not provide smoothing. Also, by default, TextField blocks become invisible, although they become visible as soon as I click in this area

+6
source share
1 answer

Play with the values โ€‹โ€‹of RenderingHints.KEY_TEXT_LCD_CONTRAST . When you find something that works, use this as a command line value.

+5
source

Source: https://habr.com/ru/post/898261/


All Articles