Hello !
Did anyone found how to do it ? It would be nice for displaying scores and stuff like that.
I couldn’t find the option anywhere so I downloaded the UI source code from bitbucket but it seems what I need is buried inside UnityEngine.TextGenerator which seems to be on the native side.
TextGenerator.characters has a UICharInfo structure which does have charWidth. That could be forced to the width of max(width(M), width(W), width(‘00’)) (see definition of quadrats in typography). Unfortunately, I could find any setters for that
Does anybody have another solution that doesn’t involve using boring fonts or render quads manually ?
If you are unable to find an acceptable solution, may I suggest you take a look at TextMesh Pro which is a replacement for Unity’s text component like UI.Text but provides much improved functionality which includes over 30 rich text tags including the <mspace=x.xx> tag where characters enclosed in the tag use monospace.
Here is an example where the top text is using proportional spacing and bottom the tag.
The font that I used for this example is Anja Eliane Accent. The visual style of the text is done by using a Material Preset as TextMesh Pro provides the ability to dynamically style the text via material properties. See the following post where you can see the material properties on this text object.
Below is an image of this same text object with default material settings.
Now the same one with a Outline and Soft Shadow.
2 Likes