Author Topic: Bitmap Fonts For Ingame Blitting  (Read 5793 times)

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bitmap Fonts For Ingame Blitting
« on: February 04, 2007, 05:39:04 pm »
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

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bitmap Fonts For Ingame Blitting
« Reply #1 on: February 04, 2007, 06:36:20 pm »
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.

Code: [Select]

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bitmap Fonts For Ingame Blitting
« Reply #2 on: February 06, 2007, 07:08:12 pm »
Quite useful. I'm using the VGA-font and your posted method now for an example game that i'm working on.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bitmap Fonts For Ingame Blitting
« Reply #3 on: February 06, 2007, 07:22:19 pm »
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