From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/gdiplus/graphics.c | 17 +++++++++++++---- dlls/gdiplus/graphicspath.c | 7 +++++++ dlls/gdiplus/tests/graphics.c | 4 +--- 3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 65b33cdc960..c249235778e 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5248,6 +5248,7 @@ GpStatus gdip_format_string(HDC hdc, if(*(stringdup + sum + lret) == '\n') { unixstyle_newline = TRUE; + lret += 1; break; }
@@ -5255,13 +5256,14 @@ GpStatus gdip_format_string(HDC hdc, && *(stringdup + sum + lret + 1) == '\n') { unixstyle_newline = FALSE; + lret += 2; 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(lret > 0 && *(stringdup + sum + lret - 1) == '\n') + lineend = fit = lret; else if(fit < (length - sum)){ if(*(stringdup + sum + fit) == ' ') while(*(stringdup + sum + fit) == ' ') @@ -5333,13 +5335,13 @@ GpStatus gdip_format_string(HDC hdc, { height += size.cy; lineno++; - sum += fit + (lret < fitcpy ? 1 : 0); + sum += fit; } else { height += size.cy; lineno++; - sum += fit + (lret < fitcpy ? 2 : 0); + sum += fit; }
hotkeyprefix_pos = hotkeyprefix_end_pos; @@ -5645,6 +5647,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);