Font Editor
Pyxen includes a font editor for creating bitmap fonts on iPad and Mac that you can use with the Text component. Design crisp, pixel-perfect text for your games without any external tools.
How bitmap fonts work
A bitmap font in Pyxen is a font atlas — a single image containing every character, plus a JSON file describing where each glyph is located. When your game renders text, the engine looks up each character in the atlas and draws the corresponding region.
Creating a font
Choose File › New Asset… and pick Font. It is made from one of two:
- Pyxen’s Font: an 8-pixel font for every letter on a keyboard, ready at once.
- A Font File: a TrueType or OpenType file (
.ttfor.otf) that you choose. The file is kept in the project, so the font can be made again.
The font opens in the Font pane.
The Font pane
At the top, Try it draws a line you type with the font, on your game’s background, at the sizes the game draws it (1×, 2× and 4×). Below it are the font’s glyphs; pick one to edit it.
The side column sets up the font:
- Made from — what the font was made from. Choose a File… makes it again from a font file.
- Size — the pixel size to make it at, from 6 to 32 pixels.
- Characters — which characters the font holds: A–Z, 0–9 and signs (the default), Accents for the accented letters of European languages, and Used in my code for every character your scripts use. At least one stays on.
- Smooth edges — off keeps every pixel crisp, as a pixel font should be.
- Spacing — the Line height between lines of text, and the Baseline, where characters sit on the line.
- Glyph — the picked glyph’s Advance (how far the next character starts) and its Left and Top offsets.
- In code — the line that uses the font, and the atlas’s size.
Size, the characters and smooth edges change by making the font again, so they need its file. A font made from Pyxen’s Font, or from a font that isn’t on this device, shows them as words until you choose a file; its spacing and its glyphs stay editable.
Editing glyphs
The picked glyph opens on the canvas, in its line, with its baseline and advance drawn. Draw on it with the Pencil (B) and erase with the Eraser (E). Every change can be undone, and Try it shows it at once.
Using fonts in your game
Once you’ve created a font, use the Text component to render text:
label = world.spawn(text=Text("Score: 0", font="myfont"))
The font parameter matches the name of your .font.json asset (without the extension). If you omit it, Pyxen uses the built-in default font.
See the Text reference for the full API.
Used in Code in the pane’s bar lists the lines of your scripts that name this font; choose one to go to it.