mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Update some gdi32 winetest
svn path=/trunk/; revision=24249
This commit is contained in:
parent
9e99515740
commit
595ffab596
9 changed files with 2747 additions and 283 deletions
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -56,7 +56,7 @@ static void test_solidbrush(void)
|
|||
}
|
||||
else
|
||||
stockBrush = NULL;
|
||||
memset(&br, sizeof(br), 0);
|
||||
memset(&br, 0, sizeof(br));
|
||||
ret = GetObject(solidBrush, sizeof(br), &br);
|
||||
ok( ret !=0, "GetObject on solid %s brush failed, error=%ld\n", stock[i].name, GetLastError());
|
||||
ok(br.lbStyle==BS_SOLID, "%s brush has wrong style, got %d expected %d\n", stock[i].name, br.lbStyle, BS_SOLID);
|
||||
|
|
125
reactos/regtests/winetests/gdi32/clipping.c
Normal file
125
reactos/regtests/winetests/gdi32/clipping.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Unit test suite for clipping
|
||||
*
|
||||
* Copyright 2005 Huw Davies
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
|
||||
static void test_GetRandomRgn(void)
|
||||
{
|
||||
HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
|
||||
HDC hdc;
|
||||
HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
|
||||
int ret;
|
||||
RECT rc, rc2;
|
||||
RECT ret_rc, window_rc;
|
||||
|
||||
ok( hwnd != 0, "CreateWindow failed\n" );
|
||||
|
||||
SetRect(&window_rc, 400, 300, 500, 400);
|
||||
MoveWindow(hwnd, window_rc.left, window_rc.top, window_rc.right - window_rc.left, window_rc.bottom - window_rc.top, FALSE);
|
||||
hdc = GetDC(hwnd);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 1);
|
||||
ok(ret == 0, "GetRandomRgn rets %d\n", ret);
|
||||
ret = GetRandomRgn(hdc, hrgn, 2);
|
||||
ok(ret == 0, "GetRandomRgn rets %d\n", ret);
|
||||
ret = GetRandomRgn(hdc, hrgn, 3);
|
||||
ok(ret == 0, "GetRandomRgn rets %d\n", ret);
|
||||
|
||||
/* Set a clip region */
|
||||
SetRect(&rc, 20, 20, 80, 80);
|
||||
IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 1);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 2);
|
||||
ok(ret == 0, "GetRandomRgn rets %d\n", ret);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 3);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
/* Move the clip to the meta and clear the clip */
|
||||
SetMetaRgn(hdc);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 1);
|
||||
ok(ret == 0, "GetRandomRgn rets %d\n", ret);
|
||||
ret = GetRandomRgn(hdc, hrgn, 2);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 3);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
/* Set a new clip (still got the meta) */
|
||||
SetRect(&rc2, 10, 30, 70, 90);
|
||||
IntersectClipRect(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 1);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 2);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
IntersectRect(&rc2, &rc, &rc2);
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, 3);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
|
||||
ret = GetRandomRgn(hdc, hrgn, SYSRGN);
|
||||
ok(ret != 0, "GetRandomRgn rets %d\n", ret);
|
||||
GetRgnBox(hrgn, &ret_rc);
|
||||
if(GetVersion() & 0x80000000)
|
||||
OffsetRect(&window_rc, -window_rc.left, -window_rc.top);
|
||||
ok(EqualRect(&window_rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
|
||||
ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
|
||||
|
||||
DeleteObject(hrgn);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
START_TEST(clipping)
|
||||
{
|
||||
test_GetRandomRgn();
|
||||
}
|
180
reactos/regtests/winetests/gdi32/dc.c
Normal file
180
reactos/regtests/winetests/gdi32/dc.c
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Unit tests for dc functions
|
||||
*
|
||||
* Copyright (c) 2005 Huw Davies
|
||||
* Copyright (c) 2005 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static void dump_region(HRGN hrgn)
|
||||
{
|
||||
DWORD i, size;
|
||||
RGNDATA *data = NULL;
|
||||
RECT *rect;
|
||||
|
||||
if (!hrgn)
|
||||
{
|
||||
printf( "(null) region\n" );
|
||||
return;
|
||||
}
|
||||
if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
|
||||
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
|
||||
GetRegionData( hrgn, size, data );
|
||||
printf( "%ld rects:", data->rdh.nCount );
|
||||
for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
|
||||
printf( " (%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
|
||||
printf( "\n" );
|
||||
HeapFree( GetProcessHeap(), 0, data );
|
||||
}
|
||||
|
||||
static void test_savedc_2(void)
|
||||
{
|
||||
HWND hwnd;
|
||||
HDC hdc;
|
||||
HRGN hrgn;
|
||||
RECT rc, rc_clip;
|
||||
int ret;
|
||||
|
||||
hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
|
||||
0, 0, 0, NULL);
|
||||
assert(hwnd != 0);
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
hrgn = CreateRectRgn(0, 0, 0, 0);
|
||||
assert(hrgn != 0);
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
ok(hdc != NULL, "CreateDC rets %p\n", hdc);
|
||||
|
||||
ret = GetClipBox(hdc, &rc_clip);
|
||||
ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
|
||||
ret = GetClipRgn(hdc, hrgn);
|
||||
ok(ret == 0, "GetClipRgn returned %d instead of 0\n", ret);
|
||||
ret = GetRgnBox(hrgn, &rc);
|
||||
ok(ret == NULLREGION, "GetRgnBox returned %d (%ld,%ld-%ld,%ld) instead of NULLREGION\n",
|
||||
ret, rc.left, rc.top, rc.right, rc.bottom);
|
||||
/*dump_region(hrgn);*/
|
||||
SetRect(&rc, 0, 0, 100, 100);
|
||||
ok(EqualRect(&rc, &rc_clip),
|
||||
"rects are not equal: (%ld,%ld-%ld,%ld) - (%ld,%ld-%ld,%ld)\n",
|
||||
rc.left, rc.top, rc.right, rc.bottom,
|
||||
rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
|
||||
|
||||
ret = SaveDC(hdc);
|
||||
todo_wine
|
||||
{
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
}
|
||||
|
||||
ret = IntersectClipRect(hdc, 0, 0, 50, 50);
|
||||
#if 0 /* XP returns COMPLEXREGION although dump_region reports only 1 rect */
|
||||
ok(ret == SIMPLEREGION, "IntersectClipRect returned %d instead of SIMPLEREGION\n", ret);
|
||||
#endif
|
||||
if (ret != SIMPLEREGION)
|
||||
{
|
||||
trace("Windows BUG: IntersectClipRect returned %d instead of SIMPLEREGION\n", ret);
|
||||
/* let's make sure that it's a simple region */
|
||||
ret = GetClipRgn(hdc, hrgn);
|
||||
ok(ret == 1, "GetClipRgn returned %d instead of 1\n", ret);
|
||||
dump_region(hrgn);
|
||||
}
|
||||
|
||||
ret = GetClipBox(hdc, &rc_clip);
|
||||
ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
|
||||
SetRect(&rc, 0, 0, 50, 50);
|
||||
ok(EqualRect(&rc, &rc_clip), "rects are not equal\n");
|
||||
|
||||
ret = RestoreDC(hdc, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
|
||||
ret = GetClipBox(hdc, &rc_clip);
|
||||
ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
|
||||
SetRect(&rc, 0, 0, 100, 100);
|
||||
ok(EqualRect(&rc, &rc_clip), "rects are not equal\n");
|
||||
|
||||
DeleteObject(hrgn);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
static void test_savedc(void)
|
||||
{
|
||||
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
|
||||
int ret;
|
||||
|
||||
ok(hdc != NULL, "CreateDC rets %p\n", hdc);
|
||||
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, -1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 3, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, -2);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, -2);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 1, "ret = %d\n", ret);
|
||||
ret = SaveDC(hdc);
|
||||
ok(ret == 2, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, -4);
|
||||
ok(!ret, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, 3);
|
||||
ok(!ret, "ret = %d\n", ret);
|
||||
|
||||
/* Under win98 the following two succeed and both clear the save stack
|
||||
ret = RestoreDC(hdc, -3);
|
||||
ok(!ret, "ret = %d\n", ret);
|
||||
ret = RestoreDC(hdc, 0);
|
||||
ok(!ret, "ret = %d\n", ret);
|
||||
*/
|
||||
|
||||
ret = RestoreDC(hdc, 1);
|
||||
ok(ret, "ret = %d\n", ret);
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
START_TEST(dc)
|
||||
{
|
||||
test_savedc();
|
||||
test_savedc_2();
|
||||
}
|
441
reactos/regtests/winetests/gdi32/font.c
Normal file
441
reactos/regtests/winetests/gdi32/font.c
Normal file
|
@ -0,0 +1,441 @@
|
|||
/*
|
||||
* Unit test suite for fonts
|
||||
*
|
||||
* Copyright 2002 Mike McCormack
|
||||
* Copyright 2004 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static void check_font(const char* test, const LOGFONTA* lf, HFONT hfont)
|
||||
{
|
||||
LOGFONTA getobj_lf;
|
||||
int ret, minlen = 0;
|
||||
|
||||
if (!hfont)
|
||||
return;
|
||||
|
||||
ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf);
|
||||
/* NT4 tries to be clever and only returns the minimum length */
|
||||
while (lf->lfFaceName[minlen] && minlen < LF_FACESIZE-1)
|
||||
minlen++;
|
||||
minlen += FIELD_OFFSET(LOGFONTA, lfFaceName) + 1;
|
||||
ok(ret == sizeof(LOGFONTA) || ret == minlen, "%s: GetObject returned %d\n", test, ret);
|
||||
ok(!memcmp(&lf, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "%s: fonts don't match\n", test);
|
||||
ok(!lstrcmpA(lf->lfFaceName, getobj_lf.lfFaceName),
|
||||
"%s: font names don't match: %s != %s\n", test, lf->lfFaceName, getobj_lf.lfFaceName);
|
||||
}
|
||||
|
||||
static HFONT create_font(const char* test, const LOGFONTA* lf)
|
||||
{
|
||||
HFONT hfont = CreateFontIndirectA(lf);
|
||||
ok(hfont != 0, "%s: CreateFontIndirect failed\n", test);
|
||||
if (hfont)
|
||||
check_font(test, lf, hfont);
|
||||
return hfont;
|
||||
}
|
||||
|
||||
static void test_logfont(void)
|
||||
{
|
||||
LOGFONTA lf;
|
||||
HFONT hfont;
|
||||
|
||||
memset(&lf, 0, sizeof lf);
|
||||
|
||||
lf.lfCharSet = ANSI_CHARSET;
|
||||
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
lf.lfWeight = FW_DONTCARE;
|
||||
lf.lfHeight = 16;
|
||||
lf.lfWidth = 16;
|
||||
lf.lfQuality = DEFAULT_QUALITY;
|
||||
|
||||
lstrcpyA(lf.lfFaceName, "Arial");
|
||||
hfont = create_font("Arial", &lf);
|
||||
DeleteObject(hfont);
|
||||
|
||||
memset(&lf, 'A', sizeof(lf));
|
||||
hfont = CreateFontIndirectA(&lf);
|
||||
ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
|
||||
|
||||
lf.lfFaceName[LF_FACESIZE - 1] = 0;
|
||||
check_font("AAA...", &lf, hfont);
|
||||
DeleteObject(hfont);
|
||||
}
|
||||
|
||||
static INT CALLBACK font_enum_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
|
||||
{
|
||||
if (type & RASTER_FONTTYPE)
|
||||
{
|
||||
LOGFONT *lf = (LOGFONT *)lParam;
|
||||
*lf = *elf;
|
||||
return 0; /* stop enumeration */
|
||||
}
|
||||
|
||||
return 1; /* continue enumeration */
|
||||
}
|
||||
|
||||
static void test_font_metrics(HDC hdc, HFONT hfont, const char *test_str,
|
||||
INT test_str_len, const TEXTMETRICA *tm_orig,
|
||||
const SIZE *size_orig, INT width_orig,
|
||||
INT scale_x, INT scale_y)
|
||||
{
|
||||
HFONT old_hfont;
|
||||
TEXTMETRICA tm;
|
||||
SIZE size;
|
||||
INT width;
|
||||
|
||||
if (!hfont)
|
||||
return;
|
||||
|
||||
old_hfont = SelectObject(hdc, hfont);
|
||||
|
||||
GetTextMetricsA(hdc, &tm);
|
||||
|
||||
ok(tm.tmHeight == tm_orig->tmHeight * scale_y, "%ld != %ld\n", tm.tmHeight, tm_orig->tmHeight * scale_y);
|
||||
ok(tm.tmAscent == tm_orig->tmAscent * scale_y, "%ld != %ld\n", tm.tmAscent, tm_orig->tmAscent * scale_y);
|
||||
ok(tm.tmDescent == tm_orig->tmDescent * scale_y, "%ld != %ld\n", tm.tmDescent, tm_orig->tmDescent * scale_y);
|
||||
ok(tm.tmAveCharWidth == tm_orig->tmAveCharWidth * scale_x, "%ld != %ld\n", tm.tmAveCharWidth, tm_orig->tmAveCharWidth * scale_x);
|
||||
|
||||
GetTextExtentPoint32A(hdc, test_str, test_str_len, &size);
|
||||
|
||||
ok(size.cx == size_orig->cx * scale_x, "%ld != %ld\n", size.cx, size_orig->cx * scale_x);
|
||||
ok(size.cy == size_orig->cy * scale_y, "%ld != %ld\n", size.cy, size_orig->cy * scale_y);
|
||||
|
||||
GetCharWidthA(hdc, 'A', 'A', &width);
|
||||
|
||||
ok(width == width_orig * scale_x, "%d != %d\n", width, width_orig * scale_x);
|
||||
|
||||
SelectObject(hdc, old_hfont);
|
||||
}
|
||||
|
||||
/* see whether GDI scales bitmap font metrics */
|
||||
static void test_bitmap_font(void)
|
||||
{
|
||||
static const char test_str[11] = "Test String";
|
||||
HDC hdc;
|
||||
LOGFONTA bitmap_lf;
|
||||
HFONT hfont, old_hfont;
|
||||
TEXTMETRICA tm_orig;
|
||||
SIZE size_orig;
|
||||
INT ret, i, width_orig, height_orig;
|
||||
|
||||
hdc = GetDC(0);
|
||||
|
||||
/* "System" has only 1 pixel size defined, otherwise the test breaks */
|
||||
ret = EnumFontFamiliesA(hdc, "System", font_enum_proc, (LPARAM)&bitmap_lf);
|
||||
if (ret)
|
||||
{
|
||||
ReleaseDC(0, hdc);
|
||||
trace("no bitmap fonts were found, skipping the test\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trace("found bitmap font %s, height %ld\n", bitmap_lf.lfFaceName, bitmap_lf.lfHeight);
|
||||
|
||||
height_orig = bitmap_lf.lfHeight;
|
||||
hfont = create_font("bitmap", &bitmap_lf);
|
||||
|
||||
old_hfont = SelectObject(hdc, hfont);
|
||||
ok(GetTextMetricsA(hdc, &tm_orig), "GetTextMetricsA failed\n");
|
||||
ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
|
||||
ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
|
||||
SelectObject(hdc, old_hfont);
|
||||
DeleteObject(hfont);
|
||||
|
||||
/* test fractional scaling */
|
||||
for (i = 1; i < height_orig; i++)
|
||||
{
|
||||
hfont = create_font("fractional", &bitmap_lf);
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, 1);
|
||||
DeleteObject(hfont);
|
||||
}
|
||||
|
||||
/* test integer scaling 3x2 */
|
||||
bitmap_lf.lfHeight = height_orig * 2;
|
||||
bitmap_lf.lfWidth *= 3;
|
||||
hfont = create_font("3x2", &bitmap_lf);
|
||||
todo_wine
|
||||
{
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 2);
|
||||
}
|
||||
DeleteObject(hfont);
|
||||
|
||||
/* test integer scaling 3x3 */
|
||||
bitmap_lf.lfHeight = height_orig * 3;
|
||||
bitmap_lf.lfWidth = 0;
|
||||
hfont = create_font("3x3", &bitmap_lf);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 3);
|
||||
}
|
||||
DeleteObject(hfont);
|
||||
|
||||
ReleaseDC(0, hdc);
|
||||
}
|
||||
|
||||
static INT CALLBACK find_font_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
|
||||
{
|
||||
LOGFONT *lf = (LOGFONT *)lParam;
|
||||
|
||||
if (elf->lfHeight == lf->lfHeight && !strcmp(elf->lfFaceName, lf->lfFaceName))
|
||||
{
|
||||
*lf = *elf;
|
||||
return 0; /* stop enumeration */
|
||||
}
|
||||
return 1; /* continue enumeration */
|
||||
}
|
||||
|
||||
static void test_bitmap_font_metrics(void)
|
||||
{
|
||||
static const struct font_data
|
||||
{
|
||||
const char face_name[LF_FACESIZE];
|
||||
int weight, height, ascent, descent, int_leading, ext_leading;
|
||||
int ave_char_width, max_char_width;
|
||||
} fd[] =
|
||||
{
|
||||
{ "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11 },
|
||||
{ "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14 },
|
||||
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16 },
|
||||
{ "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 20 },
|
||||
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 25 },
|
||||
{ "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32 },
|
||||
{ "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8 },
|
||||
{ "MS Serif", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9 },
|
||||
{ "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 12 },
|
||||
{ "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 16 },
|
||||
{ "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 19 },
|
||||
{ "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 23 },
|
||||
{ "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 27 },
|
||||
{ "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 34 },
|
||||
{ "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8 },
|
||||
{ "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9 },
|
||||
{ "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12 },
|
||||
{ "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 15 },
|
||||
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 2 },
|
||||
{ "Small Fonts", FW_NORMAL, 5, 4, 1, 1, 0, 3, 4 },
|
||||
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 13 },
|
||||
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 7 },
|
||||
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8 },
|
||||
{ "Small Fonts", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9 }
|
||||
/* FIXME: add "Fixedsys", "Terminal" */
|
||||
};
|
||||
HDC hdc;
|
||||
LOGFONT lf;
|
||||
HFONT hfont, old_hfont;
|
||||
TEXTMETRIC tm;
|
||||
INT ret, i;
|
||||
|
||||
hdc = CreateCompatibleDC(0);
|
||||
assert(hdc);
|
||||
|
||||
for (i = 0; i < sizeof(fd)/sizeof(fd[0]); i++)
|
||||
{
|
||||
memset(&lf, 0, sizeof(lf));
|
||||
|
||||
lf.lfHeight = fd[i].height;
|
||||
strcpy(lf.lfFaceName, fd[i].face_name);
|
||||
ret = EnumFontFamilies(hdc, fd[i].face_name, find_font_proc, (LPARAM)&lf);
|
||||
if (ret)
|
||||
{
|
||||
trace("font %s height %d not found\n", fd[i].face_name, fd[i].height);
|
||||
continue;
|
||||
}
|
||||
|
||||
trace("found font %s, height %ld\n", lf.lfFaceName, lf.lfHeight);
|
||||
|
||||
hfont = create_font(lf.lfFaceName, &lf);
|
||||
old_hfont = SelectObject(hdc, hfont);
|
||||
ok(GetTextMetrics(hdc, &tm), "GetTextMetrics error %ld\n", GetLastError());
|
||||
|
||||
ok(tm.tmWeight == fd[i].weight, "%s(%d): tm.tmWeight %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmWeight, fd[i].weight);
|
||||
ok(tm.tmHeight == fd[i].height, "%s(%d): tm.tmHeight %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmHeight, fd[i].height);
|
||||
ok(tm.tmAscent == fd[i].ascent, "%s(%d): tm.tmAscent %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmAscent, fd[i].ascent);
|
||||
ok(tm.tmDescent == fd[i].descent, "%s(%d): tm.tmDescent %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmDescent, fd[i].descent);
|
||||
ok(tm.tmInternalLeading == fd[i].int_leading, "%s(%d): tm.tmInternalLeading %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmInternalLeading, fd[i].int_leading);
|
||||
ok(tm.tmExternalLeading == fd[i].ext_leading, "%s(%d): tm.tmExternalLeading %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmExternalLeading, fd[i].ext_leading);
|
||||
ok(tm.tmAveCharWidth == fd[i].ave_char_width, "%s(%d): tm.tmAveCharWidth %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmAveCharWidth, fd[i].ave_char_width);
|
||||
ok(tm.tmMaxCharWidth == fd[i].max_char_width, "%s(%d): tm.tmMaxCharWidth %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmMaxCharWidth, fd[i].max_char_width);
|
||||
|
||||
SelectObject(hdc, old_hfont);
|
||||
DeleteObject(hfont);
|
||||
}
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
static void test_GdiGetCharDimensions(void)
|
||||
{
|
||||
HDC hdc;
|
||||
TEXTMETRICW tm;
|
||||
LONG ret;
|
||||
SIZE size;
|
||||
LONG avgwidth, height;
|
||||
static const char szAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
typedef LONG (WINAPI *fnGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height);
|
||||
fnGdiGetCharDimensions GdiGetCharDimensions = (fnGdiGetCharDimensions)GetProcAddress(LoadLibrary("gdi32"), "GdiGetCharDimensions");
|
||||
if (!GdiGetCharDimensions) return;
|
||||
|
||||
hdc = CreateCompatibleDC(NULL);
|
||||
|
||||
GetTextExtentPoint(hdc, szAlphabet, strlen(szAlphabet), &size);
|
||||
avgwidth = ((size.cx / 26) + 1) / 2;
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, &tm, &height);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
ok(height == tm.tmHeight, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", tm.tmHeight, height);
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, &tm, NULL);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, NULL, NULL);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
|
||||
height = 0;
|
||||
ret = GdiGetCharDimensions(hdc, NULL, &height);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
ok(height == size.cy, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", size.cy, height);
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
static void test_GetCharABCWidthsW(void)
|
||||
{
|
||||
BOOL ret;
|
||||
ABC abc[1];
|
||||
typedef BOOL (WINAPI *fnGetCharABCWidthsW)(HDC hdc, UINT first, UINT last, LPABC abc);
|
||||
fnGetCharABCWidthsW GetCharABCWidthsW = (fnGetCharABCWidthsW)GetProcAddress(LoadLibrary("gdi32"), "GetCharABCWidthsW");
|
||||
if (!GetCharABCWidthsW) return;
|
||||
|
||||
ret = GetCharABCWidthsW(NULL, 'a', 'a', abc);
|
||||
ok(!ret, "GetCharABCWidthsW should have returned FALSE\n");
|
||||
}
|
||||
|
||||
static void test_text_extents(void)
|
||||
{
|
||||
static const WCHAR wt[] = {'O','n','e','\n','t','w','o',' ','3',0};
|
||||
LPINT extents;
|
||||
INT i, len, fit1, fit2;
|
||||
LOGFONTA lf;
|
||||
TEXTMETRICA tm;
|
||||
HDC hdc;
|
||||
HFONT hfont;
|
||||
SIZE sz;
|
||||
SIZE sz1, sz2;
|
||||
|
||||
memset(&lf, 0, sizeof(lf));
|
||||
strcpy(lf.lfFaceName, "Arial");
|
||||
lf.lfHeight = 20;
|
||||
|
||||
hfont = CreateFontIndirectA(&lf);
|
||||
hdc = GetDC(0);
|
||||
hfont = SelectObject(hdc, hfont);
|
||||
GetTextMetricsA(hdc, &tm);
|
||||
GetTextExtentPointA(hdc, "o", 1, &sz);
|
||||
ok(sz.cy == tm.tmHeight, "cy %ld tmHeight %ld\n", sz.cy, tm.tmHeight);
|
||||
|
||||
len = lstrlenW(wt);
|
||||
extents = HeapAlloc(GetProcessHeap(), 0, len * sizeof extents[0]);
|
||||
memset(extents, 0, len * sizeof extents[0]);
|
||||
extents[0] = 1; /* So that the increasing sequence test will fail
|
||||
if the extents array is untouched. */
|
||||
GetTextExtentExPointW(hdc, wt, len, 32767, &fit1, extents, &sz1);
|
||||
GetTextExtentPointW(hdc, wt, len, &sz2);
|
||||
ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy,
|
||||
"results from GetTextExtentExPointW and GetTextExtentPointW differ\n");
|
||||
for (i = 1; i < len; ++i)
|
||||
ok(extents[i-1] <= extents[i],
|
||||
"GetTextExtentExPointW generated a non-increasing sequence of partial extents (at position %d)\n",
|
||||
i);
|
||||
ok(extents[len-1] == sz1.cx, "GetTextExtentExPointW extents and size don't match\n");
|
||||
ok(0 <= fit1 && fit1 <= len, "GetTextExtentExPointW generated illegal value %d for fit\n", fit1);
|
||||
ok(0 < fit1, "GetTextExtentExPointW says we can't even fit one letter in 32767 logical units\n");
|
||||
GetTextExtentExPointW(hdc, wt, len, extents[2], &fit2, NULL, &sz2);
|
||||
ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy, "GetTextExtentExPointW returned different sizes for the same string\n");
|
||||
ok(fit2 == 3, "GetTextExtentExPointW extents isn't consistent with fit\n");
|
||||
GetTextExtentExPointW(hdc, wt, len, extents[2]-1, &fit2, NULL, &sz2);
|
||||
ok(fit2 == 2, "GetTextExtentExPointW extents isn't consistent with fit\n");
|
||||
GetTextExtentExPointW(hdc, wt, 2, 0, NULL, extents + 2, &sz2);
|
||||
ok(extents[0] == extents[2] && extents[1] == extents[3],
|
||||
"GetTextExtentExPointW with lpnFit == NULL returns incorrect results\n");
|
||||
GetTextExtentExPointW(hdc, wt, 2, 0, NULL, NULL, &sz1);
|
||||
ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy,
|
||||
"GetTextExtentExPointW with lpnFit and alpDx both NULL returns incorrect results\n");
|
||||
HeapFree(GetProcessHeap(), 0, extents);
|
||||
|
||||
SelectObject(hdc, hfont);
|
||||
DeleteObject(hfont);
|
||||
ReleaseDC(NULL, hdc);
|
||||
}
|
||||
|
||||
static void test_GetGlyphIndices()
|
||||
{
|
||||
HDC hdc;
|
||||
HFONT hfont;
|
||||
DWORD charcount;
|
||||
LOGFONTA lf;
|
||||
DWORD flags = 0;
|
||||
WCHAR testtext[] = {'T','e','s','t',0xffff,0};
|
||||
WORD glyphs[(sizeof(testtext)/2)-1];
|
||||
TEXTMETRIC textm;
|
||||
|
||||
typedef BOOL (WINAPI *fnGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
|
||||
fnGetGlyphIndicesW GetGlyphIndicesW = (fnGetGlyphIndicesW)GetProcAddress(LoadLibrary("gdi32"),
|
||||
"GetGlyphIndicesW");
|
||||
if (!GetGlyphIndicesW) {
|
||||
trace("GetGlyphIndices not available on platform\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&lf, 0, sizeof(lf));
|
||||
strcpy(lf.lfFaceName, "Symbol");
|
||||
lf.lfHeight = 20;
|
||||
|
||||
hfont = CreateFontIndirectA(&lf);
|
||||
hdc = GetDC(0);
|
||||
|
||||
ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n");
|
||||
flags |= GGI_MARK_NONEXISTING_GLYPHS;
|
||||
charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
||||
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount);
|
||||
ok(glyphs[4] == 0x001f, "GetGlyphIndices should have returned a nonexistent char not %04x\n", glyphs[4]);
|
||||
flags = 0;
|
||||
charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
||||
ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount);
|
||||
ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n",
|
||||
textm.tmDefaultChar, glyphs[4]);
|
||||
}
|
||||
|
||||
START_TEST(font)
|
||||
{
|
||||
test_logfont();
|
||||
test_bitmap_font();
|
||||
test_bitmap_font_metrics();
|
||||
test_GdiGetCharDimensions();
|
||||
test_GetCharABCWidthsW();
|
||||
test_text_extents();
|
||||
test_GetGlyphIndices();
|
||||
}
|
|
@ -8,7 +8,10 @@
|
|||
<library>advapi32</library>
|
||||
<file>bitmap.c</file>
|
||||
<file>brush.c</file>
|
||||
<file>clipping.c</file>
|
||||
<file>dc.c</file>
|
||||
<file>gdiobj.c</file>
|
||||
<file>font.c</file>
|
||||
<file>metafile.c</file>
|
||||
<file>testlist.c</file>
|
||||
</module>
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -28,175 +29,6 @@
|
|||
|
||||
#include "wine/test.h"
|
||||
|
||||
|
||||
static void check_font(const char* test, const LOGFONTA* lf, HFONT hfont)
|
||||
{
|
||||
LOGFONTA getobj_lf;
|
||||
int ret, minlen = 0;
|
||||
|
||||
if (!hfont)
|
||||
return;
|
||||
|
||||
ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf);
|
||||
/* NT4 tries to be clever and only returns the minimum length */
|
||||
while (lf->lfFaceName[minlen] && minlen < LF_FACESIZE-1)
|
||||
minlen++;
|
||||
minlen += FIELD_OFFSET(LOGFONTA, lfFaceName) + 1;
|
||||
ok(ret == sizeof(LOGFONTA) || ret == minlen,
|
||||
"%s: GetObject returned %d expected %d or %d\n", test, ret, sizeof(LOGFONTA), minlen);
|
||||
ok(!memcmp(&lf, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "%s: fonts don't match\n", test);
|
||||
ok(!lstrcmpA(lf->lfFaceName, getobj_lf.lfFaceName),
|
||||
"%s: font names don't match: %s != %s\n", test, lf->lfFaceName, getobj_lf.lfFaceName);
|
||||
}
|
||||
|
||||
static HFONT create_font(const char* test, const LOGFONTA* lf)
|
||||
{
|
||||
HFONT hfont = CreateFontIndirectA(lf);
|
||||
ok(hfont != 0, "%s: CreateFontIndirect failed\n", test);
|
||||
if (hfont)
|
||||
check_font(test, lf, hfont);
|
||||
return hfont;
|
||||
}
|
||||
|
||||
static void test_logfont(void)
|
||||
{
|
||||
LOGFONTA lf;
|
||||
HFONT hfont;
|
||||
|
||||
memset(&lf, 0, sizeof lf);
|
||||
|
||||
lf.lfCharSet = ANSI_CHARSET;
|
||||
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||
lf.lfWeight = FW_DONTCARE;
|
||||
lf.lfHeight = 16;
|
||||
lf.lfWidth = 16;
|
||||
lf.lfQuality = DEFAULT_QUALITY;
|
||||
|
||||
lstrcpyA(lf.lfFaceName, "Arial");
|
||||
hfont = create_font("Arial", &lf);
|
||||
DeleteObject(hfont);
|
||||
|
||||
memset(&lf, 'A', sizeof(lf));
|
||||
hfont = CreateFontIndirectA(&lf);
|
||||
ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
|
||||
|
||||
lf.lfFaceName[LF_FACESIZE - 1] = 0;
|
||||
check_font("AAA...", &lf, hfont);
|
||||
DeleteObject(hfont);
|
||||
}
|
||||
|
||||
static INT CALLBACK font_enum_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
|
||||
{
|
||||
if (type & RASTER_FONTTYPE)
|
||||
{
|
||||
LOGFONT *lf = (LOGFONT *)lParam;
|
||||
*lf = *elf;
|
||||
return 0; /* stop enumeration */
|
||||
}
|
||||
|
||||
return 1; /* continue enumeration */
|
||||
}
|
||||
|
||||
static void test_font_metrics(HDC hdc, HFONT hfont, const char *test_str,
|
||||
INT test_str_len, const TEXTMETRICA *tm_orig,
|
||||
const SIZE *size_orig, INT width_orig,
|
||||
INT scale_x, INT scale_y)
|
||||
{
|
||||
HFONT old_hfont;
|
||||
TEXTMETRICA tm;
|
||||
SIZE size;
|
||||
INT width;
|
||||
|
||||
if (!hfont)
|
||||
return;
|
||||
|
||||
old_hfont = SelectObject(hdc, hfont);
|
||||
|
||||
GetTextMetricsA(hdc, &tm);
|
||||
|
||||
ok(tm.tmHeight == tm_orig->tmHeight * scale_y, "%ld != %ld\n", tm.tmHeight, tm_orig->tmHeight * scale_y);
|
||||
ok(tm.tmAscent == tm_orig->tmAscent * scale_y, "%ld != %ld\n", tm.tmAscent, tm_orig->tmAscent * scale_y);
|
||||
ok(tm.tmDescent == tm_orig->tmDescent * scale_y, "%ld != %ld\n", tm.tmDescent, tm_orig->tmDescent * scale_y);
|
||||
ok(tm.tmAveCharWidth == tm_orig->tmAveCharWidth * scale_x, "%ld != %ld\n", tm.tmAveCharWidth, tm_orig->tmAveCharWidth * scale_x);
|
||||
|
||||
GetTextExtentPoint32A(hdc, test_str, test_str_len, &size);
|
||||
|
||||
ok(size.cx == size_orig->cx * scale_x, "%ld != %ld\n", size.cx, size_orig->cx * scale_x);
|
||||
ok(size.cy == size_orig->cy * scale_y, "%ld != %ld\n", size.cy, size_orig->cy * scale_y);
|
||||
|
||||
GetCharWidthA(hdc, 'A', 'A', &width);
|
||||
|
||||
ok(width == width_orig * scale_x, "%d != %d\n", width, width_orig * scale_x);
|
||||
|
||||
SelectObject(hdc, old_hfont);
|
||||
}
|
||||
|
||||
/* see whether GDI scales bitmap font metrics */
|
||||
static void test_bitmap_font(void)
|
||||
{
|
||||
static const char test_str[11] = "Test String";
|
||||
HDC hdc;
|
||||
LOGFONTA bitmap_lf;
|
||||
HFONT hfont, old_hfont;
|
||||
TEXTMETRICA tm_orig;
|
||||
SIZE size_orig;
|
||||
INT ret, i, width_orig, height_orig;
|
||||
|
||||
hdc = GetDC(0);
|
||||
|
||||
/* "System" has only 1 pixel size defined, otherwise the test breaks */
|
||||
ret = EnumFontFamiliesA(hdc, "System", font_enum_proc, (LPARAM)&bitmap_lf);
|
||||
if (ret)
|
||||
{
|
||||
ReleaseDC(0, hdc);
|
||||
trace("no bitmap fonts were found, skipping the test\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trace("found bitmap font %s, height %ld\n", bitmap_lf.lfFaceName, bitmap_lf.lfHeight);
|
||||
|
||||
height_orig = bitmap_lf.lfHeight;
|
||||
hfont = create_font("bitmap", &bitmap_lf);
|
||||
|
||||
old_hfont = SelectObject(hdc, hfont);
|
||||
ok(GetTextMetricsA(hdc, &tm_orig), "GetTextMetricsA failed\n");
|
||||
ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
|
||||
ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
|
||||
SelectObject(hdc, old_hfont);
|
||||
DeleteObject(hfont);
|
||||
|
||||
/* test fractional scaling */
|
||||
for (i = 1; i < height_orig; i++)
|
||||
{
|
||||
hfont = create_font("fractional", &bitmap_lf);
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, 1);
|
||||
DeleteObject(hfont);
|
||||
}
|
||||
|
||||
/* test integer scaling 3x2 */
|
||||
bitmap_lf.lfHeight = height_orig * 2;
|
||||
bitmap_lf.lfWidth *= 3;
|
||||
hfont = create_font("3x2", &bitmap_lf);
|
||||
todo_wine
|
||||
{
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 2);
|
||||
}
|
||||
DeleteObject(hfont);
|
||||
|
||||
/* test integer scaling 3x3 */
|
||||
bitmap_lf.lfHeight = height_orig * 3;
|
||||
bitmap_lf.lfWidth = 0;
|
||||
hfont = create_font("3x3", &bitmap_lf);
|
||||
|
||||
todo_wine
|
||||
{
|
||||
test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 3);
|
||||
}
|
||||
DeleteObject(hfont);
|
||||
|
||||
ReleaseDC(0, hdc);
|
||||
}
|
||||
|
||||
static void test_gdi_objects(void)
|
||||
{
|
||||
BYTE buff[256];
|
||||
|
@ -266,70 +98,177 @@ static void test_gdi_objects(void)
|
|||
ReleaseDC(NULL, hdc);
|
||||
}
|
||||
|
||||
static void test_GdiGetCharDimensions(void)
|
||||
struct hgdiobj_event
|
||||
{
|
||||
HDC hdc;
|
||||
TEXTMETRICW tm;
|
||||
LONG ret;
|
||||
SIZE size;
|
||||
LONG avgwidth, height;
|
||||
static const char szAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
typedef LONG (WINAPI *fnGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height);
|
||||
fnGdiGetCharDimensions GdiGetCharDimensions = (fnGdiGetCharDimensions)GetProcAddress(LoadLibrary("gdi32"), "GdiGetCharDimensions");
|
||||
if (!GdiGetCharDimensions) return;
|
||||
HGDIOBJ hgdiobj1;
|
||||
HGDIOBJ hgdiobj2;
|
||||
HANDLE stop_event;
|
||||
HANDLE ready_event;
|
||||
};
|
||||
|
||||
hdc = CreateCompatibleDC(NULL);
|
||||
static DWORD WINAPI thread_proc(void *param)
|
||||
{
|
||||
LOGPEN lp;
|
||||
struct hgdiobj_event *hgdiobj_event = (struct hgdiobj_event *)param;
|
||||
|
||||
GetTextExtentPoint(hdc, szAlphabet, strlen(szAlphabet), &size);
|
||||
avgwidth = ((size.cx / 26) + 1) / 2;
|
||||
hgdiobj_event->hdc = CreateDC("display", NULL, NULL, NULL);
|
||||
ok(hgdiobj_event->hdc != NULL, "CreateDC error %ld\n", GetLastError());
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, &tm, &height);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
ok(height == tm.tmHeight, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", tm.tmHeight, height);
|
||||
hgdiobj_event->hgdiobj1 = CreatePen(PS_DASHDOTDOT, 17, RGB(1, 2, 3));
|
||||
ok(hgdiobj_event->hgdiobj1 != 0, "Failed to create pen\n");
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, &tm, NULL);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
hgdiobj_event->hgdiobj2 = CreateRectRgn(0, 1, 12, 17);
|
||||
ok(hgdiobj_event->hgdiobj2 != 0, "Failed to create pen\n");
|
||||
|
||||
ret = GdiGetCharDimensions(hdc, NULL, NULL);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
SetEvent(hgdiobj_event->ready_event);
|
||||
ok(WaitForSingleObject(hgdiobj_event->stop_event, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
|
||||
height = 0;
|
||||
ret = GdiGetCharDimensions(hdc, NULL, &height);
|
||||
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
|
||||
ok(height == size.cy, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", size.cy, height);
|
||||
ok(!GetObject(hgdiobj_event->hgdiobj1, sizeof(lp), &lp), "GetObject should fail\n");
|
||||
|
||||
ok(!GetDeviceCaps(hgdiobj_event->hdc, TECHNOLOGY), "GetDeviceCaps(TECHNOLOGY) should fail\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_thread_objects(void)
|
||||
{
|
||||
LOGPEN lp;
|
||||
DWORD tid, type;
|
||||
HANDLE hthread;
|
||||
struct hgdiobj_event hgdiobj_event;
|
||||
INT ret;
|
||||
|
||||
hgdiobj_event.stop_event = CreateEvent(NULL, 0, 0, NULL);
|
||||
ok(hgdiobj_event.stop_event != NULL, "CreateEvent error %ld\n", GetLastError());
|
||||
hgdiobj_event.ready_event = CreateEvent(NULL, 0, 0, NULL);
|
||||
ok(hgdiobj_event.ready_event != NULL, "CreateEvent error %ld\n", GetLastError());
|
||||
|
||||
hthread = CreateThread(NULL, 0, thread_proc, &hgdiobj_event, 0, &tid);
|
||||
ok(hthread != NULL, "CreateThread error %ld\n", GetLastError());
|
||||
|
||||
ok(WaitForSingleObject(hgdiobj_event.ready_event, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
|
||||
ok(GetObject(hgdiobj_event.hgdiobj1, sizeof(lp), &lp) == sizeof(lp),
|
||||
"GetObject error %ld\n", GetLastError());
|
||||
ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
|
||||
ok(lp.lopnWidth.x == 17, "wrong pen width.y %ld\n", lp.lopnWidth.x);
|
||||
ok(lp.lopnWidth.y == 0, "wrong pen width.y %ld\n", lp.lopnWidth.y);
|
||||
ok(lp.lopnColor == RGB(1, 2, 3), "wrong pen width.y %08lx\n", lp.lopnColor);
|
||||
|
||||
ret = GetDeviceCaps(hgdiobj_event.hdc, TECHNOLOGY);
|
||||
ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);
|
||||
|
||||
ok(DeleteObject(hgdiobj_event.hgdiobj1), "DeleteObject error %ld\n", GetLastError());
|
||||
ok(DeleteDC(hgdiobj_event.hdc), "DeleteDC error %ld\n", GetLastError());
|
||||
|
||||
type = GetObjectType(hgdiobj_event.hgdiobj2);
|
||||
ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
|
||||
|
||||
SetEvent(hgdiobj_event.stop_event);
|
||||
ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
CloseHandle(hthread);
|
||||
|
||||
type = GetObjectType(hgdiobj_event.hgdiobj2);
|
||||
ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
|
||||
ok(DeleteObject(hgdiobj_event.hgdiobj2), "DeleteObject error %ld\n", GetLastError());
|
||||
|
||||
CloseHandle(hgdiobj_event.stop_event);
|
||||
CloseHandle(hgdiobj_event.ready_event);
|
||||
}
|
||||
|
||||
static void test_GetCurrentObject(void)
|
||||
{
|
||||
DWORD type;
|
||||
HPEN hpen;
|
||||
HBRUSH hbrush;
|
||||
HPALETTE hpal;
|
||||
HFONT hfont;
|
||||
HBITMAP hbmp;
|
||||
HRGN hrgn;
|
||||
HDC hdc;
|
||||
HCOLORSPACE hcs;
|
||||
HGDIOBJ hobj;
|
||||
LOGBRUSH lb;
|
||||
LOGCOLORSPACEA lcs;
|
||||
|
||||
hdc = CreateCompatibleDC(0);
|
||||
assert(hdc != 0);
|
||||
|
||||
type = GetObjectType(hdc);
|
||||
ok(type == OBJ_MEMDC, "GetObjectType returned %lu\n", type);
|
||||
|
||||
hpen = CreatePen(PS_SOLID, 10, RGB(10, 20, 30));
|
||||
assert(hpen != 0);
|
||||
SelectObject(hdc, hpen);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PEN);
|
||||
ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
|
||||
hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
|
||||
ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
|
||||
|
||||
hbrush = CreateSolidBrush(RGB(10, 20, 30));
|
||||
assert(hbrush != 0);
|
||||
SelectObject(hdc, hbrush);
|
||||
hobj = GetCurrentObject(hdc, OBJ_BRUSH);
|
||||
ok(hobj == hbrush, "OBJ_BRUSH is wrong: %p\n", hobj);
|
||||
|
||||
hpal = CreateHalftonePalette(hdc);
|
||||
assert(hpal != 0);
|
||||
SelectPalette(hdc, hpal, FALSE);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PAL);
|
||||
ok(hobj == hpal, "OBJ_PAL is wrong: %p\n", hobj);
|
||||
|
||||
hfont = CreateFontA(10, 5, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH, "MS Sans Serif");
|
||||
assert(hfont != 0);
|
||||
SelectObject(hdc, hfont);
|
||||
hobj = GetCurrentObject(hdc, OBJ_FONT);
|
||||
ok(hobj == hfont, "OBJ_FONT is wrong: %p\n", hobj);
|
||||
|
||||
hbmp = CreateBitmap(100, 100, 1, 1, NULL);
|
||||
assert(hbmp != 0);
|
||||
SelectObject(hdc, hbmp);
|
||||
hobj = GetCurrentObject(hdc, OBJ_BITMAP);
|
||||
ok(hobj == hbmp, "OBJ_BITMAP is wrong: %p\n", hobj);
|
||||
|
||||
assert(GetObject(hbrush, sizeof(lb), &lb) == sizeof(lb));
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL,
|
||||
10, &lb, 0, NULL);
|
||||
assert(hpen != 0);
|
||||
SelectObject(hdc, hpen);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PEN);
|
||||
ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
|
||||
hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
|
||||
ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
|
||||
|
||||
hcs = GetColorSpace(hdc);
|
||||
if (hcs)
|
||||
{
|
||||
trace("current color space is not NULL\n");
|
||||
ok(GetLogColorSpaceA(hcs, &lcs, sizeof(lcs)), "GetLogColorSpace failed\n");
|
||||
hcs = CreateColorSpaceA(&lcs);
|
||||
ok(hcs != 0, "CreateColorSpace failed\n");
|
||||
SelectObject(hdc, hcs);
|
||||
hobj = GetCurrentObject(hdc, OBJ_COLORSPACE);
|
||||
ok(hobj == hcs, "OBJ_COLORSPACE is wrong: %p\n", hobj);
|
||||
}
|
||||
|
||||
hrgn = CreateRectRgn(1, 1, 100, 100);
|
||||
assert(hrgn != 0);
|
||||
SelectObject(hdc, hrgn);
|
||||
hobj = GetCurrentObject(hdc, OBJ_REGION);
|
||||
ok(!hobj, "OBJ_REGION is wrong: %p\n", hobj);
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
static void test_text_extents(void)
|
||||
{
|
||||
LOGFONTA lf;
|
||||
TEXTMETRICA tm;
|
||||
HDC hdc;
|
||||
HFONT hfont;
|
||||
SIZE sz;
|
||||
|
||||
memset(&lf, 0, sizeof(lf));
|
||||
strcpy(lf.lfFaceName, "Arial");
|
||||
lf.lfHeight = 20;
|
||||
|
||||
hfont = CreateFontIndirectA(&lf);
|
||||
hdc = GetDC(0);
|
||||
hfont = SelectObject(hdc, hfont);
|
||||
GetTextMetricsA(hdc, &tm);
|
||||
GetTextExtentPointA(hdc, "o", 1, &sz);
|
||||
ok(sz.cy == tm.tmHeight, "cy %ld tmHeight %ld\n", sz.cy, tm.tmHeight);
|
||||
|
||||
SelectObject(hdc, hfont);
|
||||
DeleteObject(hfont);
|
||||
ReleaseDC(NULL, hdc);
|
||||
}
|
||||
|
||||
START_TEST(gdiobj)
|
||||
{
|
||||
test_logfont();
|
||||
test_bitmap_font();
|
||||
test_gdi_objects();
|
||||
test_GdiGetCharDimensions();
|
||||
test_text_extents();
|
||||
test_thread_objects();
|
||||
test_GetCurrentObject();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,9 +22,9 @@ const struct test winetest_testlist[] =
|
|||
{
|
||||
{ "bitmap", func_bitmap },
|
||||
{ "brush", func_brush },
|
||||
// { "clipping", func_clipping },
|
||||
// { "dc", func_dc },
|
||||
// { "font", func_font },
|
||||
{ "clipping", func_clipping },
|
||||
{ "dc", func_dc },
|
||||
{ "font", func_font },
|
||||
{ "gdiobj", func_gdiobj },
|
||||
// { "generated", func_generated },
|
||||
// { "mapping", func_mapping },
|
||||
|
|
Loading…
Reference in a new issue