[SOLVED] How to add all characters to a font?

Hi, I’m developing a game for a platform with users all around the world.

Users may have Latin, Chinese, Cyrillic characters (and so on…) in their usernames (also they can use emojis in their names).

How can I add all possible characters in my font so I can display usernames on top of their avatar?

I assume the generated font texture size might be way bigger than 2048 so what can I do?

Up

Hi @Hugo_D,

Sorry for the slow reply. In situations where any character could appear you will need to use the pc.CanvasFont. I can’t find a tutorial for using this class, but have an example project that demonstrates its use.

The example includes the base64 encoded ttf font file directly and renders the required glyphs to texture at runtime using pc.CanvasFont.

Please see https://playcanvas.com/project/608225/overview/tutorial-canvasfont

Thanks!

1 Like

Hi @codebon thank you for your answer

Looks great I will try this.

Edit: works like a charm, thank you