If the string wraps, and you don't give the width to
GdipMeasureString, won't it return a too small height?
On Mon, May 14, 2012 at 9:11 AM, Dmitry Timoshkov <dmitry(a)baikal.ru> wrote:
> GdipMeasureString() clips the string extents to passed rectangle width and
> height, but that leads to wrong offsety calculation if the string doesn't
> fit into that rectangle.
> ---
> dlls/gdiplus/graphics.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
> index 38335a8..1c9780d 100644
> --- a/dlls/gdiplus/graphics.c
> +++ b/dlls/gdiplus/graphics.c
> @@ -5162,14 +5162,18 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
> /* Should be no need to explicitly test for StringAlignmentNear as
> * that is default behavior if no alignment is passed. */
> if(format->vertalign != StringAlignmentNear){
> + static const RectF empty_rect = { 0.0, 0.0, 0.0, 0.0 };
> RectF bounds;
> - GdipMeasureString(graphics, string, length, font, rect, format, &bounds, 0, 0);
> + GdipMeasureString(graphics, string, length, font, &empty_rect, format, &bounds, 0, 0);
> +
> + TRACE("bounds %s\n", debugstr_rectf(&bounds));
>
> if(format->vertalign == StringAlignmentCenter)
> offsety = (rect->Height - bounds.Height) / 2;
> else if(format->vertalign == StringAlignmentFar)
> offsety = (rect->Height - bounds.Height);
> }
> + TRACE("vertical align %d, offsety %f\n", format->vertalign, offsety);
> }
>
> save_state = SaveDC(hdc);
> --
> 1.7.10.1
>
>
>