How can I add fonts in different sizes?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 11
- Joined: Thu May 27, 2021 4:19 pm
How can I add fonts in different sizes?
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?
uhInTheProcess 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?
maybe full source code?
-
- Prole
- Posts: 37
- Joined: Thu Jun 24, 2021 5:49 pm
Re: How can I add fonts in different sizes?
Just keep it simple and use multiple lines, e.g.:
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
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...
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
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 4 guests