ReactOS  0.4.14-dev-293-g2b39b42
fontdlg.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winspool.h"
#include "winuser.h"
#include "objbase.h"
#include "commdlg.h"
#include "wine/test.h"
Include dependency graph for fontdlg.c:

Go to the source code of this file.

Functions

static int get_dpiy (void)
 
static HDC get_printer_ic (void)
 
static UINT_PTR CALLBACK CFHookProcOK (HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void test_ChooseFontA (void)
 
 START_TEST (fontdlg)
 

Function Documentation

◆ CFHookProcOK()

static UINT_PTR CALLBACK CFHookProcOK ( HWND  hdlg,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 72 of file fontdlg.c.

73 {
74  switch (msg)
75  {
76  case WM_INITDIALOG:
78  return 0;
79  default:
80  return 0;
81  }
82 }
#define IDOK
Definition: winuser.h:824
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_COMMAND
Definition: winuser.h:1722
#define msg(x)
Definition: auth_time.c:54
#define WM_INITDIALOG
Definition: winuser.h:1721

Referenced by test_ChooseFontA().

◆ get_dpiy()

static int get_dpiy ( void  )
static

Definition at line 36 of file fontdlg.c.

37 {
38  HDC hdc;
39  int result;
40 
41  hdc = GetDC(0);
43  ReleaseDC(0, hdc);
44 
45  return result;
46 }
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:718
GLuint64EXT * result
Definition: glext.h:11304

Referenced by test_ChooseFontA().

◆ get_printer_ic()

static HDC get_printer_ic ( void  )
static

Definition at line 48 of file fontdlg.c.

49 {
51  DWORD info_size, num_printers=0;
52  BOOL ret;
53  HDC result=NULL;
54 
55  EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &info_size, &num_printers);
56 
57  if (info_size == 0)
58  return NULL;
59 
60  info = HeapAlloc(GetProcessHeap(), 0, info_size);
61 
62  ret = EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)info, info_size, &info_size, &num_printers);
63 
64  if (ret)
65  result = CreateICA(info->pDriverName, info->pPrinterName, NULL, NULL);
66 
68 
69  return result;
70 }
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PRINTER_ENUM_LOCAL
Definition: winspool.h:803
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLuint64EXT * result
Definition: glext.h:11304
WINBOOL WINAPI EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by test_ChooseFontA().

◆ START_TEST()

START_TEST ( fontdlg  )

Definition at line 148 of file fontdlg.c.

149 {
151 }
static void test_ChooseFontA(void)
Definition: fontdlg.c:84

◆ test_ChooseFontA()

static void test_ChooseFontA ( void  )
static

Definition at line 84 of file fontdlg.c.

85 {
86  LOGFONTA lfa;
87  CHOOSEFONTA cfa;
88  BOOL ret;
89  int dpiy = get_dpiy();
90  int expected_pointsize, expected_lfheight;
91  HDC printer_ic;
92 
93  memset(&lfa, 0, sizeof(LOGFONTA));
94  lfa.lfHeight = -16;
95  lfa.lfWeight = FW_NORMAL;
96  strcpy(lfa.lfFaceName, "Symbol");
97 
98  memset(&cfa, 0, sizeof(CHOOSEFONTA));
99  cfa.lStructSize = sizeof(cfa);
100  cfa.lpLogFont = &lfa;
102  cfa.lpfnHook = CFHookProcOK;
103 
104  ret = ChooseFontA(&cfa);
105 
106  expected_pointsize = MulDiv(16, 72, dpiy) * 10;
107  expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720);
108 
109  ok(ret == TRUE, "ChooseFontA returned FALSE\n");
110  ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
111  ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
112  ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
113  ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
114 
115  printer_ic = get_printer_ic();
116  if (!printer_ic)
117  skip("can't get a DC for a local printer\n");
118  else
119  {
120  memset(&lfa, 0, sizeof(LOGFONTA));
121  lfa.lfHeight = -16;
122  lfa.lfWeight = FW_NORMAL;
123  strcpy(lfa.lfFaceName, "Symbol");
124 
125  memset(&cfa, 0, sizeof(CHOOSEFONTA));
126  cfa.lStructSize = sizeof(cfa);
127  cfa.lpLogFont = &lfa;
129  cfa.hDC = printer_ic;
130  cfa.lpfnHook = CFHookProcOK;
131 
132  ret = ChooseFontA(&cfa);
133 
134  expected_pointsize = MulDiv(16, 72, dpiy) * 10;
135  expected_lfheight = -MulDiv(expected_pointsize, dpiy, 720);
136 
137  ok(ret == TRUE, "ChooseFontA returned FALSE\n");
138  ok(cfa.iPointSize == expected_pointsize, "Expected %i, got %i\n", expected_pointsize, cfa.iPointSize);
139  ok(lfa.lfHeight == expected_lfheight, "Expected %i, got %i\n", expected_lfheight, lfa.lfHeight);
140  ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
141  ok((strcmp(lfa.lfFaceName, "Symbol") == 0) ||
142  broken(*lfa.lfFaceName == 0), "Expected Symbol, got %s\n", lfa.lfFaceName);
143 
144  DeleteDC(printer_ic);
145  }
146 }
static int get_dpiy(void)
Definition: fontdlg.c:36
LPLOGFONTA lpLogFont
Definition: commdlg.h:264
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
#define CF_ENABLEHOOK
Definition: commdlg.h:63
DWORD lStructSize
Definition: commdlg.h:261
static HDC get_printer_ic(void)
Definition: fontdlg.c:48
static UINT_PTR CALLBACK CFHookProcOK(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: fontdlg.c:72
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCFHOOKPROC lpfnHook
Definition: commdlg.h:269
#define CF_SCREENFONTS
Definition: commdlg.h:59
LONG lfHeight
Definition: dimm.idl:42
LONG lfWeight
Definition: dimm.idl:46
BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
Definition: fontdlg.c:238
int ret
#define CF_PRINTERFONTS
Definition: commdlg.h:60
DWORD Flags
Definition: commdlg.h:266
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI DeleteDC(_In_ HDC)
INT iPointSize
Definition: commdlg.h:265
#define ok(value,...)
Definition: atltest.h:57
#define FW_NORMAL
Definition: wingdi.h:372
#define skip(...)
Definition: atltest.h:64
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define memset(x, y, z)
Definition: compat.h:39
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66

Referenced by START_TEST().