x


GUIStyle.CalcSize giving wrong answer

My understanding is that GUIStyle.CalcSize is supposed to return the pixel size, in the given style, of the content given in the argument. However, the answer that CalcSize gives me is much larger than the actual size of the text onscreen.

Debug.Log (ScoreStyle.CalcSize(new GUIContent("HH")));
GUI.Label(new Rect(10,10,190,40), "Best: " + highScore, ScoreStyle);

In the above code, for example, logs (52.0, 36.0) to the console, but the glyphs rendered by GUI.Label are only 21 pixels tall.

What could cause such a discrepancy? I'm not using anything like GUI.matrix, and the font isn't using padding or anything.

Oh, and also the font I'm using is caps-only, so there are no descenders, and the height of each glyph is the same.

more ▼

asked Feb 01, 2013 at 08:07 PM

yujik gravatar image

yujik
3 6 4 5

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

0 answers: sort oldest
Be the first one to answer this question
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:

x5645
x364
x171
x8

asked: Feb 01, 2013 at 08:07 PM

Seen: 774 times

Last Updated: Feb 01, 2013 at 08:07 PM