How to Add Characters and Icons to the Font
Icons
Any icons specific to The Powder Toy are allocated from the private use area of unicode: U+E000 through U+F8FF. If you wish to add a new icon you should allocate it from that range.
Compiling the font editor
The data for the font is specified in data/font.cpp
but editing that file by hand is a bad idea. The TPT source comes with a graphical editor for this file.
To build the font editor with scons, just pass --font
to scons. This will produce an executable called font
or font64
. You will have to pass the path to data/font.cpp
to it as a commandline argument, e.g. build\font.exe data\font.cpp
or ./build/font data/font.cpp
If you're using a Visual Studio project then someone else should complete this guide for you... You can have some luck with configuring the preprocessor define FONTEDITOR
across the project...
Editing the font
After opening font.cpp
using the font editor you will be presented with a GUI. The top part contains the character currently being edited. Below you can select the unicode codepoint you're currently looking at (in hexadecimal, or using the arrows), make the character wider or narrower, create or delete the character, toggle the grid and the rulers (take a look at several uppercase and lowercase characters, characters with lower hooks and accents, to see how these rulers are used).
Below you can configure the foreground and background colors for the editor (sometimes useful for multi-colored icons). "Render" reflects your changes in the font editor program itself, and "Save" saves your changes into font.cpp
. On the bottom left there is a text field into which you can enter codepoints in hexadecimal, and they will be rendered on the bottom right, this is to test what they look like among other text.
The font editor also supports some key bindings: Left and Right to switch between characters; Shift-Left, Right, Up, Down to shift the current character by 1 pixel in either direction; C to copy the current character and V to paste; Q to exit.
Once you're done with editing the font press "Save" and exit. This will update font.cpp
so next time you compile TPT it will include your changes to the font.
Menu Icons
Defines for the menu sections are located in simulation/SimulationData.h
. Take a look at LoadMenus()
in simulation/SimulationData.cpp
. The first column is the unicode codepoint for the icon, the second column is the menu name. These are what you need to edit to create a new menu.