## 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6223363876342773, "perplexity": 7241.699882072597}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-40/segments/1600400265461.58/warc/CC-MAIN-20200927054550-20200927084550-00070.warc.gz"}