Welcome to another KotD. In this edition, we're exploring _ULineSpacing. I'm hosting KotD this week. While my writing skills may not match Steve's, I will do my best. Full disclosure: I'm not a typography expert. Much of the content below is based on what I learned during the rewrite of the QB64-PE font support.
In the last KotD, Steve discussed _UFontHeight. You might be curious about the difference between _UFontHeight and _ULineSpacing, as they seem similar and can even return identical values. However, they are quite different; _UFontHeight returns the global glyph height of a font, whereas _ULineSpacing returns the height from one baseline to the next (baseline-to-baseline height).
The baseline is the imaginary line on which characters sit, serving as a reference point for glyph placement within a font. The ascent is the maximum pixel height above the baseline and is typically a positive value. The descent is the maximum pixel depth below the baseline, usually a negative value. The line gap represents the extra spacing required between two lines of text.
Therefore, baseline-to-baseline height can be expressed using the following formula:
baseline-to-baseline height = ascent − descent + linegap
So, what does this all mean? Essentially, it means that when printing multiple lines and needing to calculate the Y pixel positions, one should use _ULineSpacing instead of _UFontHeight.
That's all there is to it!
_ULINESPACING - QB64 Phoenix Edition Wiki
In the last KotD, Steve discussed _UFontHeight. You might be curious about the difference between _UFontHeight and _ULineSpacing, as they seem similar and can even return identical values. However, they are quite different; _UFontHeight returns the global glyph height of a font, whereas _ULineSpacing returns the height from one baseline to the next (baseline-to-baseline height).
The baseline is the imaginary line on which characters sit, serving as a reference point for glyph placement within a font. The ascent is the maximum pixel height above the baseline and is typically a positive value. The descent is the maximum pixel depth below the baseline, usually a negative value. The line gap represents the extra spacing required between two lines of text.
Therefore, baseline-to-baseline height can be expressed using the following formula:
baseline-to-baseline height = ascent − descent + linegap
So, what does this all mean? Essentially, it means that when printing multiple lines and needing to calculate the Y pixel positions, one should use _ULineSpacing instead of _UFontHeight.
That's all there is to it!
_ULINESPACING - QB64 Phoenix Edition Wiki