Use resource font directly in Java

How can I use a resource font directly in Java?

0


source to share


1 answer


To load a font (.ttf) from a file, see Load font from ttf file .

Key lines:



InputStream is = DemoFonts.class.getResourceAsStream(fName);
font = Font.createFont(Font.TRUETYPE_FONT, is);

      

The font can then be used for JLabel

using the usual method setFont

.

+3


source







All Articles