Page 1 of 1

Question on fonts

Posted: Wed Aug 24, 2016 12:02 am
by ZBoyer1000
Does rapidly changing fonts cause any performance issues?

Re: Question on fonts

Posted: Wed Aug 24, 2016 12:06 am
by Sir_Silver
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!

Re: Question on fonts

Posted: Wed Aug 24, 2016 12:29 am
by slime
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.

Re: Question on fonts

Posted: Wed Aug 24, 2016 12:35 am
by Sir_Silver
Ah, well forget about my idea then. :P

Re: Question on fonts

Posted: Wed Aug 24, 2016 2:45 pm
by Ref
Just a slightly different approach to font changes.
Excuse extra material as I was just playing around with shaders.