Commit 1c30b894 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: Stop adding 1/6 of EM height to the created font height.

parent ec4cd117
...@@ -2138,15 +2138,13 @@ static void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font, ...@@ -2138,15 +2138,13 @@ static void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font,
{ {
HDC hdc = CreateCompatibleDC(0); HDC hdc = CreateCompatibleDC(0);
GpPointF pt[3]; GpPointF pt[3];
REAL angle, rel_width, rel_height, font_height, font_to_pixel_scale; REAL angle, rel_width, rel_height, font_height;
LOGFONTW lfw; LOGFONTW lfw;
HFONT unscaled_font; HFONT unscaled_font;
TEXTMETRICW textmet; TEXTMETRICW textmet;
font_to_pixel_scale = (format && format->generic_typographic) ? 1.0 : units_scale(UnitPoint, UnitPixel, font->family->dpi);
if (font->unit == UnitPixel) if (font->unit == UnitPixel)
font_height = font->emSize * font_to_pixel_scale; font_height = font->emSize;
else else
{ {
REAL unit_scale, res; REAL unit_scale, res;
...@@ -2154,7 +2152,7 @@ static void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font, ...@@ -2154,7 +2152,7 @@ static void get_font_hfont(GpGraphics *graphics, GDIPCONST GpFont *font,
res = (graphics->unit == UnitDisplay || graphics->unit == UnitPixel) ? graphics->xres : graphics->yres; res = (graphics->unit == UnitDisplay || graphics->unit == UnitPixel) ? graphics->xres : graphics->yres;
unit_scale = units_scale(font->unit, graphics->unit, res); unit_scale = units_scale(font->unit, graphics->unit, res);
font_height = font->emSize * font_to_pixel_scale * unit_scale; font_height = font->emSize * unit_scale;
if (graphics->unit != UnitDisplay) if (graphics->unit != UnitDisplay)
font_height /= graphics->scale; font_height /= graphics->scale;
} }
......
...@@ -3530,6 +3530,7 @@ static void test_GdipMeasureString(void) ...@@ -3530,6 +3530,7 @@ static void test_GdipMeasureString(void)
expectf(0.0, bounds.X); expectf(0.0, bounds.X);
expectf(0.0, bounds.Y); expectf(0.0, bounds.Y);
todo_wine
expectf_(height, bounds.Height, height / 100.0); expectf_(height, bounds.Height, height / 100.0);
expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1); expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
expect(7, chars); expect(7, chars);
...@@ -3546,6 +3547,7 @@ static void test_GdipMeasureString(void) ...@@ -3546,6 +3547,7 @@ static void test_GdipMeasureString(void)
expect(Ok, status); expect(Ok, status);
expectf(50.0, bounds.X); expectf(50.0, bounds.X);
expectf(50.0, bounds.Y); expectf(50.0, bounds.Y);
todo_wine
expectf_(height, bounds.Height, height / 100.0); expectf_(height, bounds.Height, height / 100.0);
expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1); expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
expect(7, chars); expect(7, chars);
...@@ -3613,6 +3615,7 @@ static void test_GdipMeasureString(void) ...@@ -3613,6 +3615,7 @@ static void test_GdipMeasureString(void)
expectf(0.0, bounds.X); expectf(0.0, bounds.X);
expectf(0.0, bounds.Y); expectf(0.0, bounds.Y);
todo_wine
expectf_(height, bounds.Height, height / 85.0); expectf_(height, bounds.Height, height / 85.0);
expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1); expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
expect(7, chars); expect(7, chars);
...@@ -3629,6 +3632,7 @@ static void test_GdipMeasureString(void) ...@@ -3629,6 +3632,7 @@ static void test_GdipMeasureString(void)
expect(Ok, status); expect(Ok, status);
expectf(50.0, bounds.X); expectf(50.0, bounds.X);
expectf(50.0, bounds.Y); expectf(50.0, bounds.Y);
todo_wine
expectf_(height, bounds.Height, height / 85.0); expectf_(height, bounds.Height, height / 85.0);
expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1); expectf_(bounds.Height / base_cy, bounds.Width / base_cx, 0.1);
expect(7, chars); expect(7, chars);
...@@ -3640,6 +3644,7 @@ static void test_GdipMeasureString(void) ...@@ -3640,6 +3644,7 @@ static void test_GdipMeasureString(void)
height *= td[i].page_scale; height *= td[i].page_scale;
/*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n", /*trace("%u: unit %u, %.1fx%.1f dpi, scale %.1f, height %f, pixels %f\n",
i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/ i, td[i].unit, td[i].res_x, td[i].res_y, td[i].page_scale, bounds.Height, height);*/
todo_wine
expectf_(100.0, height, 1.1); expectf_(100.0, height, 1.1);
status = GdipDeleteGraphics(graphics); status = GdipDeleteGraphics(graphics);
...@@ -3833,12 +3838,14 @@ static void test_font_height_scaling(void) ...@@ -3833,12 +3838,14 @@ static void test_font_height_scaling(void)
status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, &ptf, 1); status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, &ptf, 1);
expect(Ok, status); expect(Ok, status);
match = fabs(100.0 - ptf.Y) <= 1.0; match = fabs(100.0 - ptf.Y) <= 1.0;
todo_wine
ok(match, "Expected 100.0, got %f\n", ptf.Y); ok(match, "Expected 100.0, got %f\n", ptf.Y);
/* verify the result */ /* verify the result */
ptf.Y = units_to_pixels(bounds.Height, gfx_unit, dpi); ptf.Y = units_to_pixels(bounds.Height, gfx_unit, dpi);
ptf.Y /= 100.0; ptf.Y /= 100.0;
match = fabs(100.0 - ptf.Y) <= 1.0; match = fabs(100.0 - ptf.Y) <= 1.0;
todo_wine
ok(match, "Expected 100.0, got %f\n", ptf.Y); ok(match, "Expected 100.0, got %f\n", ptf.Y);
/* bounds.width of 1 glyph: [margin]+[width]+[margin] */ /* bounds.width of 1 glyph: [margin]+[width]+[margin] */
...@@ -3874,6 +3881,7 @@ static void test_font_height_scaling(void) ...@@ -3874,6 +3881,7 @@ static void test_font_height_scaling(void)
match = fabs(1.0 - margin / rect.X) <= 0.05; match = fabs(1.0 - margin / rect.X) <= 0.05;
ok(match, "Expected %f, got %f\n", margin, rect.X); ok(match, "Expected %f, got %f\n", margin, rect.X);
match = fabs(1.0 - height / rect.Height) <= 0.1; match = fabs(1.0 - height / rect.Height) <= 0.1;
todo_wine
ok(match, "Expected %f, got %f\n", height, rect.Height); ok(match, "Expected %f, got %f\n", height, rect.Height);
match = fabs(1.0 - bounds.Width / (rect.Width + margin * 2.0)) <= 0.05; match = fabs(1.0 - bounds.Width / (rect.Width + margin * 2.0)) <= 0.05;
ok(match, "Expected %f, got %f\n", bounds.Width, rect.Width + margin * 2.0); ok(match, "Expected %f, got %f\n", bounds.Width, rect.Width + margin * 2.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment