Nifty text color encoding still broken / BatchedRenderer not working

Hey guys,
in this post, @void256 mentioned he fixed the text-encoding problem in nifty: http://hub.jmonkeyengine.org/forum/topic/nifty-text-color-encoding/#post-220003

I’m currently using the stable jME3.0 version with the following nifty version: 1.3.3 (2013-06-20 23:54:54)
It doesn’t contain the “-SNAPSHOT” mentioned in his post, but the date is 3 months older than the fix - So my question is simply, if jME doesn’t contain the newest nifty version and if that’s the case, when it will be updated.

The mentioned error is still there, i.e. the text is displayed correctly (the color-encoding parts are removed) but the whole text is in one color (white). This is when using the default renderer. I tried to use the batched renderer like he mentioned in his post:
[java]NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(mainApplication.getAssetManager(), mainApplication.getInputManager(), mainApplication.getAudioRenderer(), mainApplication.getGuiViewPort(), 2048, 2048);[/java]

But it throws the following error:

Schwerwiegend: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] java.lang.NoClassDefFoundError: org/jglfont/spi/BitmapFontRenderer at com.jme3.niftygui.NiftyJmeDisplay.(NiftyJmeDisplay.java:129) at amara.engine.appstates.NiftyAppState.createNifty(NiftyAppState.java:37) at amara.engine.applications.ingame.client.appstates.NiftyAppState_IngameClient.initialize(NiftyAppState_IngameClient.java:21) at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251) at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281) at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239) at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.ClassNotFoundException: org.jglfont.spi.BitmapFontRenderer at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 10 more

Yours,
destro :slight_smile:

I think you’re missing “jglfont-core.jar” on your classpath. The last time I’ve checked it was bundled with jMonkeyEngine.jar. I’ve just checked and it is still a part of this source tree: https://code.google.com/p/jmonkeyengine/source/browse/#svn%2Ftrunk%2Fengine%2Flib%2Fniftygui not sure if this is still relevant considering the move to github. But I’m sure that you need that jar on your classpath :slight_smile:

1 Like

Thanks for responding so fast. :slight_smile: I’ve added the jar to the classpath and it seems to work (The default font has changed, but that isn’t problem xD).
I’m still curious why the *.jar isn’t bundled in the 3.0SDK - Neither was it contained in the classpath nor it is available in the “Add Library” list. I added it manually via “Add Jar/Folder”, so I’m fine for now - Just as a hint for the jME developers if this error will pop up for more users.

As i said, thx for helping me out so quick^^

The default font has changed

Actually, I encountered a new problem - I’m not using a default font, but my own font created with the sdk. With the new renderer, it isn’t displayed correctly in one case:

(Left = Default renderer, Right = Batched renderer)

Notice, that the two parts (The chat and the attributes “window”) are in two different nifties and are using the same font - So it seems to work in the one nifty but not in the other. The nifties are set up equally by calling the same methods, just the input *.xml is different.

The xml are as following: (I removed some unnecessary parts, as the xml is really large^^)

Attributes thingy:
[xml]<?xml version="1.0" encoding="UTF-8"?>


















































[/xml]

Chat:
[xml]<?xml version="1.0" encoding="UTF-8"?>































[/xml]

Both are using the Interface/fonts/Verdana_12.fnt. The nifties are created by calling: (First, the attributes thing, then the chat window)
[java]public Nifty createNifty(String filePath){
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(mainApplication.getAssetManager(), mainApplication.getInputManager(), mainApplication.getAudioRenderer(), mainApplication.getGuiViewPort(), 2048, 2048);
viewPort.addProcessor(niftyDisplay);
Nifty nifty = niftyDisplay.getNifty();
nifty.addXml(filePath);
goToScreen(nifty, “start”);
runningNifties.add(nifty);
return nifty;
}[/java]

Do you have any clues why it doesn’t work with the new renderer? Maybe it is related to the fact, that I use two nifties?

EDIT: I tried only using the attributes-window-nifty (so the chat nifty is never created) and the problem is still there - So I guess, it has to be related to the xml file.

It seems the nifty is using my font Interface/fonts/Verdana_18.fnt in the attributes-window. oO
Also, if I let the <text id=“player_name” …/> use the Verdana_18 font, the rest of the attributes-text-elements seem to work again and use the Verdana_12 font (and even the player_name text element is using a mix between 18 and 12):

I highly assume there is some bug inside the new nifty renderer related to font-caching… Otherwise I couldn’t explain this behaviour. Very strange…

EDIT: Yeah, I can insert a dummy screen that is never called in front of my start-screen like this:
[xml]




[/xml]

Then, it seems to use the right fonts in the attributes-window (Verdana_12 in all of them):

EDIT2: But if using this “dummy” screen, text fonts in the layers under the attributes-window-layer are messed up (Verdana_18 declared, Verdana_12 used)… I guess, finding a workaround isn’t worth the time. :smiley: