-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Fonts
SpiDrone edited this page Jul 22, 2026
·
1 revision
Adding a custom font for use with drawCustomFont() is uber simple.
Drop your .ttf into assets/<modid>/font/, and put a .json definition right next to it in the same folder:
assets/spis_ui_api/font/boldpixels.ttf
assets/spis_ui_api/font/boldpixels.json
{
"providers": [
{
"type": "ttf",
"file": "spis_ui_api:boldpixels.ttf",
"shift": [0.0, 0.0],
"size": 16.0,
"oversample": 2.0
}
]
}A few notes on the fields:
-
fileis relative to thefontfolder itself, not your namespace root — so it's justmodid:filename.ttf, notmodid:font/filename.ttf. -
sizecontrols the internal glyph resolution Minecraft renders at, not the final size on screen. -
oversamplesharpens the glyphs at small sizes.2.0is a safe default; bump it higher if the font looks blurry in-game.
That's the entire registration step.
Minecraft scans every font/*.json on resource reload, no extra setup needed.
The font's ID is just its namespace plus filename:
public static final ResourceLocation BOLD_PIXELS_FONT =
ResourceLocation.fromNamespaceAndPath("spis_ui_api", "boldpixels");Pass that into any drawCustomFont call and you're done:
UIGraphicsHelper.drawCustomFont(graphics, BOLD_PIXELS_FONT, "Hello!", x, y, 0xFFFFFFFF, false);If your text renders as empty boxes (tofu), check the following.
-
Is the
.jsonactually inside a folder namedfont? Notfonts, not anything else. Minecraft only scans that exact folder name. -
Does the
filepath in the json match the real filename, casing included?BoldPixels.ttfandboldpixels.ttfare not the same file on a case-sensitive lookup.