Changing font-size in _rgb32 mode
#14
(04-08-2023, 09:36 PM)Kernelpanic Wrote: Thanks @SMcNeill for the explanations. I have now reproduced this with "Monospace". But there remain open questions.
I can't understand the spacing between the textes; see the screenshot. I can't find an explanation for this.

My guess is that this is where "Locate" and "_PrintString" somehow get in each other's way.


Ariel isn't a true monospaced font.  It's variable width, by its very nature.

W -- This is a sample of Ariel font.
iiiii -- you can easily see that the "W" is somewhere around 4 to 5 times wider than the "i" with this font.

So when we specify _LOADFONT with "bold, monospace", as you have in your example, what happens??

Monospace says that all the characters in a fontset are all the same space -- that they all use up the same amount of width.  Then when we type, we always have the exact same number of columns in a row, regardless of what characters we might be typing.  See my screenshot of my example program above -- with the monospaced version of the font loaded, my 10 "i" characters all take up the same amount of screen space as my "W" characters...

But, as you can easily tell, the W is much, much wider than the i:

W
iiiii


So what's the solution to space our letters properly??

W
 i

We make each character the same width as our widest character (usually the W or M character, though I've seen some fonts where Q has a large flourish and is the widest), and then we simply center all our letters into that space.

The "W" might be 16 pixels wide, while the "i" is only 4 pixels in width, but they each need to take up the same screen space so they all align perfectly.  To accomplish that, the W has 0 pixels of blank padding before and after it, while the i would have 6 pixels of blank space padding before and after it.  (6 blank, 4 for the i, plus 6 blank = 16 pixels width -- the same as the W.)

So when you look at your screenshot and say, "What are these spaces??", they're simply the padding required to make a variable-width font perform the same as a natural monospaced font.

Honestly, I find them quite ugly, and it's not my habit to tend to use "monospace" with most variable-width fonts, but the option's there just in case it's required for some strange reason.

Try your code with a TRUE monospaced font ("courbd.ttf" for example), and you'll see that problem with having to center the letters disappears completely.  When the widest character is 16 pixels in width and the narrowest character is 16 pixels in width, there doesn't need to be any padding before or after anything to center those characters.
Reply


Messages In This Thread
RE: Changing font-size in _rgb32 mode - by bplus - 04-08-2023, 01:51 PM
RE: Changing font-size in _rgb32 mode - by bplus - 04-08-2023, 05:10 PM
RE: Changing font-size in _rgb32 mode - by SMcNeill - 04-08-2023, 10:14 PM



Users browsing this thread: 4 Guest(s)