javafontsassetsnifty-gui

How do I tell nifty GUI where my fonts files are?


I'm tired of using the default fonts bundled in the default style jar, so I figured it'd be as easy as downloading some bitmap font files and specifying which one I wanted to use by there path relative to the workspace.

e.g.

//inside of a ScreenBuilder init
//...
control(new LabelBuilder("score"){{
    alignCenter();
    font("font/13-Nimbus.fnt");
    color("#f00f");
    backgroundColor("#3300af");
    text("foobar");
    width((wGUI/3-10)+"px");
    height((hGUI-10)+"px");
}});

Unfortunately this gives me the following error:

java.lang.RuntimeException: Resource not found: font/13-Nimbus.fnt at de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader.getResourceAsStream(NiftyResourceLoader.java:72) ...

So this leads me to believe there is some of add-resource-location function I should be calling to tell nifty where my fonts are. But after looking through the Javadoc I can't find any such function.


Solution

  • Make sure that font/13-Nimbus.fnt is in your classpath. The way we've set it up it an assets source directory that contains font/etc.fnt