How do I make custom TVout fonts?

I'm working on a cool clock display using the TVout library. So far it's going pretty good with the built-in fonts.

I mocked up what I want the interface to look like. Eventually it'll end up on a small 4:3 5" CRT.

Something like this...

The problem is, there's only a few fonts that come with the library. The font for the time needs to be bigger. The largest font in the library is 8x8. What I really need is probably 16x16, or maybe bigger. I've even lowered the resolution to 90x90. (Any lower and the AM/PM in the time wraps to the next line.)

There's a small blurb over at the TVout website that says you make fonts like this:

Fixed width fonts: The first 3 bytes must contain the width, height, and first defined character followed by the font definitions. For example the following is the header and first 2 characters from the 4x6 font definition.

4,6,32,
//space
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
//!
0b01000000,
0b01000000,
0b01000000,
0b00000000,
0b01000000,
0b00000000,

There must be a full definition for each character; in this case the width of 4 fits into a single byte and the height of 6 means there needs to 6 bytes per character. Since 32 is the first printing character for this font set anything before character 32 will be ignored.

Variable width fonts: These fonts are defined by having a width of 0, height, and first defined character. An example of a variable width font with a height of 6 and the first printing character being a space.

0,6,32,
//space
2,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
//!
3,
0b01000000,
0b01000000,
0b01000000,
0b00000000,
0b01000000,
0b00000000,

But it's not making any sense to me. How do you generate the "0b00000000, 0b00000000, 0b00000000, etc...." for each character?

Does anyone know how to generate the "code"?

You create a byte array, and pack the data as it tells you. Id recommend using PROGMEM also to avoid running out of memory.

PROGMEM const unsigned char my_custom_font[] = 
{
	4,   // character width, 4 means we only use 4 bits of each byte 
	6,   // character height, 6, means we need 6 bytes per character.
	32, // first character to map (32 is space bar)

	// character data starts here...
	// space
	0b00000000,  // top row  
	0b00000000,  // 2nd pixel row
	0b00000000,  // 3rd and so fourth ...
	0b00000000,
	0b00000000,
	0b00000000,

	// ! character
	0b01000000,  // top row  
	0b01000000,  // 2nd pixel row
	0b01000000,  // 3rd and so fourth ...
	0b00000000,
	0b01000000,
	0b00000000,
}

0b means value is in binary, allows us to see bits and we can visualise the character by looking where the 1's exist.

use 'select_font(my_custom_font)' to select your custom font.

As you can see from the wiki, you can also specify variable width, where you specify 0 in the header and precede each character definition with its width.

I am unsure if it supports fonts greater than 8 wide, as this would require more bits than there are in a byte.

ryemac3:
There's a small blurb over at the TVout website that says you make fonts like this:

But it's not making any sense to me. How do you generate the "0b00000000, 0b00000000, 0b00000000, etc...." for each character?

Does anyone know how to generate the "code"?

The name of such fonts is "bitmapped fonts", as every character is formed from a black and white bitmap.

The author of the UTFT library explains a bit on his webpage how such bitmapped fonts are working.

On another page he also has several bitmapped fonts in different sizes for download.

Ah! Thanks you. Now that I see how it works, I have to agree. Fonts larger than 8x8 are probably pretty tricky to make. Good thing those large fonts over at rinkydinkelectronics.com totally work!

ryemac3:
Good thing those large fonts over at rinkydinkelectronics.com totally work!

I tried that fonts (Rinky-Dink Electronics) but only 8x8 Sinclair_S is working. The bigger fonts are like chines letters.
How did you managed to make it wokring?

I just included the c file and used: TV.select_font(Sinclair_S);

Thanks