Nifty + Fonts – can’t get it to work

Hi,

i tried to implement nifty gui, but ran into a probably simple problem which i can’t solve. it doesn’t matter if i put the font+png in the assets/interface folder, or if i specify the path completely (for example: C:UsersWolffDocumentsjMonkeyProjectsInfestationassetsInterfaceaurulent-sans-36-bold-with-shadow.fnt).

i always get this error (switch names for the chosen font):

WARNING: Cannot locate resource: default.fnt

java.lang.RuntimeException: Font not loaded:default.fnt



how do i fix this? even the example from here doesn’t work.



thanks in advance :slight_smile:





edit: got it to work. but it should really be said in the tutorial that you have to include the jar-files from nifty in your project, as i understood it (might be because english isn’t my first language) they are included in JME but apparently are not.

Hi,

I am having the exact same problem. I have tried adding jme3 libraries gui to the compile-time libraries, but things still do not work. Can you be more specific about which jar-files I need to add and where? This thing is driving me nuts :confused:

Thanks in advance



edit: Aha! It works when I specify where the font is in the xml file :D. E.g. font=“Interface/Fonts/Console.fnt”. Now to look for some better looking fonts!

hi @mercidian, i does the same thing as what you just did as well but why does it seem like all the elements such as text, image, etc not working for me :frowning:

krayonz said:
hi @mercidian, i does the same thing as what you just did as well but why does it seem like all the elements such as text, image, etc not working for me :(


i think you have the same problem i did. you have to include the nifty-jars specifically (as in copying the jars in your assets folder). nifty is kind of strange to implement the first ime imho, but you only need to do it once :)
wlfbck said:
i think you have the same problem i did. you have to include the nifty-jars specifically (as in copying the jars in your assets folder). nifty is kind of strange to implement the first ime imho, but you only need to do it once :)


You mean to load nifty-1.3.jar library in the project's property?

Were your problems like mine too? (Like what I have described in this topic -- I've included screenshots of it.)

Thank you :)

You don’t have to copy any library into the assets folder :roll: Just have the font in either a jar library (e.g. the nifty-supplied ones) or have it in the Interface/Fonts/ folder and then name it with that path in the xml file, e.g. Interface/Fonts/MyFont.fnt

All asset paths are always relative to the asset folder root.

normen said:
You don't have to copy any library into the assets folder :roll: Just have the font in either a jar library (e.g. the nifty-supplied ones) or have it in the Interface/Fonts/ folder and then name it with that path in the xml file, e.g. Interface/Fonts/MyFont.fnt
All asset paths are always relative to the asset folder root.


Thanks normen. :) But I tried what you just mentioned as well, and it still doesn't load up. Yeah, I even tested it with other font files, created them with the font creator plug-in and tried it too, didn't work out either. Updated the XML, and it seems the file are nicely read into the application but it just doesn't get displayed. :S Images as well, especially those that has transparent area, it doesn't loads up. :S

I had been doing so much test to try and debug the problems but to no avail.. (-__-) And all these checks are slowly getting senseless as well.. from relative path that I placed in the XML to place a long absolute path in it, didn't work either (but at least this one shows an error!).. Debugging something that seems to be working fine but not showing you a single thing on the screen at all is crazy -.-
normen said:
You don't have to copy any library into the assets folder :roll: Just have the font in either a jar library (e.g. the nifty-supplied ones) or have it in the Interface/Fonts/ folder and then name it with that path in the xml file, e.g. Interface/Fonts/MyFont.fnt
All asset paths are always relative to the asset folder root.

Okay :D I just listed the thing that worked for me, is there a better (more clean/uncomplicated) way to do it? :)

@krayonz: did you do this one?
[java]
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
guiViewPort.addProcessor(niftyDisplay);[/java]
wlfbck said:
@krayonz: did you do this one?
[java]
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
guiViewPort.addProcessor(niftyDisplay);[/java]


Yes. That's definitely.

And well, i also do the methods as you said and many other various silly methods to load in the image too. Here's the result of what's going on on my side (as posted in this topic I created, still no response over there though :(): Link to the Image

Nothing changes.

This is.. the 1.3 preview demo code I got it off from following the tutorial on this site. And when loaded up, some images shown, some doesn't. Fonts definitely doesn't. And I have absolutely no clue now.

oh thats strange indeed. i had a bug with font not displaying properly, but no font at all? mhm. did you try one out of the nifty jars?

wlfbck said:
oh thats strange indeed. i had a bug with font not displaying properly, but no font at all? mhm. did you try one out of the nifty jars?


Yes, I did. Not that there's no font, but the fonts were loaded (absolutely, since there's no error when it got loaded up) but the fonts were not shown. Anyway, earlier on while discussing with madjack over at my topic about this issue, I managed to fix the problem: I actually re-install the platform.

What caused the problem?
I don't know.

What really happened?
A couple of days back, I setup the nightly updates on the platform. That was before I started learning Nifty. So, nifty works but just the effect and solid color panels or images. When I said solid images, I meant images that doesn't have a single alpha channel, so, if there's gradient contained in the image, it won't load up either. I then went to another system with the platform not updated (still jme3 alpha-4), load up the nifty project and nifty over there works! :o