pixel size of a string with a given font

C

c_xyTopa

hi all,

how can i determine a size in pixel of a specific string ("hallo") with
a given Font("Arial", 9.0F, System.Drawing.FontStyle.Regular)?

thank you
 
S

Sergey Bogdanov

The Graphics.MeasureString is what you are looking for:

using(Graphics g = (new Control()).CreateGraphics())
{
SizeF sz = g.MeasureString("hallo", SpecificFont);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top