(06-27-2024, 08:27 PM)Kernelpanic Wrote:(06-27-2024, 08:02 PM)DSMan195276 Wrote: The issue is mentioned in the Wiki, but maybe isn't made that obvious:Thanks for the quick reply, but the result looks like this: Before _ Font 16 and with _ Font 16. Why doesn't that work?
> You cannot free a font which is in use. Change the font to a QB64 default font size before freeing the handle (see example below).
Basically, doing a `_FreeFont f` while `_Font f` is in use isn't allowed, it errors. To restore the default font you should use `_Font 16`, and after that is done you can do `_FreeFont f` with no issue.
Code: (Select All)
f = _LoadFont(fontfile, 30, style)
_Font f
Print "Hello!"
_Font 16
_FreeFont f
The above doesn't work as you aren't specifying the font name or style when loading it.
Code: (Select All)
fontfile$ = "C:\WINDOWS\Fonts\courbd.ttf"
style$ = "Bold,Monospace"
f = _LOADFONT(fontfile$, 30, style$)
_FONT f
PRINT "Hello!"
_FONT 16
_FREEFONT f
One thing to remember, any call to _FONT will reset your print cursor location, as different fonts are going to be different heights and such.
If you call _FONT, the next PRINT statement is always going to be at the top left of the screen, just as if you'd called CLS.