Reputation: 2881
How to use resource font directly in Java?
Upvotes: 2
Views: 8368
Reputation: 421100
To load a font (.ttf) from file, have a look at Load font from ttf file.
Key lines being:
InputStream is = DemoFonts.class.getResourceAsStream(fName);
font = Font.createFont(Font.TRUETYPE_FONT, is);
The font could then be used for a JLabel
through the usual setFont
method.
Upvotes: 9