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 7787319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:37:35+00:00 2026-06-01T20:37:35+00:00

I’m having some problems displaying text on the screen, in the past I have

  • 0

I’m having some problems displaying text on the screen, in the past I have just used sprite based text, however this time I want to use UnicodeFont. TrueTypeFonts draw perfectly however its deprecated.

When I try to draw the UnicodeFont it seems to be affected by the characters I use. for example If I draw the string “stackoverflow” the text and the box will draw, if I try “stackoverflowcom” the box will not draw.

A barebones version of my source code is below. On line ~74 I call uniFont.drawString(0, 0,”stackoverflow”); , if the com (or anything really) the box will not be drawn.

edit. > You can use the boolean tryUnicode to swap between true and unicode.

Ive tried sticking them in to seperate display lists but it made no difference.

Could anyone offer an insight in to why this is happening?

Thanks

import java.awt.Font;

import org.lwjgl.LWJGLException;


import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;

import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.UnicodeFont;
import org.newdawn.slick.font.effects.ColorEffect;



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


public class Game {


    private UnicodeFont uniFont;
    private TrueTypeFont truFont;

    public static void main(String[] argv) {    

        Game game = new Game();
        game.start(); 
    }



    public void start()
    {




        initGL(600, 600);
        initFonts();
        while(!Display.isCloseRequested()) //display not closed
        {
            render();
            Display.update();
            Display.sync(60);
        }
        Display.destroy();
        System.exit(0);

    }


    private void render()
    {

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

        glPushMatrix(); 
            glTranslatef(-0.25f,0.7f,0);
                glScalef(0.001f,-0.001f,0.001f);
                glEnable(GL_BLEND);
                boolean tryUnicode = false;
                if(tryUnicode)
                {
                    uniFont.drawString(0, 0,"stackoverflow");
                                            //EDIT.. glDisable texture is required here.
                }else
                {
                    glScalef(1.1f,1.1f,1f);
                    truFont.drawString(0, 0, "stackoverflow truFont");
                }
                glDisable(GL_BLEND);                    
        glPopMatrix();

        glPushMatrix();
            glTranslatef(-0.25f,0,0);
                glColor3f(0.5f, 0f, 0f);
                    glBegin(GL_TRIANGLE_STRIP); 
                        glVertex3f(0, 0,0.0f);
                        glVertex3f(0.5f, 0,0f);
                        glVertex3f(0f,0.5f,0f);
                        glVertex3f(0.5f, 0.5f,0f);
                    glEnd();
        glPopMatrix();
    }


    private void initGL(int width, int height) {
        try {
            Display.setDisplayMode(new DisplayMode(width,height));
            Display.create();
            //Display.setVSyncEnabled(true);
        } catch (LWJGLException e) {
            e.printStackTrace();
            System.exit(0);
        }

        glEnable(GL11.GL_TEXTURE_2D);
        glShadeModel(GL11.GL_SMOOTH);        
        glEnable(GL11.GL_DEPTH_TEST);
        glDisable(GL11.GL_LIGHTING);                    

        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);                
        glClearDepth(1);                                       

        glEnable(GL_BLEND);
        glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        glDisable(GL_BLEND);
        glMatrixMode(GL11.GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-1, 1, -1, 1, -1, 1);
        glMatrixMode(GL11.GL_MODELVIEW);

    }


    private void initFonts() {

        Font awtFont = new Font("", Font.PLAIN,55);
        truFont = new TrueTypeFont(awtFont, true); 

        uniFont = new UnicodeFont(awtFont, 128, false, false);
        uniFont.addAsciiGlyphs();
        uniFont.addGlyphs(400,600);           // Setting the unicode Range
        uniFont.getEffects().add(new ColorEffect(java.awt.Color.white));
        try {
            uniFont.loadGlyphs();
        } catch (SlickException e) {};


    }

}

  • 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-01T20:37:37+00:00Added an answer on June 1, 2026 at 8:37 pm

    It seems I have this error now, it will only draw the outlined rectangle before using the font. This seems to be a Slick error, and is a major problem so they should fix it before adding new features.
    The only work-around is to render fonts last on your frame.

    EDIT: Problem Solved!

    add this line after you render your font:

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    

    The Slick people should really add that line in as it causes so many bugs!

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

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.