http://bugs.winehq.org/show_bug.cgi?id=59569 --- Comment #4 from Esme Povirk <madewokherd@gmail.com> --- Whew, OK! So. I've compared the actual drawing to the size calculation, and the current size calculation makes very little sense. Drawing: * Handled by LabelPainter.Draw. This method draws to PaddingClientRectangle, which excludes padding and borders. * Label.Image is drawn using DrawImage. This isn't accounted for in GetPreferredSizeCore at all. * Text is drawn using Graphics.DrawString. In GetPreferredSizeCore, we use TextRenderer.MeasureString (different font engines, could give different results). We do correctly use Size.Ceiling. Padding and borders: * Padding appears to be correctly handled in GetPreferredSizeCore. * BorderStyle.FixedSingle removes BorderStaticSize == Size(1,1) from the client area. BorderStyle.Fixed3D removes Border3DSize == Size(2,2) from the client area. Oddly, that's all handled in the Hwnd class based on window style flags. Also, I would've expected the sizes to be even, since the border size needs to be removed from both sides along each axis. Anyway, GetPreferredSizeCore adds Size(0, 6) to its rectangle, and only if UseCompatibleTextRendering is set. If UseCompatibleTextRendering is set, but BorderStyle is None, it adds Size(0,3). So, where are they getting Size(0, 6)? Well, there is one sizing test that accounts for BorderStyle: https://gitlab.winehq.org/mono/mono/-/blob/main/mcs/class/System.Windows.For... This test consistently fails in .NET Framework, in my testing for Wine Mono. I guess it probably passed for some developer on some version of .NET Framework, at some point, but who knows? The extra padding in case of UseCompatibleTextRendering is probably just the padding that Windows GDI+ likes to apply to all text measurements, because GDI+ made the questionable decision to try to make text scale linearly, while still drawing individual glyphs as bitmaps with hinting that doesn't scale linearly, and they added a bunch of padding so they could mostly fudge things when that doesn't work. I have no idea why BorderSize affects the preferred height only when UseCompatibleTextRendering is set. Also, Mono seems to default UseCompatibleTextRendering to true, while MSDN says the default is false. Also, given issues we've been having with calendar sizing, there's a good chance the size calculation in libgdiplus is just broken sometimes. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.