From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/gdiplus/graphics.c | 47 +++++++++++++++-------------------- dlls/gdiplus/tests/graphics.c | 6 +---- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index f282ab447a4..d04af8c17e8 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5576,7 +5576,6 @@ GpStatus gdip_format_string(GpGraphics *graphics, HDC hdc, int sum = 0, height = 0, fit, fitcpy, i, j, lret, nwidth, nheight, lineend, lineno = 0; RectF bounds; - StringAlignment halign; GpStatus stat = Ok; SIZE size; HotkeyPrefix hkprefix; @@ -5657,8 +5656,6 @@ GpStatus gdip_format_string(GpGraphics *graphics, HDC hdc, length = j; - halign = format->align; - generate_font_link_info(&info, length, font); while(sum < length){ @@ -5723,19 +5720,33 @@ GpStatus gdip_format_string(GpGraphics *graphics, HDC hdc, else bounds.Height = size.cy; + bounds.X = rect->X; + + switch (format->align) + { + case StringAlignmentNear: + default: + break; + case StringAlignmentCenter: + bounds.X += (rect->Width - bounds.Width) / 2; + break; + case StringAlignmentFar: + bounds.X += rect->Width - bounds.Width; + break; + } + bounds.Y = rect->Y + height; - switch (halign) + switch (format->line_align) { case StringAlignmentNear: default: - bounds.X = rect->X; break; case StringAlignmentCenter: - bounds.X = rect->X + (rect->Width/2) - (bounds.Width/2); + bounds.Y += (rect->Height - bounds.Height) / 2; break; case StringAlignmentFar: - bounds.X = rect->X + rect->Width - bounds.Width; + bounds.Y += rect->Height - bounds.Height; break; } @@ -5946,7 +5957,7 @@ static GpStatus measure_string_callback(struct gdip_format_string_info *info) REAL new_width, new_height; new_width = info->bounds->Width / args->rel_width; - new_height = (info->bounds->Height + info->bounds->Y) / args->rel_height - bounds->Y; + new_height = info->bounds->Height / args->rel_height; if (new_width > bounds->Width) bounds->Width = new_width; @@ -6158,7 +6169,6 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string POINT corners[4]; REAL rel_width, rel_height, margin_x; INT save_state, format_flags = 0; - REAL offsety = 0.0; struct draw_string_args args; RectF scaled_rect; HDC hdc, temp_hdc=NULL; @@ -6186,24 +6196,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string if(format){ TRACE("may be ignoring some format flags: attr %x\n", format->attr); - format_flags = format->attr; - - /* Should be no need to explicitly test for StringAlignmentNear as - * that is default behavior if no alignment is passed. */ - if(format->line_align != StringAlignmentNear){ - RectF bounds, in_rect = *rect; - in_rect.Height = 0.0; /* avoid height clipping */ - GdipMeasureString(graphics, string, length, font, &in_rect, format, &bounds, 0, 0); - - TRACE("bounds %s\n", debugstr_rectf(&bounds)); - - if(format->line_align == StringAlignmentCenter) - offsety = (rect->Height - bounds.Height) / 2; - else if(format->line_align == StringAlignmentFar) - offsety = (rect->Height - bounds.Height); - } - TRACE("line align %d, offsety %f\n", format->line_align, offsety); } save_state = SaveDC(hdc); @@ -6248,7 +6241,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string args.brush = brush; args.x = rect->X; - args.y = rect->Y + offsety; + args.y = rect->Y; args.rel_width = rel_width; args.rel_height = rel_height; diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index e1c99e98080..ebeb8c03a37 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -3387,7 +3387,7 @@ static void test_string_functions(void) expectf(0.0, bounds.Y); ok(bounds.Width > char_bounds.Width + char_width * 2, "got %0.2f, expected at least %0.2f\n", bounds.Width, char_bounds.Width + char_width * 2); - ok(bounds.Height > char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height); + ok(bounds.Height >= char_bounds.Height, "got %0.2f, expected at least %0.2f\n", bounds.Height, char_bounds.Height); expect(6, codepointsfitted); expect(2, linesfilled); char_height = bounds.Height - char_bounds.Height; @@ -4951,7 +4951,6 @@ static void test_measure_string(void) expect(Ok, status); todo_wine expectf_(5.0 + width_rgn/2.0, bounds.X, 1.0); - todo_wine expectf_(5.0 + height_rgn/2.0, bounds.Y, 1.0); expectf_(width_rgn, bounds.Width, 1.0); expectf_(height_rgn, bounds.Height, 1.0); @@ -4967,7 +4966,6 @@ static void test_measure_string(void) expect(Ok, status); todo_wine expectf_(5.0 - width_rgn/2.0, bounds.X, 1.0); - todo_wine expectf_(5.0 - height_rgn/2.0, bounds.Y, 1.0); expectf_(width_rgn, bounds.Width, 1.0); expectf_(height_rgn, bounds.Height, 1.0); @@ -5016,7 +5014,6 @@ static void test_measure_string(void) expect(Ok, status); todo_wine expectf_(5.0 + width_rgn, bounds.X, 2.0); - todo_wine expectf_(5.0 + height_rgn, bounds.Y, 1.0); expectf_(width_rgn, bounds.Width, 1.0); expectf_(height_rgn, bounds.Height, 1.0); @@ -5032,7 +5029,6 @@ static void test_measure_string(void) expect(Ok, status); todo_wine expectf_(5.0 - width_rgn, bounds.X, 2.0); - todo_wine expectf_(5.0 - height_rgn, bounds.Y, 1.0); expectf_(width_rgn, bounds.Width, 1.0); expectf_(height_rgn, bounds.Height, 1.0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9775