GP32 Char/font Questions


Pirotic

Certified Guru
Joined
Feb 16, 2004
Messages
593
Hiya, im going to write a custom font function in the SDK i've built up to develop my projects with, and a bit puzzled as to how it looks up the ASCII character.

i know that a char holds 255 possible values and i want it to simply draw a font based on the value, but is there anyway to find out which value represents which ASCII character? must be a lookup table somewhere :D

any help apprechiated, if not i'll just have to write some to reverse engineer it.
 
There's plenty of ascii tables around if that's what you want. For example, from memory I can say that capital 'A' starts at 65 (decimal), space is at 32, numbers are 48 onwards.

To find this out in C, just enclose the character your interested in within single quotes, eg:

int A = (int)'A';

will give you 65.

Or download an ascii table (or do both, it makes the code more readable).

Most font's simply have all 256 characters, but just fill in the characters the author is interested in using.
 
thats great, the (int)'a' command was exactly what i was looking for - your guru status name is well deserved ;)

regards

Pirotic
 
Remember that a char or unsigned char is a number, even if you "often' put characters into it; 'A' is shorthand for 65 decimal; you can do things like "x - 'A'" to find out how far into the alphabet a letter is, for instabce, since 'A' just turns into 65 to the compiler.

Or unix, "man ascii"; otherwise, use Google or printf :)

jeff
 
Back
Top