[GDIPLUS_WINETEST]
[reactos.git] / rostests / winetests / gdiplus / font.c
index eb850a8..c4f7dbe 100644 (file)
 
 #include <math.h>
 
-#include "windows.h"
-#include "gdiplus.h"
-#include "wine/test.h"
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+//#include "windows.h"
+#include <wine/test.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <objbase.h>
+#include <gdiplus.h>
 
 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
 #define expect_(expected, got, precision) ok(abs((expected) - (got)) <= (precision), "Expected %d, got %d\n", (expected), (got))
 
 static const WCHAR nonexistent[] = {'T','h','i','s','F','o','n','t','s','h','o','u','l','d','N','o','t','E','x','i','s','t','\0'};
 static const WCHAR MSSansSerif[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
-static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f','\0'};
 static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
-static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
 static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
-static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
 
 static void set_rect_empty(RectF *rc)
 {
@@ -735,7 +739,7 @@ static void test_font_substitution(void)
     WCHAR ms_shell_dlg[LF_FACESIZE];
     HDC hdc;
     HFONT hfont;
-    LOGFONT lf;
+    LOGFONTA lf;
     GpStatus status;
     GpGraphics *graphics;
     GpFont *font;
@@ -750,9 +754,9 @@ static void test_font_substitution(void)
     ok(hfont != 0, "GetStockObject(DEFAULT_GUI_FONT) failed\n");
 
     memset(&lf, 0xfe, sizeof(lf));
-    ret = GetObject(hfont, sizeof(lf), &lf);
+    ret = GetObjectA(hfont, sizeof(lf), &lf);
     ok(ret == sizeof(lf), "GetObject failed\n");
-    ok(!lstrcmp(lf.lfFaceName, "MS Shell Dlg"), "wrong face name %s\n", lf.lfFaceName);
+    ok(!lstrcmpA(lf.lfFaceName, "MS Shell Dlg"), "wrong face name %s\n", lf.lfFaceName);
     MultiByteToWideChar(CP_ACP, 0, lf.lfFaceName, -1, ms_shell_dlg, LF_FACESIZE);
 
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
@@ -760,8 +764,8 @@ static void test_font_substitution(void)
     memset(&lf, 0xfe, sizeof(lf));
     status = GdipGetLogFontA(font, graphics, &lf);
     expect(Ok, status);
-    ok(!lstrcmp(lf.lfFaceName, "Microsoft Sans Serif") ||
-       !lstrcmp(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
+    ok(!lstrcmpA(lf.lfFaceName, "Microsoft Sans Serif") ||
+       !lstrcmpA(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
     GdipDeleteFont(font);
 
     status = GdipCreateFontFamilyFromName(ms_shell_dlg, NULL, &family);
@@ -771,21 +775,21 @@ static void test_font_substitution(void)
     memset(&lf, 0xfe, sizeof(lf));
     status = GdipGetLogFontA(font, graphics, &lf);
     expect(Ok, status);
-    ok(!lstrcmp(lf.lfFaceName, "Microsoft Sans Serif") ||
-       !lstrcmp(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
+    ok(!lstrcmpA(lf.lfFaceName, "Microsoft Sans Serif") ||
+       !lstrcmpA(lf.lfFaceName, "Tahoma"), "wrong face name %s\n", lf.lfFaceName);
     GdipDeleteFont(font);
     GdipDeleteFontFamily(family);
 
     status = GdipCreateFontFamilyFromName(nonexistent, NULL, &family);
     ok(status == FontFamilyNotFound, "expected FontFamilyNotFound, got %d\n", status);
 
-    lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist");
+    lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
     expect(Ok, status);
     memset(&lf, 0xfe, sizeof(lf));
     status = GdipGetLogFontA(font, graphics, &lf);
     expect(Ok, status);
-    ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
+    ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
     GdipDeleteFont(font);
 
     /* empty FaceName */
@@ -795,24 +799,30 @@ static void test_font_substitution(void)
     memset(&lf, 0xfe, sizeof(lf));
     status = GdipGetLogFontA(font, graphics, &lf);
     expect(Ok, status);
-    ok(!lstrcmp(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
+    ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName);
     GdipDeleteFont(font);
 
     /* zeroing out lfWeight and lfCharSet leads to font creation failure */
     lf.lfWeight = 0;
     lf.lfCharSet = 0;
-    lstrcpy(lf.lfFaceName, "ThisFontShouldNotExist");
+    lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
+    font = NULL;
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
 todo_wine
     ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
        "expected NotTrueTypeFont, got %d\n", status);
+    /* FIXME: remove when wine is fixed */
+    if (font) GdipDeleteFont(font);
 
     /* empty FaceName */
     lf.lfFaceName[0] = 0;
+    font = NULL;
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
 todo_wine
     ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
        "expected NotTrueTypeFont, got %d\n", status);
+    /* FIXME: remove when wine is fixed */
+    if (font) GdipDeleteFont(font);
 
     GdipDeleteGraphics(graphics);
     DeleteDC(hdc);
@@ -823,7 +833,7 @@ static void test_font_transform(void)
     static const WCHAR string[] = { 'A',0 };
     GpStatus status;
     HDC hdc;
-    LOGFONT lf;
+    LOGFONTA lf;
     GpFont *font;
     GpGraphics *graphics;
     GpMatrix *matrix;
@@ -845,7 +855,7 @@ static void test_font_transform(void)
     expect(Ok, status);
 
     memset(&lf, 0, sizeof(lf));
-    lstrcpy(lf.lfFaceName, "Tahoma");
+    lstrcpyA(lf.lfFaceName, "Tahoma");
     lf.lfHeight = -100;
     lf.lfWidth = 100;
     status = GdipCreateFontFromLogfontA(hdc, &lf, &font);
@@ -881,26 +891,21 @@ todo_wine
     expect(Ok, status);
     expectf(0.0, bounds.X);
     expectf(0.0, bounds.Y);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 1.0);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, NULL, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
     expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.5);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, matrix, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
     expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.5);
 
     /* scale matrix */
     status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
@@ -930,17 +935,14 @@ todo_wine
     expect(Ok, status);
     expectf(0.0, bounds.X);
     expectf(0.0, bounds.Y);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.05);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, NULL, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
     expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.2);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, matrix, &bounds);
@@ -979,17 +981,14 @@ todo_wine
     expect(Ok, status);
     expectf(0.0, bounds.X);
     expectf(0.0, bounds.Y);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.05);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, NULL, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
     expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.2);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, matrix, &bounds);
@@ -1030,17 +1029,14 @@ todo_wine
     expect(Ok, status);
     expectf(0.0, bounds.X);
     expectf(0.0, bounds.Y);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.2);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, NULL, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
-    expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(-100.0, bounds.Y, 0.2);
+    expectf_(height, bounds.Height, 0.2);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, matrix, &bounds);
@@ -1081,17 +1077,14 @@ todo_wine
     expect(Ok, status);
     expectf(0.0, bounds.X);
     expectf(0.0, bounds.Y);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(height, bounds.Height, 0.1);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, NULL, &bounds);
     expect(Ok, status);
     expectf(0.0, bounds.X);
-todo_wine
-    expectf_(-100.0, bounds.Y, 0.05);
-todo_wine
-    expectf(height, bounds.Height);
+    expectf_(-100.0, bounds.Y, 0.2);
+    expectf_(height, bounds.Height, 0.2);
     set_rect_empty(&bounds);
     status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
                                      DriverStringOptionsCmapLookup, matrix, &bounds);