gdiplus: Handle Windows style newline.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54962 Signed-off-by: David Kahurani <k.kahurani@gmail.com>
This commit is contained in:
parent
7ab7e299c3
commit
c1da4fb167
2 changed files with 34 additions and 6 deletions
|
@ -5186,7 +5186,7 @@ GpStatus gdip_format_string(HDC hdc,
|
|||
INT *hotkeyprefix_offsets=NULL;
|
||||
INT hotkeyprefix_count=0;
|
||||
INT hotkeyprefix_pos=0, hotkeyprefix_end_pos=0;
|
||||
BOOL seen_prefix = FALSE;
|
||||
BOOL seen_prefix = FALSE, unixstyle_newline = TRUE;
|
||||
|
||||
if(length == -1) length = lstrlenW(string);
|
||||
|
||||
|
@ -5259,9 +5259,20 @@ GpStatus gdip_format_string(HDC hdc,
|
|||
if(fit == 0)
|
||||
break;
|
||||
|
||||
for(lret = 0; lret < fit; lret++)
|
||||
for(lret = 0; lret < fit; lret++) {
|
||||
if(*(stringdup + sum + lret) == '\n')
|
||||
break;
|
||||
{
|
||||
unixstyle_newline = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(*(stringdup + sum + lret) == '\r' && lret + 1 < fit
|
||||
&& *(stringdup + sum + lret + 1) == '\n')
|
||||
{
|
||||
unixstyle_newline = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Line break code (may look strange, but it imitates windows). */
|
||||
if(lret < fit)
|
||||
|
@ -5332,9 +5343,19 @@ GpStatus gdip_format_string(HDC hdc,
|
|||
if (stat != Ok)
|
||||
break;
|
||||
|
||||
sum += fit + (lret < fitcpy ? 1 : 0);
|
||||
height += size.cy;
|
||||
lineno++;
|
||||
|
||||
if (unixstyle_newline)
|
||||
{
|
||||
height += size.cy;
|
||||
lineno++;
|
||||
sum += fit + (lret < fitcpy ? 1 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
height += size.cy;
|
||||
lineno++;
|
||||
sum += fit + (lret < fitcpy ? 2 : 0);
|
||||
}
|
||||
|
||||
hotkeyprefix_pos = hotkeyprefix_end_pos;
|
||||
|
||||
|
|
|
@ -3197,6 +3197,7 @@ static void test_string_functions(void)
|
|||
HDC hdc = GetDC( hwnd );
|
||||
const WCHAR teststring[] = L"MM M\nM";
|
||||
const WCHAR teststring2[] = L"j";
|
||||
const WCHAR teststring3[] = L"MM M\r\nM\0";
|
||||
REAL char_width, char_height;
|
||||
INT codepointsfitted, linesfilled;
|
||||
GpStringFormat *format;
|
||||
|
@ -3268,6 +3269,12 @@ static void test_string_functions(void)
|
|||
status = GdipMeasureString(graphics, teststring, 6, font, &rc, NULL, &bounds, &codepointsfitted, NULL);
|
||||
expect(Ok, status);
|
||||
|
||||
/* new line handling */
|
||||
status = GdipMeasureString(graphics, teststring3, -1, font, &rc, NULL, &bounds, &codepointsfitted, &linesfilled);
|
||||
expect(Ok, status);
|
||||
expect(7, codepointsfitted);
|
||||
expect(2, linesfilled);
|
||||
|
||||
status = GdipMeasureString(graphics, teststring, 1, font, &rc, NULL, &char_bounds, &codepointsfitted, &linesfilled);
|
||||
expect(Ok, status);
|
||||
expectf(0.0, char_bounds.X);
|
||||
|
|
Loading…
Add table
Reference in a new issue