Text with Bitmaps?

Blitz3D Forums/Blitz3D Beginners Area/Text with Bitmaps?

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.

Quick example I just made.
Graphics 640,480,32,2

Global Font      = LoadFont("Arial",20,False,False,False)
Global ImageFont = ConvertFont2Image(Font,255,255,255)
Global FontCharacterGap = 8

SetBuffer BackBuffer()

Repeat
	Cls
	DrawText(ImageFont,MouseX()+40,MouseY(),"x="+MouseX()+", y="+MouseY())
	DrawText(ImageFont,MouseX()+40,MouseY()+15,"Hello there how are you!")
	Flip
Until KeyDown(1)

FreeImage(ImageFont)
FreeFont(Font)

Function ConvertFont2Image(Font,Red,Green,Blue,TransparentR=255,TransparentG=0,TransparentB=255)
	SetFont(Font)
	Color Red,Green,Blue
	
	Width  = FontWidth()
	Height = FontHeight()
	
	Image  = CreateImage(Width,Height,256)
	MaskImage Image,TransparentR,TransparentG,TransparentB
	
	For Ascii=0 To 255
		SetBuffer ImageBuffer(Image,Ascii)
		Text 0,0,Chr$(Ascii)
	Next
	Return Image
End Function

Function DrawText(Font,x,y,TextString$)
	For i=1 To Len(TextString$)
		DrawImage Font,x,y,Asc(Mid$(TextString$,i,1))
		x=x+FontCharacterGap
	Next
End Function