From 6ab04040e52465e77558a067309e8a54bdc0f32c Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 15 Mar 2013 13:38:21 +0900 Subject: [PATCH] gdiplus: GdipMeasureCharacterRanges should treat empty layout extents as infinite when StringFormatFlagsNoClip is specified. Unlike GdipMeasureString which always treats empty layout extents as infinite. --- dlls/gdiplus/gdiplus_private.h | 2 +- dlls/gdiplus/graphics.c | 21 +++++++++++++-------- dlls/gdiplus/graphicspath.c | 3 ++- dlls/gdiplus/tests/graphics.c | 8 -------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 87f3b8b0e5b..f2214b5685e 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -442,7 +442,7 @@ typedef GpStatus (*gdip_format_string_callback)(HDC hdc, GpStatus gdip_format_string(HDC hdc, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, - GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, + GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip, gdip_format_string_callback callback, void *user_data) DECLSPEC_HIDDEN; void get_log_fontW(const GpFont *, GpGraphics *, LOGFONTW *) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 93f85b13002..10a640294e3 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -4418,7 +4418,7 @@ GpStatus WINGDIPAPI GdipIsVisibleRectI(GpGraphics *graphics, INT x, INT y, INT w GpStatus gdip_format_string(HDC hdc, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, - GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, + GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip, gdip_format_string_callback callback, void *user_data) { WCHAR* stringdup; @@ -4441,6 +4441,11 @@ GpStatus gdip_format_string(HDC hdc, nwidth = rect->Width; nheight = rect->Height; + if (ignore_empty_clip) + { + if (!nwidth) nwidth = INT_MAX; + if (!nheight) nheight = INT_MAX; + } if (format) hkprefix = format->hkprefix; @@ -4698,7 +4703,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, args.regions = regions; stat = gdip_format_string(hdc, string, length, font, &scaled_rect, stringFormat, - measure_ranges_callback, &args); + (stringFormat->attr & StringFormatFlagsNoClip) != 0, measure_ranges_callback, &args); SelectObject(hdc, oldfont); DeleteObject(gdifont); @@ -4806,8 +4811,8 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, if (scaled_rect.Width < 0.5) return Ok; /* doesn't fit */ } - if (scaled_rect.Width >= 1 << 23 || scaled_rect.Width < 0.5) scaled_rect.Width = 1 << 23; - if (scaled_rect.Height >= 1 << 23 || scaled_rect.Height < 0.5) scaled_rect.Height = 1 << 23; + if (scaled_rect.Width >= 1 << 23) scaled_rect.Width = 1 << 23; + if (scaled_rect.Height >= 1 << 23) scaled_rect.Height = 1 << 23; get_font_hfont(graphics, font, format, &gdifont, NULL); oldfont = SelectObject(hdc, gdifont); @@ -4822,7 +4827,7 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, args.linesfilled = &lines; lines = glyphs = 0; - gdip_format_string(hdc, string, length, font, &scaled_rect, format, + gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE, measure_string_callback, &args); if (linesfilled) *linesfilled = lines; @@ -4979,8 +4984,8 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string if (scaled_rect.Width < 0.5) return Ok; /* doesn't fit */ } - if (scaled_rect.Width >= 1 << 23 || scaled_rect.Width < 0.5) scaled_rect.Width = 1 << 23; - if (scaled_rect.Height >= 1 << 23 || scaled_rect.Height < 0.5) scaled_rect.Height = 1 << 23; + if (scaled_rect.Width >= 1 << 23) scaled_rect.Width = 1 << 23; + if (scaled_rect.Height >= 1 << 23) scaled_rect.Height = 1 << 23; if (!(format_flags & StringFormatFlagsNoClip) && scaled_rect.Width != 1 << 23 && scaled_rect.Height != 1 << 23) @@ -5005,7 +5010,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string GetTextMetricsW(hdc, &textmetric); args.ascent = textmetric.tmAscent / rel_height; - gdip_format_string(hdc, string, length, font, &scaled_rect, format, + gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE, draw_string_callback, &args); DeleteObject(rgn); diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index f4d1a4b1efa..62f84907101 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1009,7 +1009,8 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT args.maxY = 0; args.scale = emSize / native_height; args.ascent = textmetric.tmAscent * args.scale; - status = gdip_format_string(dc, string, length, NULL, &scaled_layout_rect, format, format_string_callback, &args); + status = gdip_format_string(dc, string, length, NULL, &scaled_layout_rect, + format, TRUE, format_string_callback, &args); DeleteDC(dc); DeleteObject(hfont); diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 4df2119ec46..cbe0b9d19f3 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4050,13 +4050,9 @@ todo_wine set_rect_empty(&bounds); status = GdipGetRegionBounds(region, graphics, &bounds); expect(Ok, status); -todo_wine expectf_(5.0 + margin_x, bounds.X, 1.0); -todo_wine expectf(5.0, bounds.Y); -todo_wine expectf(width_rgn, bounds.Width); -todo_wine expectf(height_rgn, bounds.Height); rect.X = 5.0; @@ -4247,9 +4243,7 @@ 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); -todo_wine expectf_(width_rgn, bounds.Width, 1.0); -todo_wine expectf_(height_rgn, bounds.Height, 1.0); /* Far alignment */ @@ -4317,9 +4311,7 @@ todo_wine expectf_(5.0 - width_rgn, bounds.X, 2.0); todo_wine expectf_(5.0 - height_rgn, bounds.Y, 1.0); -todo_wine expectf_(width_rgn, bounds.Width, 1.0); -todo_wine expectf_(height_rgn, bounds.Height, 1.0); status = GdipDeleteFont(font);