UI and Fonts
Make a palette-locked 9-slice UI kit with a Godot 4 theme, and export the built-in pixel font as a BMFont any engine can load.
One command writes a UI kit: a dialog box, a panel, a button in all its states, an inventory slot and a health bar, as 9-slice pieces in your palette, plus a Godot 4 theme that styles the built-in controls with them. Another writes Mode 8's pixel font as a BMFont. Both run on the CPU, need no GPU, and give the same pixels every time.

Make a UI kit#
Inside a project, the kit uses the project's palette. Make an empty project to try it:
$ mode8 init my-game
✓ Created project my-game/
palette nes_crimson_hero · new assets 64x72 · ComfyUI http://127.0.0.1:8188
Next:
cd my-game
mode8 draft knight_right --out drafts/hero.png
mode8 studio .
mode8 doctor # check the local AI setup for mode8 gen
$ cd my-game
$ mode8 ui --out-dir exports/ui --sheet shots/ui.png
✓ UI kit (bevel): 31 pieces → exports/ui/
dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
Godot theme exports/ui/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)
palette nes_crimson_hero from mode8.toml
Next:
mode8 verify --assets-dir exports/uiThat is the whole kit in the default bevel style: 9 pieces, their Godot styleboxes, a theme, a health bar scene and the theme's font. --sheet also writes a labeled, zoomed contact sheet of every piece for review.

