Java Graphics Font字体设置没有用,一直都是Java默认字体,如何解决?

我的电脑上已经安装了Computer Modern字体,并且用WPS Word是可以正常写入字体的,但是我重新g.setFont()时却出不来字体

public class Font_ extends JFrame{
    MyPanel mp;
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new Font_();
    }
    public Font_() {
        this.setSize(300, 400);
        this.setVisible(true);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        
        mp = new MyPanel();
        this.add(mp);
    }
}

class MyPanel extends JPanel {
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setFont(new Font("Computer Modern", Font.ITALIC, 15));
        g.drawString("xyz", 100, 100);
    }
}

运行结果与字体对比:

img

很明显,此时的x y z和字体上的不一致,但是如果我修改成 黑体 宋体等等 的话就没问题
这是什么情况

你可以打开FontDialog对话框,里面有的字体就可以设置。