Bitmap Fonts For Ingame Blitting

Started by cyberkilla, February 04, 2007, 05:39:04 PM

Previous topic - Next topic

cyberkilla

I find a nice bitmapped font is useful for games, and I've been searching.

I found the following character sets, incase anyone is having great difficulty.
NOTE: They *may* not be perfectly monospaced for blitting in these images.

I am converting them myself slowly, so you might not have to go to the trouble.
If anyone has a better way I doing this, It would be great to share it with us:).

I used to use the Tauron VGA Utilities to edit fonts, but it only exports into asm byte declarations.
There are some windows utilities hanging around, but none of them seem to install under Wine in Ubuntu.





The sites I found them on are bookmarked on my del.icio.us page(/cyberkilla), if you need them.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

If you replace the charset1 stuff with what it obviously needs, then this
method seems to paint glyphs from any texture size, with any row length.
Hope it helps someone. Its just a modification to the one in the paradroidz source, to permit any number of rows.


public static void blitText(FrameBuffer buffer, String line, int x, int y)
{
if (charset1 == null)
return;

char end    = charset1.getEnd();
char start  = charset1.getStart();
int  rowLength  = charset1.getRowLength();
int  width  = charset1.getFontWidth();
int  height = charset1.getFontHeight();
Texture texture = charset1.getGlyphTexture();
   //line = line.toUpperCase();
   
   for (int i=0; i<line.length(); i++)
   {
    char cNum = line.charAt(i);
       int  iNum = cNum-start;
       int  yNum = 0;
       
       if (iNum > rowLength-1)
       {
        int rows = (int)Math.floor(iNum/rowLength);
       
        yNum += rows*height;
        iNum -= rows*rowLength;
       }
       if (iNum>0 && iNum<=end)
           buffer.blit(texture, iNum * width, yNum, x, y, width, height,
               FrameBuffer.TRANSPARENT_BLITTING);
       x += width;
   }
}
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

Quite useful. I'm using the VGA-font and your posted method now for an example game that i'm working on.

cyberkilla

I'm glad it has found purpose;).

I have not had any problems with it yet, so it seems to be ok.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG