Page 2 of 2

Re: Font Aligning Problems

Posted: Tue Jun 19, 2012 2:22 am
by kexisse
kikito wrote:Fonts are complex. That "extra space" you see could be the font ascent. See this link:
http://en.wikipedia.org/wiki/Typeface#Font_metrics
Kikito is right, there is space above letters in most fonts for the ascenders. You used capital letters, but the ascenders typically rise above capital height.

Image

Re: Font Aligning Problems

Posted: Tue Jun 19, 2012 2:13 pm
by Roland_Yonaba
That's good to know.
Actually isn't it any way to predict how much the ascent will rise depending on the font size one might want to set ?

Re: Font Aligning Problems

Posted: Wed Jun 20, 2012 8:23 am
by Robin
Depends on the font, so unless and until LÖVE has a way to extract that information from the font, the answer is no.

Re: Font Aligning Problems

Posted: Fri Jun 29, 2012 1:46 am
by the_leg
rcm wrote:All 3 sizes should be aligned along the top of the window, instead there's extra space above them. Is this supposed to happen
For this particular font, there should be some space above the ABC. However, LOVE is adding too much space, from what I can tell. I tracked this down to a line of code in LOVE's print() function in /opengl/Font.cpp):

Code: Select all

if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() / 1.25f + 0.5f), 0);
This is assuming that every font has a maximum ascent of 80% its height. For your font, the max ascent is 60% of its height. The result is the font is printed further down the screen than it should be. Another result is that some fonts will have up to 20% of their outlines drawn above the y position you pass love.graphics.print().

To fix this that line of code should look like this, IMO:

Code: Select all

	if (type == FONT_TRUETYPE) glTranslatef(0, getAscent(), 0);

Re: Font Aligning Problems

Posted: Fri Jun 29, 2012 7:52 am
by kikito
I think that post belongs in the issue tracker. Good find!