(07-02-2025, 08:48 PM)madscijr Wrote: Steve, why do you use _UFontHeight instead of _FontHeight? _FontHeight is working for me, just curious why the different function?
Okay, here's the skivvy on those two functions:
_FontHeight is basically an old font handling tool which reports back to you the size of your font that you loaded. It's kinda primitive and is *always* the value that you set. If you _LOADFONT("courier.ttf", 17, "monospace"), it's going to be size 17. It takes the value you specify and makes it the absolute size of your font.
_UFontHeight doesn't do that. Instead, it looks at the *base* of the font and makes the size according to that. In many cases, those values will match, or only be 1 or 2 pixels different.
So, what's the difference?
Imagine a fairy tale font with a lot of flourishing under the capital letters, like you sometimes see at the start of pages in those style books. That's a lot of UNDER-font and OVER-font, and _PRINTSTING and _FONTHEIGHT don't count those pixels in most cases. They'll draw the letters, but cut off those flowing, curvy, extra flourishes. You'll lose part of the font, which will pack things together nice and neatly and give you more lines on the screen.
_UPRINTSTRING and _UFONTHEIGHT tracks the extra space for over-font and under-font usage. If you specify _LOADFONT("fairytale.ttf", 20, "monospace"), with _PRINTSTRING and _FONTHEIGHT, the font is going to be 20 pixels in size. With _UPRINTSTRING and _UFONTHEIGHT, it might be 24 or 28 pixels in height, making certain that it reserves extra space for those excessive flourishes.
That's the difference in a nutshell. PRINT and _PRINTSTRING doesn't reserve that extra over/under space for fonts, _UPRINTSTRING does. You can end up with text being truncated and cut off (which could, in most cases, shorten the tail of p's, q's, or even in extreme cases, make rendering underline characters impossible) by using PRINT or _PRINTSTRING, depending on your font choice. That won't happen with _UPRINTSTRING as it reserves that extra space and reports it with _UFONTHEIGHT.
*Most* of the time, it shouldn't be much of an issue for you, unless you're trying to print unicode characters. (Which is what _UPrintString is specifically designed to do.) Those all-important accents and such... those can be cut off with PRINT or _PRINTSTRING...
So, since you were using _UPRINTSTRING, I swapped in the use of _UFONTHEIGHT to go with it. The size isn't going to match up to your normal PRINT/_PRINTSTRING columns, as it reserves that little extra space to *FULLY* draw each character and not overlap on top of each other.
It's why I wrote in my comments that you might want to swap to _PRINTSTRING instead, if you're going to go with _FONTHEIGHT and keep those rows matching PRINT statements... It *could* truncate portions of your text (such as the accents above the standard font, or underlines under the standard font, or deep flourishes in various script fonts...), but if you're going to be PRINT for everything else, it's probably what you want to use for positioning and sizing here -- even if it does mean not drawing the font fully onto each line.


