1c2c66affSColin Finck /*
2c2c66affSColin Finck * PROJECT: ReactOS api tests
3c2c66affSColin Finck * LICENSE: GPL - See COPYING in the top level directory
4c2c66affSColin Finck * PURPOSE: Test for GetFontResourceInfoW
5c2c66affSColin Finck * PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6c2c66affSColin Finck */
7*aee83c35SAmine Khaldi
8*aee83c35SAmine Khaldi #include "precomp.h"
9c2c66affSColin Finck
10c2c66affSColin Finck /* GetFontResourceInfoW is undocumented */
11c2c66affSColin Finck BOOL WINAPI GetFontResourceInfoW(LPCWSTR lpFileName, DWORD *pdwBufSize, void* lpBuffer, DWORD dwType);
12c2c66affSColin Finck
13c2c66affSColin Finck /* structure of test entry */
14c2c66affSColin Finck typedef struct GFRI_ENTRY
15c2c66affSColin Finck {
16c2c66affSColin Finck LPCWSTR File;
17c2c66affSColin Finck BOOL Preinstalled;
18c2c66affSColin Finck WCHAR FontInfo[64];
19c2c66affSColin Finck INT FontCount;
20c2c66affSColin Finck WCHAR FaceNames[10][64];
21c2c66affSColin Finck } GFRI_ENTRY;
22c2c66affSColin Finck
23c2c66affSColin Finck /* test entries */
24c2c66affSColin Finck static const GFRI_ENTRY TestEntries[] =
25c2c66affSColin Finck {
26c2c66affSColin Finck { L"symbol.ttf", TRUE, L"Symbol|", 1, { L"Symbol" } },
27c2c66affSColin Finck { L"tahoma.ttf", TRUE, L"Tahoma|", 1, { L"Tahoma" } },
28c2c66affSColin Finck { L"tahomabd.ttf", TRUE, L"Tahoma Bold|", 1, { L"Tahoma" } }
29c2c66affSColin Finck };
30c2c66affSColin Finck
31c2c66affSColin Finck /* Japanese */
32c2c66affSColin Finck static const GFRI_ENTRY AdditionalTestEntriesJapanese[] =
33c2c66affSColin Finck {
34c2c66affSColin Finck {
35c2c66affSColin Finck /* MS Gothic & MS UI Gothic & MS PGothic */
36c2c66affSColin Finck L"msgothic.ttc", TRUE,
37c2c66affSColin Finck {
38c2c66affSColin Finck 0xFF2D, 0xFF33, 0x0020, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0x0020,
39c2c66affSColin Finck 0x0026, 0x0020, 0x004D, 0x0053, 0x0020, 0x0055, 0x0049, 0x0020,
40c2c66affSColin Finck 0x0047, 0x006F, 0x0074, 0x0068, 0x0069, 0x0063, 0x0020, 0x0026,
41c2c66affSColin Finck 0x0020, 0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x30B4, 0x30B7, 0x30C3,
42c2c66affSColin Finck 0x30AF, L'|', 0
43c2c66affSColin Finck },
44c2c66affSColin Finck 6,
45c2c66affSColin Finck {
46c2c66affSColin Finck { 0xFF2D, 0xFF33, 0x0020, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 },
47c2c66affSColin Finck { L'@', 0xFF2D, 0xFF33, 0x0020, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 },
48c2c66affSColin Finck L"MS UI Gothic",
49c2c66affSColin Finck L"@MS UI Gothic",
50c2c66affSColin Finck { 0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 },
51c2c66affSColin Finck { L'@', 0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 }
52c2c66affSColin Finck }
53c2c66affSColin Finck },
54c2c66affSColin Finck {
55c2c66affSColin Finck L"ExampleFont.ttf", FALSE,
56c2c66affSColin Finck L"JapaneseDisplayName|",
57c2c66affSColin Finck 1,
58c2c66affSColin Finck {
59c2c66affSColin Finck L"JapaneseFamilyName"
60c2c66affSColin Finck }
61c2c66affSColin Finck }
62c2c66affSColin Finck };
63c2c66affSColin Finck
64c2c66affSColin Finck /* English */
65c2c66affSColin Finck static const GFRI_ENTRY AdditionalTestEntriesEnglish[] =
66c2c66affSColin Finck {
67c2c66affSColin Finck {
68c2c66affSColin Finck /* MS Gothic & MS UI Gothic & MS PGothic */
69c2c66affSColin Finck L"msgothic.ttc", TRUE,
70c2c66affSColin Finck L"MS Gothic & MS UI Gothic & MS PGothic|",
71c2c66affSColin Finck 6,
72c2c66affSColin Finck {
73c2c66affSColin Finck L"MS Gothic",
74c2c66affSColin Finck L"@MS Gothic",
75c2c66affSColin Finck L"MS UI Gothic",
76c2c66affSColin Finck L"@MS UI Gothic",
77c2c66affSColin Finck L"MS PGothic",
78c2c66affSColin Finck L"@MS PGothic"
79c2c66affSColin Finck }
80c2c66affSColin Finck },
81c2c66affSColin Finck {
82c2c66affSColin Finck L"ExampleFont.ttf", FALSE,
83c2c66affSColin Finck L"EnglishDisplayName|",
84c2c66affSColin Finck 1,
85c2c66affSColin Finck {
86c2c66affSColin Finck L"EnglishFamilyName"
87c2c66affSColin Finck }
88c2c66affSColin Finck }
89c2c66affSColin Finck };
90c2c66affSColin Finck
91c2c66affSColin Finck static void
GetSystemFontDirectory(LPWSTR pszDir)92c2c66affSColin Finck GetSystemFontDirectory(LPWSTR pszDir)
93c2c66affSColin Finck {
94c2c66affSColin Finck GetWindowsDirectoryW(pszDir, MAX_PATH);
95c2c66affSColin Finck lstrcatW(pszDir, L"\\Fonts");
96c2c66affSColin Finck }
97c2c66affSColin Finck
98c2c66affSColin Finck static void
GetSystemFontPath(LPWSTR pszPath,LPCWSTR pszFile)99c2c66affSColin Finck GetSystemFontPath(LPWSTR pszPath, LPCWSTR pszFile)
100c2c66affSColin Finck {
101c2c66affSColin Finck GetSystemFontDirectory(pszPath);
102c2c66affSColin Finck lstrcatW(pszPath, L"\\");
103c2c66affSColin Finck lstrcatW(pszPath, pszFile);
104c2c66affSColin Finck }
105c2c66affSColin Finck
106c2c66affSColin Finck static INT
GetMultiSzLength(const WCHAR * pszz)107c2c66affSColin Finck GetMultiSzLength(const WCHAR *pszz)
108c2c66affSColin Finck {
109c2c66affSColin Finck INT Len, TotalLen = 0;
110c2c66affSColin Finck for (;;)
111c2c66affSColin Finck {
112c2c66affSColin Finck Len = lstrlenW(pszz);
113c2c66affSColin Finck TotalLen += Len + 1;
114c2c66affSColin Finck pszz += Len + 1;
115c2c66affSColin Finck if (*pszz == 0)
116c2c66affSColin Finck break;
117c2c66affSColin Finck }
118c2c66affSColin Finck ++TotalLen;
119c2c66affSColin Finck return TotalLen;
120c2c66affSColin Finck }
121c2c66affSColin Finck
122c2c66affSColin Finck static void
ReplaceChars(WCHAR * pch,INT Len,WCHAR From,WCHAR To)123c2c66affSColin Finck ReplaceChars(WCHAR *pch, INT Len, WCHAR From, WCHAR To)
124c2c66affSColin Finck {
125c2c66affSColin Finck while (Len > 0)
126c2c66affSColin Finck {
127c2c66affSColin Finck if (*pch == From)
128c2c66affSColin Finck {
129c2c66affSColin Finck *pch = To;
130c2c66affSColin Finck }
131c2c66affSColin Finck //printf("0x%04X, ", *pch);
132c2c66affSColin Finck ++pch;
133c2c66affSColin Finck --Len;
134c2c66affSColin Finck }
135c2c66affSColin Finck }
136c2c66affSColin Finck
137c2c66affSColin Finck static void
SzFromMultiSz(WCHAR * pszz)138c2c66affSColin Finck SzFromMultiSz(WCHAR *pszz)
139c2c66affSColin Finck {
140c2c66affSColin Finck INT Length = GetMultiSzLength(pszz);
141c2c66affSColin Finck //printf("Length: %d\n", Length);
142c2c66affSColin Finck if (Length > 0)
143c2c66affSColin Finck {
144c2c66affSColin Finck ReplaceChars(pszz, Length - 1, L'\0', L'|');
145c2c66affSColin Finck pszz[Length - 1] = 0;
146c2c66affSColin Finck }
147c2c66affSColin Finck else
148c2c66affSColin Finck {
149c2c66affSColin Finck pszz[0] = 0;
150c2c66affSColin Finck }
151c2c66affSColin Finck //printf("pszz: %S\n", pszz);
152c2c66affSColin Finck }
153c2c66affSColin Finck
154c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case0(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)155c2c66affSColin Finck Test_GetFontResourceInfoW_case0(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
156c2c66affSColin Finck {
157c2c66affSColin Finck BOOL Ret;
158c2c66affSColin Finck DWORD Size, Case = 0;
159c2c66affSColin Finck DWORD Data;
160c2c66affSColin Finck
161c2c66affSColin Finck /* data NULL, size zero */
162c2c66affSColin Finck Size = 0;
163c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
164c2c66affSColin Finck ok_int(Ret, 1);
165c2c66affSColin Finck ok_int(Size, 4);
166c2c66affSColin Finck
167c2c66affSColin Finck /* data NULL, size non-zero */
168c2c66affSColin Finck Size = 1024;
169c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
170c2c66affSColin Finck ok_int(Ret, 0);
171c2c66affSColin Finck ok_int(Size, 1024);
172c2c66affSColin Finck
173c2c66affSColin Finck /* size zero */
174c2c66affSColin Finck Data = 0xDEADFACE;
175c2c66affSColin Finck Size = 0;
176c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, &Data, Case);
177c2c66affSColin Finck ok_int(Ret, 1);
178c2c66affSColin Finck ok_int(Data, 0xDEADFACE);
179c2c66affSColin Finck ok_int(Size, 4);
180c2c66affSColin Finck
181c2c66affSColin Finck /* size non-zero */
182c2c66affSColin Finck Data = 0xDEADFACE;
183c2c66affSColin Finck Size = sizeof(Data);
184c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, &Data, Case);
185c2c66affSColin Finck ok_int(Ret, 1);
186c2c66affSColin Finck ok_int(Data, Entry->FontCount);
187c2c66affSColin Finck ok_int(Size, 4);
188c2c66affSColin Finck }
189c2c66affSColin Finck
190c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case1(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)191c2c66affSColin Finck Test_GetFontResourceInfoW_case1(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
192c2c66affSColin Finck {
193c2c66affSColin Finck BOOL Ret;
194c2c66affSColin Finck DWORD Size, Case = 1;
195c2c66affSColin Finck static WCHAR Data[1024 / sizeof(WCHAR)];
196c2c66affSColin Finck
197c2c66affSColin Finck /* data NULL, size zero */
198c2c66affSColin Finck Size = 0;
199c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
200c2c66affSColin Finck ok_int(Ret, 1);
201c2c66affSColin Finck /* FIXME: What's the result of Size? */
202c2c66affSColin Finck ok(Size != 0, "Size expected non-zero but zero\n");
203c2c66affSColin Finck
204c2c66affSColin Finck /* data NULL, size non-zero */
205c2c66affSColin Finck Size = 1024;
206c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
207c2c66affSColin Finck ok_int(Ret, 0);
208c2c66affSColin Finck ok_int(Size, 1024);
209c2c66affSColin Finck
210c2c66affSColin Finck /* size zero */
211c2c66affSColin Finck Size = 0;
212c2c66affSColin Finck CopyMemory(Data, L"ABC\0", sizeof(L"ABC\0"));
213c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
214c2c66affSColin Finck ok_int(Ret, 1);
215c2c66affSColin Finck /* FIXME: What's the result of Size? */
216c2c66affSColin Finck ok(Size != 0, "Size expected non-zero but zero\n");
217c2c66affSColin Finck ok(lstrcmpiW(Data, L"ABC") == 0, "data mismatched: \"%S\"\n", Data);
218c2c66affSColin Finck
219c2c66affSColin Finck /* size non-zero */
220c2c66affSColin Finck Size = 1024;
221c2c66affSColin Finck CopyMemory(Data, L"ABC\0", sizeof(L"ABC\0"));
222c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
223c2c66affSColin Finck ok_int(Ret, 1);
224c2c66affSColin Finck /* FIXME: What's the result of Size? */
225c2c66affSColin Finck ok(Size != 0, "Size expected non-zero but zero\n");
226c2c66affSColin Finck
227c2c66affSColin Finck SzFromMultiSz(Data);
228c2c66affSColin Finck ok(lstrcmpiW(Data, Entry->FontInfo) == 0, "data mismatched: \"%S\" and \"%S\"\n",
229c2c66affSColin Finck Data, Entry->FontInfo);
230c2c66affSColin Finck #if 0
231c2c66affSColin Finck if (lstrcmpiW(Data, Entry->FontInfo) != 0)
232c2c66affSColin Finck {
233c2c66affSColin Finck int i, len = lstrlenW(Data) + 1;
234c2c66affSColin Finck for (i = 0; i < len; ++i)
235c2c66affSColin Finck {
236c2c66affSColin Finck printf("0x%04X <=> 0x%04X\n", Data[i], Entry->FontInfo[i]);
237c2c66affSColin Finck }
238c2c66affSColin Finck }
239c2c66affSColin Finck #endif
240c2c66affSColin Finck }
241c2c66affSColin Finck
242c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case2(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)243c2c66affSColin Finck Test_GetFontResourceInfoW_case2(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
244c2c66affSColin Finck {
245c2c66affSColin Finck BOOL Ret;
246c2c66affSColin Finck DWORD i, Size, Case = 2;
247c2c66affSColin Finck static LOGFONTW Data[100];
248c2c66affSColin Finck
249c2c66affSColin Finck /* data NULL, size zero */
250c2c66affSColin Finck Size = 0;
251c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
252c2c66affSColin Finck ok_int(Ret, 1);
253c2c66affSColin Finck ok_int(Size, Entry->FontCount * sizeof(LOGFONTW));
254c2c66affSColin Finck
255c2c66affSColin Finck /* data NULL, size non-zero */
256c2c66affSColin Finck Size = 1024;
257c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
258c2c66affSColin Finck ok_int(Ret, 0);
259c2c66affSColin Finck ok_int(Size, 1024);
260c2c66affSColin Finck
261c2c66affSColin Finck /* size zero */
262c2c66affSColin Finck Size = 0;
263c2c66affSColin Finck ZeroMemory(Data, sizeof(Data));
264c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
265c2c66affSColin Finck ok_int(Ret, 1);
266c2c66affSColin Finck ok_int(Size, Entry->FontCount * sizeof(LOGFONTW));
267c2c66affSColin Finck
268c2c66affSColin Finck /* size non-zero */
269c2c66affSColin Finck Size = sizeof(Data);
270c2c66affSColin Finck ZeroMemory(Data, sizeof(Data));
271c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
272c2c66affSColin Finck ok_int(Ret, 1);
273c2c66affSColin Finck ok_int(Size, Entry->FontCount * sizeof(LOGFONTW));
274c2c66affSColin Finck for (i = 0; i < Entry->FontCount; ++i)
275c2c66affSColin Finck {
276c2c66affSColin Finck ok(lstrcmpiW(Data[i].lfFaceName, Entry->FaceNames[i]) == 0,
277c2c66affSColin Finck "face name #%d mismatched: \"%S\" and \"%S\"\n", (int)i, Data[i].lfFaceName, Entry->FaceNames[i]);
278c2c66affSColin Finck #if 0
279c2c66affSColin Finck if (lstrcmpiW(Data[i].lfFaceName, Entry->FaceNames[i]) != 0)
280c2c66affSColin Finck {
281c2c66affSColin Finck int k, len = lstrlenW(Data[i].lfFaceName);
282c2c66affSColin Finck for (k = 0; k < len; ++k)
283c2c66affSColin Finck {
284c2c66affSColin Finck printf("0x%04X <=> 0x%04X\n", Entry->FaceNames[i][k], Data[i].lfFaceName[k]);
285c2c66affSColin Finck }
286c2c66affSColin Finck }
287c2c66affSColin Finck #endif
288c2c66affSColin Finck }
289c2c66affSColin Finck }
290c2c66affSColin Finck
291c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case3(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)292c2c66affSColin Finck Test_GetFontResourceInfoW_case3(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
293c2c66affSColin Finck {
294c2c66affSColin Finck BOOL Ret;
295c2c66affSColin Finck DWORD Size, Case = 3;
296c2c66affSColin Finck DWORD Data[2];
297c2c66affSColin Finck
298c2c66affSColin Finck /* data NULL, size zero */
299c2c66affSColin Finck Size = 0;
300c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
301c2c66affSColin Finck ok_int(Ret, 1);
302c2c66affSColin Finck ok_int(Size, 4);
303c2c66affSColin Finck
304c2c66affSColin Finck /* data NULL, size non-zero */
305c2c66affSColin Finck Size = sizeof(Data);
306c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
307c2c66affSColin Finck ok_int(Ret, 0);
308c2c66affSColin Finck ok_int(Size, 8);
309c2c66affSColin Finck
310c2c66affSColin Finck /* size zero */
311c2c66affSColin Finck Size = 0;
312c2c66affSColin Finck Data[0] = 0xDEADFACE;
313c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
314c2c66affSColin Finck ok_int(Ret, 1);
315c2c66affSColin Finck ok_int(Size, 4);
316c2c66affSColin Finck ok_int(Data[0], 0xDEADFACE);
317c2c66affSColin Finck
318c2c66affSColin Finck /* size non-zero */
319c2c66affSColin Finck Size = sizeof(Data);
320c2c66affSColin Finck Data[0] = 0xDEADFACE;
321c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
322c2c66affSColin Finck ok_int(Ret, 1);
323c2c66affSColin Finck ok_int(Size, 4);
324c2c66affSColin Finck ok_int(Data[0], 1);
325c2c66affSColin Finck }
326c2c66affSColin Finck
327c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case4(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)328c2c66affSColin Finck Test_GetFontResourceInfoW_case4(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
329c2c66affSColin Finck {
330c2c66affSColin Finck BOOL Ret;
331c2c66affSColin Finck DWORD Size, Case = 4;
332c2c66affSColin Finck WCHAR Data[MAX_PATH];
333c2c66affSColin Finck
334c2c66affSColin Finck /* data NULL, size zero */
335c2c66affSColin Finck Size = 0;
336c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
337c2c66affSColin Finck ok_int(Ret, 1);
338c2c66affSColin Finck ok_int(Size, (lstrlenW(pszFilePath) + 1) * sizeof(WCHAR));
339c2c66affSColin Finck
340c2c66affSColin Finck /* data NULL, size non-zero */
341c2c66affSColin Finck Size = MAX_PATH;
342c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
343c2c66affSColin Finck ok_int(Ret, 0);
344c2c66affSColin Finck ok_int(Size, MAX_PATH);
345c2c66affSColin Finck
346c2c66affSColin Finck /* size zero */
347c2c66affSColin Finck Size = 0;
348c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
349c2c66affSColin Finck ok_int(Ret, 1);
350c2c66affSColin Finck ok_int(Size, (lstrlenW(pszFilePath) + 1) * sizeof(WCHAR));
351c2c66affSColin Finck
352c2c66affSColin Finck /* size non-zero */
353c2c66affSColin Finck Size = MAX_PATH;
354c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, Data, Case);
355c2c66affSColin Finck ok_int(Ret, 1);
356c2c66affSColin Finck ok_int(Size, (lstrlenW(pszFilePath) + 1) * sizeof(WCHAR));
357c2c66affSColin Finck ok(lstrcmpiW(pszFilePath, Data) == 0, "data mismatched: \"%S\"\n", Data);
358c2c66affSColin Finck }
359c2c66affSColin Finck
360c2c66affSColin Finck static void
Test_GetFontResourceInfoW_case5(LPCWSTR pszFilePath,const GFRI_ENTRY * Entry)361c2c66affSColin Finck Test_GetFontResourceInfoW_case5(LPCWSTR pszFilePath, const GFRI_ENTRY *Entry)
362c2c66affSColin Finck {
363c2c66affSColin Finck BOOL Ret;
364c2c66affSColin Finck DWORD Size, Case = 5;
365c2c66affSColin Finck DWORD Data;
366c2c66affSColin Finck
367c2c66affSColin Finck /* data NULL, size zero */
368c2c66affSColin Finck Size = 0;
369c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
370c2c66affSColin Finck ok_int(Ret, 1);
371c2c66affSColin Finck ok_int(Size, 4);
372c2c66affSColin Finck
373c2c66affSColin Finck /* data NULL, size non-zero */
374c2c66affSColin Finck Size = sizeof(Data);
375c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, NULL, Case);
376c2c66affSColin Finck ok_int(Ret, 0);
377c2c66affSColin Finck ok_int(Size, 4);
378c2c66affSColin Finck
379c2c66affSColin Finck /* size zero */
380c2c66affSColin Finck Size = 0;
381c2c66affSColin Finck Data = 0xDEADFACE;
382c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, &Data, Case);
383c2c66affSColin Finck ok_int(Ret, 1);
384c2c66affSColin Finck ok_int(Size, 4);
385c2c66affSColin Finck ok_int(Data, 0xDEADFACE);
386c2c66affSColin Finck
387c2c66affSColin Finck /* size non-zero */
388c2c66affSColin Finck Size = sizeof(Data);
389c2c66affSColin Finck Data = 0xDEADFACE;
390c2c66affSColin Finck Ret = GetFontResourceInfoW(pszFilePath, &Size, &Data, Case);
391c2c66affSColin Finck ok_int(Ret, 1);
392c2c66affSColin Finck ok_int(Size, 4);
393c2c66affSColin Finck ok_int(Data, 0);
394c2c66affSColin Finck }
395c2c66affSColin Finck
396c2c66affSColin Finck static void
DoEntry(const GFRI_ENTRY * Entry)397c2c66affSColin Finck DoEntry(const GFRI_ENTRY *Entry)
398c2c66affSColin Finck {
399c2c66affSColin Finck WCHAR szPath[MAX_PATH], szTempPath[MAX_PATH];
400c2c66affSColin Finck BOOL Installed = FALSE;
401c2c66affSColin Finck
402c2c66affSColin Finck if (Entry->Preinstalled)
403c2c66affSColin Finck {
404c2c66affSColin Finck GetSystemFontPath(szPath, Entry->File);
405c2c66affSColin Finck printf("GetSystemFontPath: %S\n", szPath);
406c2c66affSColin Finck if (GetFileAttributesW(szPath) == INVALID_FILE_ATTRIBUTES)
407c2c66affSColin Finck {
408c2c66affSColin Finck skip("Font file \"%S\" was not found\n", szPath);
409c2c66affSColin Finck return;
410c2c66affSColin Finck }
411c2c66affSColin Finck }
412c2c66affSColin Finck else
413c2c66affSColin Finck {
414c2c66affSColin Finck /* load font data from resource */
415c2c66affSColin Finck HANDLE hFile;
416c2c66affSColin Finck HMODULE hMod = GetModuleHandleW(NULL);
417c2c66affSColin Finck HRSRC hRsrc = FindResourceW(hMod, Entry->File, (LPCWSTR)RT_RCDATA);
418c2c66affSColin Finck HGLOBAL hGlobal = LoadResource(hMod, hRsrc);
419c2c66affSColin Finck DWORD Size = SizeofResource(hMod, hRsrc);
420c2c66affSColin Finck LPVOID pFont = LockResource(hGlobal);
421c2c66affSColin Finck
422c2c66affSColin Finck /* get temporary file name */
423c2c66affSColin Finck GetTempPathW(_countof(szTempPath), szTempPath);
424c2c66affSColin Finck GetTempFileNameW(szTempPath, L"FNT", 0, szPath);
425c2c66affSColin Finck printf("GetTempFileNameW: %S\n", szPath);
426c2c66affSColin Finck
427c2c66affSColin Finck /* write to file */
428c2c66affSColin Finck hFile = CreateFileW(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
429c2c66affSColin Finck CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
430c2c66affSColin Finck WriteFile(hFile, pFont, Size, &Size, NULL);
431c2c66affSColin Finck CloseHandle(hFile);
432c2c66affSColin Finck
433c2c66affSColin Finck /* check existence */
434c2c66affSColin Finck if (GetFileAttributesW(szPath) == INVALID_FILE_ATTRIBUTES)
435c2c66affSColin Finck {
436c2c66affSColin Finck skip("Font file \"%S\" was not stored\n", szPath);
437c2c66affSColin Finck return;
438c2c66affSColin Finck }
439c2c66affSColin Finck
440c2c66affSColin Finck /* install */
441c2c66affSColin Finck Installed = !!AddFontResourceW(szPath);
442c2c66affSColin Finck if (!Installed)
443c2c66affSColin Finck {
444c2c66affSColin Finck skip("Font file \"%S\" was not installed\n", szPath);
445c2c66affSColin Finck RemoveFontResourceW(szPath);
446c2c66affSColin Finck DeleteFileW(szPath);
447c2c66affSColin Finck return;
448c2c66affSColin Finck }
449c2c66affSColin Finck }
450c2c66affSColin Finck
451c2c66affSColin Finck Test_GetFontResourceInfoW_case0(szPath, Entry);
452c2c66affSColin Finck Test_GetFontResourceInfoW_case1(szPath, Entry);
453c2c66affSColin Finck Test_GetFontResourceInfoW_case2(szPath, Entry);
454c2c66affSColin Finck Test_GetFontResourceInfoW_case3(szPath, Entry);
455c2c66affSColin Finck Test_GetFontResourceInfoW_case4(szPath, Entry);
456c2c66affSColin Finck Test_GetFontResourceInfoW_case5(szPath, Entry);
457c2c66affSColin Finck
458c2c66affSColin Finck if (!Entry->Preinstalled)
459c2c66affSColin Finck {
460c2c66affSColin Finck if (Installed)
461c2c66affSColin Finck {
462c2c66affSColin Finck RemoveFontResourceW(szPath);
463c2c66affSColin Finck DeleteFileW(szPath);
464c2c66affSColin Finck }
465c2c66affSColin Finck }
466c2c66affSColin Finck }
467c2c66affSColin Finck
START_TEST(GetFontResourceInfoW)468c2c66affSColin Finck START_TEST(GetFontResourceInfoW)
469c2c66affSColin Finck {
470c2c66affSColin Finck INT i;
471c2c66affSColin Finck const GFRI_ENTRY *Entry;
472c2c66affSColin Finck
473c2c66affSColin Finck printf("sizeof(LOGFONTW) == %u\n", (int)sizeof(LOGFONTW));
474c2c66affSColin Finck
475c2c66affSColin Finck for (i = 0; i < _countof(TestEntries); ++i)
476c2c66affSColin Finck {
477c2c66affSColin Finck Entry = &TestEntries[i];
478c2c66affSColin Finck DoEntry(Entry);
479c2c66affSColin Finck }
480c2c66affSColin Finck
481c2c66affSColin Finck if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_JAPANESE)
482c2c66affSColin Finck {
483c2c66affSColin Finck /* Japanese */
484c2c66affSColin Finck for (i = 0; i < _countof(AdditionalTestEntriesJapanese); ++i)
485c2c66affSColin Finck {
486c2c66affSColin Finck Entry = &AdditionalTestEntriesJapanese[i];
487c2c66affSColin Finck DoEntry(Entry);
488c2c66affSColin Finck }
489c2c66affSColin Finck }
490c2c66affSColin Finck else
491c2c66affSColin Finck {
492c2c66affSColin Finck /* non-Japanese */
493c2c66affSColin Finck for (i = 0; i < _countof(AdditionalTestEntriesEnglish); ++i)
494c2c66affSColin Finck {
495c2c66affSColin Finck Entry = &AdditionalTestEntriesEnglish[i];
496c2c66affSColin Finck DoEntry(Entry);
497c2c66affSColin Finck }
498c2c66affSColin Finck }
499c2c66affSColin Finck }
500