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


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
 
Ad

Advertisements

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


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

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

Similar Threads


Top