## Question on fonts

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
ZBoyer1000
Prole
Posts: 39
Joined: Sat Nov 28, 2015 10:13 am

### Question on fonts

Does rapidly changing fonts cause any performance issues?

Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm

### Re: Question on fonts

Does rapidly changing fonts cause any performance issues?
Assuming that your fonts are stored in local variables and not being generated every tick/draw frame, I don't see why it would cause performance issues. I guess it kind of depends on exactly what it is that you're doing though.

One way I can think of that would probably be pretty efficient would be to set a font using:

Code: Select all

font = love.graphics.setNewFont( filename, size )
Next, you could use:

Code: Select all

love.graphics.print( text, x, y, r, sx, sy, ox, oy, kx, ky )
--or
love.graphics.printf( text, x, y, limit, align )

to draw your text somewhere on the screen according to the font that you set with the first function.

You could also use:

Code: Select all

love.graphics.newText( font, textstring )
to create a new drawable text object and simply draw that with a love.graphics.draw call.

https://love2d.org/wiki/love.graphics.setNewFont
https://love2d.org/wiki/love.graphics.print
https://love2d.org/wiki/love.graphics.printf
https://love2d.org/wiki/love.graphics.newText

I hope this was clear and helps!
Last edited by Sir_Silver on Wed Aug 24, 2016 12:31 am, edited 1 time in total.

slime
Solid Snayke
Posts: 2898
Joined: Mon Aug 23, 2010 6:45 am
Contact:

### Re: Question on fonts

There won't be any performance issues as long as you aren't creating new Fonts every frame. Both love.graphics.newFont and love.graphics.setNewFont create an entirely new Font object, so avoid calling either of those in love.draw or love.update.

Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm

### Re: Question on fonts

Ah, well forget about my idea then.

Ref
Party member
Posts: 690
Joined: Wed May 02, 2012 11:05 pm

### Re: Question on fonts

Just a slightly different approach to font changes.
Excuse extra material as I was just playing around with shaders.
Attachments