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.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
2000 True Type Fonts & 5000 Clip Art Images | $13.46 | Buy on Amazon |
| 2 |
|
Shareware Treasure Chest TrueType Display Fonts with Disk | $14.95 | Buy on Amazon |
| 3 |
|
Fonts & Encodings: From Advanced Typography to Unicode and Everything in Between | $59.99 | Buy on Amazon |
| 4 |
|
True Type Font Pack | $19.99 | Buy on Amazon |
| 5 |
|
The Windows 3.1 Font Book | $12.95 | Buy on Amazon |
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.
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:
#1 Best Overall
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.
Rank #2
- Used Book in Good Condition
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.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →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.
Rank #3
- Used Book in Good Condition
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.
Rank #4
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.
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.
Best Value
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
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.




