Redefining The System Font

All the characters in the system font are defined on an eight-by-eight grid, like this :

Now, on the Beeb, you could only change the definition of characters 224 to 255 inclusive, but on RISC OS you may change the lot. This is often used (for example) as an easy way of adding a more space-age look to an arcade game, or for a distinctive font for an adventure game. You might find it useful to produce a more plain font if you have poor eyesight.

Eight bytes are required to describe a character - one for each line. Each line is calculated by adding the values of each column that is used, as shown by this example :

To change the definition of character, the easiest way is :

VDU 23, <ASCII code>, <line 1>, <line 2>, ... <line 8>

So, as a simple example, the following line will turn the space character into a solid block :

VDU 23,32,255,255,255,255,255,255,255,255

To see the messy results, type something like *SHOW.

Reading the font


It's possible to read the current definition of a character, using OS_Word 10. The following program illustrates this :

DIM block% 16

block%?0=ASC("R")
SYS "OS_Word",10,block%

FOR K%=1 TO 8
  line%=block%?K%
  FOR B%=7 TO 0 STEP -1
    IF (line% AND (1<<B%)) THEN PRINT "#"; ELSE PRINT ".";
  NEXT
  PRINT " (";line%;")"
NEXT

This allocates a small chunk of memory to store the results in (you only need 9 bytes, in fact). The ASCII value of the character is poked into the first byte (byte 0), then OS_Word 10 is called. On exit, the block contains the eight bytes of the characters definition, stored in bytes 1 to 8. The rest of the program (after the OS_Word call) just shows these values in a meaningful way.

When run, this produces :

.#####.. (124)
.##..##. (102)
.##..##. (102)
.#####.. (124)
.##.##.. (108)
.##..##. (102)
.##..##. (102)
........ (0)

Resetting the font definition


Your font changes will stick until the next hard reset, or until another program changes them again. But if you'd like to reset the font to the defaults, use:

SYS "OS_Byte",20


Contributor: Kris Adcock