font = love.objects:newImageFont("imagefont.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
and before " is escape character \. I did it but love didn't draw it. Even if i use ' instead of " to mark string in draw method.
And I have one more question or maybe idea. Is it possible to use smaller source font and resize it inside the game? If i want pixel font i have to resize it to see large pixels and it also means two-times bigger source image.
ImageFont is generally confusing and gay (not really gay, but still I didn't test it thoroughly before releasing). Working on a bunch of fixes for the next version and this is all VERY helpful.
edit: Fixed the tutorial to mention the fact that the separation color needs to be at the end of the image as well (the image scanning algorithm will change to something more logical soon, but it will still be important) and I actually got something wrong: you do not need to set color mode to love.color_modulate for the current color to affect imagefonts. That is a mistake. And a lie.
I am not sure what is going wrong with getWidth() as this code (which calls getWidth() before the first draw()) works... could you post an erroneous example?
function load()
local font = love.objects:newImageFont("imagefont.png", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
love.graphics:setFont(font)
num = font:getWidth("BUTT")
end
function draw()
love.graphics:draw("BUTT:" .. num, 100, 100)
end
It was in early startfield demo code. And I've just put it in load() and it works. It's possible that it was just a mistake in my code. I've also change the image font many times. But I remember that it didn't work and when I drew it it worked. If I was wrong, then sorry.
Unfortunately I don't have the old version . I think the problem was that I didn't draw it at all but I also tried it and it worked fine.
That's right. You're sorry! Hehe, don't worry about it. I wouldn't be surprised if it was a little buggy as I was "coding blind" when I made it, so this goes out to all followers: Any strange behavior (no matter how small) should be noted and reported. That is how we grow... 8-)