Page 1 of 1
How can I add fonts in different sizes?
Posted: Thu Jul 15, 2021 5:59 pm
by InTheProcess
I passed in a table in the function and then throws an error; such as this "love.graphics.newFont(font[1],font[2])". How do I add a new font with a size parameter?
Re: How can I add fonts in different sizes?
Posted: Thu Jul 15, 2021 7:24 pm
by GVovkiv
InTheProcess wrote: ↑Thu Jul 15, 2021 5:59 pm
I passed in a table in the function and then throws an error; such as this "love.graphics.newFont(font[1],font[2])". How do I add a new font with a size parameter?
uh
maybe full source code?
Re: How can I add fonts in different sizes?
Posted: Thu Jul 15, 2021 7:56 pm
by applebappu
Just keep it simple and use multiple lines, e.g.:
Code: Select all
font1 = love.graphics.newFont(courier.ttf, 10)
font2 = love.graphics.newFont(courier.ttf, 20)
love.graphics.setFont(font1)
...stuff that needs to be drawn in font1...
love.graphics.setFont(font2)
...stuff that needs to be drawn in font2...
Sure, you could compact it or whatever, but this makes it very clear what you're doing.
When you say "love.graphics.newFont(font[1],font[2])", you're trying to pass the thing in the second position of your font table as the argument to set the size of the first item in that table. Unless font = {font.ttf, integer} you're not going to get anything useful out of that. You should also assign the output of newFont somewhere, otherwise it's not going anywhere to be used.
documentation:
https://love2d.org/wiki/love.graphics.newFont