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@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
Vincent Povirk madewokherd@gmail.com wrote:
If the string wraps, and you don't give the width to GdipMeasureString, won't it return a too small height?
GdipMeasureString considers an empty rect as a rect without clipping.
OK, but if the rect passed to GdipDrawString has a non-zero width, and depending on the string formatting options, GdipDrawString may wrap the text. GdipMeasureString will not wrap the text if you call it with a width of 0.
On Mon, May 14, 2012 at 9:37 AM, Dmitry Timoshkov dmitry@baikal.ru wrote:
Vincent Povirk madewokherd@gmail.com wrote:
If the string wraps, and you don't give the width to GdipMeasureString, won't it return a too small height?
GdipMeasureString considers an empty rect as a rect without clipping.
-- Dmitry.
Vincent Povirk madewokherd@gmail.com wrote:
OK, but if the rect passed to GdipDrawString has a non-zero width, and depending on the string formatting options, GdipDrawString may wrap the text. GdipMeasureString will not wrap the text if you call it with a width of 0.
That's a good point, thanks.