ReactOS  0.4.15-dev-3428-g0609db5
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_FREEMONO_count   _countof(g_FREEMONO)
 
#define g_DEJAVUSERIF_count   _countof(g_DEJAVUSERIF)
 
#define g_DEJAVUSANS_count   _countof(g_DEJAVUSANS)
 
#define g_UBUNTUMONO_count   _countof(g_UBUNTUMONO)
 
#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_FREEMONO []
 
static const TEST_ENTRY g_DEJAVUSERIF []
 
static const TEST_ENTRY g_DEJAVUSANS []
 
static const TEST_ENTRY g_UBUNTUMONO []
 
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_DEJAVUSANS_count

#define g_DEJAVUSANS_count   _countof(g_DEJAVUSANS)

Definition at line 225 of file GetTextMetrics.c.

◆ g_DEJAVUSERIF_count

#define g_DEJAVUSERIF_count   _countof(g_DEJAVUSERIF)

Definition at line 175 of file GetTextMetrics.c.

◆ g_FREEMONO_count

#define g_FREEMONO_count   _countof(g_FREEMONO)

Definition at line 125 of file GetTextMetrics.c.

◆ g_MSGOTHIC_count

#define g_MSGOTHIC_count   _countof(g_MSGOTHIC)

Definition at line 325 of file GetTextMetrics.c.

◆ g_MSMINCHO_count

#define g_MSMINCHO_count   _countof(g_MSMINCHO)

Definition at line 375 of file GetTextMetrics.c.

◆ g_TAHOMA_count

#define g_TAHOMA_count   _countof(g_TAHOMA)

Definition at line 425 of file GetTextMetrics.c.

◆ g_UBUNTUMONO_count

#define g_UBUNTUMONO_count   _countof(g_UBUNTUMONO)

Definition at line 275 of file GetTextMetrics.c.

Typedef Documentation

◆ FONT_ENTRY

◆ TEST_ENTRY

Function Documentation

◆ START_TEST()

START_TEST ( GetTextMetrics  )

Definition at line 460 of file GetTextMetrics.c.

461 {
462  size_t i, k;
463  LOGFONTA lf;
464  HFONT hFont;
465  HDC hDC;
466  HGDIOBJ hFontOld;
467  SIZE siz;
468  TEXTMETRIC tm;
469  char szPath[MAX_PATH];
470  static const char *text = "This is a test.";
471 
473  for (i = 0; i < g_font_entry_count; ++i)
474  {
476  ZeroMemory(&lf, sizeof(lf));
478  lstrcpyA(lf.lfFaceName, font->font_name);
479 
481  lstrcatA(szPath, "\\Fonts\\");
482  lstrcatA(szPath, font->font_file);
483  if (GetFileAttributesA(szPath) == 0xFFFFFFFF)
484  {
485  skip("Font file '%s' doesn't exists\n", font->font_file);
486  continue;
487  }
488 
489  trace("Testing '%s'.\n", font->font_file);
490 
491 #ifdef EMIT_TESTCASES
492  printf("static const TEST_ENTRY g_%s[] =\n", font->entry_name);
493  printf("{\n");
494  for (k = 0; k < g_test_entry_count; ++k)
495  {
496  const TEST_ENTRY *test = &g_test_entries[k];
497 
498  lf.lfHeight = test->lfHeight;
499  lf.lfWidth = test->lfWidth;
500 
501  hFont = CreateFontIndirectA(&lf);
502  hFontOld = SelectObject(hDC, hFont);
503  {
505  GetTextMetrics(hDC, &tm);
506  }
507  SelectObject(hDC, hFontOld);
509 
510  printf(" { __LINE__, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld },\n",
511  lf.lfHeight, lf.lfWidth,
512  siz.cx, siz.cy,
513  tm.tmHeight, tm.tmAscent, tm.tmDescent, tm.tmInternalLeading, tm.tmExternalLeading);
514  }
515  printf("};\n");
516  printf("#define g_%s_count _countof(g_%s)\n\n", font->entry_name, font->entry_name);
517 #else
518  for (k = 0; k < font->test_count; ++k)
519  {
520  const TEST_ENTRY *test = &font->tests[k];
521 
522  lf.lfHeight = test->lfHeight;
523  lf.lfWidth = test->lfWidth;
524 
525  hFont = CreateFontIndirectA(&lf);
526  hFontOld = SelectObject(hDC, hFont);
527  {
529  GetTextMetrics(hDC, &tm);
530  }
531  SelectObject(hDC, hFontOld);
533 
534  if (test->cxText > 0)
535  {
536  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);
537  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);
538  }
539  if (test->cyText > 0)
540  {
541  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);
542  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);
543  }
544  if (test->tmHeight > 0)
545  {
546  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);
547  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);
548  }
549  if (test->tmAscent > 0)
550  {
551  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);
552  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);
553  }
554  if (test->tmDescent > 0)
555  {
556  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);
557  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);
558  }
559  if (test->tmInternalLeading > 0)
560  {
561  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);
562  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);
563  }
564  if (test->tmExternalLeading > 0)
565  {
566  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);
567  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);
568  }
569  }
570 #endif
571  }
572  DeleteDC(hDC);
573 }
Definition: mk_font.cpp:20
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
const WCHAR * text
Definition: package.c:1827
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BYTE lfCharSet
Definition: dimm.idl:50
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define test
Definition: rosglue.h:37
#define GetTextMetrics
Definition: wingdi.h:4474
#define DEFAULT_CHARSET
Definition: wingdi.h:384
HFONT hFont
Definition: main.c:53
static size_t g_font_entry_count
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
LONG lfHeight
Definition: dimm.idl:42
LONG cx
Definition: windef.h:334
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define trace
Definition: atltest.h:70
#define MAX_PATH
Definition: compat.h:34
LONG lfWidth
Definition: dimm.idl:43
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
Definition: cmd.c:12
Definition: time.h:68
static HDC hDC
Definition: 3dtext.c:33
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
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
BOOL WINAPI DeleteDC(_In_ HDC)
LPCWSTR szPath
Definition: env.c:37
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
#define NULL
Definition: types.h:112
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define skip(...)
Definition: atltest.h:64
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
static FONT_ENTRY g_font_entries[]
_Check_return_ long __cdecl labs(_In_ long x)
LONG cy
Definition: windef.h:335
int k
Definition: mpi.c:3369
#define ok_(x1, x2)
Definition: atltest.h:61
#define printf
Definition: config.h:203

