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

[Image: Vor-Font16-danach.jpg]

I just remembered that I tried something about this and it worked.

Code: (Select All)

'Text im Grafikbildschirm positionieren - 8. April 2023

Option _Explicit

Screen _NewImage(600, 440, 32)

Dim As Integer schrift
Dim As String text

schrift = _LoadFont("C:\WINDOWS\Fonts\courbd.ttf", 24, "Bold")
_Font schrift

'Notwendig fuer Locate Zeile 22
Locate 3, 10
text = String$(20, "X")

'Positionierung in Grafikpixeln!
_PrintString (20, 20), text

'Die Positionierung durch Grafikpixel
'wird NICHT beruecksichtigt.
Locate CsrLin + 2, 20
Print "Screen width is 80 chars"

Locate CsrLin + 2, 297
Print "Middle"
'_PrintString (35, 300), "Mitte"

'Neue Schriftgroesse
'Eigenartiges Verhalten bei der Darstellung und Positionierung.
'Nach was richtet die sich?
_Font 16

'Damit geht es nach Pixel, und umgekehrt: Spalte - Zeile
'Locate ist: Zeile - Spalte
_PrintString (22, 220), "Middle"

'Das bedeutet: ", X mal 6 Buchstaben"
Locate CsrLin + 14, 38
Print "Middle"

_FreeFont schrift

End
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: 3 Guest(s)