您创建的字体必须先在中注册,
GraphicsEnvironment以供所有人访问并得出字体的大小:
Font font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResource("/CUSTOMFONT-MEDIUM.TTF").openStream());GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();genv.registerFont(font);// makesure to derive the sizefont = font.deriveFont(12f);


