Skip to content

Commit

Permalink
gdiplus: Round width and height in gdip_format_string().
Browse files Browse the repository at this point in the history
CW-Bug-Id: #23002
  • Loading branch information
Paul Gofman committed Nov 17, 2023
1 parent 8cb26d4 commit 9a04c16
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dlls/gdiplus/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -5195,8 +5195,8 @@ GpStatus gdip_format_string(HDC hdc,
if (!format)
format = &default_drawstring_format;

nwidth = rect->Width;
nheight = rect->Height;
nwidth = (int)(rect->Width + 0.005f);
nheight = (int)(rect->Height + 0.005f);
if (ignore_empty_clip)
{
if (!nwidth) nwidth = INT_MAX;
Expand Down
15 changes: 14 additions & 1 deletion dlls/gdiplus/tests/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -4672,7 +4672,7 @@ static void test_measure_string(void)

set_rect_empty(&rect);
rect.Height = height;
rect.Width = width_2 - 0.05;
rect.Width = width_2 - 0.006;
set_rect_empty(&bounds);
status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
expect(Ok, status);
Expand All @@ -4683,6 +4683,19 @@ static void test_measure_string(void)
expectf_(width_1, bounds.Width, 0.01);
expectf(height, bounds.Height);

set_rect_empty(&rect);
rect.Height = height;
rect.Width = width_2 - 0.004;
set_rect_empty(&bounds);
status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, &glyphs, &lines);
expect(Ok, status);
expect(2, glyphs);
expect(1, lines);
expectf(0.0, bounds.X);
expectf(0.0, bounds.Y);
expectf_(width_2, bounds.Width, 0.01);
expectf(height, bounds.Height);

/* Default (Near) alignment */
rect.X = 5.0;
rect.Y = 5.0;
Expand Down

0 comments on commit 9a04c16

Please sign in to comment.