GLBasic User Manual

Main sections

GENFONT()

id% = GENFONT()



This command returns an index that can be used to open a resource with LOADFONT without overwriting already loaded data.

If no more memory is available, -1 will be returned.

The obvious advantage of this approach is that you can write libraries that fit seamlessly into existing projects without interfering with the existing code.
If using these commands to allocate indices for fonts in any part of your code, you should use them throughout your whole program.


The example here:
PRINT "Hello World", 100, 100
LOADFONT "comp_fnt.bmp", 1
SETFONT 1
PRINT "Hello World in new font", 100, 150
SHOWSCREEN
MOUSEWAIT


Can be written as:
GLOBAL gNewFont

PRINT "Hello World", 100, 100
gNewFont = GENFONT()
LOADFONT "comp_fnt.bmp", gNewFont
SETFONT gNewFont
PRINT "Hello World in new font", 100, 150
SHOWSCREEN
MOUSEWAIT

See also...