Archive for the 'ironpython' Category

01
Oct
09

measuring a string using .net


Here’s how you get the width and height of a string using the .NET framework ( the example is for IronPython, but you can easily adjust this for any CLI language ) :


size = System.Windows.Forms.TextRenderer.MeasureText("measure this",font)
print size.Width
print size.Height

note that font must be the font you’re using to draw the string.




Blog Stats

  • 222,663 hits