Problem with loading font


I’m trying create text space in nifty:
[java] <panel id=“mapNamePanel” height=“50” width =“200” childLayout=“center”>
<text font=“SegoeUISemibold.fnt” text=“Map: ${PROP.MAP}”></text>

Here’s my file:

I get error:[java]java.lang.RuntimeException: com.jme3.asset.AssetNotFoundException: SegoeUISemibold.fnt[/java],

Also, how can I set String value in my java class, and later get it from nifty? because I don’t know should I use normal String or somehow nifty property?

<text font=”SegoeUISemibold.fnt” text=”Map: ${PROP.MAP}”></text>

should be

<text font=”Interface/SegoeUISemibold.fnt” text=”Map: ${PROP.MAP}”></text>

Shouldn’t it?

EDIT: Can’t answer your second question because I don’t use Nifty… sorry.

Oh yea. Thought if GUI.xml is in same folder it will read correctly.

@Skatty said: Oh yea. Thought if GUI.xml is in same folder it will read correctly.

Did this stop the error? I’m assuming yes, because the error looks as if it was thrown by JME’s asset manager.

Yes it work. But now need some help with that variables

1 Like

About variables , I guess you are referencing to this attribute in your xml : text=”Map: ${PROP.MAP}" right ? . If yes you just need to set a global variable in your nifty instance , calling this method
Properties properties = new Properties();
properties.setProperty(“MAP”, “whateveryouwant”);

I believe that you must call this before you read from your xml but I’m not sure . Notice that Properties is a java.util class and you can also store them in a file . Here an example . Also you have an other choice to set a String in your xml : use a method the returns your property in your screen controller and then in xml :
<panel id=”mapNamePanel” height=”50″ width =”200″ childLayout=”center”>
<text font=”SegoeUISemibold.fnt” text=”Map: ${CALL.yourmethod()}”></text>
Here you have a bit more flexibility . :slight_smile:

[java]Properties properties = new Properties();
properties.setProperty(“MAP”, “Current Location: Le Tholonet”);
nifty = niftyDisplay.getNifty();

but doesn’t work. it print me ${PROP.MAP}

Just tried with the last sdk and it works… here is my code and xml:
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,

        nifty = niftyDisplay.getNifty();
        Properties prop = new Properties();
        prop.setProperty("MAP", "try");
        nifty.fromXml("Interface/ex.xml", "start", this);[/java] 

<useControls filename=“nifty-default-controls.xml”/>
<useStyles filename=“nifty-default-styles.xml”/>
<screen id=“start” controller=“mygame.Main”>
<layer id=“layer” backgroundColor="#000f" childLayout=“center”>
<control name=“label” syle="nifty-label"text=“Hello World : ${PROP.MAP}” />

Can you provide a runnuble example of this problem ? :slight_smile:

1 Like

Oh, I was using <text> not control. Thanks ! :slight_smile:

Well ,I’ve just tried also with <text> tag and it works … wired! But If now it works for you it’s just fine :smiley: