06-27-2024, 08:27 PM
(This post was last modified: 06-27-2024, 08:33 PM by Kernelpanic.)
(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
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