Inline Bold/Italic Text Styling

Hi all,

I notice that text elements have an Enable Markup option, and this post covers that at the very least color styling is possible, but I can’t find any resources on regular markup styles like bold and italic. It seems [b]text[/b] isn’t working, and while I saw that will commented here regarding the fact that text is rendered using WebGL rather than the DOM, I was thinking that it should be possible for the PlayCanvas engine to bind multiple related fonts together in a font-object.

Right now, there exists a font asset, and while my project has two font assets (one for Regular, one for Bold), they’re in no way linked, and it would make sense to be able to link them so that I can switch between regular, bold, and italic on the text element (additional text features like Unity’s TextMeshPro has, like auto-capitalize all, auto-uncapitalize would also be excellent), or, as my current problem poses, being able to change them via markup mid-text.

At least those are my thoughts, assuming I haven’t missed some way to properly bold mid-text as I’m looking for.

As an additional note, if I have something like

this.entity.element.text = ("[color=\"#ff0000\"]text[/color]").toUpperCase();

the toUpperCase() throws off the color as I assume [COLOR="#hex"] isn’t the same as [color="#hex"], which doesn’t feel like it should act that way.

1 Like

Hi @TingleyWJ,

Indeed as you found out right now only colors are supported for inline text markup. I think in the future we will get more attributes since there is an elaborate markup parser in the engine.

And yes the attributes are case sensitive so a good practise is to execute the lower case the text value before adding the attributes. Which is more work agreed :slight_smile:

Maybe valid feature requests for the engine repo.