How to define what fonts to use for bold or italic when using "Rich Text" markup with imported fonts

I’m trying to bold a certain word in a textmesh. I’ve imported a bold version of the font as well as a normal version of the font, but it appears that Unity is not using the bold version - presumably because the bold version is not linked to the normal version in any way that I’m aware of. How can I tell Unity to use the bold version of the font?

Thanks.

You don’t. The markup applies to the current font. There’s nothing like CSS in Unity. (Well, GUI elements can be styled. but that applies to the controls and not the font.)

You can of course fake it. Create your normal TTF. Then add the bold and italic versions of your glyphs to this font. Define some substitution rules. Normal A is ascii 65. Perhaps your bold A is 65+100, and your italic A is 65+200. So, write some code that scans your strings, and add 100 to the characters that are inside bold tags, and 200 to characters inside italic tags. Then remove the tags. Your ability to do this of course depends on your character set being small, and having access to tools to create/modify your fonts. If you have commissioned the creation of your own fonts, then just ask the creator to combine the glyphs into a single font.

Select the normal font asset in your project view, and change the Character field from ASCII default set to Dynamic. You should then be able to use mark up to bold, underline, etc in you text.
You don’t need an extra font.

Sources:

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/StyledText.html