From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/gdi32/tests/font.c | 100 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 362ddd381f1..7b66ee9e37c 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -22,6 +22,7 @@ #include <stdarg.h> #include <stdio.h> #include <assert.h> +#include <math.h>
#include "windef.h" #include "winbase.h" @@ -7862,6 +7863,104 @@ static void test_font_weight(void) ok(bret, "got error %ld\n", GetLastError()); }
+static void test_rotated_metrics(void) +{ + static const WCHAR str[] = L"Hello World!"; + static const struct + { + float angle_g; + POINT pt; + LONG tmHeight, tmAscent, tmDescent; + SIZE ext; + } test[] = + { + { 0.0f, {50,50}, 87,72,15, {392,87} }, + { 45.0f, {94,24}, 107,76,31, {391,107} }, + { 90.0f, {100,-50}, 90,74,16, {391,90} }, + { 135.0f, {0,-71}, 108,76,32, {391,108} }, + { 180.0f, {-50,-50}, 87,72,15, {392,87} } + }; + float angle_r; + HDC hdc; + LOGFONTW lf; + HFONT hfont; + XFORM xform; + TEXTMETRICW tm; + POINT pt; + SIZE sz; + int i; + + hdc = CreateCompatibleDC(0); + + memset(&lf, 0, sizeof(lf)); + wcscpy(lf.lfFaceName, L"Tahoma"); + lf.lfHeight = -72; + hfont = CreateFontIndirectW(&lf); + + SetGraphicsMode(hdc, GM_ADVANCED); + SetMapMode(hdc, MM_TEXT); + + hfont = SelectObject(hdc, hfont); + + pt.x = 100; + pt.y = 100; + DPtoLP(hdc, &pt, 1); + ok(pt.x == 100, "got %ld\n", pt.x); + ok(pt.y == 100, "got %ld\n", pt.y); + + GetTextMetricsW(hdc, &tm); + ok(match_off_by_n(tm.tmHeight, 87, 5), "got %ld\n", tm.tmHeight); + ok(match_off_by_n(tm.tmAscent, 72, 5), "got %ld\n", tm.tmAscent); + ok(match_off_by_n(tm.tmDescent, 15, 5), "got %ld\n", tm.tmDescent); + + GetTextExtentPoint32W(hdc, str, wcslen(str), &sz); + ok(match_off_by_n(sz.cx, 391, 5), "got %ld\n", sz.cx); + ok(match_off_by_n(sz.cy, 87, 5), "got %ld\n", sz.cy); + + for (i = 0; i < ARRAY_SIZE(test); i++) + { + winetest_push_context("%d", i); + + angle_r = test[i].angle_g * 3.141592f / 180.0f; + + xform.eM11 = cosf(angle_r) * 2.0f; + xform.eM12 = sinf(angle_r); + xform.eM21 = -xform.eM12 * 2.0f; + xform.eM22 = xform.eM11; + xform.eDx = 0.0f; + xform.eDy = 0.0f; + SetWorldTransform(hdc, &xform); + + pt.x = 100; + pt.y = 100; + DPtoLP(hdc, &pt, 1); + ok(pt.x == test[i].pt.x, "got %ld\n", pt.x); + ok(pt.y == test[i].pt.y, "got %ld\n", pt.y); + + GetTextMetricsW(hdc, &tm); + /* Windows produces noticeable diff for angles 45.0 and 135.0 */ + todo_wine_if(i != 0 && i != 4) + ok(match_off_by_n(tm.tmHeight, test[i].tmHeight, 25), "got %ld\n", tm.tmHeight); + todo_wine_if(i != 0 && i != 4) + ok(match_off_by_n(tm.tmAscent, test[i].tmAscent, 10), "got %ld\n", tm.tmAscent); + todo_wine_if(i != 0 && i != 2 && i != 4) + ok(match_off_by_n(tm.tmDescent, test[i].tmDescent, 17), "got %ld\n", tm.tmDescent); + + GetTextExtentPoint32W(hdc, str, wcslen(str), &sz); + todo_wine_if(i != 0 && i != 4) + ok(match_off_by_n(sz.cx, test[i].ext.cx, 10), "got %ld\n", sz.cx); + todo_wine_if(i != 0 && i != 4) + ok(match_off_by_n(sz.cy, test[i].ext.cy, 21), "got %ld\n", sz.cy); + + winetest_pop_context(); + } + + hfont = SelectObject(hdc, hfont); + DeleteObject(hfont); + + DeleteDC(hdc); +} + START_TEST(font) { static const char *test_names[] = @@ -7883,6 +7982,7 @@ START_TEST(font) return; }
+ test_rotated_metrics(); test_stock_fonts(); test_logfont(); test_bitmap_font();