所有问题都在:
我怎样才能创建一个字体,其中包含字体文件的路径? 因为对于图像,我做了:
URL fond_path_3 = getClass().getResource("/hepta/Images/BoutonQuitter.png");
Image myPicture3 = Toolkit.getDefaultToolkit().getImage(fond_path_3);
但现在对于一个文件,我不知道如何获得它:
URL font_path = getClass().getResource("/hepta/Images/moolbor.ttf");
newfont = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File(font_path))).deriveFont(Font.PLAIN, 24);
问题似乎来自:
new FileInputStream(new File(font_path))
谢谢!
答案 0 :(得分:2)
您应该在URL上打开一个流,而不是创建FileInputStream。
newfont = Font.createFont(Font.TRUETYPE_FONT, font_path.openStream()).deriveFont(Font.PLAIN, 24);