- Home /
TextMesh characterSize vs fontSize
Hi all,
I'm having some trouble with the sizing TextMesh objects.
Specifically, the meaning of characterSize seems to change with the fontSize.
Fonts created with a larger fontSize are larger for the same value of characterSize as fonts created with a smaller fontSize. If you have a dynamic font, then a charSize of 16 and a fontSize of 8 is the same as a charSize of 8 and a fontSize of 16.
The problem is, there is no way in the script interface of finding out the fontSize, so even if I figure out the relationship and how to make my font a given number of units tall, I have no way to calculate the correct values in script. (without telling the artists, all fonts should have a fontSize of n).
Does anybody have any insight? Should I just roll my own text system? (I have a text system from our previous games that works pretty well, but I'd prefer to use the inbuilt Unity one if at all possible)
Thanks, Martin
Answer by Martin Brownlow · Mar 30, 2011 at 07:23 PM
OK it turns out that by the wonders of hidden magic numbers, here is how to work out characterSize for a given fontSize and target size in world units:
characterSize = targetSizeInWorldUnits*10.0f/fontSize;
Of course, you can't actually read fontSize from the font in any way shape or form.
But that's how to do it.
WoW. How did you figure that out?
And how stoked are you that it's not possible to read font size? Let alone change it. Welcome to Unity Answers.
Answer by Jason B · Mar 30, 2011 at 06:43 PM
Font size effectively changes the resolution of the font. Turn your font size super small, and your character size super big, and your text will look like crap. Do the opposite, and you'll have very nice, smooth letters.
TextMeshes have numerous flaws though with their general operation, and there's not really anything they can do that a GUIText can't do better (unless you specifically need text to follow objects around in the 3D world).
Except you can add Depth to Text$$anonymous$$eshes, which you can't do to GUIText since there is no option to select a specific shader/material
Your answer
![](https://koobas.hobune.stream/wayback/20220613115809im_/https://answers.unity.com/themes/thub/images/avi.jpg)