Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
VGSources
Blog

How to Use TrueType Fonts in libGDX

Generate BitmapFont assets from TrueType files in libGDX with gdx-freetype, or use Hiero when you need pre-generated fonts or HTML5 support.
Length3 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use a TrueType font in libGDX, add the gdx-freetype extension and the native dependency for each supported target, then use FreeTypeFontGenerator to create a BitmapFont. The generated bitmap font is what you render in the game. For HTML5 builds, use a pre-generated bitmap font instead: the official libGDX documentation says gdx-freetype is not compatible with HTML5.

1. Add gdx-freetype to your project

The FreeType extension is not included by default. In an existing Gradle project, add the gdx-freetype core dependency and the matching gdx-freetype-platform native dependency for each target you build, using the same libGDX version as the rest of the project. Dependency coordinates and target-specific setup are documented in libGDX’s Gradle dependency guide. When creating a new project, you can select FreeType in the official project-generation tool.

As an Amazon Associate I earn from qualifying purchases.

Keep the extension and native dependencies aligned with the project’s libGDX version. Adding only the Java extension without the native libraries required by a target can prevent the font generator from working on that target.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Generate a BitmapFont from a TTF file

Place the font file in your game’s assets directory, for example assets/fonts/myfont.ttf. Then generate the bitmap font at the size you need:

FreeTypeFontGenerator generator = new FreeTypeFontGenerator(
    Gdx.files.internal("fonts/myfont.ttf")
);

FreeTypeFontGenerator.FreeTypeFontParameter parameter =
    new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 24; // size in pixels

BitmapFont font = generator.generateFont(parameter);
generator.dispose();

The resulting BitmapFont is the font to use with libGDX’s text-rendering APIs. The generator is only needed to create the font, so dispose of it after generation; dispose of the BitmapFont when the game no longer needs it. Avoid repeatedly creating generators without disposing of them. The gdx-freetype guide documents the generation options and cleanup pattern.

Choose the size and glyphs deliberately

parameter.size specifies the generated size in pixels. The font is rasterized into a bitmap atlas, so a small generated font scaled up substantially may look poor. If the display resolution or UI scale changes significantly, generate a more suitable size and dispose of the old font when it is no longer in use.

The parameter’s characters field lets you choose which glyphs to generate. Include the letters, numerals, punctuation, and symbols your game actually needs; generating a large character set uses more atlas space. The extension documentation notes limitations with large Asian character sets and that BitmapFont’s layout algorithms do not handle right-to-left scripts such as Arabic. A TTF containing the glyphs alone does not guarantee that the game will lay out every script correctly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Watch atlas and texture limits

Large font sizes or broad glyph sets may exceed the default texture page size. The extension guide describes using a custom PixmapPacker or FreeTypeFontGenerator.setMaxTextureSize when a larger page is needed. Keep the atlas size, glyph coverage, and target device constraints in mind when choosing the font parameters.

3. Load generated fonts with AssetManager

If the game uses AssetManager, register the FreeType generator loader and the FreeType font loader for the .ttf suffix, then load the font with a FreeTypeFontLoaderParameter. Set fontParameters.size to the desired pixel size and retrieve the generated BitmapFont from the manager after loading completes. The official asset-management guide covers the loader registration and parameter setup.

When loading the same source TTF at more than one size, give each generated font a unique AssetManager identifier. The identifiers represent separately generated assets, even though they originate from the same font file.

4. Choose runtime generation or a pre-generated font

Approach When it fits Trade-offs
Runtime generation with gdx-freetype Supported desktop, Android, or iOS targets where the game needs to generate a font from a TTF at runtime or use different sizes. Requires the extension and target-specific native dependencies; uses runtime rasterization and bitmap-atlas space. Official libGDX documentation says it is not compatible with HTML5.
Offline generation with Hiero Projects that prefer to package pre-generated bitmap-font assets instead of rasterizing TTFs at runtime. Requires producing the font assets ahead of time. Hiero exports AngelCode font files that libGDX can load as a BitmapFont.

Hiero is libGDX’s documented bitmap-font packing utility. Its FreeType rasterizer is documented as matching the output of runtime gdx-freetype generation. A pre-generated font is the practical route when HTML5 is a target, since the official docs state that gdx-freetype itself is incompatible with that platform. The extension page mentions a third-party gdx-freetype-gwt project, but its current maintenance and compatibility with current libGDX versions are not established here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Check font options and licensing

Beyond size and glyph selection, FreeType font parameters include options for color, borders, shadows, kerning, mipmaps, and texture filters. Consult the extension documentation for their behavior and use only the options your interface needs.

Check the TTF’s license before using or redistributing it with a game. The license attached to the font file—not libGDX—determines what uses and distribution are permitted.

Quick Recap

Bestseller No. 2
Bestseller No. 4
Bestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.