gdiplus: Add more font transformation tests.

Dmitry Timoshkov dmitry at baikal.ru
Tue Oct 9 04:41:47 CDT 2012


---
 dlls/gdiplus/tests/font.c | 177 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 176 insertions(+), 1 deletion(-)

diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c
index 0ac9558..e808278 100644
--- a/dlls/gdiplus/tests/font.c
+++ b/dlls/gdiplus/tests/font.c
@@ -26,7 +26,8 @@
 #include "wine/test.h"
 
 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
-#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %f, got %f\n", expected, got)
+#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
+#define expectf(expected, got) expectf_((expected), (got), 0.001)
 
 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'};
@@ -36,6 +37,14 @@ static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','
 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)
+{
+    rc->X = 0.0;
+    rc->Y = 0.0;
+    rc->Width = 0.0;
+    rc->Height = 0.0;
+}
+
 static void test_createfont(void)
 {
     GpFontFamily* fontfamily = NULL, *fontfamily2;
@@ -806,17 +815,30 @@ todo_wine
 
 static void test_font_transform(void)
 {
+    static const WCHAR string[] = { 'A',0 };
     GpStatus status;
     HDC hdc;
     LOGFONT lf;
     GpFont *font;
     GpGraphics *graphics;
     GpMatrix *matrix;
+    GpStringFormat *format, *typographic;
+    PointF pos[1] = { { 0,0 } };
+    REAL height;
+    RectF bounds, rect;
 
     hdc = CreateCompatibleDC(0);
     status = GdipCreateFromHDC(hdc, &graphics);
     expect(Ok, status);
 
+    status = GdipSetPageUnit(graphics, UnitPixel);
+    expect(Ok, status);
+
+    status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
+    expect(Ok, status);
+    status = GdipStringFormatGetGenericTypographic(&typographic);
+    expect(Ok, status);
+
     memset(&lf, 0, sizeof(lf));
     lstrcpy(lf.lfFaceName, "Tahoma");
     lf.lfHeight = -100;
@@ -833,6 +855,34 @@ static void test_font_transform(void)
     expect(Ok, status);
     expect(-100, lf.lfHeight);
     expect(0, lf.lfWidth);
+    status = GdipGetFontHeight(font, graphics, &height);
+    expect(Ok, status);
+    expectf(120.703125, height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(133.203125, bounds.Height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(120.703125, bounds.Height);
+    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(120.703125, bounds.Height);
 
     /* scale matrix */
     status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
@@ -844,6 +894,34 @@ static void test_font_transform(void)
 todo_wine
     expect(-300, lf.lfHeight);
     expect(0, lf.lfWidth);
+    status = GdipGetFontHeight(font, graphics, &height);
+    expect(Ok, status);
+    expectf(120.703125, height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(133.203125, bounds.Height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(120.703125, bounds.Height);
+    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(120.703125, bounds.Height);
 
     /* scale + ratate matrix */
     status = GdipRotateMatrix(matrix, 45.0, MatrixOrderAppend);
@@ -855,6 +933,34 @@ todo_wine
 todo_wine
     expect(-300, lf.lfHeight);
     expect(0, lf.lfWidth);
+    status = GdipGetFontHeight(font, graphics, &height);
+    expect(Ok, status);
+    expectf(120.703125, height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(133.203125, bounds.Height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(120.703125, bounds.Height);
+    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(120.703125, bounds.Height);
 
     /* scale + ratate + shear matrix */
     status = GdipShearMatrix(matrix, 4.0, 5.0, MatrixOrderAppend);
@@ -866,10 +972,79 @@ todo_wine
 todo_wine
     expect(1032, lf.lfHeight);
     expect(0, lf.lfWidth);
+    status = GdipGetFontHeight(font, graphics, &height);
+    expect(Ok, status);
+    expectf(120.703125, height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(133.203125, bounds.Height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(120.703125, bounds.Height);
+    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(120.703125, bounds.Height);
+
+    /* scale + ratate + shear + translate matrix */
+    status = GdipTranslateMatrix(matrix, 10.0, 20.0, MatrixOrderAppend);
+    expect(Ok, status);
+    status = GdipSetWorldTransform(graphics, matrix);
+    expect(Ok, status);
+    status = GdipGetLogFontA(font, graphics, &lf);
+    expect(Ok, status);
+todo_wine
+    expect(1032, lf.lfHeight);
+    expect(0, lf.lfWidth);
+    status = GdipGetFontHeight(font, graphics, &height);
+    expect(Ok, status);
+    expectf(120.703125, height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(133.203125, bounds.Height);
+    set_rect_empty(&rect);
+    set_rect_empty(&bounds);
+    status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
+    expect(Ok, status);
+    expectf(0.0, bounds.X);
+    expectf(0.0, bounds.Y);
+todo_wine
+    expectf(120.703125, bounds.Height);
+    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(120.703125, bounds.Height);
 
     GdipDeleteMatrix(matrix);
     GdipDeleteFont(font);
     GdipDeleteGraphics(graphics);
+    GdipDeleteStringFormat(typographic);
+    GdipDeleteStringFormat(format);
     DeleteDC(hdc);
 }
 
-- 
1.7.12.2




More information about the wine-patches mailing list