Getting the right size of a font... (e.Graphics.MeasureString)

  • Thread starter Thread starter Sonnich Jensen
  • Start date Start date
S

Sonnich Jensen

Hi

I use

sizef textSize = e.Graphics.MeasureString(Headers, this.Font);

Now, the textSize.Width and textSize.Height differs - a lot.
On 2 different computers, I get different sizes as the use different fonts, BUT one leave more white space in one place, the other in the other side.
This means that I can center a text using one (font) but not with another.

This is clearly related to the fonts. Usually the difference is app 2 pixels

But how do I get the TRUE size of my text?

WBR
Sonnich
 
Hi

I use

sizef textSize = e.Graphics.MeasureString(Headers, this.Font);

Now, the textSize.Width and textSize.Height differs - a lot.
On 2 different computers, I get different sizes as the use different fonts, BUT one leave more white space in one place, the other in the other side.
This means that I can center a text using one (font) but not with another.

This is clearly related to the fonts. Usually the difference is app 2 pixels

But how do I get the TRUE size of my text?

WBR
Sonnich


Found this:
http://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations
 
Back
Top