How to Create a Custom Font in Defold
Defold is a lean, powerful game engine — and one of the things developers appreciate about it is how much control it gives you over rendering, including typography. Whether you want pixel-perfect retro text, stylized UI headers, or multilingual support, creating a custom font in Defold is a core skill worth understanding properly.
What "Fonts" Mean in Defold
Defold doesn't use fonts the way a word processor does. Instead, it generates a font resource from a source file — typically a .ttf (TrueType Font) or .otf (OpenType Font) — and converts it into a texture atlas at build time. This means the font is essentially baked into a texture, which the engine then renders efficiently via its sprite-based pipeline.
This approach gives you fast rendering performance but introduces trade-offs around resolution, character set size, and memory — all of which become important as your project scales.
Step 1: Import Your Font File
Start by placing your .ttf or .otf file inside your Defold project directory. You can drop it anywhere in the asset folder structure — a /fonts subfolder is a clean convention.
Once the file is in the project, it will appear in the Assets panel in the Defold editor. Defold supports standard TrueType and OpenType formats, so most free or commercial font files you download from sources like Google Fonts will work without conversion.
Step 2: Create a Font Resource (.font File)
This is the step most beginners skip past too quickly. The font file (.ttf) is just the raw source — you need to create a Defold font resource that tells the engine how to render it.
To do this:
- Right-click in the Assets panel where you want to save the resource
- Select New → Font
- Name the file (e.g.,
my_font.font)
The .font file opens in the font editor, where you configure the key parameters.
Step 3: Configure the Font Properties 🎨
This is where the real customization happens. The font editor exposes several important settings:
| Property | What It Controls |
|---|---|
| Font | Path to your .ttf or .otf source file |
| Material | Shader used to render the font (default covers most cases) |
| Size | Rendered font size in pixels |
| Antialias | Smoothing applied to glyph edges (0 = off, 1 = on) |
| Alpha | Transparency of the rendered glyphs |
| Outline Width | Pixel width of glyph outlines (0 disables) |
| Shadow Blur | Softness of drop shadow |
| Shadow X / Y | Drop shadow offset |
| Extra Characters | Unicode characters beyond the default Latin set |
| Output Format | How the font texture is stored (TYPE_BITMAP, TYPE_DISTANCE_FIELD) |
Output Format is one of the most consequential decisions here. Bitmap fonts are baked at a specific size and look sharp at that size but blur or pixelate if scaled. Distance Field fonts use a signed distance field technique that allows smooth scaling at multiple sizes — useful for UI elements that appear at different resolutions or screen densities.
Step 4: Expand the Character Set When Needed
By default, Defold includes a standard set of Latin characters. If your game supports other languages — Cyrillic, Greek, accented European characters, CJK scripts — you need to explicitly add those code points.
Use the Extra Characters field to define additional Unicode ranges. For example, to include basic Cyrillic, you'd add the relevant Unicode block. Be aware that larger character sets increase the size of the generated font texture, which has memory implications on constrained platforms like mobile.
If you're building a game with dynamic language support, think carefully about how many fonts you're loading simultaneously and what character ranges each one needs.
Step 5: Assign the Font to a Label or GUI Node
Once your .font file is configured, you use it by:
- In a GUI scene: Select a text node, then set its Font property to your
.fontresource - In a Label component: Add a Label component to a game object and assign the font there
- Via script: You can swap fonts at runtime using
gui.set_font()for GUI nodes
The Label component is suited for in-world text — damage numbers, name tags, environmental text. The GUI system is better for HUD elements, menus, and UI overlays where you need layering, anchoring, and screen-relative positioning.
Variables That Affect Your Results 🖥️
Several factors determine how a custom font performs in practice:
- Target platform — mobile devices have tighter memory budgets and lower tolerance for large font textures
- Scaling behavior — if your UI scales across resolutions, distance field fonts are generally more forgiving than bitmap fonts
- Render pipeline — if you're using a custom material or shader, font rendering may behave differently than with the default material
- Script complexity — right-to-left scripts, ligatures, and complex glyph shaping are not natively supported in Defold's standard font pipeline; those cases require workarounds or external tools
- Character set size — the more glyphs included, the larger the generated texture; this has downstream effects on memory and load time
A developer shipping a pixel art RPG with a fixed resolution and English-only text has a very different set of trade-offs than one building a multilingual mobile puzzle game with adaptive UI.
Knowing how each of these variables applies to your specific project is what determines which font format, size, and configuration settings will actually serve you well.