How can i make the characters of my simple font renderer face the correct direction

Started by
2 comments, last by nomacaly 8 months, 1 week ago

hello. gamedev.net this is my first post here.

im trying to add font rendering to my simple pixel graphics engine, i dont really understand how bitmaps work but i have gotten quite close.

the problem that i am facing is the characters that are rendered aren't facing the correction direction. and i can't seem to figure out how to fix it. i know I'm suppose to inverse something but i cant figure out what or how to do it.

void drawCharacter(char *bitmap, int x, int y, Color c) {
    int i,j;
    int set;
    for (i=0; i < 8; i++) {
        for (j=0; j < 8; j++) {
            set = bitmap[j] & 1 << i; 
            if (set)
            {
              drawPixel(i+x,j+y,c);
            }
        }
    }
}

it works with the character C

but not the A

any help would be appreciated. 🙂

Advertisement

Is the second image an ‘a’?

If so, i assume your letter are flipped vertically, which for ‘C’ does not show because it's symmetric. A fix could be:

drawPixel(x+i, y-j /*+8*/, c);

Btw, i always use the letter 'F' in debug textures. Because with this letter you see any combination of flipping instantly without uncertainty.

JoeJ said:
Is the second image an ‘a’?

i was messing around with the bitmap font header file and changed something with out realizing. but yes it is an A.

JoeJ said:
drawPixel(x+i, y-j /*+8*/, c);

thanks dude that fixed it. 🙂

This topic is closed to new replies.

Advertisement