demiculus

When to use Bitmap Text & Text?

Recommended Posts

  • Bitmap Text gives much better performance for dynamically changing Text. (source)

Text has more attributes and is easier to change it's style. Bitmap Text has better better performance but static when it comes to styling.

From this I understand that every text should be Bitmap Text except for some edge cases which Bitmap Text doesn't help.

Have I understood this correctly or am I missing a part?

 

Share this post


Link to post
Share on other sites

Bitmap text will also not size like normal text, it will become blocky or illegible if you try to use a size different from it's original.

image.png.410ffdd310c49513149d0044cacb2ac6.png

You might also have trouble displaying text that contains characters which are not in your image.

image.png.7cc5fd49e63016476691969f01e21ba0.png Here for example the text has actually been set to "5¬5" but since ¬ is not in this font it is just missed out. I believe you can get around this by setting a fallback font to use for unknown characters but these won't fit with the style of the rest of the text.

If you know exactly what you're using the text for perhaps we could give you better guidance.

Share this post


Link to post
Share on other sites
38 minutes ago, lgibson02 said:

If you know exactly what you're using the text for perhaps we could give you better guidance.

As I remember someone posted something like this: `using bitmap text is your solution 99% of the time` here. But later someone deleted that post. So I was wondering if that is the reason my computer heats up when I play my game

Share this post


Link to post
Share on other sites

It really depends on your needs. Bitmap text is faster to render, yes, because normal text requires generating and uploading a new texture to the GPU each time it changes. And every piece of text also requires it's own texture, which can mount up.

But, as you say, normal Text gives you much more flexibility at runtime to create different styled text. And if you're supporting other languages, much easier to use normal Text than trying to create bitmap fonts for every character set.....

So they both have strengths and weaknesses, so there is never a 'this is always the best one to use in all scenarios'.

You can mitigate a Text weaknesses, for example, by generating all of the Text textures up front, avoiding the slowness of generating them as they're being rendered for the first time. It uses more memory, but maybe that's an acceptable trade off? Or have some fancy code so that if you have the same word and style in 2 places, you don't have 2 Text objects with their own textures, but they share the 1 texture? Or use textures from Text to create a dynamic atlas, which pixi-ui uses I believe.

a rapidly updating high score object might rule out normal Text because the rapidly regeneration of the texture may cause performance issues. Or maybe not. Profile your own use case :)

Share this post


Link to post
Share on other sites

If your current view needs as much memory/perf as possible then all normal texts displayed anywhere in that view will take away some of that memory/perf and it actually does add up quick. In that case you want to use bitmaptext instead and it will save you memory/perf for your view. If the current view doesn't need extensive memory/perf then use normal text (but keep the amount reasonable, eg. less than 10)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.