https://bugs.winehq.org/show_bug.cgi?id=54943
Bug ID: 54943 Summary: The gdipdrawstring function uses the wrong width when rendering CJK fonts Product: Wine Version: 8.6 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdiplus Assignee: wine-bugs@winehq.org Reporter: 399989567@qq.com Distribution: ---
1. First create a LOGFONT, and make lfwidth=0, and use the font Tahoma 2. Use Font "font(hdc, &lf)" to create the font 3. Use " graphics.DrawString(string, -1, &font, { 1.0f,1.0f,0,0 }, &format, &brush);" to render the string where WCHAR string[] = L "这里有一些错误".
You will find the Chinese font is too narrow.If you fail to render, make sure your lfCharSet=134
ps:Don't say there is no Chinese in tahoma so there is a rendering problem, it has nothing to do with this bug
I researched the bug and found that it is related to the implementation of gdipdrawstring. The function finally calls GDI32_GdipDrawDriverString, which uses SelectObject to select the font and ExtTextOutW to output the font.
So the problem can be well abstracted out, the reason for the problem is in the last selectobject lf.lfwidth=7 (instead of the 0 you set at the beginning)
ps:7 is the result of my computer's calculation
So we can write a simple demo to reproduce this problem: 1.lf.lfWidth = 0; 2.hUnderline = CreateFontIndirectA(&lf); 3.SelectObject(hdc, hUnderline); 4.ExtTextOutW(hdc, x, y, 0, NULL, string, lstrlenW(string), NULL);
5.lf.lfWidth = 7; 6.hUnderline = CreateFontIndirectA(&lf); 7.SelectObject(hdc, hUnderline); 8.ExtTextOutW(hdc, x, y, 0, NULL, string, lstrlenW(string), NULL);
You can find that the strings in 4 are drawn at the correct width, while the strings in 8 are too narrow; I don't know how to fix this bug, as it also affects the calculation of the string width
I hope I can get an answer
https://bugs.winehq.org/show_bug.cgi?id=54943
Bartosz gang65@poczta.onet.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |gang65@poczta.onet.pl
--- Comment #1 from Bartosz gang65@poczta.onet.pl --- Could you please attach example application/source code?
https://bugs.winehq.org/show_bug.cgi?id=54943
--- Comment #2 from Bartosz gang65@poczta.onet.pl --- It would be great if you could write test case for that issue in:
https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/gdiplus/tests/
https://bugs.winehq.org/show_bug.cgi?id=54943
Esme Povirk madewokherd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |madewokherd@gmail.com