Bitmap font code?

BlitzMax Forums/BlitzMax Programming/Bitmap font code?

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.

I'm not sure if you are asking for a function that prints a bitmap font, or somethign that helps to create one.

I've gone for the former. This is a simplified version of a function I use (I've removed all aspects for kerning and resizing text and shadows/outlines).

Graphics 640,480,0,60

SetMaskColor 255,0,255

Global fnt=LoadAnimImage("font.png",12,26,0,96,1)

Global text_width=12

While Not KeyHit(KEY_ESCAPE)

txt("Hello",10,10,255,0,0)
txt("Hello",10,40,255,128,0)
txt("Hello",10,70,255,255,0)
txt("Hello",10,100,128,255,0)
txt("Hello",10,130,0,255,0)
txt("Hello",10,160,0,128,255)
txt("Hello",10,190,0,0,255)

Flip

Cls

Wend


' Display text
Function txt(text$,x,y,r,g,b)

  For i=0 To Len(text$)-1
   cr=(Asc(Mid$(text$,i+1,1))-32)

    SetColor r,g,b
     DrawImage fnt,(x+(xpos*text_width)),y,cr
    SetColor 255,255,255

 	xpos=xpos+1
  Next
EndFunction




This code allows you to display and adapt the text colour easily by altering the R,G,B values.

Text_width is the width of each text character in pixels - change this value to suit your font.