Question on fonts

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
ZBoyer1000
Prole
Posts: 39
Joined: Sat Nov 28, 2015 10:13 am

Question on fonts

Post by ZBoyer1000 »

Does rapidly changing fonts cause any performance issues?
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Question on fonts

Post 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!
Last edited by Sir_Silver on Wed Aug 24, 2016 12:31 am, edited 1 time in total.
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Question on fonts

Post 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.
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Question on fonts

Post by Sir_Silver »

Ah, well forget about my idea then. :P
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Question on fonts

Post by Ref »

Just a slightly different approach to font changes.
Excuse extra material as I was just playing around with shaders.
Attachments
font_shader_test.love
(47.31 KiB) Downloaded 115 times
Post Reply

Who is online

Users browsing this forum: No registered users and 95 guests