Robin wrote:I'm just guessing here, but maybe it's because different characters have different heights? So if we were to draw two strings next to each other, but the one has an "f", while the other only has an "a", they would be misaligned if the origin is top-left. I don't know whether this makes any sense or not.
This is what I thought too, but I kept running into problems, for instance:
(the following is done in Love 0.6 with image x,y defaulting to the upper left, but the same behavior appears in 0.5)
Code: Select all
testImage = love.graphics.newImage("button.png")
testFont = love.graphics.newFont(love._vera_ttf, 18)
testText = "play"
love.graphics.setFont(testFont)
imageX = 400
imageY = 300
imageCenterX = imageX + (testImage:getWidth() / 2)
imageCenterY = imageY + (testImage:getHeight() / 2)
textX = imageCenterX - (testFont:getWidth(testText) / 2)
textY = imageCenterY + (testFont:getHeight() / 2)
love.graphics.draw(testImage, imageX, imageY)
love.graphics.print(testText, textX, textY)
The results:
Notice that the 'p' and 'y' extend below the other letters, while the 'l' rises higher than the other letters, yet even the 'l' is too low. Along the x-axis though, everything is properly centered.