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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:11:25+00:00 2026-06-07T19:11:25+00:00

I am attempting to change the default font for the Slick Graphics API to

  • 0

I am attempting to change the default font for the Slick Graphics API to simply draw the title of a game I’m writing, but I can’t seem to get it to work (it doesn’t draw anything, just leaving the screen blank). I want to use one of the standard Java fonts (Verdana).

Here is the code I am using to set the font:

import java.awt.Font;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.UnicodeFont;

public class Controller extends BasicGame {
UnicodeFont uFont;

@Override
public void render(GameContainer container, Graphics g) throws SlickException {
    g.setFont(uFont);
    g.setColor(Color.white);
    g.drawString("Hello World!", 50, 50);
}

@Override
public void init(GameContainer container) throws SlickException {
    //Set font
    Font font = new Font("Serif", Font.PLAIN, 20);
    uFont = new UnicodeFont(font, font.getSize(), font.isBold(), font.isItalic());
}

/**
 * @param args
 * @throws SlickException 
 */
public static void main(String[] args) throws SlickException {
    //Set up application
    Controller c = new Controller("Tetris");
    AppGameContainer app = new AppGameContainer(c);
    app.setDisplayMode(500, 800, false);

    //Start application
    app.start();
}
}

After numerous attempts myself, I’m using the code found at the bottom of this website:

http://slick.javaunlimited.net/viewtopic.php?t=3508

My question is: how can I change the default font in Slick, and draw text in that font to the screen for the title of my game.

  • 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-07T19:11:26+00:00Added an answer on June 7, 2026 at 7:11 pm

    Slick-Util uses Java’s built in Font support to load the fonts.You can use either the default built in java fonts or load external ttf files.

    The fonts are stored and drawn through slick’s TrueTypeFont class.

    See this code from ninjacave:

    TrueTypeFont font;
    TrueTypeFont font2;
    
    public void init() {
        // load a default java font
        Font awtFont = new Font("Times New Roman", Font.BOLD, 24);
        font = new TrueTypeFont(awtFont, false);
    
        // load font from a .ttf file
        try {
            InputStream inputStream = ResourceLoader.getResourceAsStream("myfont.ttf");
    
            Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
            awtFont2 = awtFont2.deriveFont(24f); // set font size
            font2 = new TrueTypeFont(awtFont2, false);
    
        } catch (Exception e) {
            e.printStackTrace();
        }   
    }
    

    For further detail look at these sites:

    http://ninjacave.com/slickutil1

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

Sidebar

Related Questions

Sorry but I can't seem to get my special-kid helmet off today. I'm attempting
I'm attempting to make a parallax page, but when I change the placeholder image
I'm attempting to change an icon shown on the option title ( .option-title )
Attempting to change the files folder location in a Drupal site from /files to
I'm attempting to change the style of a button using the :checked and :unchecked
I'm attempting to change the screen brightness from withing a service, like so: android.provider.Settings.System.putInt(getContentResolver(),
I'm attempting to just change the background colour of a webpage upon page load.
I'm attempting to use the #define directive to change all of ulong to unsigned
I'm attempting to debug a grails application and when I change controller code (method
I'm attempting to change the nil possibility of a boolean attribute on the existing

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.