'How to fix the look of rendered string in Java

I am drawing a string in a JPanel with a pixel font. Some parts of the letters are drawn with extra pixels so it looks wider. How can I remove those extra pixels? Here's what it looks like.

three rendered strings with different looks

public void paintComponent(Graphics g) {
    
    Graphics2D gtd = (Graphics2D) g;
    
    gtd.setFont(new Font("EXEPixelPerfect", Font.PLAIN, 50));
    gtd.drawString("continue", 100, 100);

    gtd.setFont(new Font("EXEPixelPerfect", Font.PLAIN, 51));
    gtd.drawString("continue", 100, 150);

    gtd.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    gtd.setFont(new Font("EXEPixelPerfect", Font.PLAIN, 50));
    gtd.drawString("continue", 100, 200);
    
}

The first text is what I have originally. As you can see in the picture, some parts are wider.

In the second text, I increased the font size by one. I want it to look like that, but it's still not fixed. A part of 'e' looks wider.

The third text has the same font format with the first text but it has anti-alias. It fixed the wide lines but the problem is, it looks blurry.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source