[1/2] gdiplus: Measure the passed in string without clipping in order to compute correct Y offset. Take 2.

Vincent Povirk madewokherd at gmail.com
Mon May 14 09:25:06 CDT 2012


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 at 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
>
>
>



More information about the wine-devel mailing list