Page 1 of 1
I don't understand Font:getWrap
Posted: Sat Mar 22, 2014 9:21 pm
by RoToRa
I'm new to LÖVE and Lua, and I have problems understanding Font:getWrap. I have a simple main.lua containing solely of
Code: Select all
io.stdout:write(love.graphics.getFont():getWrap("Test", 100) .. "\n")
nothing else, so font, font size, etc. all are at default. Since the text should fit without any problems into 100 pixel width, I'd though the function should return 1, however I'm getting 31.
What am I missing? What does the 31 mean?
Re: I don't understand Font:getWrap
Posted: Sat Mar 22, 2014 10:58 pm
by DaedalusYoung
getWrap return
two values. Width, and then lines. I think you're only reading the width, currently. To get the lines, read the 2nd value. I think you can do this with select(), otherwise, just make some variables:
Code: Select all
local _, t = love.graphics.getFont():getWrap("Test", 100) .. "\n"
io.stdout:write(t)
Re: I don't understand Font:getWrap
Posted: Sun Mar 23, 2014 9:08 am
by Robin
That should be:
Code: Select all
local _, t = love.graphics.getFont():getWrap("Test", 100)
io.stdout:write(t .. "\n")
Re: I don't understand Font:getWrap
Posted: Sun Mar 23, 2014 1:28 pm
by DaedalusYoung
lol, of course, that's my copy & paste skills messing things up
Re: I don't understand Font:getWrap
Posted: Sun Mar 23, 2014 2:21 pm
by RoToRa
I feel so dumb. I was sure to read the Wiki page hundreds of time, and somehow I missed that.
Thanks!