Chapter 5. Working With Text
It is relatively easy to work with text in Impact. If you remember back to our default main class, we had removed an instance of font class from the game—but in this section, we are going to talk about adding it back in and how to customize text at runtime.
Creating Font Sprite Sheets
Since Impact renders all the graphics to the page’s Canvas tag, we
will not be able to use system fonts. Instead, Impact uses a special
sprite sheet for each font. Figure 5-1 is an example of the
default font 04b03.font.png, which
comes with the template project.
As you can see, all the font’s characters are laid out horizontally with one pixel line under each character, which defines the width of that character. Figure 5-2 is a close-up of a few characters from the sprite sheet.
All fonts you want to use in Impact must be set up in a similar way. Luckily, there is an online tool to help generate new font sprite sheets.

This tool allows you to select one of your system fonts and tweak its style, size, and thickness then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access