https://bugs.winehq.org/show_bug.cgi?id=46947
David Kahurani k.kahurani@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |k.kahurani@gmail.com
--- Comment #10 from David Kahurani k.kahurani@gmail.com --- I believe this program is relying on a gdiplus bug.
Windows bug:
0024:trace:gdiplus:GdipCreateStringFormat (0, 0, 0115D080) 0024:trace:gdiplus:GdipCreateStringFormat <-- 0394D7B8 0024:trace:gdiplus:GdipSetStringFormatAlign (0394D7B8, 0) 0024:trace:gdiplus:GdipSetStringFormatLineAlign (0394D7B8, 1) 0024:trace:gdiplus:GdipSetStringFormatHotkeyPrefix (0394D7B8, 0) 0024:trace:gdiplus:GdipSetStringFormatTrimming (0394D7B8, 3) 0024:trace:gdiplus:GdipSetStringFormatFlags (0394D7B8, 3000) 0024:trace:gdiplus:GdipDrawString (039D7430, L"Kontakt", 7, 039D7340, (3168.00,3079.00,1288.00,192.00), 0394D7B8, 039C6FC0)
From here we can see that FormatFlags are set to 0x3000 - which is StringFormatFlagsLineLimit | StringFormatFlagsNoWrap.
From the documentation we can read that:
StringFormatFlagsLineLimit Value: 0x00002000 Specifies that only entire lines are laid out in the layout rectangle. By default, layout continues until the end of the text or until no more lines are visible as a result of clipping, whichever comes first. The default settings allow the last line to be partially obscured by a layout rectangle that is not a whole multiple of the line height. To ensure that only whole lines are seen, set this flag and be careful to provide a layout rectangle at least as tall as the height of one line.
However, on testing, this seems to give varying results, at least with GdipDrawString because for instance, the following code snippet does actually draw some clipped text on the screen:
HDC hdc = GetDC(hwnd); const WCHAR to_draw[] = L"Spice";
Graphics graphics(hdc); StringFormat stringFormat; Font font(L"Arial", 48); RectF size;
stringFormat.SetAlignment(0); stringFormat.SetLineAlignment(1); stringFormat.SetHotkeyPrefix(0); stringFormat.SetFormatFlags(0x3000);
SolidBrush brush(Color::Black);
graphics.MeasureString(to_draw, 5, &font, PointF(300.f, 300.f), &size); size.Height = size.Height - 50; graphics.DrawString(to_draw, 5, &font, size, &stringFormat, &brush);
This is all while having the StringFormatFlagsLineLimit set in the flags which dictates that clipped text shouldn't be rendered. Other than this example, Windows seems to randomly show or not show text that shouldn't be rendered(as dictated by StringFormatFlagsLineLimit). I have not been able to identify any patterns in its behaviour. This I think is a bug.
Coming to our program as in this bug. The program calls GdipMeasureString on strings before calling GdipDrawString on them. However, it can be observed that even after calling GdipMeasureString, the program goes on to ignore the layout rectangle height provided by GdipMeasureString and setting, instead, a constant height of 192.0
0024:trace:gdiplus:GdipDrawString (039D7430, L"Kontakt", 7, 039D7340, (3168.00,3079.00,1288.00,192.00), 0394D7B8, 039C6FC0)
0024:trace:gdiplus:GdipDrawString (07767388, L"Raum verlassen Kitchen _ Diner", 30, 077675A0, (10176.00,1831.00,1288.00,192.00), 03B44BE0, 03A9F9D0)
Now, the bold font has a size of 160 while the non-bold font has a size of 120. It goes without saying that the non-bold font will fit in the layout rectangle while the bold will not. With StringFormatFlagsLineLimit the text that doesn't fit in the layout rectangle is not rendered and hence the bold text is missing. This however works on windows, contrary to what the documentation says. It however doesn't seem to work reliably making me think this is a bug.
This solution would probably be to relax the StringFormatFlagsLineLimit flag on Wine.