Variable Documentation

◆ g_DEJAVUSANS

const TEST_ENTRY g_DEJAVUSANS[]
static

Definition at line 177 of file GetTextMetrics.c.

◆ g_DEJAVUSERIF

const TEST_ENTRY g_DEJAVUSERIF[]
static

Definition at line 127 of file GetTextMetrics.c.

◆ g_font_entries

FONT_ENTRY g_font_entries[]
static
Initial value:
=
{
{ "FREEMONO", "FreeMono", "FreeMono.ttf", g_FREEMONO_count, g_FREEMONO },
{ "DEJAVUSERIF", "DejaVu Serif", "DejaVuSerif.ttf", g_DEJAVUSERIF_count, g_DEJAVUSERIF },
{ "DEJAVUSANS", "DejaVu Sans", "DejaVuSans.ttf", g_DEJAVUSANS_count, g_DEJAVUSANS },
{ "UBUNTUMONO", "Ubuntu Mono", "UbuntuMono-R.ttf", g_UBUNTUMONO_count, g_UBUNTUMONO },
{ "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_MSGOTHIC[]
#define g_DEJAVUSERIF_count
#define g_TAHOMA_count
static const TEST_ENTRY g_TAHOMA[]
#define g_UBUNTUMONO_count
static const TEST_ENTRY g_DEJAVUSERIF[]
#define g_MSMINCHO_count
#define g_FREEMONO_count
#define g_DEJAVUSANS_count
static const TEST_ENTRY g_MSMINCHO[]
static const TEST_ENTRY g_UBUNTUMONO[]
#define g_MSGOTHIC_count
static const TEST_ENTRY g_FREEMONO[]
static const TEST_ENTRY g_DEJAVUSANS[]

Definition at line 438 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 458 of file GetTextMetrics.c.

Referenced by START_TEST().

◆ g_FREEMONO

const TEST_ENTRY g_FREEMONO[]
static

Definition at line 77 of file GetTextMetrics.c.

◆ g_MSGOTHIC

const TEST_ENTRY g_MSGOTHIC[]
static

Definition at line 277 of file GetTextMetrics.c.

◆ g_MSMINCHO

const TEST_ENTRY g_MSMINCHO[]
static

Definition at line 327 of file GetTextMetrics.c.

◆ g_TAHOMA

const TEST_ENTRY g_TAHOMA[]
static

Definition at line 377 of file GetTextMetrics.c.

◆ g_UBUNTUMONO

const TEST_ENTRY g_UBUNTUMONO[]
static

Definition at line 227 of file GetTextMetrics.c.