How do you reset back to the default font?

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
User avatar
20047m
Prole
Posts: 13
Joined: Sun Nov 03, 2013 5:44 am

How do you reset back to the default font?

Post 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.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How do you reset back to the default font?

Post 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.
User avatar
SneakySnake
Citizen
Posts: 94
Joined: Fri May 31, 2013 2:01 pm
Contact:

Re: How do you reset back to the default font?

Post 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.
User avatar
20047m
Prole
Posts: 13
Joined: Sun Nov 03, 2013 5:44 am

Re: How do you reset back to the default font?

Post 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 :awesome:
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: How do you reset back to the default font?

Post 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.
User avatar
20047m
Prole
Posts: 13
Joined: Sun Nov 03, 2013 5:44 am

Re: How do you reset back to the default font?

Post 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 :nyu:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 10 guests