Minggu, 12 April 2020

Asteroids Font - Trammell Hudson's Projects Asteroid Font

Asteroids font - Trammell Hudson's Projects

Asteroids font - Trammell Hudson's Projects

Asteroids font

My version of the Asteroids font is derived from ). I modified a few of the characters to make them more distinct as well as added a strike to the 0 so that it stands out from the O.

Asteroids font - Trammell Hudson's Projects

Examples

I've used the font in my Asteroids "clone" . It is a very easy font to embed, so it shows up in several places where I need to draw legible text with a microcontroller. It is uppercase only, and I've had to create a few special characters for ones that weren't represented in Logg's notes.

Code

The source code is in and has been compressed to use very little memory in representing the font in memory.

The drawing routine extracts the 4-bit X and Y offsets from the array and generates the moveto() or lineto() commands:

	const uint8_t * const pts = asteroids_font[c - ' '].points;
	int next_moveto = 1;

	for(int i = 0 ; i < 8 ; i++)
	
		uint8_t delta = pts[i];
		if (delta == FONT_LAST)
			break;
		if (delta == FONT_UP)
		
			next_moveto = 1;
			continue;
		

		unsigned dx = ((delta >> 4) & 0xF) * size;
		unsigned dy = ((delta >> 0) & 0xF) * size;

		if (next_moveto)
			moveto(x + dx, y + dy);
		else
			lineto(x + dx, y + dy);

		next_moveto = 0;
	

	return 12 * size;

0 Comments

Posting Komentar