FreeBasic GRFont Object

Using the Object

GrFont is a FreeBasic object that uses a bitmap image to draw custom fonts and images to a graphic screen. To use the object in your program #Include the grfont.bi file in your project:

#Include "grfont.bi"

Then create a variable of the object:

Dim As grfont.gfont myfont

Before using the object, you must load the font bitmap using the Load method.

If myfont.Load("aesomatica.bmp") <> grfont.TRUE Then
   Print "Could not load file."
   Sleep
   End   
EndIf

If Load returns False then the image could not be loaded.

GRFont can print individual characters or strings. There are three methods available for printing characters:

myfont.PrintChar 65, x, y : Print a character using ascii codes.
myfont.PrintChar "A", x, y : Print a character using character.
myfont.PrintString "Font Object Using aesomatica", x, y : Print a string.

The x and y parameters are the pixel locations of the graphic screen.

The object locks the screen before the font is printed. If this causes a problem then you can remove the screelocks in ub gfont.PrintChar(c As Integer, x As Integer, y As Integer) ib grfont.bi.

This is released under the WOL license.

Graphic File Format

The bitmap image needs to match the screen resolution.

The characters of the image should be a grid 16 by 16. The first row has the ascii characters 0 throguh 15, the second row 16 through 31, etc. So the first character should be character 0 and the last character should be character 255. 
You can leave unused characters blank, but the total number of characters should be 256.

See aesomatica.bmp for an example of the format. 