Font Aligning Problems

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: Font Aligning Problems

Post 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
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Font Aligning Problems

Post 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 ?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Font Aligning Problems

Post 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.
Help us help you: attach a .love.
User avatar
the_leg
Prole
Posts: 25
Joined: Sun Sep 05, 2010 3:43 am

Re: Font Aligning Problems

Post 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);
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Font Aligning Problems

Post by kikito »

I think that post belongs in the issue tracker. Good find!
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests