ReactOS 0.4.15-dev-6661-gcc6e444
GetTextMetrics.c File Reference
#include "precomp.h"
Include dependency graph for GetTextMetrics.c:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 
struct  FONT_ENTRY
 

Macros

#define g_MSGOTHIC_count   _countof(g_MSGOTHIC)
 
#define g_MSMINCHO_count   _countof(g_MSMINCHO)
 
#define g_TAHOMA_count   _countof(g_TAHOMA)
 

Typedefs

typedef struct TEST_ENTRY TEST_ENTRY
 
typedef struct FONT_ENTRY FONT_ENTRY
 

Functions

 START_TEST (GetTextMetrics)
 

Variables

static const TEST_ENTRY g_MSGOTHIC []
 
static const TEST_ENTRY g_MSMINCHO []
 
static const TEST_ENTRY g_TAHOMA []
 
static FONT_ENTRY g_font_entries []
 
static size_t g_font_entry_count = _countof(g_font_entries)
 

Macro Definition Documentation

◆ g_MSGOTHIC_count

#define g_MSGOTHIC_count   _countof(g_MSGOTHIC)

Definition at line 125 of file GetTextMetrics.c.

◆ g_MSMINCHO_count

#define g_MSMINCHO_count   _countof(g_MSMINCHO)

Definition at line 175 of file GetTextMetrics.c.

◆ g_TAHOMA_count

#define g_TAHOMA_count   _countof(g_TAHOMA)

Definition at line 225 of file GetTextMetrics.c.

Typedef Documentation

◆ FONT_ENTRY

◆ TEST_ENTRY

Function Documentation

◆ START_TEST()

START_TEST ( GetTextMetrics  )

Definition at line 252 of file GetTextMetrics.c.

