SCREEN _NEWIMAGE(1024, 720, 32) '720p screen, which is standard for most things I do font_name$ = "OLDENGL.ttf" 'Don't forget the path, if necessary!
font_size = 32
font_style$ = "" 'Unless we just HAVE to, we don't want Old English to be a monospaced font.
' Remember this distinction, as it CAN affect which commands are available for us to use.
'font_style$ = "MONOSPACE" ' <-- IF we have to have it monospaced, we can use this, but I don't recommend it.
font_handle
= _LOADFONT(font_name$
, font_size
, font_style$
) 'get a handle for the font, with size and style set_FONT font_handle
'swap to that font handle
PRINT "Hello World" 'print something to the screen.
'Now, the one important note when dealing with non-monospaced fonts is with the following:
'If you look at your screen, you'll see that we're NOT 100 characters right of the screen.
'Since we don't know exactly how wide any one character is going to be, we LOCATE row, PIXEL instead.
'The 10, 100 in the above says LOCATE "10 rows down, 100 pixels right"
'Also notice that the above will give us a fontwidth of 0. This is because, once again, we're NOT using
'a monospaced font. We're using a variable width font, so there's no standard font width to apply.
'Instead, use _PRINTWIDTH to calculate how much screen space your text is going to use.
'Now, as you can see from the above, those two lines have the same number of characters, but each takes up
'a different amount of space to print to.
'Now, press any key to see what happens when we DO use monospace with OLDENGL.ttf
font_style$ = "MONOSPACE" ' <-- IF we have to have it monospaced, we can use this, but I don't recommend it.
font_handle2
= _LOADFONT(font_name$
, font_size
, font_style$
) 'get a handle for the font, with size and style set_FONT font_handle2
'swap to that font handle _FREEFONT font_handle
'free the old font to release it from memory COLOR _RGB32(255, 0, 0) 'red text to make the comparison very visible PRINT "Hello World" 'print something to the screen.
'No issue with LOCATE like normal. It's row, column just like usual, but look at how the font looks.
'YUCKY!!
LOCATE , 10:
PRINT "Font Width: ";
_FONTWIDTH 'here we can get our fontwidth, as all characters are the same size.
_FONT 16 'back to the default font _FREEFONT font_handle2
'free the monospaced font I used above