Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Imguimc Wiki › Guides › Load and Use Custom Fonts in ImGui Panels

Load and Use Custom Fonts in ImGui Panels

Adding TrueType Fonts

ImGuiMC includes built-in font loading for TrueType (.ttf) files. This lets you style your debug panels with custom typefaces instead of the default font.

Steps

1. Prepare your .ttf file — Obtain or create a TrueType font file and place it in an accessible location your mod can read.

2. Register the font — Use the mod's font event system to load your font file. Call the font loading function and pass the file path and desired size in pixels.

3. Push the font to ImGui — Before drawing text that should use your custom font, push it onto ImGui's font stack with the appropriate function.

4. Draw your text — Add labels, buttons, or other text elements. They will now render using your custom font.

5. Pop the font — After finishing text that uses the custom font, pop it from the stack to return to the default.

The mod handles TrueType parsing automatically, so you don't need to convert or pre-process fonts. Multiple fonts can be loaded and switched between in the same frame.