Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

21. November 2014


In the last video tutorial we used a graphic instead of text to create a Hello World.  This is because drawing text is actually a multi step process in LibGDX and not really appropriate for a first tutorial.  It is however perfect for a second tutorial, so here we are! ;)


In this video we explore the difference between TTF and Bitmap fonts, show how to run the Hiero font generation tool in both Eclipse and IntelliJ IDEA then create and save a bitmap font.  We then explore the code needed to show a bitmap font on screen, including how to measure the results, apply color and text justification.


The video is available in up to 1080P on YouTube by clicking here.


The source code:

Initial Example – Loading a font and drawing text:

package com.gamefromscratch;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;

public class gdxtext extends ApplicationAdapter {
   SpriteBatch batch;
    BitmapFont font;

   public void create () {
      batch = new SpriteBatch();
        font = new BitmapFont(Gdx.files.internal("Papy.fnt"));

   public void render () {, 0, 0, 1);;

        //Example One -- Drawing Text
        font.draw(batch,"Hello World",,;



Example 2 – Measuring and centering text:

BitmapFont.TextBounds bounds = font.getBounds("Hello World");
font.draw(batch,"Hello World", - bounds.width/2, + bounds.height/2);

Example 3 – Multi-line Text

String debugString = "I took one, one cause you left me\n"
           + "Two, two for my family\n"
           + "Three, three for my heartache\n"
           + "Four, four for my headaches\n"
           + "Five, five for my sorrow\n";
   BitmapFont.TextBounds bounds = font.getMultiLineBounds(debugString);


Example 4 -- Center justified text in the colour purple

   + bounds.height/2,

Programming , , ,

blog comments powered by Disqus

Month List

Popular Comments

New AMD VR Headset Announced – Sulon Q
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

15. 三月 2016


VR is hot right now but also insanely expensive.  Right now we can choose between the Oculus Rift, GearVR, HTC Vive, Google Cardboard and PlayStation VR is coming soon.  Except the GearVR every single one of those headsets have the same problems... they are expensive and have to be tethered to a device to work.  The AMD Sulon Q looks to change that by including all of the processing power in the unit.  We need to wait and see what happens with the price tag.

More details from

Sulon Q looks to be a powerful bit of kit, too. The device is based around an AMD FX-8800P processor, a system-on-chip boasting quad-core CPU and octo-core GPU abilities. The 12 total cores share memory to boost performce, AMDclaims. It supports "the latest graphics APIs including DirectX 12 and Vulkan", and promises console-quality visuals on a 2560x1440 OLED display.

When it comes to AR, it offers a 110° field-of-view, and operates similarly to Hololens. You'll be able to 'hang' application windows in your real-world environment, control opacity, and control them with gestures. The Sulon Q will also come with a wireless keyboard and mouse for more conventional office input.

In many ways, the Sulon Q is shaping up like a powerful laptop for your face. It will ship with Windows 10 pre-installed, have built-in WiFi and Bluetooth 4.0, two USB 3.0 Type A ports, and a Micro HDMI out port. Although it has to combat the years of build-up and excitement surrounding Oculus Rift and even Sony's PlayStation VR, it potentially has advantages in portability and power, while removing the question mark over whether your PC is powerful enough to actually run VR content.


Right now I still hold that the first one that comes to market at a good price point wins, like VHS vs Beta all over again.   That said building a powerful computer into the device could also be a winning combination.  Name sucks though.

GameDev News

blog comments powered by Disqus

Month List

Popular Comments