Freefont error - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Freefont error (/showthread.php?tid=2830) Pages:
1
2
|
Freefont error - Kernelpanic - 06-27-2024 Inspired by @grymmjack's comment about the fonts, I looked at "_LoadFont" in the wiki. The first example works, but I want that the output to return to the standard font at the end. Unfortunately, I get an error message with "_FreeFont"; I looked up what the error number says, but I don't know where the error is. Can anyone tell me where the error is in the program? Thanks! Code: (Select All)
RE: Freefont error - DSMan195276 - 06-27-2024 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. RE: Freefont error - Kernelpanic - 06-27-2024 (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? Code: (Select All)
I just remembered that I tried something about this and it worked. Code: (Select All)
RE: Freefont error - SMcNeill - 06-27-2024 (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? The above doesn't work as you aren't specifying the font name or style when loading it. Code: (Select All)
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. RE: Freefont error - Kernelpanic - 06-28-2024 Quote: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.I understand that, what I don't understand is why the font doesn't change. No matter what I try, it doesn't work. Either it doesn't work or I don't understand how it works. Errors at 16 and 25 -- _FreeFont f/myFont Code: (Select All)
RE: Freefont error - SMcNeill - 06-28-2024 The reason why you're getting errors is because the font is still active. It's just like trying to turn the engine off on your car -- you have to be in park and not moving. You certainly can't just turn if off while driving down the road and in drive! Let me ask you this -- what Font is in use at line 16? As the line 24 issue, let me ask this: What screen mode are you in? Does SCREEN 0 have any limitations to the fonts that we can use with it? Hint: Screen 0 requires fonts to be MONOSPACED, as it doesn't work with variable-width fonts. Hinr2: Screen 0 only uses ONE font for the whole screen. When you change font on SCREEN 0, you change all the text to use that font. Code: (Select All)
See the above? No errors anymore, but since this is SCREEN 0, *all* the text on the screen changes fonts each time we change our font. The SLEEP statements here should allow you to slowly go through and see that. If you want to use more than a single font for the whole screen, use a graphics screen such as SCREEN _NEWIMAGE(x, y, 32). RE: Freefont error - Pete - 06-28-2024 I discovered I actually can turn my car off while still in drive. Dammit Steve, you owe me a new front end plus a garage door repair. @KP. Stay with it. Properly freeing fonts takes a bit of getting used to but in larger apps it will save you from potential out of memory errors. Pete - Critical Error 101 (Out of Beer). RE: Freefont error - Kernelpanic - 06-28-2024 Quote:Hint: Screen 0 requires fonts to be MONOSPACED, as it doesn't work with variable-width fonts.Ok, now I understand how it works; I think so. Thanks! RE: Freefont error - Pete - 06-28-2024 You say you don't want limitations Well you know We all want to change our fonts You say you have anticipations Well you know You have to work with what you've got But if you start coding around in graphics screens You ain't going to create an app that works worth beans Don't you know it's gonna be Alright... Pete (Follow me!) - I'm the same bot I used to be. RE: Freefont error - bplus - 06-28-2024 you say you want a revolution well you know you can get out of screen 0 |