Need help with different font sizes

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Nixonite
Prole
Posts: 2
Joined: Tue Jan 08, 2013 10:37 am

Need help with different font sizes

Post 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.
User avatar
Yell0w
Prole
Posts: 28
Joined: Wed Nov 21, 2012 7:40 am
Location: Norway
Contact:

Re: Need help with different font sizes

Post by Yell0w »

I think there is an example of this in the demo that comes with love, the sinescroller
You can learn anything, but you cannot learn everything!
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Need help with different font sizes

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests