here is a very primative class for displaying a bitmap font using fontext. You only need to export the image itself, not the ini file. For this to work, you must check all the boxes under the characters tab EXCEPT 'full' and 'skip 0-32' , this can be changed to accomodate the full options and 0-32 by simply changing the asciiCount variable. Feel free to enhance this and post your findings here. Enjoy!
' TBitmapFont Bitmap font class
Type TBitmapFont
Field font:TPixMap 'the original bitmap font image is stored here
Field tempPixMap:TPixMap 'this is a temp pixmap to store each letter
Field textSpacing:Int 'this controls how far apart horizontally each letter is spaced
Field ascii:TImage[512] 'stores ascii values
' Load font
Method load(url:Object, width:Int, height:Int, size:Int)
'url = link to image
'width = width of each cell
'height = height of each cell
'size = size of the total image i.e. 512 for 512x512
'load the bitmap font
font = LoadPixmap(url)
If Not font Then RuntimeError ("Unable to load '"+URL.toString()+"'")
'set text spacing
textSpacing = width
'create a pixmap to store each letter
tempPixMap =CreatePixmap(width, height,PF_RGB888)
'fill ascii[] array with letters corresponding to ascii values
'since the space is the first cell on the font
'start with the space ascii value 32
Local asciiCount = 32
For Local offsetY = 0 To Floor(size/height)-1
For Local offsetX = 0 To Floor(size/width)-1
For Local x = 0 To width-1
For Local y = 0 To height-1
WritePixel(tempPixMap, x, y, ReadPixel(font, x+(offsetX*width),y+(offsetY*height)))
Next
Next
ascii[asciiCount] = LoadImage(tempPixMap)
asciiCount:+1
Next
Next
EndMethod
' Draw text to the screen
Method text(text:String, x:Int, y:Int)
' text = string to output
' x = x start location of text
' y = y start location of text
For Local i:Int= 0 To text.length-1
Local tempText:String = Mid(text, i+1, 1)
Local asciiVal:Int = Asc(tempText)
If ascii[asciiVal]
DrawImage(ascii[asciiVal], x+(i*textSpacing), y)
EndIf
Next
EndMethod
'set text spacing
Method setTextSpacing(n:Int)
textSpacing = n
EndMethod
EndType
|