Notifications
Clear all

[Closed] pixel width of text in UI

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?

2 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

use TextRenderer.MeasureText


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

Awesome! Thanks Denis! Somehow I know you would answer that one for me