Choose a style#
--style picks the look. Each style draws its pieces from named material ramps of the palette, so a kit always matches the rest of your art:
| Style | Body | Accent | Looks like |
|---|---|---|---|
bevel | metal | gold | raised steel plates with a gold rim (the default) |
flat | neutral | water | flat panels with a thin border, no bevel |
rounded | wood | gold | warm wood with rounded corners |
scifi | tech | energy | hull panels with cut corners and a glowing edge |
The health bar fill is the palette's blood ramp in every style.
$ mode8 ui --out-dir exports/ui-scifi --style scifi --palette cyberpunk_neon
✓ UI kit (scifi): 31 pieces → exports/ui-scifi/
dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
Godot theme exports/ui-scifi/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)
Next:
mode8 verify --assets-dir exports/ui-scifi--palette overrides the project's palette for one kit. Outside a project, always pass one.
Pick the pieces#
--kinds takes a comma-separated list of dialog_box, panel, button, slot_frame and health_bar (the default is all of them). button writes four states, normal, hover, pressed and disabled, plus a focus ring; health_bar writes its frame and its fill. --size sets one size for every piece you ask for:
$ mode8 ui --out-dir exports/hud --kinds button,health_bar --size 64x16
✓ UI kit (bevel): 6 pieces → exports/hud/
button_normal, button_hover, button_pressed, button_disabled, health_bar_frame, health_bar_fill
Godot theme exports/hud/ui_theme.tres (font size 9, a white tint mask; health bar scene)
palette nes_crimson_hero from mode8.toml
Next:
mode8 verify --assets-dir exports/hudWithout --size, each kind has its own: dialog box 48x32, panel 32x32, button 32x16, slot frame 24x24, health bar 48x10. A 9-slice piece stretches to any size in the engine, so the default sizes are usually what you want.
Change the materials#
Each style fills three slots: body, accent and bar. --materials swaps the material a slot uses, for a stone and gold kit for a castle, say. mode8 list materials names every material a palette can declare:
$ mode8 ui --out-dir exports/ui-stone --materials body=stone,accent=gold
✓ UI kit (bevel): 31 pieces → exports/ui-stone/
dialog_box, panel, button_normal, button_hover, button_pressed, button_disabled, +25 more
Godot theme exports/ui-stone/ui_theme.tres (font size 9, a white tint mask; health bar, preview scene)
palette nes_crimson_hero from mode8.toml
Next:
mode8 verify --assets-dir exports/ui-stoneWhat gets written#
$ ls exports/ui
ui_button_disabled.png
ui_button_disabled_stylebox.tres
ui_button_focus_stylebox.tres
ui_button_hover.png
ui_button_hover_stylebox.tres
ui_button_normal.png
ui_button_normal_stylebox.tres
ui_button_pressed.png
ui_button_pressed_stylebox.tres
ui_checkbox_checked.png
ui_checkbox_checked_disabled.png
ui_checkbox_checked_disabled_texture.tresShow 58 more lines
ui_checkbox_checked_hover.png
ui_checkbox_checked_hover_texture.tres
ui_checkbox_checked_texture.tres
ui_checkbox_empty.tres
ui_checkbox_radio_checked.png
ui_checkbox_radio_checked_disabled.png
ui_checkbox_radio_checked_disabled_texture.tres
ui_checkbox_radio_checked_texture.tres
ui_checkbox_radio_unchecked.png
ui_checkbox_radio_unchecked_disabled.png
ui_checkbox_radio_unchecked_disabled_texture.tres
ui_checkbox_radio_unchecked_texture.tres
ui_checkbox_unchecked.png
ui_checkbox_unchecked_disabled.png
ui_checkbox_unchecked_disabled_texture.tres
ui_checkbox_unchecked_hover.png
ui_checkbox_unchecked_hover_texture.tres
ui_checkbox_unchecked_texture.tres
ui_cursor.png
ui_cursor_texture.tres
ui_dialog_box.png
ui_dialog_box_stylebox.tres
ui_font.fnt
ui_font.png
ui_health_bar.tscn
ui_health_bar_fill.png
ui_health_bar_fill_stylebox.tres
ui_health_bar_frame.png
ui_health_bar_frame_stylebox.tres
ui_panel.png
ui_panel_stylebox.tres
ui_preview.tscn
ui_slider_fill.png
ui_slider_fill_hover.png
ui_slider_fill_hover_stylebox.tres
ui_slider_fill_stylebox.tres
ui_slider_grabber.png
ui_slider_grabber_disabled.png
ui_slider_grabber_disabled_texture.tres
ui_slider_grabber_hover.png
ui_slider_grabber_hover_texture.tres
ui_slider_grabber_texture.tres
ui_slider_track.png
ui_slider_track_stylebox.tres
ui_slot_frame.png
ui_slot_frame_stylebox.tres
ui_tab_disabled.png
ui_tab_disabled_stylebox.tres
ui_tab_hover.png
ui_tab_hover_stylebox.tres
ui_tab_selected.png
ui_tab_selected_stylebox.tres
ui_tab_unselected.png
ui_tab_unselected_stylebox.tres
ui_theme.tres
ui_tooltip.png
ui_tooltip_stylebox.tres
ui_ui.jsonWith the default --name ui:
| File | What it is |
|---|---|
ui_<piece>.png | one PNG per piece, in the palette |
ui_<piece>_stylebox.tres | a Godot 4 StyleBoxTexture per piece: its 9-slice margins, content margins and a nearest-filtered texture |
ui_button_focus_stylebox.tres | the keyboard focus ring for buttons |
ui_theme.tres | a Godot 4 Theme that wires the styleboxes and the font into the built-in controls |
ui_health_bar.tscn | a ready ProgressBar scene that uses the theme |
ui_font.fnt, ui_font.png | the theme's font (see Fonts) |
ui_ui.json | every piece's size, 9-slice margins, content insets and min_size, for other engines |
margins are the pixels on each side that never stretch. content is where text and child controls sit inside the frame. --formats png,json,godot limits the outputs, for example to png,json when you are not using Godot.
Every piece is checked against the palette as it is written. A piece that fails makes the command exit 1; mode8 verify --assets-dir exports/ui checks the whole folder again later.
Use it in Godot 4#
Copy the folder anywhere under your Godot project: the resources point at their PNGs by paths relative to themselves. Then give a Control the theme, and every Panel, PanelContainer, PopupPanel, AcceptDialog, Button and ProgressBar under it picks the kit up:
$HUD.theme = load("res://ui/ui_theme.tres")
$HUD/Dialog.theme_type_variation = &"DialogBox" # a PanelContainer drawn as the dialog box
$HUD/Slot.theme_type_variation = &"SlotFrame" # a PanelContainer drawn as an inventory slotOr instance ui_health_bar.tscn for a health bar that is already themed. The theme sets the font at size 9, which draws the pixel font 1:1. The font in a kit is white, and the theme colors it: label and button text in a light color of the palette, disabled text in a darker one.
If your project imports the kit under a fixed folder and you want absolute paths, pass --godot-res-prefix res://ui.
Tip
Every starter already ships a full kit in godot/art/ui/ and one project asset per piece (assets/ui_panel/ and so on), so you can start by painting over those in the Studio.
Re-export a piece you edited#
A generated piece is a starting point. Paint over it in the Studio or any editor, then hand it back with --source and its 9-slice margins (left, top, right, bottom). Name the piece in --kinds, such as panel, or one button state such as button_hover:
$ mode8 ui --out-dir exports/ui --source exports/ui/ui_panel.png --kinds panel --margins 4,4,4,4
✓ UI kit: 1 piece → exports/ui/
panel
Next:
mode8 verify --assets-dir exports/uiThe re-export checks the piece, rewrites its stylebox with the new margins (the theme points at that file, so Godot picks up the change), and writes the piece's metadata to ui_panel_ui.json. It keeps your PNG's size and look, so --style and --size do not apply. Forgetting --margins is an input error:
$ mode8 ui --out-dir exports/ui --source exports/ui/ui_panel.png --kinds panel
error: --source needs --margins L,T,R,B (the 9-slice borders of the hand-edited piece)
e.g. mode8 ui --source edits/panel.png --kinds panel --margins 4,4,4,4 --out-dir exports/uiFonts#
Mode 8 has one built-in pixel font: 95 printable ASCII glyphs on a 5x9 grid, with 7 px capitals and 2 px descenders, proportional by default with digits of equal width. mode8 font writes it as an AngelCode BMFont: a .fnt description and a PNG atlas.
$ mode8 font --out-dir exports/font
✓ Bitmap font: 191 glyphs, line height 11 → exports/font/
exports/font/font.fnt · exports/font/font.png
proportional · Latin-1 · 1132 kerning pairs · Godot font size 9 draws it 1:1
The .fnt names its PNG by file name, so keep the two files together. font_font.json describes the same glyphs as JSON. --formats png,fnt skips the JSON.
Style it#
The glyphs are white by default. --color sets another color, --outline adds a 1 px outline and --shadow a drop shadow. --scale draws the font at an integer multiple, 1 to 16, so the pixels stay square:
$ mode8 font --out-dir exports/font-title --name title --color '#f8e8b0' --outline '#000000' --shadow '#3a1c28' --scale 2
✓ Bitmap font title: 191 glyphs, line height 22 → exports/font-title/
exports/font-title/title.fnt · exports/font-title/title.png
proportional · Latin-1 · 1132 kerning pairs · Godot font size 18 draws it 1:1Quote the colors: # starts a comment in most shells. --mono gives every glyph the same advance, for score counters and tables:
$ mode8 font --out-dir exports/font-mono --mono
✓ Bitmap font: 191 glyphs, line height 11 → exports/font-mono/
exports/font-mono/font.fnt · exports/font-mono/font.png
monospaced · Latin-1 · Godot font size 9 draws it 1:1Load it in Godot 4#
Godot 4 imports a .fnt file as a FontFile. Use it at the size the summary names (9 at --scale 1, 18 at --scale 2) and it draws 1:1:
var font := load("res://font/font.fnt")
$Score.add_theme_font_override("font", font)
$Score.add_theme_font_size_override("font_size", 9)PixiJS and LÖVE read the same BMFont text format. Whatever the engine, give the atlas a nearest-neighbor filter so it is never smoothed.