Sunday, 15 September 2013

java - Libgdx cant load font from jar file -



java - Libgdx cant load font from jar file -

i trying initiate bitmapfont, when run project works when jarsplice project , run this.

exception in thread "lwjgl application" com.badlogic.gdx.utils.gdxruntimeexcepti on: error reading file: assets\texture\font.fnt (absolute) @ com.badlogic.gdx.files.filehandle.read(filehandle.java:144) @ com.badlogic.gdx.graphics.g2d.bitmapfont$bitmapfontdata.<init>(bitmap font.java:835) @ com.badlogic.gdx.graphics.g2d.bitmapfont.<init>(bitmapfont.java:106) @ catt.main.game.create(game.java:105) @ com.badlogic.gdx.backends.lwjgl.lwjglapplication.mainloop(lwjglapplic ation.java:136) @ com.badlogic.gdx.backends.lwjgl.lwjglapplication$1.run(lwjglapplicati on.java:114) caused by: java.io.filenotfoundexception: assets\texture\font.fnt (the scheme ca nnot find path specified) @ java.io.fileinputstream.open(native method) @ java.io.fileinputstream.<init>(fileinputstream.java:138) @ com.badlogic.gdx.files.filehandle.read(filehandle.java:140) ... 5 more

this how load font.

fonttexture = new texture("assets/texture/font.tga"); buttonfont = new bitmapfont(new filehandle("assets/texture/font.fnt"), new textureregion(fonttexture), true); titlefont = new bitmapfont(new filehandle("assets/texture/font.fnt"), new textureregion(fonttexture), true);

they're all fields public static.

libgdx has function filehandle straight jar. load fonts this:

bitmapfont font = new bitmapfont(gdx.files.internal("texture/font.fnt"));

you should create sure have correctly linked assets folder.

java fonts libgdx

No comments:

Post a Comment