Java でカスタム フォントを作成しようとしていますが、さまざまな方法を試しましたが、jar をエクスポートするときに機能しません。これが私の現在のコードです:
Font font = null;
try {
font = Font.createFont(0, new File("res/fonts/PlayTheGame.ttf"));
font.deriveFont(20f);
} catch (FontFormatException | IOException e) {
e.printStackTrace();
}
Font fntPlayTheGame = font.deriveFont(0, 40f);
lblTitle = new JLabel("Cell Defender");
lblTitle.setFont(fntPlayTheGame);
フォントはEclipse内で機能しますが、コンパイル後に実行すると、それを読み取ることができないと表示されます。などを使用してみましたInputStream
が、うまくいきません。
どうすればこれを機能させることができますか?