Fastest Bitmap Font character positioning

Blitz3D Forums/Blitz3D Beginners Area/Fastest Bitmap Font character positioning

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Okay, get the width of the screen. Subtract the width of the "test" string (64*4 in this case). Divide this number by 2. This is your starting x position.

Get the height of the screen. Subtract the height of the string (64 in this case). Divide this number by 2. This is your starting y position.

Draw all four letters from the starting x and y positions. Remember to add 64 to the x position afterwsards.

If your letters on the bitmap are layed out in Fontext style (that is an ASCII table, starting with space) then all you have to do is get the ASCII value if the first letter, and subtract 32.

Then to get the x position of the letter, you need to do a modulus width test. That is the x position will be at ASCII value modulus the number of characters per row, multiplied by the width of each characters, so say you have 10 chars per line, the starting x position will be at (((asc("t")-32) Mod 10) *64).

The y position of the letter, is the same deal except you need to use integer division instead of modulus, so it'll be at (((asc("t")-32) / 10) *64).

Hope this helps. If not, send over the bitmap font and I'll write a small routine to demonstrate.