x


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

more ▼

asked Mar 30 '11 at 06:40 PM

Martin Brownlow gravatar image

Martin Brownlow
11 1 1 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Mar 30 '11 at 07:23 PM

Martin Brownlow gravatar image

Martin Brownlow
11 1 1 6

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.

Mar 30 '11 at 09:15 PM dissidently
(comments are locked)
10|3000 characters needed characters left

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).

more ▼

answered Mar 30 '11 at 06:43 PM

Jason B gravatar image

Jason B
1.7k 29 32 44

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x100
x16
x1

asked: Mar 30 '11 at 06:40 PM

Seen: 1450 times

Last Updated: Mar 30 '11 at 06:40 PM