Spectrum Fonts
Text on the Spectrum is drawn from an 8×8 character set held in ROM. The whole font can be replaced by pointing one system variable at your own table in RAM, and a block of user-defined graphics gives extra shapes for games.
Overview
Each character is an 8×8 cell, exactly the size of one attribute cell, so text and colour share the same grid. A character is eight bytes, one per pixel row, the top bit leftmost. The Spectrum prints characters by copying these eight bytes into the display file, so a redefined font changes every printed character with no extra cost.
Character format
A glyph is eight consecutive bytes. The first byte is the top row of the character, the last byte the bottom row. In each byte a set bit is an ink pixel and the most significant bit is the leftmost pixel.
| Byte | Row | Bits (bit 7 = left) |
|---|---|---|
| 0 | Top | 8 pixels of row 0 |
| 1–6 | Middle | rows 1 to 6 |
| 7 | Bottom | 8 pixels of row 7 |
Most ROM glyphs leave the top row and the rightmost column blank, so characters have built-in spacing when printed side by side.
The ROM font
The built-in font lives in ROM at address 15616 (0x3D00). It holds the 96 printable characters of the code range 32 to 127, from space to the copyright symbol, at eight bytes each. Because it is in ROM you can read and copy it but not change it in place; to alter the font you copy it to RAM and edit there.
Redefining the font
The system variable CHARS, a two-byte pointer at address 23606, tells the ROM print routine where the font is. It normally holds 15360, which is 256 below the real font, because the routine adds the character code times eight and codes start at 32. Point CHARS at your own 768-byte table (96 characters × 8 bytes), biased the same way, and every printed character switches to your font at once.
| System variable | Address | Meaning |
|---|---|---|
| CHARS | 23606 (0x5C36) | Font base minus 256; add code × 8 for a glyph. |
User-defined graphics
The Spectrum reserves a small block for user-defined graphics, the 21 characters A to U reached in BASIC as graphics-mode letters. Their base is held in the UDG system variable at 23675, and each is the same eight-byte format. Games use these for extra shapes such as a player, a wall tile or a border piece without replacing the main font. Larger character sets simply define a full redefined font as above and treat chosen codes as tiles.
| System variable | Address | Meaning |
|---|---|---|
| UDG | 23675 (0x5C7B) | Base of the 21 user-defined graphics, 8 bytes each. |