Before updating to Windows 10 you may need to return your Pro license. More information here

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

avatar image

3 6 4 6

(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



Answers and Comments



asked: Feb 01, 2013 at 08:07 PM

Seen: 878 times

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