Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Freefont error
#4
(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:

> 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.
Thanks for the quick reply, but the result looks like this: Before _ Font 16 and with _ Font 16. Why doesn't that work?

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.
Reply


Messages In This Thread
Freefont error - by Kernelpanic - 06-27-2024, 07:57 PM
RE: Freefont error - by DSMan195276 - 06-27-2024, 08:02 PM
RE: Freefont error - by Kernelpanic - 06-27-2024, 08:27 PM
RE: Freefont error - by SMcNeill - 06-27-2024, 08:52 PM
RE: Freefont error - by Kernelpanic - 06-28-2024, 02:05 PM
RE: Freefont error - by SMcNeill - 06-28-2024, 02:55 PM
RE: Freefont error - by Pete - 06-28-2024, 04:11 PM
RE: Freefont error - by Kernelpanic - 06-28-2024, 07:31 PM
RE: Freefont error - by Pete - 06-28-2024, 10:03 PM
RE: Freefont error - by bplus - 06-28-2024, 10:38 PM
RE: Freefont error - by Pete - 06-29-2024, 03:26 AM



Users browsing this thread: 2 Guest(s)