SamSol
SamSol

Reputation: 2881

Use resource font directly in Java

How to use resource font directly in Java?

Upvotes: 2

Views: 8368

Answers (1)

aioobe
aioobe

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

Related Questions