From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/gdiplus/graphics.c | 38 +++++++++++++++++------------------ dlls/gdiplus/graphicspath.c | 7 +++++++ dlls/gdiplus/tests/graphics.c | 4 +--- 3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 65b33cdc960..fdb1b7d8b36 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5171,7 +5171,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, unixstyle_newline = TRUE; + BOOL seen_prefix = FALSE, found_newline;
if(length == -1) length = lstrlenW(string);
@@ -5244,24 +5244,27 @@ GpStatus gdip_format_string(HDC hdc, if(fit == 0) break;
+ found_newline = FALSE; for(lret = 0; lret < fit; lret++) { if(*(stringdup + sum + lret) == '\n') { - unixstyle_newline = TRUE; + lret += 1; + found_newline = TRUE; break; }
if(*(stringdup + sum + lret) == '\r' && lret + 1 < fit && *(stringdup + sum + lret + 1) == '\n') { - unixstyle_newline = FALSE; + lret += 2; + found_newline = TRUE; break; } }
/* Line break code (may look strange, but it imitates windows). */ - if(lret < fit) - lineend = fit = lret; /* this is not an off-by-one error */ + if(found_newline) + lineend = fit = lret; else if(fit < (length - sum)){ if(*(stringdup + sum + fit) == ' ') while(*(stringdup + sum + fit) == ' ') @@ -5328,19 +5331,9 @@ GpStatus gdip_format_string(HDC hdc, if (stat != Ok) break;
- - if (unixstyle_newline) - { - height += size.cy; - lineno++; - sum += fit + (lret < fitcpy ? 1 : 0); - } - else - { - height += size.cy; - lineno++; - sum += fit + (lret < fitcpy ? 2 : 0); - } + height += size.cy; + lineno++; + sum += fit;
hotkeyprefix_pos = hotkeyprefix_end_pos;
@@ -5348,7 +5341,7 @@ GpStatus gdip_format_string(HDC hdc, break;
/* Stop if this was a linewrap (but not if it was a linebreak). */ - if ((lret == fitcpy) && (format->attr & StringFormatFlagsNoWrap)) + if (!found_newline && (format->attr & StringFormatFlagsNoWrap)) break; }
@@ -5645,6 +5638,13 @@ static GpStatus draw_string_callback(HDC hdc, position.X = args->x + bounds->X / args->rel_width; position.Y = args->y + bounds->Y / args->rel_height + args->ascent;
+ if (length > 0 && string[index + length - 1] == '\n') + { + length--; + if (length > 0 && string[index + length - 1] == '\r') + length--; + } + stat = draw_driver_string(args->graphics, &string[index], length, font, format, args->brush, &position, DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance, NULL); diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index fd2622daf0e..67d8a980ee5 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -964,6 +964,13 @@ static GpStatus format_string_callback(HDC dc, float y = rect->Y + (bounds->Y - rect->Y) * args->scale; int i;
+ if (length > 0 && string[index + length - 1] == '\n') + { + length--; + if (length > 0 && string[index + length - 1] == '\r') + length--; + } + if (underlined_index_count) FIXME("hotkey underlines not drawn yet\n");
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 96a940d5fb7..392c828a442 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -3321,7 +3321,7 @@ static void test_string_functions(void) expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); - todo_wine expect(5, codepointsfitted); + expect(5, codepointsfitted); todo_wine expect(1, linesfilled);
/* Cut off everything after the first space. */ @@ -3368,9 +3368,7 @@ static void test_string_functions(void) expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(3.33, bounds.Width, 0.01); - todo_wine expectf_(char_bounds.Height, bounds.Height, 0.05); - todo_wine expect(1, codepointsfitted); expect(1, linesfilled);