Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:18:35+00:00 2026-06-17T21:18:35+00:00

I’ve been using nifty GUI with lwjgl, and its been working great, but I

  • 0

I’ve been using nifty GUI with lwjgl, and its been working great, but I can’t figure out how to get it to use fonts I’ve provided it; it only seems to be able to render the default fonts. I’ve added the folder with my .fnt files to the runtime classpath (via eclipse), and this makes it so that no “resource not found” exception occurs, but when I run the program, any text fields using my font don’t render.

Here’s the source code, it renders two text fields in the upper left corner and 2 white shapes in the center. the textfield on the right won’t render unless I use the default font.

package game;
import static org.lwjgl.opengl.GL11.*;

import org.lwjgl.opengl.*;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.builder.TextBuilder;
import de.lessvoid.nifty.nulldevice.NullSoundDevice;
import de.lessvoid.nifty.renderer.lwjgl.input.LwjglInputSystem;
import de.lessvoid.nifty.renderer.lwjgl.render.LwjglRenderDevice;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.tools.TimeProvider;

public class NiftyWontUseMyFont {
    private Nifty nifty;
    private Screen screen;
    private float[] WINDOW_DIMENSIONS = {640,480};
    public NiftyWontUseMyFont() throws Exception{
            //init display
            Display.setDisplayMode(new DisplayMode(640,480));
            Display.create();

            //init nifty gui
              LwjglInputSystem inputSystem = new LwjglInputSystem();
              inputSystem.startup();
              nifty = new Nifty(
                new LwjglRenderDevice(),
              new NullSoundDevice(),
                inputSystem,
              new TimeProvider());
            // load default styles
            nifty.loadStyleFile("nifty-default-styles.xml");
            // load standard controls
            nifty.loadControlFile("nifty-default-controls.xml");
            screen = new ScreenBuilder("start") {{
                  layer(new LayerBuilder("baseLayer") {{
                    childLayoutHorizontal();
                    text(new TextBuilder("test"){{
                        font("aurulent-sans-16.fnt");
                        color("#f00f");
                        backgroundColor("#33af");
                        text("l33t");
                    }});
                    text(new TextBuilder("test2"){{
                        font("16-Jackash.fnt");//doesn't work with this external font
//                      font("aurulent-sans-16.fnt");//works with the default font
                        color("#f00f");
                        backgroundColor("#33af");
                        text("l33t");
                    }});
                  }});
                }}.build(nifty);
                nifty.gotoScreen("start");

        //init opengl
                glDisable(GL_DEPTH_TEST);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,640,480,0,1,-1);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glViewport(0,0,640,480);
        glPushMatrix();

        glPopMatrix();
        while(!Display.isCloseRequested())
        {
            //render

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glBegin(GL_QUADS);
            glTexCoord2f(0,0);glVertex2i(400,400); //Upper left
            glTexCoord2f(1,0);glVertex2i(450,400);//upper right
            glTexCoord2f(1,1);glVertex2i(450,450);//bottom right
            glTexCoord2f(0,1);glVertex2i(400,450);//bottom left 
            glEnd();

            glBegin(GL_LINES);
                glVertex2i(100,100);
                glVertex2i(200,200);
            glEnd();

            nifty.update();

            glPushMatrix();
            glPushAttrib(GL_ALL_ATTRIB_BITS);
            nifty.render(false);
            glPopAttrib();
            glPopMatrix();
            Display.update();
            Display.sync(60);
        }
        Display.destroy();
    }
    public static void main(String[] args) throws Exception {
        new NiftyWontUseMyFont();

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:18:36+00:00Added an answer on June 17, 2026 at 9:18 pm

    Your example works for me when I add a fnt with that name to my classpath. I’m using maven and I’ve just put the .fnt into src/main/resources. When you specify the font name Nifty expects it to be accessible either in the filesystem relative to the current directory OR at the root at the classpath as a classpath resource.

    There is nothing special going on. You can inspect the class that loads the resources here

    However, there might be a problem with your .fnt file. How did you create that file? And usually you need the corresponding .png or .tga in the same position as your .fnt AND there is a reference inside the .fnt to the actual image file which Nifty reads. Maybe Nifty can find the .fnt but not the actual image resource?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to understand how to use SyndicationItem to display feed which is
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.