I am going to use custom font in my application. For that I am using Font.createFont()
method.
My code is given below. It works fine when I run my main class using command
java myAppl.class
The font file is in same directory that of my class file. But when I bundled all files and font files in JAR and then run my application from JAR, the custom font do not loaded. Why?
InputStream is = this.getClass().getResourceAsStream("myfont.TTF");
uniFont=Font.createFont(Font.TRUETYPE_FONT,is);
Font f = uniFont.deriveFont(24f);
What should I do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…