Commit c1da4fb1 authored by David Kahurani's avatar David Kahurani Committed by Alexandre Julliard

gdiplus: Handle Windows style newline.

parent 7ab7e299
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment