PDA

View Full Version : pixel width of text in UI


floopyb
02-10-2011, 09:43 PM
Hi all,
Im coding a UI which is completely generated procedurally via a text file. The on issue im coming up with is trying to get the buttons to line up as they vary thir width with what text is on them. I was looking at something like this:

(dotNetClass "System.Drawing.Graphics").measurestring "Hello" (dotNetObject "System.Drawing.Font" "Times New Roman" 12)
But was getting
-- Runtime error: dotNet runtime exception: Non-static method requires a target.

any ideas?

denisT
02-10-2011, 10:07 PM
Hi all,
Im coding a UI which is completely generated procedurally via a text file. The on issue im coming up with is trying to get the buttons to line up as they vary thir width with what text is on them. I was looking at something like this:

(dotNetClass "System.Drawing.Graphics").measurestring "Hello" (dotNetObject "System.Drawing.Font" "Times New Roman" 12)
But was getting
-- Runtime error: dotNet runtime exception: Non-static method requires a target.

any ideas?

use TextRenderer.MeasureText

(dotNetClass "TextRenderer").MeasureText "Hello" (dotNetObject "System.Drawing.Font" "Times New Roman" 12)

floopyb
02-10-2011, 11:04 PM
Awesome! Thanks Denis! Somehow I know you would answer that one for me :)

CGTalk Moderation
02-10-2011, 11:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.