[PATCH 0/1] MR10722: gdiplus: Add support to line alignment for GdipMeasureString
From: Bartosz Kosiorek <gang65@poczta.onet.pl> --- dlls/gdiplus/graphics.c | 39 ++++++++++++++++++++++++----------- dlls/gdiplus/tests/graphics.c | 6 ------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index b278bfd1d94..32450630a92 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -6075,18 +6075,6 @@ static GpStatus measure_string_callback(struct gdip_format_string_info *info) if (args->linesfilled) (*args->linesfilled)++; - switch (info->format ? info->format->align : StringAlignmentNear) - { - case StringAlignmentCenter: - bounds->X = bounds->X + (info->rect->Width/2) - (bounds->Width/2); - break; - case StringAlignmentFar: - bounds->X = bounds->X + info->rect->Width - bounds->Width; - break; - default: - break; - } - return Ok; } @@ -6173,6 +6161,33 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, if (lines) bounds->Width += margin_x * 2.0; + if (lines && format) + { + switch (format->align) + { + case StringAlignmentCenter: + bounds->X = rect->X + (rect->Width - bounds->Width) / 2.0f; + break; + case StringAlignmentFar: + bounds->X = rect->X + rect->Width - bounds->Width; + break; + default: + break; + } + + switch (format->line_align) + { + case StringAlignmentCenter: + bounds->Y = rect->Y + (rect->Height - bounds->Height) / 2.0f; + break; + case StringAlignmentFar: + bounds->Y = rect->Y + rect->Height - bounds->Height; + break; + default: + break; + } + } + SelectObject(hdc, oldfont); DeleteObject(gdifont); end: diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 96ef52ce935..c039d67c2de 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4921,7 +4921,6 @@ static void test_measure_string(void) expect(3, glyphs); expect(1, lines); expectf_(5.0 + width/2.0, bounds.X, 0.01); - todo_wine expectf(5.0 + height/2.0, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -4935,9 +4934,7 @@ static void test_measure_string(void) expect(Ok, status); expect(3, glyphs); expect(1, lines); - todo_wine expectf_(5.0 - width/2.0, bounds.X, 0.01); - todo_wine expectf(5.0 - height/2.0, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -4988,7 +4985,6 @@ static void test_measure_string(void) expect(3, glyphs); expect(1, lines); expectf_(5.0 + width, bounds.X, 0.01); - todo_wine expectf(5.0 + height, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); @@ -5002,9 +4998,7 @@ static void test_measure_string(void) expect(Ok, status); expect(3, glyphs); expect(1, lines); - todo_wine expectf_(5.0 - width, bounds.X, 0.01); - todo_wine expectf(5.0 - height, bounds.Y); expectf_(width, bounds.Width, 0.01); expectf(height, bounds.Height); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10722
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10722
participants (3)
-
Bartosz Kosiorek -
Bartosz Kosiorek (@gang65) -
Esme Povirk (@madewokherd)