From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/gdiplus/graphics.c | 19 +++++++++++++++++-- dlls/gdiplus/tests/graphics.c | 4 ---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 898a2e90d28..0faac1325d2 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5986,7 +5986,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, struct measure_ranges_args args; HDC hdc, temp_hdc=NULL; RectF scaled_rect; - REAL margin_x; + REAL margin_x, offsety = 0.0f; TRACE("(%p %s %d %p %s %p %d %p)\n", graphics, debugstr_wn(string, length), length, font, debugstr_rectf(layoutRect), stringFormat, regionCount, regions); @@ -6012,11 +6012,26 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, if (stringFormat->attr) TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr); + if (stringFormat->line_align != StringAlignmentNear) + { + RectF bounds, in_rect = *layoutRect; + in_rect.Height = 0.0f; /* avoid height clipping */ + GdipMeasureString(graphics, string, length, font, &in_rect, stringFormat, &bounds, NULL, NULL); + + TRACE("bounds %s\n", debugstr_rectf(&bounds)); + + if (stringFormat->line_align == StringAlignmentCenter) + offsety = (layoutRect->Height - bounds.Height) / 2.0f; + else if (stringFormat->line_align == StringAlignmentFar) + offsety = layoutRect->Height - bounds.Height; + } + TRACE("line align %d, offsety %f\n", stringFormat->line_align, offsety); + margin_x = stringFormat->generic_typographic ? 0.0 : font->emSize / 6.0; margin_x *= units_scale(font->unit, graphics->unit, graphics->xres, graphics->printer_display); transform_properties(graphics, NULL, TRUE, &args.rel_width, &args.rel_height, NULL); scaled_rect.X = (layoutRect->X + margin_x) * args.rel_width; - scaled_rect.Y = layoutRect->Y * args.rel_height; + scaled_rect.Y = (layoutRect->Y + offsety) * args.rel_height; scaled_rect.Width = layoutRect->Width * args.rel_width; scaled_rect.Height = layoutRect->Height * args.rel_height; if (scaled_rect.Width >= 0.5f) diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 337e1955021..8703081070f 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4956,7 +4956,6 @@ static void test_measure_string(void) status = GdipGetRegionBounds(region, graphics, &bounds); expect(Ok, status); 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); @@ -4972,7 +4971,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); @@ -5020,7 +5018,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); @@ -5036,7 +5033,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