253{
254 size_t i, k;
255 LOGFONTA lf;
256 HFONT hFont;
257 HDC hDC;
258 HGDIOBJ hFontOld;
259 SIZE siz;
261 char szPath[MAX_PATH];
262 static const char *text = "This is a test.";
263
265 for (i = 0; i < g_font_entry_count; ++i)
266 {
268 ZeroMemory(&lf, sizeof(lf));
270 lstrcpyA(lf.lfFaceName, font->font_name);
271
273 lstrcatA(szPath, "\\Fonts\\");
274 lstrcatA(szPath, font->font_file);
275 if (GetFileAttributesA(szPath) == 0xFFFFFFFF)
276 {
277 skip("Font file '%s' doesn't exists\n", font->font_file);
278 continue;
279 }
280
281 trace("Testing '%s'.\n", font->font_file);
282
283#ifdef EMIT_TESTCASES
284 printf("static const TEST_ENTRY g_%s[] =\n", font->entry_name);
285 printf("{\n");
286 for (k = 0; k < g_test_entry_count; ++k)
287 {
288 const TEST_ENTRY *test = &g_test_entries[k];
289
290 lf.lfHeight = test->lfHeight;
291 lf.lfWidth = test->lfWidth;
292
294 hFontOld = SelectObject(hDC, hFont);
295 {
298 }
299 SelectObject(hDC, hFontOld);
301
302 printf(" { __LINE__, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld },\n",
303 lf.lfHeight, lf.lfWidth,
304 siz.cx, siz.cy,
305 tm.tmHeight, tm.tmAscent, tm.tmDescent, tm.tmInternalLeading, tm.tmExternalLeading);
306 }
307 printf("};\n");
308 printf("#define g_%s_count _countof(g_%s)\n\n", font->entry_name, font->entry_name);
309#else
310 for (k = 0; k < font->test_count; ++k)
311 {
312 const TEST_ENTRY *test = &font->tests[k];
313
314 lf.lfHeight = test->lfHeight;
315 lf.lfWidth = test->lfWidth;
316
318 hFontOld = SelectObject(hDC, hFont);
319 {
322 }
323 SelectObject(hDC, hFontOld);
325
326 if (test->cxText > 0)
327 {
328 ok_(__FILE__, test->line)(labs(test->cxText - siz.cx) <= 1, "%s (%ld): cxText: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->cxText, siz.cx);
329 ok_(__FILE__, test->line)(labs(test->cxText - siz.cx) == 0, "%s (%ld): cxText: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->cxText, siz.cx);
330 }
331 if (test->cyText > 0)
332 {
333 ok_(__FILE__, test->line)(labs(test->cyText - siz.cy) <= 1, "%s (%ld): cyText: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->cyText, siz.cy);
334 ok_(__FILE__, test->line)(labs(test->cyText - siz.cy) == 0, "%s (%ld): cyText: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->cyText, siz.cy);
335 }
336 if (test->tmHeight > 0)
337 {
338 ok_(__FILE__, test->line)(labs(test->tmHeight - tm.tmHeight) <= 1, "%s (%ld): tmHeight: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmHeight, tm.tmHeight);
339 ok_(__FILE__, test->line)(labs(test->tmHeight - tm.tmHeight) == 0, "%s (%ld): tmHeight: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmHeight, tm.tmHeight);
340 }
341 if (test->tmAscent > 0)
342 {
343 ok_(__FILE__, test->line)(labs(test->tmAscent - tm.tmAscent) <= 1, "%s (%ld): tmAscent: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmAscent, tm.tmAscent);
344 ok_(__FILE__, test->line)(labs(test->tmAscent - tm.tmAscent) == 0, "%s (%ld): tmAscent: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmAscent, tm.tmAscent);
345 }
346 if (test->tmDescent > 0)
347 {
348 ok_(__FILE__, test->line)(labs(test->tmDescent - tm.tmDescent) <= 1, "%s (%ld): tmDescent: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmDescent, tm.tmDescent);
349 ok_(__FILE__, test->line)(labs(test->tmDescent - tm.tmDescent) == 0, "%s (%ld): tmDescent: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmDescent, tm.tmDescent);
350 }
351 if (test->tmInternalLeading > 0)
352 {
353 ok_(__FILE__, test->line)(labs(test->tmInternalLeading - tm.tmInternalLeading) <= 1, "%s (%ld): tmInternalLeading: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmInternalLeading, tm.tmInternalLeading);
354 ok_(__FILE__, test->line)(labs(test->tmInternalLeading - tm.tmInternalLeading) == 0, "%s (%ld): tmInternalLeading: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmInternalLeading, tm.tmInternalLeading);
355 }
356 if (test->tmExternalLeading > 0)
357 {
358 ok_(__FILE__, test->line)(labs(test->tmExternalLeading - tm.tmExternalLeading) <= 1, "%s (%ld): tmExternalLeading: labs(%ld - %ld) > 1\n", font->entry_name, test->lfHeight, test->tmExternalLeading, tm.tmExternalLeading);
359 ok_(__FILE__, test->line)(labs(test->tmExternalLeading - tm.tmExternalLeading) == 0, "%s (%ld): tmExternalLeading: labs(%ld - %ld) != 0\n", font->entry_name, test->lfHeight, test->tmExternalLeading, tm.tmExternalLeading);
360 }
361 }
362#endif
363 }
364 DeleteDC(hDC);
365}
static HDC hDC
Definition: 3dtext.c:33
static FONT_ENTRY g_font_entries[]
static size_t g_font_entry_count
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
#define ok_(x1, x2)
Definition: atltest.h:61
HFONT hFont
Definition: main.c:53
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
const WCHAR * text
Definition: package.c:1799
#define printf
Definition: freeldr.h:94
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ long __cdecl labs(_In_ long x)
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
LPCWSTR szPath
Definition: env.c:37
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
int k
Definition: mpi.c:3369
Definition: mk_font.cpp:20
#define test
Definition: rosglue.h:37
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LONG lfWidth
Definition: dimm.idl:43
Definition: cmd.c:13
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
Definition: time.h:68
#define ZeroMemory
Definition: winbase.h:1700
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
BOOL WINAPI DeleteDC(_In_ HDC)
#define GetTextMetrics
Definition: wingdi.h:4474
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE psizl)

Variable Documentation

◆ g_font_entries

FONT_ENTRY g_font_entries[]
static
Initial value:
=
{
{ "MSGOTHIC", "MS Gothic", "msgothic.ttc", g_MSGOTHIC_count, g_MSGOTHIC },
{ "MSMINCHO", "MS Mincho", "msmincho.ttc", g_MSMINCHO_count, g_MSMINCHO },
{ "TAHOMA", "Tahoma", "Tahoma.ttf", g_TAHOMA_count, g_TAHOMA },
}
static const TEST_ENTRY g_TAHOMA[]
#define g_MSMINCHO_count
#define g_TAHOMA_count
static const TEST_ENTRY g_MSGOTHIC[]
#define g_MSGOTHIC_count
static const TEST_ENTRY g_MSMINCHO[]

Definition at line 238 of file GetTextMetrics.c.

Referenced by START_TEST().

◆ g_font_entry_count

size_t g_font_entry_count = _countof(g_font_entries)
static

Definition at line 250 of file GetTextMetrics.c.

Referenced by START_TEST().

◆ g_MSGOTHIC

const TEST_ENTRY g_MSGOTHIC[]
static

Definition at line 77 of file GetTextMetrics.c.

◆ g_MSMINCHO

const TEST_ENTRY g_MSMINCHO[]
static

Definition at line 127 of file GetTextMetrics.c.

◆ g_TAHOMA

const TEST_ENTRY g_TAHOMA[]
static

Definition at line 177 of file GetTextMetrics.c.