[Resolved] special character glyphs in the terminal not printing in WebGL builds

This is a general question I’ve stumbled into while tinkering with my Terminal Hacker code, but it’s beyond the scope of the section and certainly not related to any specific lecture, as I see it. I figure, post it, and see what happens:

In brief, I wanted to expunge the _ underscore cursor we have been using in our terminal by default. More specifically, I wanted to replace it with a “block cursor”, i.e. ░

Well it was all fine and dandy… until I built for the web, that is. Suddenly, my cursor was missing entirely. It works just fine inside Unity (the Editor). I’m about to try a PC build (seems to work fine, I guess I’ll add that to the downloadables of the working verision) but really… with a minigame like this, I’d rather just have it working properly in the web version.

Status: If anyone has insight into why the block cursor doesn’t work in the web version (and/or ways to fix it) that would be awesome, of course. Feedback telling me you see something different than I do would also be rather elucidating. Finally, any discussion whatsoever related to this would certainly be interesting.

I’ll start: I’m wondering if I might be able to fix this by scouring through the files created for the web-build… perhaps in compilation the block cursor got mis-managed, but can be salvaged with a simple text-edit of a CSS or HTML file? (The fact that the web version seems to be the only one with trouble boosts my confidence I might already have my answer…)**

**Nope, tried that too (looking for something I can modify in the web-build files) and couldn’t find anything I could change that would fix it.

Nina found this: https://forum.unity.com/threads/special-characters-in-ugui-webgl.409654/

If I understand the issue as described it has to do with how the system does “fallback” when characters are not available in the font which is being used; for some reason the Editor and PC builds are able to fallback to a different font, i.e. Arial, while the WebGL builds are not.

My research says there are two options to pursue:

  1. edit the font I’m using to add the character(s) I want to use. (The font has an open license, but I’m having some difficulty doing this; ultimately it seems like the best option: it doesn’t require any extra code, and it perfectly solves the problem… Hopefully I figure it out).

  2. use the TextMesh Pro asset in Unity to combine more than one font in the same TextMeshPro UGUI element. On this front I’ve had several small successes. I might be able to get it to do what I want/need, but it’s going to take a tonne of massaging and code. (So far, I am managing to get both character-sets to display in the same UGUI, but there are “issues” with quality, size, “floating text”, and even this fun one: if a user types too many characters, suddenly the UGUI starts to render the RTF tags used to select the font… so Like I said, it would/will be a lot of work to get a result I’m happy with this way.

I think for now I should focus on just modifying my original font asset (path #1).

Wow this would have been a non-issue if I knew then what I know now:

The issue: Unity Editor and PC builds are able to “fallback” to a system font when the font-in-use lacks glyphs that are being printed. WebGL builds can’t do this (my bug report has been closed).

Psych! Actually they can:

  1. make sure you have included the fallback font in your Assets. (not highlighted above, but “arial” can be seen there).

  2. on the Import setting of the primary font (select the font in your Assets) you need to add your fallback font(s) to the list of Font Names (see red circled areas above) as a comma separated list. Click Apply in the Inspector.

  3. generate a WebGL build.

  4. profit!