Font size differences between VB6 and VB.NET
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.
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.
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.
精彩评论