User generated text in chinese font - font bitmap gets too large

Hi community,

I’d like users to input custom text (e.g. their usernames) in various languages. Since I don’t know which characters they’ll use, I can not generate the font bitmap beforehand, since the bitmap would get too big - especially for Chinese or Japanese Fonts.

A painful workaround would be to use a HTML overlay: HTML/CSS UI | Learn PlayCanvas

But I would really prefer to have the text properly within the canvas, in order to layout/animate/z-order the text with other elements within the canvas.

Any hints appreciated!

Canvas font may help here. It allows you to generate a font atlas dynamically at runtime.

Here is an engine only example and also an editor version (I need to clean this up as I think the integration could be a lot nicer)

1 Like

@yaustar Wow, thanks for the very fast reply. I’ll check this out today/next week!

What’s the drawbacks of using a dynamic font generation? I guess it justs impacts performance, right?


Potentially performance hitches when updating the glyphs, texture size is larger so VRAM usage is affected, some of the text elements properties (like outline is not affected), the setup in Editor is a bit of a pain and it’s private API so it’s subject to change and not finalised yet.

1 Like