gdi32: Add a buch of CreateScalableFontResource() tests.
This commit is contained in:
parent
083abe3fe9
commit
dfb4d2e960
|
@ -17,4 +17,6 @@ C_SRCS = \
|
|||
path.c \
|
||||
pen.c
|
||||
|
||||
RC_SRCS = resource.rc
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
|
|
@ -48,6 +48,8 @@ static BOOL (WINAPI *pGdiRealizationInfo)(HDC hdc, DWORD *);
|
|||
static HFONT (WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDV *);
|
||||
static HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD *);
|
||||
static BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
|
||||
static INT (WINAPI *pAddFontResourceExA)(LPCSTR, DWORD, PVOID);
|
||||
static BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR, DWORD, PVOID);
|
||||
|
||||
static HMODULE hgdi32 = 0;
|
||||
static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
|
||||
|
@ -68,6 +70,8 @@ static void init(void)
|
|||
pCreateFontIndirectExA = (void *)GetProcAddress(hgdi32, "CreateFontIndirectExA");
|
||||
pAddFontMemResourceEx = (void *)GetProcAddress(hgdi32, "AddFontMemResourceEx");
|
||||
pRemoveFontMemResourceEx = (void *)GetProcAddress(hgdi32, "RemoveFontMemResourceEx");
|
||||
pAddFontResourceExA = (void *)GetProcAddress(hgdi32, "AddFontResourceExA");
|
||||
pRemoveFontResourceExA = (void *)GetProcAddress(hgdi32, "RemoveFontResourceExA");
|
||||
}
|
||||
|
||||
static INT CALLBACK is_truetype_font_installed_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
|
||||
|
@ -3799,6 +3803,190 @@ static void test_fullname(void)
|
|||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
static BOOL write_ttf_file(char *tmp_name)
|
||||
{
|
||||
char tmp_path[MAX_PATH];
|
||||
HRSRC rsrc;
|
||||
void *rsrc_data;
|
||||
DWORD rsrc_size;
|
||||
HANDLE hfile;
|
||||
BOOL ret;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
rsrc = FindResource(GetModuleHandle(0), "wine_test.ttf", RT_RCDATA);
|
||||
ok(rsrc != 0, "FindResource error %d\n", GetLastError());
|
||||
if (!rsrc) return FALSE;
|
||||
SetLastError(0xdeadbeef);
|
||||
rsrc_data = LockResource(LoadResource(GetModuleHandle(0), rsrc));
|
||||
ok(rsrc_data != 0, "LockResource error %d\n", GetLastError());
|
||||
if (!rsrc_data) return FALSE;
|
||||
SetLastError(0xdeadbeef);
|
||||
rsrc_size = SizeofResource(GetModuleHandle(0), rsrc);
|
||||
ok(rsrc_size != 0, "SizeofResource error %d\n", GetLastError());
|
||||
if (!rsrc_size) return FALSE;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetTempPath(MAX_PATH, tmp_path);
|
||||
ok(ret, "GetTempPath() error %d\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = GetTempFileName(tmp_path, "ttf", 0, tmp_name);
|
||||
ok(ret, "GetTempFileName() error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hfile = CreateFile(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
ok(hfile != INVALID_HANDLE_VALUE, "CreateFile() error %d\n", GetLastError());
|
||||
if (hfile == INVALID_HANDLE_VALUE) return FALSE;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = WriteFile(hfile, rsrc_data, rsrc_size, &rsrc_size, NULL);
|
||||
ok(ret, "WriteFile() error %d\n", GetLastError());
|
||||
|
||||
CloseHandle(hfile);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void test_CreateScalableFontResource(void)
|
||||
{
|
||||
char ttf_name[MAX_PATH];
|
||||
char tmp_path[MAX_PATH];
|
||||
char fot_name[MAX_PATH];
|
||||
char *file_part;
|
||||
DWORD ret;
|
||||
|
||||
if (!pAddFontResourceExA || !pRemoveFontResourceExA)
|
||||
{
|
||||
win_skip("AddFontResourceExA is not available on this platform\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!write_ttf_file(ttf_name))
|
||||
{
|
||||
skip("Failed to create ttf file for testing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trace("created %s\n", ttf_name);
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
ret = GetTempPath(MAX_PATH, tmp_path);
|
||||
ok(ret, "GetTempPath() error %d\n", GetLastError());
|
||||
ret = GetTempFileName(tmp_path, "fot", 0, fot_name);
|
||||
ok(ret, "GetTempFileName() error %d\n", GetLastError());
|
||||
|
||||
ret = GetFileAttributes(fot_name);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "file %s does not exist\n", fot_name);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, ttf_name, NULL);
|
||||
ok(!ret, "CreateScalableFontResource() should fail\n");
|
||||
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, ttf_name, "");
|
||||
ok(!ret, "CreateScalableFontResource() should fail\n");
|
||||
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
||||
|
||||
file_part = strrchr(ttf_name, '\\');
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, file_part, tmp_path);
|
||||
ok(!ret, "CreateScalableFontResource() should fail\n");
|
||||
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, "random file name", tmp_path);
|
||||
ok(!ret, "CreateScalableFontResource() should fail\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, NULL, ttf_name);
|
||||
ok(!ret, "CreateScalableFontResource() should fail\n");
|
||||
todo_wine
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
|
||||
|
||||
ret = DeleteFile(fot_name);
|
||||
ok(ret, "DeleteFile() error %d\n", GetLastError());
|
||||
|
||||
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
||||
todo_wine
|
||||
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
||||
|
||||
/* FIXME: since CreateScalableFontResource is a stub further testing is impossible */
|
||||
if (ret) return;
|
||||
|
||||
/* test public font resource */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(0, fot_name, ttf_name, NULL);
|
||||
ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pAddFontResourceExA(fot_name, 0, 0);
|
||||
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(ret, "font wine_test should be enumerated\n");
|
||||
|
||||
ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
|
||||
ok(!ret, "RemoveFontResourceEx() with not matching flags should fail\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
||||
todo_wine
|
||||
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
todo_wine
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
/* FIXME: since RemoveFontResource is a stub correct testing is impossible */
|
||||
if (ret)
|
||||
{
|
||||
/* remove once RemoveFontResource is implemented */
|
||||
DeleteFile(fot_name);
|
||||
DeleteFile(ttf_name);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
||||
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
||||
|
||||
DeleteFile(fot_name);
|
||||
|
||||
/* test hidden font resource */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CreateScalableFontResource(1, fot_name, ttf_name, NULL);
|
||||
ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pAddFontResourceExA(fot_name, 0, 0);
|
||||
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
/* XP allows removing a private font added with 0 flags */
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
|
||||
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
||||
|
||||
ret = is_truetype_font_installed("wine_test");
|
||||
ok(!ret, "font wine_test should not be enumerated\n");
|
||||
|
||||
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
||||
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
||||
|
||||
DeleteFile(fot_name);
|
||||
DeleteFile(ttf_name);
|
||||
}
|
||||
|
||||
START_TEST(font)
|
||||
{
|
||||
init();
|
||||
|
@ -3851,4 +4039,9 @@ START_TEST(font)
|
|||
test_CreateFontIndirectEx();
|
||||
test_oemcharset();
|
||||
test_fullname();
|
||||
|
||||
/* CreateScalableFontResource should be last test until RemoveFontResource
|
||||
* is properly implemented.
|
||||
*/
|
||||
test_CreateScalableFontResource();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Resources for gdi32 test suite.
|
||||
*
|
||||
* Copyright 2010 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 "windef.h"
|
||||
|
||||
/* @makedep: wine_test.ttf */
|
||||
wine_test.ttf RCDATA wine_test.ttf
|
|
@ -0,0 +1,180 @@
|
|||
SplineFontDB: 3.0
|
||||
FontName: wine_test
|
||||
FullName: wine_test
|
||||
FamilyName: wine_test
|
||||
Weight: Medium
|
||||
Copyright: Copyright (c) 2010 Dmitry Timoshkov
|
||||
Version: 001.000
|
||||
ItalicAngle: 0
|
||||
UnderlinePosition: -205
|
||||
UnderlineWidth: 102
|
||||
Ascent: 1638
|
||||
Descent: 410
|
||||
sfntRevision: 0x00010000
|
||||
LayerCount: 2
|
||||
Layer: 0 1 "Back" 1
|
||||
Layer: 1 1 "Fore" 0
|
||||
XUID: [1021 905 592216984 1247726]
|
||||
FSType: 0
|
||||
OS2Version: 2
|
||||
OS2_WeightWidthSlopeOnly: 0
|
||||
OS2_UseTypoMetrics: 1
|
||||
CreationTime: 1288336343
|
||||
ModificationTime: 1288336873
|
||||
PfmFamily: 17
|
||||
TTFWeight: 500
|
||||
TTFWidth: 5
|
||||
LineGap: 184
|
||||
VLineGap: 0
|
||||
Panose: 2 0 6 3 0 0 0 0 0 0
|
||||
OS2TypoAscent: 0
|
||||
OS2TypoAOffset: 1
|
||||
OS2TypoDescent: 0
|
||||
OS2TypoDOffset: 1
|
||||
OS2TypoLinegap: 184
|
||||
OS2WinAscent: 0
|
||||
OS2WinAOffset: 1
|
||||
OS2WinDescent: 0
|
||||
OS2WinDOffset: 1
|
||||
HheadAscent: 0
|
||||
HheadAOffset: 1
|
||||
HheadDescent: 0
|
||||
HheadDOffset: 1
|
||||
OS2SubXSize: 1331
|
||||
OS2SubYSize: 1433
|
||||
OS2SubXOff: 0
|
||||
OS2SubYOff: 286
|
||||
OS2SupXSize: 1331
|
||||
OS2SupYSize: 1433
|
||||
OS2SupXOff: 0
|
||||
OS2SupYOff: 983
|
||||
OS2StrikeYSize: 102
|
||||
OS2StrikeYPos: 530
|
||||
OS2Vendor: 'Wine'
|
||||
OS2CodePages: 00000001.00000000
|
||||
OS2UnicodeRanges: 00000001.00000000.00000000.00000000
|
||||
MarkAttachClasses: 1
|
||||
DEI: 91125
|
||||
ShortTable: cvt 2
|
||||
68
|
||||
1297
|
||||
EndShort
|
||||
ShortTable: maxp 16
|
||||
1
|
||||
0
|
||||
4
|
||||
8
|
||||
2
|
||||
0
|
||||
0
|
||||
2
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
||||
64
|
||||
46
|
||||
0
|
||||
0
|
||||
EndShort
|
||||
LangName: 1033 "" "" "" "Wine : wine_test : 4-11-2010"
|
||||
GaspTable: 1 65535 2
|
||||
Encoding: UnicodeBmp
|
||||
UnicodeInterp: none
|
||||
NameList: Adobe Glyph List
|
||||
DisplaySize: -24
|
||||
AntiAlias: 1
|
||||
FitToEm: 1
|
||||
WinInfo: 65 65 19
|
||||
BeginChars: 65539 4
|
||||
|
||||
StartChar: .notdef
|
||||
Encoding: 65536 -1 0
|
||||
Width: 748
|
||||
Flags: W
|
||||
TtInstrs:
|
||||
PUSHB_2
|
||||
1
|
||||
0
|
||||
MDAP[rnd]
|
||||
ALIGNRP
|
||||
PUSHB_3
|
||||
7
|
||||
4
|
||||
0
|
||||
MIRP[min,rnd,black]
|
||||
SHP[rp2]
|
||||
PUSHB_2
|
||||
6
|
||||
5
|
||||
MDRP[rp0,min,rnd,grey]
|
||||
ALIGNRP
|
||||
PUSHB_3
|
||||
3
|
||||
2
|
||||
0
|
||||
MIRP[min,rnd,black]
|
||||
SHP[rp2]
|
||||
SVTCA[y-axis]
|
||||
PUSHB_2
|
||||
3
|
||||
0
|
||||
MDAP[rnd]
|
||||
ALIGNRP
|
||||
PUSHB_3
|
||||
5
|
||||
4
|
||||
0
|
||||
MIRP[min,rnd,black]
|
||||
SHP[rp2]
|
||||
PUSHB_3
|
||||
7
|
||||
6
|
||||
1
|
||||
MIRP[rp0,min,rnd,grey]
|
||||
ALIGNRP
|
||||
PUSHB_3
|
||||
1
|
||||
2
|
||||
0
|
||||
MIRP[min,rnd,black]
|
||||
SHP[rp2]
|
||||
EndTTInstrs
|
||||
LayerCount: 2
|
||||
Fore
|
||||
SplineSet
|
||||
68 0 m 1,0,-1
|
||||
68 1365 l 1,1,-1
|
||||
612 1365 l 1,2,-1
|
||||
612 0 l 1,3,-1
|
||||
68 0 l 1,0,-1
|
||||
136 68 m 1,4,-1
|
||||
544 68 l 1,5,-1
|
||||
544 1297 l 1,6,-1
|
||||
136 1297 l 1,7,-1
|
||||
136 68 l 1,4,-1
|
||||
EndSplineSet
|
||||
EndChar
|
||||
|
||||
StartChar: .null
|
||||
Encoding: 65537 -1 1
|
||||
Width: 0
|
||||
Flags: W
|
||||
LayerCount: 2
|
||||
EndChar
|
||||
|
||||
StartChar: nonmarkingreturn
|
||||
Encoding: 65538 -1 2
|
||||
Width: 682
|
||||
Flags: W
|
||||
LayerCount: 2
|
||||
EndChar
|
||||
|
||||
StartChar: exclam
|
||||
Encoding: 33 33 3
|
||||
Width: 0
|
||||
Flags: W
|
||||
LayerCount: 2
|
||||
EndChar
|
||||
EndChars
|
||||
EndSplineFont
|
Binary file not shown.
Loading…
Reference in New Issue