ReactOS  0.4.15-dev-494-g1d8c567
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 {
87  EnumProcCalls++;
88 
91  "Context is %p, expected %p or %p\n",
93 
94  LastFontA = *(ENUMLOGFONTA *)elf;
95  return lParam == (LPARAM)&ContextContinue ? 7 : 0;
96 }
static BYTE ContextStop
static ENUMLOGFONTA LastFontA
LONG_PTR LPARAM
Definition: windef.h:208
static int EnumProcCalls
#define ok(value,...)
Definition: atltest.h:57
static BYTE ContextContinue
LPARAM lParam
Definition: combotst.c:139

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 {
107  EnumProcCalls++;
108 
111  "Context is %p, expected %p or %p\n",
113 
114  LastFontW = *(ENUMLOGFONTW *)elf;
115  return lParam == (LPARAM)&ContextContinue ? 7 : 0;
116 }
static BYTE ContextStop
LONG_PTR LPARAM
Definition: windef.h:208
static int EnumProcCalls
#define ok(value,...)
Definition: atltest.h:57
static ENUMLOGFONTW LastFontW
static BYTE ContextContinue
LPARAM lParam
Definition: combotst.c:139

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 }
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
static void TestEnumFontFamilies(_In_ HDC hdc, _In_ PCWSTR FontName, _In_ BOOLEAN ExpectToFind)
#define skip(...)
Definition: atltest.h:64

◆ 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  {
127  PWRAP_ENUM_FONT_FAMILIES Wrapper;
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  {
139  PVOID Context;
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);
163  error = GetLastError();
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 EnumProcA(_In_ const LOGFONTA *elf, _In_ const TEXTMETRICA *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
#define TRUE
Definition: types.h:120
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static BYTE ContextStop
static const WCHAR Description[]
Definition: oid.c:1266
static int CALLBACK EnumProcW(_In_ const LOGFONTW *elf, _In_ const TEXTMETRICW *ntm, _In_ DWORD FontType, _In_ LPARAM lParam)
static int WrapEnumFontFamiliesExW(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
struct NameRec_ * Name
Definition: cdprocs.h:459
unsigned char BOOLEAN
LONG_PTR LPARAM
Definition: windef.h:208
WRAP_ENUM_FONT_FAMILIES * PWRAP_ENUM_FONT_FAMILIES
static int WrapEnumFontFamiliesA(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
#define _countof(array)
Definition: sndvol32.h:68
static int WrapEnumFontFamiliesW(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
int ret
HDC hdc
Definition: main.c:9
static int EnumProcCalls
#define ok(value,...)
Definition: atltest.h:57
static int WrapEnumFontFamiliesExA(_In_ HDC hdc, _In_ PCWSTR Family, _In_ PVOID EnumProc, _In_ LPARAM lParam)
struct tagContext Context
Definition: acpixf.h:1034
const char * PCSTR
Definition: typedefs.h:52
static BYTE ContextContinue

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 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static int Family
Definition: ping.c:62
int WINAPI EnumFontFamiliesA(_In_ HDC, _In_opt_ LPCSTR, _In_ FONTENUMPROCA, _In_ LPARAM)
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
LPARAM lParam
Definition: combotst.c:139

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;
57  WideCharToMultiByte(CP_ACP, 0, Family, -1, lf.lfFaceName, sizeof(lf.lfFaceName), NULL, NULL);
58  return EnumFontFamiliesExA(hdc, &lf, EnumProc, lParam, 0);
59 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
#define ZeroMemory
Definition: winbase.h:1648
BYTE lfCharSet
Definition: dimm.idl:50
#define DEFAULT_CHARSET
Definition: wingdi.h:383
static int Family
Definition: ping.c:62
smooth NULL
Definition: ftsmooth.c:416
BYTE lfPitchAndFamily
Definition: dimm.idl:54
HDC hdc
Definition: main.c:9
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
int WINAPI EnumFontFamiliesExA(_In_ HDC, _In_ PLOGFONTA, _In_ FONTENUMPROCA, _In_ LPARAM, _In_ DWORD)
LPARAM lParam
Definition: combotst.c:139

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;
74  StringCbCopyW(lf.lfFaceName, sizeof(lf.lfFaceName), Family);
75  return EnumFontFamiliesExW(hdc, &lf, EnumProc, lParam, 0);
76 }
BYTE lfPitchAndFamily
Definition: dimm.idl:71
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
BYTE lfCharSet
Definition: dimm.idl:67
#define ZeroMemory
Definition: winbase.h:1648
#define DEFAULT_CHARSET
Definition: wingdi.h:383
static int Family
Definition: ping.c:62
HDC hdc
Definition: main.c:9
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
LPARAM lParam
Definition: combotst.c:139

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 }
static int Family
Definition: ping.c:62
HDC hdc
Definition: main.c:9
int WINAPI EnumFontFamiliesW(_In_ HDC, _In_opt_ LPCWSTR, _In_ FONTENUMPROCW, _In_ LPARAM)
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
LPARAM lParam
Definition: combotst.c:139

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().