ReactOS 0.4.15-dev-7889-g76290a6
EnumFontFamilies.c File Reference
#include "precomp.h"
Include dependency graph for EnumFontFamilies.c:

Go to the source code of this file.

Typedefs

typedef int WRAP_ENUM_FONT_FAMILIES(_In_ HDC, _In_ PCWSTR, _In_ PVOID, _In_ LPARAM)
 
typedef WRAP_ENUM_FONT_FAMILIESPWRAP_ENUM_FONT_FAMILIES
 

Functions

static int WrapEnumFontFamiliesA (_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
 
static int WrapEnumFontFamiliesW (_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
 
static int WrapEnumFontFamiliesExA (_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
 
static int WrapEnumFontFamiliesExW (_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
 
static int CALLBACK EnumProcA (_In_ const LOGFONTA *elf, _In_ const TEXTMETRICA *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
 
static int CALLBACK EnumProcW (_In_ const LOGFONTW *elf, _In_ const TEXTMETRICW *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
 
static void TestEnumFontFamilies (_In_ HDC hdc, _In_ PCWSTR FontName, _In_ BOOLEAN ExpectToFind)
 
 START_TEST (EnumFontFamilies)
 

Variables

static BYTE ContextContinue
 
static BYTE ContextStop
 
static int EnumProcCalls
 
static ENUMLOGFONTA LastFontA
 
static ENUMLOGFONTW LastFontW
 

Typedef Documentation

◆ PWRAP_ENUM_FONT_FAMILIES

◆ WRAP_ENUM_FONT_FAMILIES

typedef int WRAP_ENUM_FONT_FAMILIES(_In_ HDC, _In_ PCWSTR, _In_ PVOID, _In_ LPARAM)

Definition at line 17 of file EnumFontFamilies.c.

Function Documentation

◆ EnumProcA()

static int CALLBACK EnumProcA ( _In_ const LOGFONTA elf,
_In_ const TEXTMETRICA ntm,
_In_ DWORD  FontType,
_In_ LPARAM  lParam 
)
static

Definition at line 81 of file EnumFontFamilies.c.

86{
88
91 "Context is %p, expected %p or %p\n",
93
94 LastFontA = *(ENUMLOGFONTA *)elf;
95 return lParam == (LPARAM)&ContextContinue ? 7 : 0;
96}
static ENUMLOGFONTA LastFontA
static int EnumProcCalls
static BYTE ContextContinue
static BYTE ContextStop
#define ok(value,...)
Definition: atltest.h:57
LPARAM lParam
Definition: combotst.c:139
LONG_PTR LPARAM
Definition: windef.h:208

Referenced by TestEnumFontFamilies().

◆ EnumProcW()

static int CALLBACK EnumProcW ( _In_ const LOGFONTW elf,
_In_ const TEXTMETRICW ntm,
_In_ DWORD  FontType,
_In_ LPARAM  lParam 
)
static

Definition at line 101 of file EnumFontFamilies.c.

106{
108
111 "Context is %p, expected %p or %p\n",
113
114 LastFontW = *(ENUMLOGFONTW *)elf;
115 return lParam == (LPARAM)&ContextContinue ? 7 : 0;
116}
static ENUMLOGFONTW LastFontW

Referenced by TestEnumFontFamilies().

◆ START_TEST()

START_TEST ( EnumFontFamilies  )

Definition at line 187 of file EnumFontFamilies.c.

188{
189 HDC hdc;
190
192 if (!hdc)
193 {
194 skip("No DC\n");
195 return;
196 }
197
198 TestEnumFontFamilies(hdc, L"ThisFontDoesNotExist", FALSE);
199 /* Basic fonts that should be installed */
200 TestEnumFontFamilies(hdc, L"MS Sans Serif", TRUE);
201 TestEnumFontFamilies(hdc, L"Tahoma", TRUE);
202 TestEnumFontFamilies(hdc, L"System", TRUE);
203 /* Show case insensitivity */
204 TestEnumFontFamilies(hdc, L"tahOmA", TRUE);
205 /* Special fonts that we have a hack for in win32k ;) */
206 TestEnumFontFamilies(hdc, L"Marlett", TRUE);
207 TestEnumFontFamilies(hdc, L"Symbol", TRUE);
209
210 DeleteDC(hdc);
211}
static void TestEnumFontFamilies(_In_ HDC hdc, _In_ PCWSTR FontName, _In_ BOOLEAN ExpectToFind)
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define L(x)
Definition: ntvdm.h:50
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

◆ TestEnumFontFamilies()

static void TestEnumFontFamilies ( _In_ HDC  hdc,
_In_ PCWSTR  FontName,
_In_ BOOLEAN  ExpectToFind 
)
static

Definition at line 120 of file EnumFontFamilies.c.

124{
125 const struct
126 {
128 PCSTR Name;
129 BOOLEAN Wide;
130 } *fun, functions[] =
131 {
132 { WrapEnumFontFamiliesA, "EnumFontFamiliesA", FALSE },
133 { WrapEnumFontFamiliesW, "EnumFontFamiliesW", TRUE },
134 { WrapEnumFontFamiliesExA, "EnumFontFamiliesExA", FALSE },
135 { WrapEnumFontFamiliesExW, "EnumFontFamiliesExW", TRUE },
136 };
137 const struct
138 {
141 } *ctx, contexts[] =
142 {
143 { &ContextContinue, "Continue" },
144 { &ContextStop, "Stop" },
145 };
146 int ret;
147 DWORD error;
148 unsigned iFunction;
149 unsigned iContext;
150
151 for (iContext = 0; iContext < _countof(contexts); iContext++)
152 {
153 ctx = &contexts[iContext];
154 for (iFunction = 0; iFunction < _countof(functions); iFunction++)
155 {
156 fun = &functions[iFunction];
157 EnumProcCalls = 0;
158 SetLastError(0xdeadbeef);
159 ret = fun->Wrapper(hdc,
160 FontName,
161 fun->Wide ? (PVOID)EnumProcW : (PVOID)EnumProcA,
162 (LPARAM)ctx->Context);
164 ok(error == 0xdeadbeef, "[%s, %s, '%ls'] error is %lu\n", fun->Name, ctx->Description, FontName, error);
165 if (ExpectToFind)
166 {
167 if (ctx->Context == &ContextContinue)
168 {
169 ok(ret == 7, "[%s, %s, '%ls'] ret is %d, expected 7\n", fun->Name, ctx->Description, FontName, ret);
170 ok(EnumProcCalls >= 1, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
171 }
172 else
173 {
174 ok(ret == 0, "[%s, %s, '%ls'] ret is %d, expected 0\n", fun->Name, ctx->Description, FontName, ret);
175 ok(EnumProcCalls == 1, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
176 }
177 }
178 else
179 {
180 ok(ret == 1, "[%s, %s, '%ls'] ret is %d, expected 1\n", fun->Name, ctx->Description, FontName, ret);
181 ok(EnumProcCalls == 0, "[%s, %s, '%ls'] EnumProcCalls is %d\n", fun->Name, ctx->Description, FontName, EnumProcCalls);
182 }
183 }
184 }
185}
static int CALLBACK EnumProcW(_In_ const LOGFONTW *elf, _In_ const TEXTMETRICW *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
static int WrapEnumFontFamiliesA(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
static int CALLBACK EnumProcA(_In_ const LOGFONTA *elf, _In_ const TEXTMETRICA *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
WRAP_ENUM_FONT_FAMILIES * PWRAP_ENUM_FONT_FAMILIES
static int WrapEnumFontFamiliesW(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
static int WrapEnumFontFamiliesExW(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
static int WrapEnumFontFamiliesExA(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
unsigned char BOOLEAN
struct NameRec_ * Name
Definition: cdprocs.h:460
static const WCHAR Description[]
Definition: oid.c:1266
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
#define error(str)
Definition: mkdosfs.c:1605
#define _countof(array)
Definition: sndvol32.h:68
const char * PCSTR
Definition: typedefs.h:52
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ WrapEnumFontFamiliesA()

static int WrapEnumFontFamiliesA ( _In_ HDC  hdc,
_In_ PCWSTR  Family,
_In_ PVOID  EnumProc,
_In_ LPARAM  lParam 
)
static

Definition at line 22 of file EnumFontFamilies.c.

27{
28 char FamilyA[100];
29 WideCharToMultiByte(CP_ACP, 0, Family, -1, FamilyA, sizeof(FamilyA), NULL, NULL);
30 return EnumFontFamiliesA(hdc, FamilyA, EnumProc, lParam);
31}
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
static int Family
Definition: ping.c:62
int WINAPI EnumFontFamiliesA(_In_ HDC, _In_opt_ LPCSTR, _In_ FONTENUMPROCA, _In_ LPARAM)

Referenced by TestEnumFontFamilies().

◆ WrapEnumFontFamiliesExA()

static int WrapEnumFontFamiliesExA ( _In_ HDC  hdc,
_In_ PCWSTR  Family,
_In_ PVOID  EnumProc,
_In_ LPARAM  lParam 
)
static

Definition at line 46 of file EnumFontFamilies.c.

51{
52 LOGFONTA lf;
53
54 ZeroMemory(&lf, sizeof(lf));
56 lf.lfPitchAndFamily = 0;
58 return EnumFontFamiliesExA(hdc, &lf, EnumProc, lParam, 0);
59}
BYTE lfPitchAndFamily
Definition: dimm.idl:54
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define ZeroMemory
Definition: winbase.h:1712
int WINAPI EnumFontFamiliesExA(_In_ HDC, _In_ PLOGFONTA, _In_ FONTENUMPROCA, _In_ LPARAM, _In_ DWORD)
#define DEFAULT_CHARSET
Definition: wingdi.h:384

Referenced by TestEnumFontFamilies().

◆ WrapEnumFontFamiliesExW()

static int WrapEnumFontFamiliesExW ( _In_ HDC  hdc,
_In_ PCWSTR  Family,
_In_ PVOID  EnumProc,
_In_ LPARAM  lParam 
)
static

Definition at line 63 of file EnumFontFamilies.c.

68{
69 LOGFONTW lf;
70
71 ZeroMemory(&lf, sizeof(lf));
73 lf.lfPitchAndFamily = 0;
75 return EnumFontFamiliesExW(hdc, &lf, EnumProc, lParam, 0);
76}
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfPitchAndFamily
Definition: dimm.idl:71
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)

Referenced by TestEnumFontFamilies().

◆ WrapEnumFontFamiliesW()

static int WrapEnumFontFamiliesW ( _In_ HDC  hdc,
_In_ PCWSTR  Family,
_In_ PVOID  EnumProc,
_In_ LPARAM  lParam 
)
static

Definition at line 35 of file EnumFontFamilies.c.

40{
42}
int WINAPI EnumFontFamiliesW(_In_ HDC, _In_opt_ LPCWSTR, _In_ FONTENUMPROCW, _In_ LPARAM)

Referenced by TestEnumFontFamilies().

Variable Documentation

◆ ContextContinue

BYTE ContextContinue
static

Definition at line 10 of file EnumFontFamilies.c.

Referenced by EnumProcA(), EnumProcW(), and TestEnumFontFamilies().

◆ ContextStop

BYTE ContextStop
static

Definition at line 11 of file EnumFontFamilies.c.

Referenced by EnumProcA(), EnumProcW(), and TestEnumFontFamilies().

◆ EnumProcCalls

int EnumProcCalls
static

Definition at line 13 of file EnumFontFamilies.c.

Referenced by EnumProcA(), EnumProcW(), and TestEnumFontFamilies().

◆ LastFontA

ENUMLOGFONTA LastFontA
static

Definition at line 14 of file EnumFontFamilies.c.

Referenced by EnumProcA().

◆ LastFontW

ENUMLOGFONTW LastFontW
static

Definition at line 15 of file EnumFontFamilies.c.

Referenced by EnumProcW().