Page 1 of 1

Need help with different font sizes

Posted: Tue Jan 08, 2013 11:21 am
by Nixonite
Hello, first time poster here.

I've been working with Love2d for a short while but I have the hang of it, except with fonts.

I don't understand how to make a game with 2 different font sizes with two different texts.

So I have a text that says "Score: "..hero.score and the score is supposed to be in the default font size of 16 which I set at the load with

Code: Select all

	love.graphics.setNewFont(16)
but then I have another text that I want to set the font size to 24, how do I do this? The only way I can get bigger fonts is if I put the setNewFont in the draw, but that lags hard. I can also scale, but the text looks really bad.

Any examples of 2 different fonts with 2 separate texts? I can't find it on the wiki.

Re: Need help with different font sizes

Posted: Tue Jan 08, 2013 11:34 am
by Yell0w
I think there is an example of this in the demo that comes with love, the sinescroller

Re: Need help with different font sizes

Posted: Tue Jan 08, 2013 11:39 am
by Lafolie
If you're using the default font you can do it like this:

Code: Select all

love.load = function()
    default = love.graphics.newFont(12)
    sixteen = love.graphics.newFont(16)
end

love.draw = function()
    love.graphics.setFont(default)
    love.graphics.print("Hello", 1, 1)
    love.graphics.setFont(sixteen)
    love.graphics.print("World", 1, 15)
end
If you're using something other than Vera Sans you can use specify a file to load too, love.graphics.newFont.