Page 1 of 1
How do you reset back to the default font?
Posted: Mon May 12, 2014 3:37 am
by 20047m
I have loaded up a font, and set it as the default with love.graphics.setFont. Now, I need to reset the font back to what the default is when you load up the game. How would I go about doing this? I thought love.graphics.reset would accomplish this, but it doesn't.
Re: How do you reset back to the default font?
Posted: Mon May 12, 2014 4:00 am
by slime
If you store the default font in a variable before setting a custom one (e.g. defaultfont = love.graphics.getFont()), then you can use that with love.graphics.setFont later.
Re: How do you reset back to the default font?
Posted: Mon May 12, 2014 4:07 am
by SneakySnake
love.graphics.newFont without any arguments returns the default font.
See
http://www.love2d.org/wiki/love.graphic ... Function_4
Just don't call it in a tight loop or something, because it creates a new font every time.
Alternatively, you can save the font into a variable using
love.graphics.getFont() and restore it at a later time.
Re: How do you reset back to the default font?
Posted: Mon May 12, 2014 3:06 pm
by 20047m
Thanks guys! I really didn't want to have to store it in a variable because storing variables would clutter the API that I'm making. I ended up using "love.graphics.setFont(love.graphics.newFont(12))" for now. It's not enclosed in a tight loop, and what I'm making is supposed to be very lightweight, so I shouldn't have a problem using it. Thanks again
Re: How do you reset back to the default font?
Posted: Mon May 12, 2014 6:13 pm
by bartbes
You shouldn't be calling that with any kind of frequency. Also, is it really that hard to store a variable? I doubt it.
Re: How do you reset back to the default font?
Posted: Thu May 15, 2014 5:49 pm
by 20047m
bartbes wrote:You shouldn't be calling that with any kind of frequency. Also, is it really that hard to store a variable? I doubt it.
It's really not being called that often, it's not frequent at all. And, no, it's obviously not hard to store a variable. I need to make this as clean and efficient as possible though and not clutter up this table with variables I won't use besides on startup, if I don't have to