tags:

views:

324

answers:

2

When setting a point 10 font size in VB6:

Me.FontName = "Verdana"
Me.FontSize = 10
Debug.Print Me.FontSize

The reported font size is 9.75. However, when the same is done in VB.NET:

Me.Font = New System.Drawing.Font("Verdana", 10)
Console.WriteLine(Me.Font.Size)

The reported size is 10. Can someone explain the difference here? My hunch is that VB6 is using a .75 step because my system is configured at 96 DPI, and .NET is not using said step, or not reporting its usage, but I'm not sure.

+1  A: 

There is nothing wrong and both are techinically the same in display. It just reporting the font "more accurately". The font step size for 96dpi is 0.75 (0.6 at 120 DPI), so the steps are technically 9 to 9.75 to 10.5.

jasonk
So VB6 is accurately displaying the font, whereas VB.NET is simply displaying what I requested?
DAC
Fonts sizes are "conceptual". They are broken down into the various pt levels (9, 10, 10.5, 11, 12, 14) we've come to accept as standard representations.
jasonk
A: 

The step of Size property is 72 / GetDeviceCaps(hDC, LOGPIXELSY) which in small-fonts (96 DPI) is 0.75 and in large-fonts (120 DPI) is 0.6

You can use SetRatio on OleFont to control the denominator in the previous expression. GetDeviceCaps is the default setting.

wqw