Commit de6c150d authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdiplus: Add a test for extra space added by GdipMeasureString.

parent 6f630a40
......@@ -3892,6 +3892,77 @@ todo_wine
GdipDeleteStringFormat(format);
}
static void test_measured_extra_space(void)
{
static const WCHAR tahomaW[] = { 'T','a','h','o','m','a',0 };
static const WCHAR string[2] = { 'W','W' };
GpStringFormat *format;
HDC hdc;
GpGraphics *graphics;
GpFontFamily *family;
GpFont *font;
GpStatus status;
GpUnit gfx_unit, font_unit;
RectF bounds_1, bounds_2, rect;
REAL margin, font_size, dpi;
status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
expect(Ok, status);
status = GdipCreateFontFamilyFromName(tahomaW, NULL, &family);
expect(Ok, status);
hdc = CreateCompatibleDC(0);
status = GdipCreateFromHDC(hdc, &graphics);
expect(Ok, status);
status = GdipGetDpiX(graphics, &dpi);
expect(Ok, status);
/* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
/* UnitPixel as a font base unit is not tested because it differs in behaviour */
for (font_unit = 3; font_unit <= 6; font_unit++)
{
status = GdipCreateFont(family, 1234.0, FontStyleRegular, font_unit, &font);
expect(Ok, status);
status = GdipGetFontSize(font, &font_size);
expect(Ok, status);
font_size = units_to_pixels(font_size, font_unit, dpi);
/*trace("font size/6 = %f pixels\n", font_size / 6.0);*/
/* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
for (gfx_unit = 2; gfx_unit <= 6; gfx_unit++)
{
status = GdipSetPageUnit(graphics, gfx_unit);
expect(Ok, status);
/* bounds.width of 1 glyph: [margin]+[width]+[margin] */
set_rect_empty(&rect);
set_rect_empty(&bounds_1);
status = GdipMeasureString(graphics, string, 1, font, &rect, format, &bounds_1, NULL, NULL);
expect(Ok, status);
/* bounds.width of 2 identical glyphs: [margin]+[width]+[width]+[margin] */
set_rect_empty(&rect);
set_rect_empty(&bounds_2);
status = GdipMeasureString(graphics, string, 2, font, &rect, format, &bounds_2, NULL, NULL);
expect(Ok, status);
/* margin = [bounds.width of 1] - [bounds.width of 2] / 2*/
margin = units_to_pixels(bounds_1.Width - bounds_2.Width / 2.0, gfx_unit, dpi);
/*trace("margin %f pixels\n", margin);*/
todo_wine
expectf_(font_size / 6.0, margin, font_size / 100.0);
}
GdipDeleteFont(font);
}
GdipDeleteGraphics(graphics);
DeleteDC(hdc);
GdipDeleteFontFamily(family);
GdipDeleteStringFormat(format);
}
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
......@@ -3918,6 +3989,7 @@ START_TEST(graphics)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_measured_extra_space();
test_measure_string();
test_font_height_scaling();
test_transform();
......
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