I tried just using the bound box position calculated by gdip_format_string but I couldn't find a way to get tests to pass.
From: Santino Mazza smazza@codeweavers.com
--- dlls/gdiplus/graphics.c | 23 ++++++++++++++++++----- dlls/gdiplus/tests/graphics.c | 2 -- 2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 1c0e6aa07d6..bdb2e1c917c 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5826,16 +5826,17 @@ struct measure_string_args { static GpStatus measure_string_callback(struct gdip_format_string_info *info) { struct measure_string_args *args = info->user_data; + RectF *bounds = args->bounds; REAL new_width, new_height;
new_width = info->bounds->Width / args->rel_width; - new_height = (info->bounds->Height + info->bounds->Y) / args->rel_height - args->bounds->Y; + new_height = (info->bounds->Height + info->bounds->Y) / args->rel_height - bounds->Y;
- if (new_width > args->bounds->Width) - args->bounds->Width = new_width; + if (new_width > bounds->Width) + bounds->Width = new_width;
- if (new_height > args->bounds->Height) - args->bounds->Height = new_height; + if (new_height > bounds->Height) + bounds->Height = new_height;
if (args->codepointsfitted) *args->codepointsfitted = info->index + info->length; @@ -5843,6 +5844,18 @@ 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; }
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index c1c0fa67669..29529463fa5 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4911,7 +4911,6 @@ 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); @@ -4979,7 +4978,6 @@ 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);
This merge request was approved by Esme Povirk.