Is it possible to create a custom font with a .ttf file that is inside a .jar file? I've created a jar file with the following structure
Game.jar
├──Snake
│ ├── lib
│ | └── game_over.ttf
| ├── src
│ | ├── GameFrame.class
│ | ├── GamePanel.class
│ | └── SnakeGame.class
I've tried to get the custom font by doing
Font GAMEOVER_FONT;
InputStream is = this.getClass().getClassLoader().getResourceAsStream("Snake/lib/game_over.ttf");
GAMEOVER_FONT = Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(200f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, is));
g.setFont(GAMEOVER_FONT);
What am I doing wrong? Is it even possible to achieve what I'm trying?