Ugly Fonts in Java Swing - How to set antialiasing?

48 views Asked by At

I'm creating a modern-looking program with a cool GUI, but Java prevents me from doing that by showing a eye-burning text presentation.

Here's how it looks like: .

Look at the numbers, they are shaped horribly.

I'm using a custom font too, Montserrat, which is known for being modern and smooth-edged, but Java ruins it.

(The component used to display those numbers is a JFreeChart, so I can't know which component is used precisely, but I assume it's a JLabel)

I already tried:

  • Activating anti-aliasing with System.setProperty("awt.useSystemAAFontSettings","on");, System.setProperty("awt.useSystemAAFontSettings","lcd"); and System.setProperty("swing.aatext", "true");, but none of them worked.
  • Replacing the paintComponent of the component I'm using to render those numbers with:
ChartPanel graficoInnerPanel = new ChartPanel(grafico){
            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            }
        };
0

There are 0 answers