tags:

views:

95

answers:

2

I am creating an .Net 2.0 SP2 windows Forms Application. The form fonts looks fine in my machine, when i tried in another machine, it looks bigger. (This is not because of resolution difference, fonts are bigger relatively to other icons etc.)

I tried to debug the problem and found following code returns different sizes on different machine.

//inside a windows form
private void checkfont()
{
    var g = this.CreateGraphics();
    MessageBox.Show(g.MeasureString("Hello World", this.Font) + "," + this.Font);
}

I expect graphics.measurestring() to return same value for same arguments in different machines.

For font 'Verdana 8.25'

  • On Machine 1 "Hello World" measures 69.0px,14.7px
  • On Machine 2 "Hello World" measures 86.3px,18.4px

Why this difference ? because of this my application fonts looks bigger and affect layout.

alt text alt text

edit:

Both Machines have .Net 2.0 SP2 , but their resolution and screen sizes differ. I understand that fonts physical dimension (on physical screen) will vary with resolution and screen size. But my question is why their dimension in pixel units differ ?

Machine 2 is eeetop ET1602 with windows xp, its touch screen system, by default it came with all desktop fonts bigger, but i have reset windows theme/windows fonts to default.

+1  A: 

This looks like DPI font scaling being set to "large fonts"?

EDIT
See Akash Kava's reply - he goes into more detail on the "large fonts" setting.

Thorsten Dittmar
+1  A: 

When you secify "Verdana 8.25" , this 8.25 has nothing to do with pixels directly, instead they are considered as "Points" and they will be rendered differently on different machines if the Screen DPI is different.

In Windows, under Desktop settings you have option of increasing the screen font size without changing the resolution. If you increase screen font size then the Dot per pixel changes which can measure different pixel size for same text on different machine.

This is due to fact that old people can not read smaller fonts, thats why they can increase the font size in desktop settings. And you can only specify the font size in points, if font size will be fixed to pixels, it will be difficult for the old or visually impaired people to read the text correctly. This way the text size of entire operating system is in control by the user.

Akash Kava
"Display Properties > Apperance > font size > Normal" didn't helpBut "Display Properties > Settings > Advanced > Display dpi setting > Normal Size 96 Dpi" solved the problem
Palani