Libgdx Font Generator

Posted on  by
  1. Libgdx Font Generator App
  2. Libgdx Font Generator Software

Does anyone know how I can use a TTF font in libGDX? I have looked around and have seen things about StbTrueTypeFont but it doesn't seem to be in the latest release. BitmapFont font12 = generator.generateFont(parameter); // font size 12 pixels generator.dispose; // don't forget to dispose to avoid memory leaks! And put myfont.ttf in core. Last Year I finished my 3 player split screen 3D RPG adventure using LibGDX as glue to all the openGL calls. I wrote my own vertex, VBO, VAO and rendering classes, (wanted to learn). LibGDX had a lot of the glue and Math/utility I didn't want to re-write. Objective Shows how to create a ParticleEffect, assign it to a Scene2D actor so that when that actor moves, the particle generator moves with it. Concepts used in the code Create a Stage and Image (See basic Image Sample) Create a Label using a Skin (See basic Label Sample) Create a TextButton (See basic Button Sample) Create.

Objective

Shows how to create a ParticleEffect, assign it to a Scene2D actor so that when that actor moves, the particle generator moves with it.

Concepts used in the code

  • Create a Stage and Image (See basic Image Sample)
  • Create a Label using a Skin (See basic Label Sample)
  • Create a TextButton (See basic Button Sample)
  • Create a Screen (See Screen Sample)

Libgdx Font Generator App

Particle effect is created using LibGDX’s Particle Effect editor.

Within the sample we create a stage, add the actors. The actors are added the particle effects and are drawn overriding the draw method.

Code

Full Code available for download here

Tutorial Objectives:

Showcase Label using BitmapFont, the “Gdx FreeType” extension and Skin

Introduction

Libgdx font generator software

A Label is one of the components available out of the box with LibGDX through the Scene2D Library.

The Label’s font can be :

  • Gdx FreeType: Extension that allow you to generate your BitmapFont on the fly. This is the most flexible to programatically. It gives you plenty of parameters to manipulate your font size, color, shadow… It would be your preferred approach for handling fonts butCarefull! You cannot use this if you target HTML. That is why it is not included by default when you create a LibGDX Project, the extension must be included by ticking the FreeType box within the Project creation tool.
  • BitmapFont: a graphical representation of a ttf font that can be generated by a tool such as Hierro. Bitmap Font do not scale very well (as it streches the image) but if you are going for a predefined resolution it works.
  • Skin: Equivalent on LibGDX to a CSS on HTML. Create your Label using style defined within your Skin. Download an existing Skin from sites such as czyzby’s gdx-skins repository or create your own using one on of the tool available on that site.

Libgdx Font Generator Software

For this tutorial it is assumed you have been through the Image basic tutorial.

Video

Code:

Code available for download or can be read below: