Page 1 of 1
Text placement bug ... err.. feature :-}
Posted: Wed Sep 15, 2010 7:47 pm
by An00biS
Hello.
I believe I've found a bug in LOVE's printf function - it behaves differently on Linux and Windows.
Here's the testing code:
Code: Select all
function love.draw()
love.graphics.setColor(255,255,255,255);
love.graphics.setLineStyle("rough");
love.graphics.line(0,200,600,200)
love.graphics.line(200,0,200,400)
love.graphics.line(400,0,400,400)
love.graphics.printf("X200 Y200 L200 center",200,200,200,"center");
end
Here's result on Windows XP, SP3:
- text-pos-windowsXP.gif (3.66 KiB) Viewed 4811 times
Here's result on Fedora 13:
- text-pos-Fedora13.gif (3.57 KiB) Viewed 4811 times
Does anybody here have the same problem?
~ An00biS
Edit: fixed thread title
Re: Text placement bug
Posted: Wed Sep 15, 2010 7:52 pm
by Robin
I think you're using different versions -- starting 0.7, text is drawn top-left rather than bottom-left. You're using the PPA or something? my 666th post in S&D!
Re: Text placement bug
Posted: Wed Sep 15, 2010 7:54 pm
by kikito
Are you using exactly the same versions in windows and ubuntu?
I think I've read somewhere that the Ubuntu version using on the PPA had been updated, or something along those lines. On the new version, the text placement is corrected so it uses top-left coordinates, like everything else.
EDIT- woops, got ninja'ed by robin.
Re: Text placement bug
Posted: Wed Sep 15, 2010 8:11 pm
by An00biS
I forgot to specify the versions
Windows - 0.6.2 stable download
Fedora - recent svn
Re: Text placement bug
Posted: Wed Sep 15, 2010 8:15 pm
by Jasoco
Sometimes I wish I could draw text with the origin being the baseline. That is the bottom of the letters not counting the dangly parts. It could be useful in some situations. Does text have a way to retrieve the pixel height of the current font?
Re: Text placement bug
Posted: Wed Sep 15, 2010 8:18 pm
by bartbes
An00biS wrote:Windows - 0.6.2 stable download
Fedora - recent svn
Well, 0.6.2 had baseline drawing, and current hg (not svn, mind you!) has top-left, you observed well.
Re: Text placement bug
Posted: Wed Sep 15, 2010 8:29 pm
by Jasoco
If we could specify it optionally that would be neat. Can we in 0.7.0?
Re: Text placement bug
Posted: Thu Sep 16, 2010 5:49 am
by kikito
Unless I'm missing something, you can add textheight to the y coordinate instead of having an additional method.
Code: Select all
love.graphics.print(x,y+height,text)
vs
Code: Select all
love.graphics.setTextBaseline(true)
love.graphics.print(x,y,text)
Re: Text placement bug
Posted: Thu Sep 16, 2010 7:12 pm
by Robin
kikito wrote:Code: Select all
love.graphics.setTextBaseline(true)
love.graphics.print(x,y,text)
Yuck. Do it either manually, as your first example, or add an extra parameter to love.graphics.print(), I'd say (the former has my preference, btw).
Re: Text placement bug
Posted: Fri Sep 17, 2010 11:31 am
by An00biS