ReactOS 0.4.17-dev-243-g1369312
font.c File Reference
#include <math.h>
#include "objbase.h"
#include "gdiplus.h"
#include "wine/test.h"
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  font_metrics
 

Macros

#define expect(expected, got)   expect_inline(__LINE__, expected, got)
 
#define expect_(expected, got, precision)   ok(abs((expected) - (got)) <= (precision), "Expected %d, got %ld\n", (expected), (got))
 
#define expectf_(expected, got, precision)   ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))
 
#define expectf(expected, got)   expectf_((expected), (got), 0.001)
 
#define load_resource(a, b, c)   _load_resource(__LINE__, a, b, c)
 
#define DELETE_FONTFILE(filename)   _delete_testfontfile(filename, __LINE__)
 

Functions

static void expect_inline (unsigned line, DWORD expected, DWORD got)
 
static void set_rect_empty (RectF *rc)
 
static void _load_resource (int line, const WCHAR *filename, BYTE **data, DWORD *size)
 
static void create_testfontfile (const WCHAR *filename, int resource, WCHAR pathW[MAX_PATH])
 
static void _delete_testfontfile (const WCHAR *filename, int line)
 
static void test_long_name (void)
 
static void test_createfont (void)
 
static void test_createfont_charset (void)
 
static void test_logfont (void)
 
static void test_fontfamily (void)
 
static void test_fontfamily_properties (void)
 
static void check_family (const char *context, GpFontFamily *family, WCHAR *name)
 
static void test_getgenerics (void)
 
static void test_installedfonts (void)
 
static void test_heightgivendpi (void)
 
static int CALLBACK font_enum_proc (const LOGFONTW *lfe, const TEXTMETRICW *ntme, DWORD type, LPARAM lparam)
 
static void gdi_get_font_metrics (LOGFONTW *lf, struct font_metrics *fm)
 
static void gdip_get_font_metrics (GpFont *font, struct font_metrics *fm)
 
static void cmp_font_metrics (struct font_metrics *fm1, struct font_metrics *fm2, int line)
 
static void test_font_metrics (void)
 
static void test_font_substitution (void)
 
static void test_font_transform (void)
 
static void test_GdipGetFontCollectionFamilyList (void)
 
static void test_GdipGetFontCollectionFamilyCount (void)
 
static BOOL is_family_in_collection (GpFontCollection *collection, GpFontFamily *family)
 
static void test_CloneFont (void)
 
static void test_GdipPrivateAddMemoryFont (void)
 
 START_TEST (font)
 

Macro Definition Documentation

◆ DELETE_FONTFILE

#define DELETE_FONTFILE (   filename)    _delete_testfontfile(filename, __LINE__)

Definition at line 75 of file font.c.

◆ expect

#define expect (   expected,
  got 
)    expect_inline(__LINE__, expected, got)

Definition at line 28 of file font.c.

◆ expect_

#define expect_ (   expected,
  got,
  precision 
)    ok(abs((expected) - (got)) <= (precision), "Expected %d, got %ld\n", (expected), (got))

Definition at line 34 of file font.c.

◆ expectf

#define expectf (   expected,
  got 
)    expectf_((expected), (got), 0.001)

Definition at line 36 of file font.c.

◆ expectf_

#define expectf_ (   expected,
  got,
  precision 
)    ok(fabs((expected) - (got)) <= (precision), "Expected %f, got %f\n", (expected), (got))

Definition at line 35 of file font.c.

◆ load_resource

#define load_resource (   a,
  b,
  c 
)    _load_resource(__LINE__, a, b, c)

Definition at line 46 of file font.c.

Function Documentation

◆ _delete_testfontfile()

static void _delete_testfontfile ( const WCHAR filename,
int  line 
)
static

Definition at line 76 of file font.c.

77{
79 ok_(__FILE__,line)(ret, "failed to delete file %s, error %ld\n", wine_dbgstr_w(filename), GetLastError());
80}
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
const char * filename
Definition: ioapi.h:137
#define wine_dbgstr_w
Definition: kernel32.h:34
Definition: parser.c:49
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ _load_resource()

static void _load_resource ( int  line,
const WCHAR filename,
BYTE **  data,
DWORD size 
)
static

Definition at line 47 of file font.c.

48{
50 ok_(__FILE__, line)(!!resource, "FindResourceW failed, error %lu\n", GetLastError());
52 ok_(__FILE__, line)(!!*data, "LockResource failed, error %lu\n", GetLastError());
54 ok_(__FILE__, line)(*size > 0, "SizeofResource failed, error %lu\n", GetLastError());
55}
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define resource
Definition: kernel32.h:9
short WCHAR
Definition: pedump.c:58
#define RT_RCDATA
Definition: pedump.c:372

◆ check_family()

static void check_family ( const char context,
GpFontFamily family,
WCHAR name 
)
static

Definition at line 565 of file font.c.

566{
568 GpFont* font;
569
570 *name = 0;
572 ok(stat == Ok, "could not get the %s family name: %.8x\n", context, stat);
573
575 ok(stat == Ok, "could not create a font for the %s family: %.8x\n", context, stat);
576 if (stat == Ok)
577 {
579 ok(stat == Ok, "could not delete the %s family font: %.8x\n", context, stat);
580 }
581
582 stat = GdipDeleteFontFamily(family);
583 ok(stat == Ok, "could not delete the %s family: %.8x\n", context, stat);
584}
#define stat
Definition: acwin.h:100
#define ok(value,...)
Definition: atltest.h:57
GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
Definition: font.c:821
GpStatus WINGDIPAPI GdipDeleteFont(GpFont *font)
Definition: font.c:272
GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font)
Definition: font.c:150
GpStatus WINGDIPAPI GdipGetFamilyName(GDIPCONST GpFontFamily *family, WCHAR *name, LANGID language)
Definition: font.c:786
@ FontStyleRegular
Definition: gdiplusenums.h:301
@ UnitPixel
Definition: gdiplusenums.h:29
Status
Definition: gdiplustypes.h:24
@ Ok
Definition: gdiplustypes.h:25
Definition: mk_font.cpp:20
#define LANG_NEUTRAL
Definition: nls.h:22
Definition: http.c:7252
Definition: name.c:39
Definition: stat.h:66

Referenced by test_getgenerics().

◆ cmp_font_metrics()

static void cmp_font_metrics ( struct font_metrics fm1,
struct font_metrics fm2,
int  line 
)
static

Definition at line 812 of file font.c.

813{
814 ok_(__FILE__, line)(fm1->lfHeight == fm2->lfHeight, "lfHeight %d != %d\n", fm1->lfHeight, fm2->lfHeight);
815 ok_(__FILE__, line)(fm1->em_height == fm2->em_height, "em_height %u != %u\n", fm1->em_height, fm2->em_height);
816 ok_(__FILE__, line)(fm1->line_spacing == fm2->line_spacing, "line_spacing %u != %u\n", fm1->line_spacing, fm2->line_spacing);
817 ok_(__FILE__, line)(abs(fm1->ascent - fm2->ascent) <= 1, "ascent %u != %u\n", fm1->ascent, fm2->ascent);
818 ok_(__FILE__, line)(abs(fm1->descent - fm2->descent) <= 1, "descent %u != %u\n", fm1->descent, fm2->descent);
819 ok(fm1->font_height > 0.0, "fm1->font_height should be positive, got %f\n", fm1->font_height);
820 ok(fm2->font_height > 0.0, "fm2->font_height should be positive, got %f\n", fm2->font_height);
821 ok_(__FILE__, line)(fm1->font_height == fm2->font_height, "font_height %f != %f\n", fm1->font_height, fm2->font_height);
822 ok(fm1->font_size > 0.0, "fm1->font_size should be positive, got %f\n", fm1->font_size);
823 ok(fm2->font_size > 0.0, "fm2->font_size should be positive, got %f\n", fm2->font_size);
824 ok_(__FILE__, line)(fm1->font_size == fm2->font_size, "font_size %f != %f\n", fm1->font_size, fm2->font_size);
825}
#define abs(i)
Definition: fconv.c:206
UINT16 em_height
Definition: font.c:628
UINT16 ascent
Definition: font.c:628
UINT16 line_spacing
Definition: font.c:628
INT lfHeight
Definition: font.c:739
REAL font_size
Definition: font.c:738
UINT16 descent
Definition: font.c:628
REAL font_height
Definition: font.c:738

Referenced by test_font_metrics().

◆ create_testfontfile()

static void create_testfontfile ( const WCHAR filename,
int  resource,
WCHAR  pathW[MAX_PATH] 
)
static

Definition at line 57 of file font.c.

58{
59 DWORD written, length;
61 void *ptr;
62
65
67 ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %ld\n", wine_dbgstr_w(pathW), GetLastError());
68
70 WriteFile(file, ptr, length, &written, NULL);
71 ok(written == length, "couldn't write resource\n");
73}
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:1999
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
#define load_resource(a, b, c)
Definition: font.c:46
static const WCHAR pathW[]
Definition: path.c:2368
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:127
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_long_name().

◆ expect_inline()

static void expect_inline ( unsigned  line,
DWORD  expected,
DWORD  got 
)
inlinestatic

Definition at line 29 of file font.c.

30{
31 ok_(__FILE__, line)(expected == got, "Expected %ld, got %ld\n", expected, got);
32}
BOOL expected
Definition: store.c:2000

◆ font_enum_proc()

static int CALLBACK font_enum_proc ( const LOGFONTW lfe,
const TEXTMETRICW ntme,
DWORD  type,
LPARAM  lparam 
)
static

Definition at line 724 of file font.c.

726{
728
729 if (type != TRUETYPE_FONTTYPE) return 1;
730
731 *ntm = *(NEWTEXTMETRICW *)ntme;
732 return 0;
733}
@ lparam
Definition: SystemMenu.c:31
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109

◆ gdi_get_font_metrics()

static void gdi_get_font_metrics ( LOGFONTW lf,
struct font_metrics fm 
)
static

Definition at line 742 of file font.c.

743{
744 HDC hdc;
745 HFONT hfont;
746 NEWTEXTMETRICW ntm;
748 int ret;
749
751
752 /* it's the only way to get extended NEWTEXTMETRIC fields */
754 ok(!ret, "EnumFontFamiliesExW failed to find %s\n", wine_dbgstr_w(lf->lfFaceName));
755
758
759 otm.otmSize = sizeof(otm);
761 ok(ret, "GetOutlineTextMetrics failed\n");
762
763 DeleteDC(hdc);
765
767 fm->line_spacing = ntm.ntmCellHeight;
769 fm->font_height = (REAL)fm->line_spacing * fm->font_size / (REAL)ntm.ntmSizeEM;
770 fm->em_height = ntm.ntmSizeEM;
771 fm->ascent = ntm.ntmSizeEM;
772 fm->descent = ntm.ntmCellHeight - ntm.ntmSizeEM;
773}
static HFONT hfont
float REAL
Definition: types.h:41
pKey DeleteObject()
LONG_PTR LPARAM
Definition: minwindef.h:175
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static INT CALLBACK font_enum_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
Definition: font.c:228
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
TEXTMETRICW otmTextMetrics
Definition: wingdi.h:2960
UINT ntmCellHeight
Definition: wingdi.h:3112
LONG tmAscent
Definition: wingdi.h:2830
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by test_font_metrics().

◆ gdip_get_font_metrics()

static void gdip_get_font_metrics ( GpFont font,
struct font_metrics fm 
)
static

Definition at line 775 of file font.c.

776{
777 INT style;
778 GpFontFamily *family;
780
782 expect(Ok, stat);
783
786
789
791 expect(Ok, stat);
793 expect(Ok, stat);
794
795 fm->lfHeight = (INT)(fm->font_size * -1.0);
796
797 stat = GdipGetFamily(font, &family);
798 expect(Ok, stat);
799
800 stat = GdipGetEmHeight(family, style, &fm->em_height);
801 expect(Ok, stat);
802 stat = GdipGetLineSpacing(family, style, &fm->line_spacing);
803 expect(Ok, stat);
804 stat = GdipGetCellAscent(family, style, &fm->ascent);
805 expect(Ok, stat);
806 stat = GdipGetCellDescent(family, style, &fm->descent);
807 expect(Ok, stat);
808
809 GdipDeleteFontFamily(family);
810}
Arabic default style
Definition: afstyles.h:94
GpStatus WINGDIPAPI GdipGetFontSize(GpFont *font, REAL *size)
Definition: font.c:352
GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height)
Definition: font.c:530
GpStatus WINGDIPAPI GdipGetFamily(GpFont *font, GpFontFamily **family)
Definition: font.c:321
GpStatus WINGDIPAPI GdipGetCellDescent(GDIPCONST GpFontFamily *family, INT style, UINT16 *CellDescent)
Definition: font.c:845
GpStatus WINGDIPAPI GdipGetFontStyle(GpFont *font, INT *style)
Definition: font.c:395
GpStatus WINGDIPAPI GdipGetCellAscent(GDIPCONST GpFontFamily *family, INT style, UINT16 *CellAscent)
Definition: font.c:834
GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family, INT style, UINT16 *LineSpacing)
Definition: font.c:899
GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, UINT16 *EmHeight)
Definition: font.c:872
@ InvalidParameter
Definition: gdiplustypes.h:27
#define expect(expected, got)
Definition: font.c:40
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:58

Referenced by test_font_metrics().

◆ is_family_in_collection()

static BOOL is_family_in_collection ( GpFontCollection collection,
GpFontFamily family 
)
static

Definition at line 1445 of file font.c.

1446{
1449 int count, i;
1450 BOOL found = FALSE;
1451
1453 expect(Ok, status);
1454
1455 list = GdipAlloc(count * sizeof(GpFontFamily *));
1457 expect(Ok, status);
1458
1459 for (i = 0; i < count; i++)
1460 {
1461 if (list[i] == family)
1462 {
1463 found = TRUE;
1464 break;
1465 }
1466 }
1467
1468 GdipFree(list);
1469
1470 return found;
1471}
Definition: list.h:37
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(GpFontCollection *fontCollection, INT *numFound)
Definition: font.c:1528
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(GpFontCollection *fontCollection, INT numSought, GpFontFamily *gpfamilies[], INT *numFound)
Definition: font.c:1543
void WINGDIPAPI GdipFree(void *ptr)
Definition: gdiplus.c:152
void *WINGDIPAPI GdipAlloc(SIZE_T size)
Definition: gdiplus.c:144
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
static ICollection collection
Definition: typelib.c:184
#define list
Definition: rosglue.h:35
Definition: ps.c:97

Referenced by test_CloneFont().

◆ set_rect_empty()

static void set_rect_empty ( RectF rc)
static

Definition at line 38 of file font.c.

39{
40 rc->X = 0.0;
41 rc->Y = 0.0;
42 rc->Width = 0.0;
43 rc->Height = 0.0;
44}
REAL Height
Definition: gdiplustypes.h:659
REAL X
Definition: gdiplustypes.h:656
REAL Width
Definition: gdiplustypes.h:658
REAL Y
Definition: gdiplustypes.h:657

Referenced by test_font_transform().

◆ START_TEST()

START_TEST ( font  )

Definition at line 1586 of file font.c.

1587{
1588 struct GdiplusStartupInput gdiplusStartupInput;
1589 ULONG_PTR gdiplusToken;
1590 HMODULE hmsvcrt;
1591 int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
1592
1593 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
1594 hmsvcrt = LoadLibraryA("msvcrt");
1595 _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
1596 if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
1597
1598 gdiplusStartupInput.GdiplusVersion = 1;
1599 gdiplusStartupInput.DebugEventCallback = NULL;
1600 gdiplusStartupInput.SuppressBackgroundThread = 0;
1601 gdiplusStartupInput.SuppressExternalCodecs = 0;
1602
1603 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1604
1612 test_logfont();
1621
1622 GdiplusShutdown(gdiplusToken);
1623}
#define CDECL
Definition: compat.h:29
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
_ACRTIMP errno_t __cdecl _controlfp_s(unsigned int *, unsigned int, unsigned int)
Definition: math.c:1304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, struct GdiplusStartupOutput *output)
Definition: gdiplus.c:83
void WINAPI GdiplusShutdown(ULONG_PTR)
GLenum GLint GLuint mask
Definition: glext.h:6028
static void test_logfont(void)
Definition: font.c:201
static void test_font_substitution(void)
Definition: font.c:967
static void test_font_metrics(void)
Definition: font.c:827
static void test_GdipPrivateAddMemoryFont(void)
Definition: font.c:1546
static void test_CloneFont(void)
Definition: font.c:1473
static void test_fontfamily(void)
Definition: font.c:458
static void test_long_name(void)
Definition: font.c:82
static void test_GdipGetFontCollectionFamilyList(void)
Definition: font.c:1353
static void test_GdipGetFontCollectionFamilyCount(void)
Definition: font.c:1424
static void test_font_transform(void)
Definition: font.c:1063
static void test_fontfamily_properties(void)
Definition: font.c:514
static void test_createfont(void)
Definition: font.c:148
static void test_getgenerics(void)
Definition: font.c:586
static void test_createfont_charset(void)
Definition: font.c:202
static void test_heightgivendpi(void)
Definition: font.c:636
static void test_installedfonts(void)
Definition: font.c:623
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ test_CloneFont()

static void test_CloneFont ( void  )
static

Definition at line 1473 of file font.c.

1474{
1476 GpFontCollection *collection, *collection2;
1477 GpFont *font, *font2;
1478 GpFontFamily *family, *family2;
1479 REAL height;
1480 Unit unit;
1481 int style;
1482 BOOL ret;
1483
1485 expect(Ok, status);
1486
1487 status = GdipNewInstalledFontCollection(&collection2);
1488 expect(Ok, status);
1489 ok(collection == collection2, "got %p\n", collection2);
1490
1491 status = GdipCreateFontFamilyFromName(L"ThisFontShouldNotExist", NULL, &family);
1493
1494 status = GdipCreateFontFamilyFromName(L"ThisFontShouldNotExist", collection, &family);
1496
1497 status = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
1498 expect(Ok, status);
1499
1501 ok(ret, "family is not in collection\n");
1502
1504 expect(Ok, status);
1505
1507 expect(Ok, status);
1508 ok(unit == UnitPixel, "got %u\n", unit);
1509
1511 expect(Ok, status);
1512 ok(height == 30.0f, "got %f\n", height);
1513
1515 expect(Ok, status);
1516 ok(style == FontStyleRegular, "got %d\n", style);
1517
1518 status = GdipGetFamily(font, &family2);
1519 expect(Ok, status);
1520 ok(family == family2, "got %p\n", family2);
1521
1522 status = GdipCloneFont(font, &font2);
1523 expect(Ok, status);
1524
1525 status = GdipGetFontUnit(font2, &unit);
1526 expect(Ok, status);
1527 ok(unit == UnitPixel, "got %u\n", unit);
1528
1529 status = GdipGetFontSize(font2, &height);
1530 expect(Ok, status);
1531 ok(height == 30.0f, "got %f\n", height);
1532
1533 status = GdipGetFontStyle(font2, &style);
1534 expect(Ok, status);
1535 ok(style == FontStyleRegular, "got %d\n", style);
1536
1537 status = GdipGetFamily(font2, &family2);
1538 expect(Ok, status);
1539 ok(family == family2, "got %p\n", family2);
1540
1541 GdipDeleteFont(font2);
1543 GdipDeleteFontFamily(family);
1544}
GpStatus WINGDIPAPI GdipNewInstalledFontCollection(GpFontCollection **fontCollection)
Definition: font.c:1669
GpStatus WINGDIPAPI GdipGetFontUnit(GpFont *font, Unit *unit)
Definition: font.c:419
GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
Definition: font.c:503
GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name, GpFontCollection *collection, GpFontFamily **family)
Definition: font.c:701
#define L(x)
Definition: resources.c:13
Unit
Definition: gdiplusenums.h:26
@ FontFamilyNotFound
Definition: gdiplustypes.h:39
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static BOOL is_family_in_collection(GpFontCollection *collection, GpFontFamily *family)
Definition: font.c:1445
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392

Referenced by START_TEST().

◆ test_createfont()

static void test_createfont ( void  )
static

Definition at line 148 of file font.c.

149{
150 GpFontFamily* fontfamily = NULL, *fontfamily2;
151 GpFont* font = NULL;
153 Unit unit;
154 UINT i;
155 REAL size;
156 WCHAR familyname[LF_FACESIZE];
157
158 stat = GdipCreateFontFamilyFromName(L"ThisFontShouldNotExist", NULL, &fontfamily);
162 stat = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &fontfamily);
163 expect (Ok, stat);
164 stat = GdipCreateFont(fontfamily, 12, FontStyleRegular, UnitPoint, &font);
165 expect (Ok, stat);
167 expect (Ok, stat);
169
170 stat = GdipGetFamily(font, &fontfamily2);
171 expect(Ok, stat);
172 stat = GdipGetFamilyName(fontfamily2, familyname, 0);
173 expect(Ok, stat);
174 ok (fontfamily == fontfamily2, "Unexpected family instance.\n");
175 ok (lstrcmpiW(L"Tahoma", familyname) == 0, "Expected Tahoma, got %s\n",
176 wine_dbgstr_w(familyname));
177 stat = GdipDeleteFontFamily(fontfamily2);
178 expect(Ok, stat);
179
180 /* Test to see if returned size is based on unit (it's not) */
182 ok (size == 12, "Expected 12, got %f\n", size);
184
185 /* Make sure everything is converted correctly for all Units */
186 for (i = UnitWorld; i <=UnitMillimeter; i++)
187 {
188 if (i == UnitDisplay) continue; /* Crashes WindowsXP, wtf? */
189 stat = GdipCreateFont(fontfamily, 24, FontStyleRegular, i, &font);
190 expect(Ok, stat);
192 ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i);
194 ok (stat == Ok, "Failed to get font unit, %d.\n", stat);
195 expect (i, unit);
197 }
198
199 GdipDeleteFontFamily(fontfamily);
200}
#define LF_FACESIZE
Definition: dimm.idl:39
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
@ UnitMillimeter
Definition: gdiplusenums.h:33
@ UnitDisplay
Definition: gdiplusenums.h:28
@ UnitWorld
Definition: gdiplusenums.h:27
@ UnitPoint
Definition: gdiplusenums.h:30
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_createfont_charset()

static void test_createfont_charset ( void  )
static

Definition at line 202 of file font.c.

203{
204 GpFontFamily* fontfamily = NULL;
205 GpGraphics *graphics;
206 GpFont* font = NULL;
208 LOGFONTW lf;
209 HDC hdc;
210 UINT i;
211
212 static const struct {
214 BYTE char_set;
215 } td[] =
216 {
217 {L"Tahoma", ANSI_CHARSET},
218 {L"Symbol", SYMBOL_CHARSET},
219 {L"Marlett", SYMBOL_CHARSET},
220 {L"Wingdings", SYMBOL_CHARSET},
221 };
222
224 stat = GdipCreateFromHDC(hdc, &graphics);
225 expect (Ok, stat);
226
227 for (i = 0; i < ARRAY_SIZE(td); i++)
228 {
230
232 expect (Ok, stat);
233 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font);
234 expect (Ok, stat);
235
236 stat = GdipGetLogFontW(font, graphics, &lf);
237 expect(Ok, stat);
238
239 if (lstrcmpiW(lf.lfFaceName, td[i].family_name) != 0)
240 {
241 skip("%s not installed\n", wine_dbgstr_w(td[i].family_name));
242 }
243 else
244 {
245 ok(lf.lfHeight < 0, "Expected negative height, got %ld\n", lf.lfHeight);
246 expect(0, lf.lfWidth);
247 expect(0, lf.lfEscapement);
248 expect(0, lf.lfOrientation);
249 ok((lf.lfWeight >= 100) && (lf.lfWeight <= 900), "Expected weight to be set\n");
250 expect(0, lf.lfItalic);
251 expect(0, lf.lfUnderline);
252 expect(0, lf.lfStrikeOut);
253 ok(td[i].char_set == lf.lfCharSet ||
254 (td[i].char_set == ANSI_CHARSET && lf.lfCharSet == GetTextCharset(hdc)),
255 "got %#x\n", lf.lfCharSet);
256 expect(0, lf.lfOutPrecision);
257 expect(0, lf.lfClipPrecision);
258 expect(0, lf.lfQuality);
260 }
261
263 GdipDeleteFontFamily(fontfamily);
264
266 }
267
268 GdipDeleteGraphics(graphics);
269 DeleteDC(hdc);
270}
#define skip(...)
Definition: atltest.h:64
#define ARRAY_SIZE(A)
Definition: main.h:20
GpStatus WINGDIPAPI GdipGetLogFontW(GpFont *font, GpGraphics *graphics, LOGFONTW *lf)
Definition: font.c:457
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
Definition: graphics.c:2434
GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
Definition: graphics.c:2616
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
BYTE lfOutPrecision
Definition: dimm.idl:68
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
LONG lfOrientation
Definition: dimm.idl:62
LONG lfWidth
Definition: dimm.idl:60
BYTE lfUnderline
Definition: dimm.idl:65
BYTE lfClipPrecision
Definition: dimm.idl:69
LONG lfEscapement
Definition: dimm.idl:61
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfQuality
Definition: dimm.idl:70
BYTE lfPitchAndFamily
Definition: dimm.idl:71
T1_FIELD_DICT_FONTDICT family_name
Definition: t1tokens.h:30
const uint16_t * LPCWSTR
Definition: typedefs.h:57
int WINAPI GetTextCharset(_In_ HDC)
Definition: text.c:187
#define ANSI_CHARSET
Definition: wingdi.h:383
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by START_TEST().

◆ test_font_metrics()

static void test_font_metrics ( void  )
static

Definition at line 827 of file font.c.

828{
829 LOGFONTW lf;
830 GpFont *font;
831 GpFontFamily *family;
832 GpGraphics *graphics;
834 Unit unit;
835 struct font_metrics fm_gdi, fm_gdip;
836 HDC hdc;
837
839 stat = GdipCreateFromHDC(hdc, &graphics);
840 expect(Ok, stat);
841
842 memset(&lf, 0, sizeof(lf));
843
844 /* Tahoma,-13 */
845 lstrcpyW(lf.lfFaceName, L"Tahoma");
846 lf.lfHeight = -13;
848 expect(Ok, stat);
849
851 expect(Ok, stat);
853
854 gdip_get_font_metrics(font, &fm_gdip);
855 trace("gdiplus:\n");
856 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
858 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
859 fm_gdip.font_height, fm_gdip.font_size);
860
861 gdi_get_font_metrics(&lf, &fm_gdi);
862 trace("gdi:\n");
863 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
865 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
866 fm_gdi.font_height, fm_gdi.font_size);
867
868 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
869
870 stat = GdipGetLogFontW(font, graphics, &lf);
871 expect(Ok, stat);
872 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %ld\n", lf.lfHeight);
873 gdi_get_font_metrics(&lf, &fm_gdi);
874 trace("gdi:\n");
875 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
877 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
878 fm_gdi.font_height, fm_gdi.font_size);
879 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
880
881 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
882
884
885 /* Tahoma,13 */
886 lstrcpyW(lf.lfFaceName, L"Tahoma");
887 lf.lfHeight = 13;
889 expect(Ok, stat);
890
892 expect(Ok, stat);
894
895 gdip_get_font_metrics(font, &fm_gdip);
896 trace("gdiplus:\n");
897 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
899 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
900 fm_gdip.font_height, fm_gdip.font_size);
901
902 gdi_get_font_metrics(&lf, &fm_gdi);
903 trace("gdi:\n");
904 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
906 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
907 fm_gdi.font_height, fm_gdi.font_size);
908
909 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
910
911 stat = GdipGetLogFontW(font, graphics, &lf);
912 expect(Ok, stat);
913 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %ld\n", lf.lfHeight);
914 gdi_get_font_metrics(&lf, &fm_gdi);
915 trace("gdi:\n");
916 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
918 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
919 fm_gdi.font_height, fm_gdi.font_size);
920 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
921
922 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
923
925
926 stat = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &family);
927 expect(Ok, stat);
928
929 /* Tahoma,13 */
931 expect(Ok, stat);
932
933 gdip_get_font_metrics(font, &fm_gdip);
934 trace("gdiplus:\n");
935 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
937 fm_gdip.em_height, fm_gdip.line_spacing, fm_gdip.ascent, fm_gdip.descent,
938 fm_gdip.font_height, fm_gdip.font_size);
939
940 stat = GdipGetLogFontW(font, graphics, &lf);
941 expect(Ok, stat);
942 ok(lf.lfHeight < 0, "lf.lfHeight should be negative, got %ld\n", lf.lfHeight);
943 gdi_get_font_metrics(&lf, &fm_gdi);
944 trace("gdi:\n");
945 trace("%s,%ld: EmHeight %u, LineSpacing %u, CellAscent %u, CellDescent %u, FontHeight %f, FontSize %f\n",
947 fm_gdi.em_height, fm_gdi.line_spacing, fm_gdi.ascent, fm_gdi.descent,
948 fm_gdi.font_height, fm_gdi.font_size);
949 ok((REAL)lf.lfHeight * -1.0 == fm_gdi.font_size, "expected %f, got %f\n", (REAL)lf.lfHeight * -1.0, fm_gdi.font_size);
950
951 cmp_font_metrics(&fm_gdip, &fm_gdi, __LINE__);
952
953 stat = GdipGetLogFontW(font, NULL, &lf);
955
957
960
961 GdipDeleteFontFamily(family);
962
963 GdipDeleteGraphics(graphics);
964 DeleteDC(hdc);
965}
#define trace
Definition: atltest.h:70
#define lstrcpyW
Definition: compat.h:749
GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc, GDIPCONST LOGFONTW *logfont, GpFont **font)
Definition: font.c:204
static void cmp_font_metrics(struct font_metrics *fm1, struct font_metrics *fm2, int line)
Definition: font.c:812
static void gdip_get_font_metrics(GpFont *font, struct font_metrics *fm)
Definition: font.c:775
static void gdi_get_font_metrics(LOGFONTW *lf, struct font_metrics *fm)
Definition: font.c:742
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST(), test_bitmap_font(), and test_outline_font().

◆ test_font_substitution()

static void test_font_substitution ( void  )
static

Definition at line 967 of file font.c.

968{
969 char fallback_font[LF_FACESIZE];
970 HDC hdc;
971 LOGFONTA lf;
973 GpGraphics *graphics;
974 GpFont *font;
975 GpFontFamily *family;
976
978 status = GdipCreateFromHDC(hdc, &graphics);
979 expect(Ok, status);
980
981 memset(&lf, 0, sizeof(lf));
982 lstrcpyA(lf.lfFaceName, "MS Shell Dlg");
983
985 expect(Ok, status);
986 memset(&lf, 0xfe, sizeof(lf));
987 status = GdipGetLogFontA(font, graphics, &lf);
988 expect(Ok, status);
989 ok(lstrcmpA(lf.lfFaceName, "MS Shell Dlg") != 0, "expected substitution of MS Shell Dlg\n");
991
992 family = NULL;
993 status = GdipCreateFontFamilyFromName(L"MS Shell Dlg", NULL, &family);
994 expect(Ok, status);
995 font = NULL;
997 expect(Ok, status);
998 memset(&lf, 0xfe, sizeof(lf));
999 status = GdipGetLogFontA(font, graphics, &lf);
1000 expect(Ok, status);
1001 ok(lstrcmpA(lf.lfFaceName, "MS Shell Dlg") != 0, "expected substitution of MS Shell Dlg\n");
1003 GdipDeleteFontFamily(family);
1004
1005 status = GdipCreateFontFamilyFromName(L"ThisFontShouldNotExist", NULL, &family);
1006 ok(status == FontFamilyNotFound, "expected FontFamilyNotFound, got %d\n", status);
1007
1008 /* nonexistent fonts fallback to Arial, or something else if it's missing */
1009 strcpy(lf.lfFaceName,"Arial");
1011 expect(Ok, status);
1012 status = GdipGetLogFontA(font, graphics, &lf);
1013 expect(Ok, status);
1014 strcpy(fallback_font,lf.lfFaceName);
1015 trace("fallback font %s\n", fallback_font);
1017
1018 lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
1020 expect(Ok, status);
1021 memset(&lf, 0xfe, sizeof(lf));
1022 status = GdipGetLogFontA(font, graphics, &lf);
1023 expect(Ok, status);
1024 ok(!lstrcmpA(lf.lfFaceName, fallback_font), "wrong face name %s / %s\n", lf.lfFaceName, fallback_font);
1026
1027 /* empty FaceName */
1028 lf.lfFaceName[0] = 0;
1030 expect(Ok, status);
1031 memset(&lf, 0xfe, sizeof(lf));
1032 status = GdipGetLogFontA(font, graphics, &lf);
1033 expect(Ok, status);
1034 ok(!lstrcmpA(lf.lfFaceName, fallback_font), "wrong face name %s / %s\n", lf.lfFaceName, fallback_font);
1036
1037 /* zeroing out lfWeight and lfCharSet leads to font creation failure */
1038 lf.lfWeight = 0;
1039 lf.lfCharSet = 0;
1040 lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist");
1041 font = NULL;
1043 todo_wine
1044 ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
1045 "expected NotTrueTypeFont, got %d\n", status);
1046 /* FIXME: remove when wine is fixed */
1047 if (font) GdipDeleteFont(font);
1048
1049 /* empty FaceName */
1050 lf.lfFaceName[0] = 0;
1051 font = NULL;
1053 todo_wine
1054 ok(status == NotTrueTypeFont || broken(status == FileNotFound), /* before XP */
1055 "expected NotTrueTypeFont, got %d\n", status);
1056 /* FIXME: remove when wine is fixed */
1057 if (font) GdipDeleteFont(font);
1058
1059 GdipDeleteGraphics(graphics);
1060 DeleteDC(hdc);
1061}
#define broken(x)
Definition: atltest.h:178
GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc, GDIPCONST LOGFONTA *lfa, GpFont **font)
Definition: font.c:251
GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics, LOGFONTA *lfa)
Definition: font.c:434
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
@ FileNotFound
Definition: gdiplustypes.h:35
@ NotTrueTypeFont
Definition: gdiplustypes.h:41
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define todo_wine
Definition: minitest.h:80
strcpy
Definition: string.h:131
BYTE lfCharSet
Definition: dimm.idl:50
LONG lfWeight
Definition: dimm.idl:46
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55

Referenced by START_TEST().

◆ test_font_transform()

static void test_font_transform ( void  )
static

Definition at line 1063 of file font.c.

1064{
1065 static const WCHAR string[] = L"A";
1067 HDC hdc;
1068 LOGFONTA lf;
1069 GpFont *font;
1070 GpGraphics *graphics;
1072 GpStringFormat *format, *typographic;
1073 PointF pos[1] = { { 0,0 } };
1074 REAL height, margin_y;
1075 RectF bounds, rect;
1076
1078 status = GdipCreateFromHDC(hdc, &graphics);
1079 expect(Ok, status);
1080
1081 status = GdipSetPageUnit(graphics, UnitPixel);
1082 expect(Ok, status);
1083
1085 expect(Ok, status);
1087 expect(Ok, status);
1088
1089 memset(&lf, 0, sizeof(lf));
1090 lstrcpyA(lf.lfFaceName, "Tahoma");
1091 lf.lfHeight = -100;
1092 lf.lfWidth = 100;
1094 expect(Ok, status);
1095
1096 margin_y = 100.0 / 8.0;
1097
1098 /* identity matrix */
1100 expect(Ok, status);
1101 status = GdipSetWorldTransform(graphics, matrix);
1102 expect(Ok, status);
1103 status = GdipGetLogFontA(font, graphics, &lf);
1104 expect(Ok, status);
1105 expect(-100, lf.lfHeight);
1106 expect(0, lf.lfWidth);
1107 expect(0, lf.lfEscapement);
1108 expect(0, lf.lfOrientation);
1109 status = GdipGetFontHeight(font, graphics, &height);
1110 expect(Ok, status);
1111 expectf(120.703125, height);
1113 set_rect_empty(&bounds);
1114 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1115 expect(Ok, status);
1116 expectf(0.0, bounds.X);
1117 expectf(0.0, bounds.Y);
1118 todo_wine
1119 expectf(height + margin_y, bounds.Height);
1121 set_rect_empty(&bounds);
1122 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1123 expect(Ok, status);
1124 expectf(0.0, bounds.X);
1125 expectf(0.0, bounds.Y);
1126 expectf_(height, bounds.Height, 1.0);
1127 set_rect_empty(&bounds);
1128 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1130 expect(Ok, status);
1131 expectf(0.0, bounds.X);
1132 expectf_(-100.0, bounds.Y, 0.05);
1133 expectf_(height, bounds.Height, 0.5);
1134 set_rect_empty(&bounds);
1135 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1137 expect(Ok, status);
1138 expectf(0.0, bounds.X);
1139 expectf_(-100.0, bounds.Y, 0.05);
1140 expectf_(height, bounds.Height, 0.5);
1141
1142 /* scale matrix */
1144 expect(Ok, status);
1145 status = GdipSetWorldTransform(graphics, matrix);
1146 expect(Ok, status);
1147 status = GdipGetLogFontA(font, graphics, &lf);
1148 expect(Ok, status);
1149 expect(-300, lf.lfHeight);
1150 expect(0, lf.lfWidth);
1151 expect(0, lf.lfEscapement);
1152 expect(0, lf.lfOrientation);
1153 status = GdipGetFontHeight(font, graphics, &height);
1154 expect(Ok, status);
1155 expectf(120.703125, height);
1157 set_rect_empty(&bounds);
1158 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1159 expect(Ok, status);
1160 expectf(0.0, bounds.X);
1161 expectf(0.0, bounds.Y);
1162 todo_wine
1163 expectf(height + margin_y, bounds.Height);
1165 set_rect_empty(&bounds);
1166 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1167 expect(Ok, status);
1168 expectf(0.0, bounds.X);
1169 expectf(0.0, bounds.Y);
1170 expectf_(height, bounds.Height, 0.05);
1171 set_rect_empty(&bounds);
1172 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1174 expect(Ok, status);
1175 expectf(0.0, bounds.X);
1176 expectf_(-100.0, bounds.Y, 0.05);
1177 expectf_(height, bounds.Height, 0.2);
1178 set_rect_empty(&bounds);
1179 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1181 expect(Ok, status);
1182 expectf(0.0, bounds.X);
1183 todo_wine
1184 expectf_(-300.0, bounds.Y, 0.15);
1185 todo_wine
1186 expectf(height * 3.0, bounds.Height);
1187
1188 /* scale + ratate matrix */
1190 expect(Ok, status);
1191 status = GdipSetWorldTransform(graphics, matrix);
1192 expect(Ok, status);
1193 status = GdipGetLogFontA(font, graphics, &lf);
1194 expect(Ok, status);
1195 expect(-300, lf.lfHeight);
1196 expect(0, lf.lfWidth);
1197 expect_(3151, lf.lfEscapement, 1);
1198 expect_(3151, lf.lfOrientation, 1);
1199 status = GdipGetFontHeight(font, graphics, &height);
1200 expect(Ok, status);
1201 expectf(120.703125, height);
1203 set_rect_empty(&bounds);
1204 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1205 expect(Ok, status);
1206 expectf(0.0, bounds.X);
1207 expectf(0.0, bounds.Y);
1208 todo_wine
1209 expectf(height + margin_y, bounds.Height);
1211 set_rect_empty(&bounds);
1212 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1213 expect(Ok, status);
1214 expectf(0.0, bounds.X);
1215 expectf(0.0, bounds.Y);
1216 expectf_(height, bounds.Height, 0.05);
1217 set_rect_empty(&bounds);
1218 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1220 expect(Ok, status);
1221 expectf(0.0, bounds.X);
1222 expectf_(-100.0, bounds.Y, 0.05);
1223 expectf_(height, bounds.Height, 0.2);
1224 set_rect_empty(&bounds);
1225 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1227 expect(Ok, status);
1228 todo_wine
1229 expectf_(-43.814377, bounds.X, 0.05);
1230 todo_wine
1231 expectf_(-212.235611, bounds.Y, 0.05);
1232 todo_wine
1233 expectf_(340.847534, bounds.Height, 0.05);
1234
1235 /* scale + ratate + shear matrix */
1237 expect(Ok, status);
1238 status = GdipSetWorldTransform(graphics, matrix);
1239 expect(Ok, status);
1240 status = GdipGetLogFontA(font, graphics, &lf);
1241 expect(Ok, status);
1242 todo_wine
1243 expect(1032, lf.lfHeight);
1244 expect(0, lf.lfWidth);
1245 expect_(3099, lf.lfEscapement, 1);
1246 expect_(3099, lf.lfOrientation, 1);
1247 status = GdipGetFontHeight(font, graphics, &height);
1248 expect(Ok, status);
1249 expectf(120.703125, height);
1251 set_rect_empty(&bounds);
1252 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1253 expect(Ok, status);
1254 expectf(0.0, bounds.X);
1255 expectf(0.0, bounds.Y);
1256 todo_wine
1257 expectf(height + margin_y, bounds.Height);
1259 set_rect_empty(&bounds);
1260 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1261 expect(Ok, status);
1262 expectf(0.0, bounds.X);
1263 expectf(0.0, bounds.Y);
1264 expectf_(height, bounds.Height, 0.2);
1265 set_rect_empty(&bounds);
1266 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1268 expect(Ok, status);
1269 expectf(0.0, bounds.X);
1270 expectf_(-100.0, bounds.Y, 0.2);
1271 expectf_(height, bounds.Height, 0.2);
1272 set_rect_empty(&bounds);
1273 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1275 expect(Ok, status);
1276 todo_wine
1277 expectf_(-636.706848, bounds.X, 0.05);
1278 todo_wine
1279 expectf_(-175.257523, bounds.Y, 0.05);
1280 todo_wine
1281 expectf_(1532.984985, bounds.Height, 0.05);
1282
1283 /* scale + ratate + shear + translate matrix */
1285 expect(Ok, status);
1286 status = GdipSetWorldTransform(graphics, matrix);
1287 expect(Ok, status);
1288 status = GdipGetLogFontA(font, graphics, &lf);
1289 expect(Ok, status);
1290 todo_wine
1291 expect(1032, lf.lfHeight);
1292 expect(0, lf.lfWidth);
1293 expect_(3099, lf.lfEscapement, 1);
1294 expect_(3099, lf.lfOrientation, 1);
1295 status = GdipGetFontHeight(font, graphics, &height);
1296 expect(Ok, status);
1297 expectf(120.703125, height);
1299 set_rect_empty(&bounds);
1300 status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL);
1301 expect(Ok, status);
1302 expectf(0.0, bounds.X);
1303 expectf(0.0, bounds.Y);
1304 todo_wine
1305 expectf(height + margin_y, bounds.Height);
1307 set_rect_empty(&bounds);
1308 status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL);
1309 expect(Ok, status);
1310 expectf(0.0, bounds.X);
1311 expectf(0.0, bounds.Y);
1312 expectf_(height, bounds.Height, 0.1);
1313 set_rect_empty(&bounds);
1314 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1316 expect(Ok, status);
1317 expectf(0.0, bounds.X);
1318 expectf_(-100.0, bounds.Y, 0.2);
1319 expectf_(height, bounds.Height, 0.2);
1320 set_rect_empty(&bounds);
1321 status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos,
1323 expect(Ok, status);
1324 todo_wine
1325 expectf_(-626.706848, bounds.X, 0.05);
1326 todo_wine
1327 expectf_(-155.257523, bounds.Y, 0.05);
1328 todo_wine
1329 expectf_(1532.984985, bounds.Height, 0.05);
1330
1331 GdipDeleteGraphics(graphics);
1332
1334 SetWindowExtEx(hdc, 200, 200, NULL);
1335 SetViewportExtEx(hdc, 100, 100, NULL);
1336 status = GdipCreateFromHDC(hdc, &graphics);
1337 expect(Ok, status);
1338 status = GdipGetLogFontA(font, graphics, &lf);
1339 expect(Ok, status);
1340 expect(-50, lf.lfHeight);
1341 expect(0, lf.lfWidth);
1342 expect(0, lf.lfEscapement);
1343 expect(0, lf.lfOrientation);
1344
1347 GdipDeleteGraphics(graphics);
1348 GdipDeleteStringFormat(typographic);
1350 DeleteDC(hdc);
1351}
unsigned short UINT16
Definition: actypes.h:129
RECT rect
Definition: combotst.c:67
GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, RectF *bounds, INT *codepointsfitted, INT *linesfilled)
Definition: graphics.c:5890
GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
Definition: graphics.c:6724
GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, GDIPCONST GpFont *font, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix, RectF *boundingBox)
Definition: graphics.c:7456
GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
Definition: graphics.c:6560
GpStatus WINGDIPAPI GdipScaleMatrix(GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
Definition: matrix.c:288
GpStatus WINGDIPAPI GdipShearMatrix(GpMatrix *matrix, REAL shearX, REAL shearY, GpMatrixOrder order)
Definition: matrix.c:337
GpStatus WINGDIPAPI GdipTranslateMatrix(GpMatrix *matrix, REAL offsetX, REAL offsetY, GpMatrixOrder order)
Definition: matrix.c:420
GpStatus WINGDIPAPI GdipRotateMatrix(GpMatrix *matrix, REAL angle, GpMatrixOrder order)
Definition: matrix.c:257
GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
Definition: matrix.c:156
GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
Definition: matrix.c:136
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, GpStringFormat **format)
Definition: stringformat.c:76
GpStatus WINGDIPAPI GdipStringFormatGetGenericTypographic(GpStringFormat **format)
Definition: stringformat.c:401
GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
Definition: stringformat.c:105
@ MatrixOrderAppend
Definition: gdiplusenums.h:188
@ DriverStringOptionsCmapLookup
Definition: gdiplusenums.h:47
GLuint GLenum matrix
Definition: glext.h:9407
#define expectf_(expected, got, precision)
Definition: font.c:35
static void set_rect_empty(RectF *rc)
Definition: font.c:38
#define expect_(expected, got, precision)
Definition: font.c:34
#define expectf(expected, got)
Definition: font.c:36
LONG lfOrientation
Definition: dimm.idl:45
LONG lfHeight
Definition: dimm.idl:42
LONG lfEscapement
Definition: dimm.idl:44
LONG lfWidth
Definition: dimm.idl:43
Definition: format.c:58
int WINAPI SetMapMode(_In_ HDC, _In_ int)
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define MM_ISOTROPIC
Definition: wingdi.h:870

Referenced by START_TEST().

◆ test_fontfamily()

static void test_fontfamily ( void  )
static

Definition at line 458 of file font.c.

459{
460 GpFontFamily *family, *clonedFontFamily;
461 WCHAR itsName[LF_FACESIZE];
463
464 /* FontFamily cannot be NULL */
467
468 /* FontFamily must be able to actually find the family.
469 * If it can't, any subsequent calls should fail.
470 */
471 stat = GdipCreateFontFamilyFromName (L"ThisFontShouldNotExist", NULL, &family);
473
474 /* Bitmap fonts are not found */
475 stat = GdipCreateFontFamilyFromName (L"MS Sans Serif", NULL, &family);
477 if(stat == Ok) GdipDeleteFontFamily(family);
478
479 stat = GdipCreateFontFamilyFromName (L"Tahoma", NULL, &family);
480 expect (Ok, stat);
481
482 stat = GdipGetFamilyName (family, itsName, LANG_NEUTRAL);
483 expect (Ok, stat);
484 expect (0, lstrcmpiW(itsName, L"Tahoma"));
485
486#ifdef __REACTOS__
487 if (!is_reactos() && (GetNTVersion() < _WIN32_WINNT_WIN7))
488 {
489 win_skip("Skipping test that crashes on Windows 2003 / Vista\n");
490 }
491 else
492 {
493#endif
494 /* Crashes on Windows XP SP2 and Vista */
496 expect (Ok, stat);
497#ifdef __REACTOS__
498 }
499#endif
500
501 /* Make sure we don't read old data */
502 ZeroMemory (itsName, sizeof(itsName));
503 stat = GdipCloneFontFamily(family, &clonedFontFamily);
504 expect (Ok, stat);
505 ok (family == clonedFontFamily, "Unexpected family instance.\n");
506 GdipDeleteFontFamily(family);
507 stat = GdipGetFamilyName(clonedFontFamily, itsName, LANG_NEUTRAL);
508 expect(Ok, stat);
509 expect(0, lstrcmpiW(itsName, L"Tahoma"));
510
511 GdipDeleteFontFamily(clonedFontFamily);
512}
#define GetNTVersion()
Definition: apitest.h:17
GpStatus WINGDIPAPI GdipCloneFontFamily(GpFontFamily *family, GpFontFamily **clone)
Definition: font.c:754
#define win_skip
Definition: minitest.h:67
#define ZeroMemory
Definition: minwinbase.h:31
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28

Referenced by START_TEST().

◆ test_fontfamily_properties()

static void test_fontfamily_properties ( void  )
static

Definition at line 514 of file font.c.

515{
518 UINT16 result = 0;
519
521 expect(Ok, stat);
522
524 expect(Ok, stat);
525 ok (result == 2472, "Expected 2472, got %d\n", result);
526 result = 0;
528 expect(Ok, stat);
529 ok(result == 2048, "Expected 2048, got %d\n", result);
530 result = 0;
532 expect(Ok, stat);
533 ok(result == 2049, "Expected 2049, got %d\n", result);
534 result = 0;
536 expect(Ok, stat);
537 ok(result == 423, "Expected 423, got %d\n", result);
539
540 stat = GdipCreateFontFamilyFromName(L"Times New Roman", NULL, &FontFamily);
542 skip("Times New Roman not installed\n");
543 else
544 {
545 result = 0;
547 expect(Ok, stat);
548 ok(result == 2355, "Expected 2355, got %d\n", result);
549 result = 0;
551 expect(Ok, stat);
552 ok(result == 2048, "Expected 2048, got %d\n", result);
553 result = 0;
555 expect(Ok, stat);
556 ok(result == 1825, "Expected 1825, got %d\n", result);
557 result = 0;
559 expect(Ok, stat);
560 ok(result == 443, "Expected 443 got %d\n", result);
562 }
563}
GLuint64EXT * result
Definition: glext.h:11304

Referenced by START_TEST().

◆ test_GdipGetFontCollectionFamilyCount()

static void test_GdipGetFontCollectionFamilyCount ( void  )
static

Definition at line 1424 of file font.c.

1425{
1428 INT count;
1429
1431 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1432
1433 count = 123;
1435 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1436 ok(count == 123, "Unexpected family count %d.\n", count);
1437
1439 ok(status == Ok, "Failed to get system collection, status %d.\n", status);
1440
1442 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1443}

Referenced by START_TEST().

◆ test_GdipGetFontCollectionFamilyList()

static void test_GdipGetFontCollectionFamilyList ( void  )
static

Definition at line 1353 of file font.c.

1354{
1355 GpFontFamily *family, *family2, **families;
1357 UINT i;
1358 INT found, count;
1360
1362 ok(status == Ok, "Failed to get system collection, status %d.\n", status);
1363
1364 count = 0;
1366 ok(status == Ok, "Failed to get family count, status %d.\n", status);
1367 ok(count > 0, "Unexpected empty collection.\n");
1368
1370 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1371
1372 found = 123;
1374 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1375 ok(found == 123, "Unexpected list count %d.\n", found);
1376
1378 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1379
1380 found = 123;
1382 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1383 ok(found == 123, "Unexpected list count %d.\n", found);
1384
1385 found = 123;
1387 ok(status == InvalidParameter, "Unexpected status %d.\n", status);
1388 ok(found == 123, "Unexpected list count %d.\n", found);
1389
1390 family = NULL;
1391 found = 0;
1392 status = GdipGetFontCollectionFamilyList(collection, 1, &family, &found);
1393 ok(status == Ok, "Failed to get family list, status %d.\n", status);
1394 ok(found == 1, "Unexpected list count %d.\n", found);
1395 ok(family != NULL, "Expected family instance.\n");
1396
1397 family2 = NULL;
1398 found = 0;
1399 status = GdipGetFontCollectionFamilyList(collection, 1, &family2, &found);
1400 ok(status == Ok, "Failed to get family list, status %d.\n", status);
1401 ok(found == 1, "Unexpected list count %d.\n", found);
1402 ok(family2 == family, "Unexpected family instance.\n");
1403
1404 status = GdipDeleteFontFamily(family);
1405 expect(Ok, status);
1406
1407 status = GdipDeleteFontFamily(family2);
1408 expect(Ok, status);
1409
1410 families = GdipAlloc((count + 1) * sizeof(*families));
1411 found = 0;
1412 status = GdipGetFontCollectionFamilyList(collection, count + 1, families, &found);
1413 ok(status == Ok, "Failed to get family list, status %d.\n", status);
1414 ok(found == count, "Unexpected list count %d, extected %d.\n", found, count);
1415
1416 for (i = 0; i < found; i++)
1417 {
1418 status = GdipDeleteFontFamily(families[i]);
1419 expect(Ok, status);
1420 }
1421 GdipFree(families);
1422}

Referenced by START_TEST().

◆ test_GdipPrivateAddMemoryFont()

static void test_GdipPrivateAddMemoryFont ( void  )
static

Definition at line 1546 of file font.c.

1547{
1548 static const WORD resource_ids[] =
1549 {
1550 3, /* A font that has an invalid full name on Mac platform and a valid full name on Microsoft platform */
1551 4, /* A font that has an invalid full name on Unicode platform and a valid full name on Mac platform */
1552 };
1553 GpFontCollection *fonts;
1554 GpStatus stat;
1555 int count, i;
1556 void *buffer;
1557 DWORD size;
1558
1559 for (i = 0; i < ARRAY_SIZE(resource_ids); i++)
1560 {
1561 winetest_push_context("test %d", i);
1562
1564 ok(stat == Ok, "GdipNewPrivateFontCollection failed, error %d\n", stat);
1565
1566 load_resource(MAKEINTRESOURCEW(resource_ids[i]), (BYTE **)&buffer, &size);
1568 if (stat == Ok)
1569 {
1571 ok(stat == Ok, "GdipGetFontCollectionFamilyCount failed, error %d\n", stat);
1572 ok(count == 1, "Expected count 1, got %d\n", count);
1573 }
1574 else if (i == 1 && stat == FileNotFound)
1575 win_skip("Fonts without Microsoft platform names are unsupported on win7.\n");
1576 else
1577 ok(0, "GdipPrivateAddMemoryFont failed, error %d\n", stat);
1578
1580 ok(stat == Ok, "GdipDeletePrivateFontCollection failed, error %d\n", stat);
1581
1583 }
1584}
GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection *fontCollection, GDIPCONST void *memory, INT length)
Definition: font.c:1479
GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
Definition: font.c:1076
GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection **fontCollection)
Definition: font.c:1054
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint buffer
Definition: glext.h:5915

Referenced by START_TEST().

◆ test_getgenerics()

static void test_getgenerics ( void  )
static

Definition at line 586 of file font.c.

587{
589 GpFontFamily *family;
590 WCHAR sansname[LF_FACESIZE], serifname[LF_FACESIZE], mononame[LF_FACESIZE];
591 int missingfonts = 0;
592
594 expect (Ok, stat);
596 missingfonts = 1;
597 else
598 check_family("Sans Serif", family, sansname);
599
601 expect (Ok, stat);
603 missingfonts = 1;
604 else
605 check_family("Serif", family, serifname);
606
608 expect (Ok, stat);
610 missingfonts = 1;
611 else
612 check_family("Monospace", family, mononame);
613
614 if (missingfonts && strcmp(winetest_platform, "wine") == 0)
615 trace("You may need to install either the Microsoft Web Fonts or the Liberation Fonts\n");
616
617 /* Check that the family names are all different */
618 ok(lstrcmpiW(sansname, serifname) != 0, "Sans Serif and Serif families should be different: %s\n", wine_dbgstr_w(sansname));
619 ok(lstrcmpiW(sansname, mononame) != 0, "Sans Serif and Monospace families should be different: %s\n", wine_dbgstr_w(sansname));
620 ok(lstrcmpiW(serifname, mononame) != 0, "Serif and Monospace families should be different: %s\n", wine_dbgstr_w(serifname));
621}
GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily)
Definition: font.c:997
GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily)
Definition: font.c:1029
GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily)
Definition: font.c:965
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
const char * winetest_platform
static void check_family(const char *context, GpFontFamily *family, WCHAR *name)
Definition: font.c:565

Referenced by START_TEST().

◆ test_heightgivendpi()

static void test_heightgivendpi ( void  )
static

Definition at line 636 of file font.c.

637{
639 GpFont* font = NULL;
640 GpFontFamily* fontfamily = NULL;
641 REAL height;
642 Unit unit;
643
644 stat = GdipCreateFontFamilyFromName(L"Tahoma", NULL, &fontfamily);
645 expect(Ok, stat);
646
647 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font);
648 expect(Ok, stat);
649
652
655
657 expect(Ok, stat);
658 expectf(36.210938, height);
660
661 height = 12345;
662 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font);
663 expect(Ok, stat);
664
666 expect(Ok, stat);
668
670 expect(Ok, stat);
671 expectf(36.210938, height);
673
674 height = 12345;
675 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font);
676 expect(Ok, stat);
678 expect(Ok, stat);
679 expectf(48.281250, height);
681
682 height = 12345;
683 stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font);
684 expect(Ok, stat);
685
687 expect(Ok, stat);
689
691 expect(Ok, stat);
692 expectf(3476.250000, height);
694
695 height = 12345;
697 expect(Ok, stat);
698
700 expect(Ok, stat);
702
704 expect(Ok, stat);
705 expectf(11.587500, height);
707
708 height = 12345;
710 expect(Ok, stat);
711
713 expect(Ok, stat);
715
717 expect(Ok, stat);
718 expectf(136.860245, height);
720
721 GdipDeleteFontFamily(fontfamily);
722}
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
Definition: font.c:577
@ UnitDocument
Definition: gdiplusenums.h:32
@ UnitInch
Definition: gdiplusenums.h:31

Referenced by START_TEST().

◆ test_installedfonts()

static void test_installedfonts ( void  )
static

Definition at line 623 of file font.c.

624{
627
630
632 expect (Ok, stat);
633 ok (collection != NULL, "got NULL font collection\n");
634}

Referenced by START_TEST().

◆ test_logfont()

static void test_logfont ( void  )
static

Definition at line 272 of file font.c.

273{
274 LOGFONTA lfa, lfa2;
275 GpFont *font;
276 GpFontFamily *family;
278 GpGraphics *graphics;
279 HDC hdc = GetDC(0);
280 INT style;
281 REAL rval;
282 UINT16 em_height, line_spacing;
283 Unit unit;
284
285 stat = GdipCreateFromHDC(hdc, &graphics);
286 expect(Ok, stat);
287
288 memset(&lfa, 0, sizeof(LOGFONTA));
289 memset(&lfa2, 0xff, sizeof(LOGFONTA));
290 lstrcpyA(lfa.lfFaceName, "Tahoma");
291
293 expect(Ok, stat);
294 stat = GdipGetLogFontA(font, graphics, &lfa2);
295 expect(Ok, stat);
296
297 ok(lfa2.lfHeight < 0, "Expected negative height\n");
298 expect(0, lfa2.lfWidth);
299 expect(0, lfa2.lfEscapement);
300 expect(0, lfa2.lfOrientation);
301 ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
302 expect(0, lfa2.lfItalic);
303 expect(0, lfa2.lfUnderline);
304 expect(0, lfa2.lfStrikeOut);
306 "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
307 expect(0, lfa2.lfOutPrecision);
308 expect(0, lfa2.lfClipPrecision);
309 expect(0, lfa2.lfQuality);
310 expect(0, lfa2.lfPitchAndFamily);
311
313
314 memset(&lfa, 0, sizeof(LOGFONTA));
315 lfa.lfHeight = 25;
316 lfa.lfWidth = 25;
317 lfa.lfEscapement = lfa.lfOrientation = 50;
318 lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE;
319
320 memset(&lfa2, 0xff, sizeof(LOGFONTA));
321 lstrcpyA(lfa.lfFaceName, "Tahoma");
322
324 expect(Ok, stat);
325 stat = GdipGetLogFontA(font, graphics, &lfa2);
326 expect(Ok, stat);
327
328 ok(lfa2.lfHeight < 0, "Expected negative height\n");
329 expect(0, lfa2.lfWidth);
330 expect(0, lfa2.lfEscapement);
331 expect(0, lfa2.lfOrientation);
332 ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n");
333 expect(TRUE, lfa2.lfItalic);
334 expect(TRUE, lfa2.lfUnderline);
335 expect(TRUE, lfa2.lfStrikeOut);
337 "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
338 expect(0, lfa2.lfOutPrecision);
339 expect(0, lfa2.lfClipPrecision);
340 expect(0, lfa2.lfQuality);
341 expect(0, lfa2.lfPitchAndFamily);
342
344 expect(Ok, stat);
346 "Expected , got %d\n", style);
347
349 expect(Ok, stat);
351
352 stat = GdipGetFontHeight(font, graphics, &rval);
353 expect(Ok, stat);
354 expectf(25.347656, rval);
356 expect(Ok, stat);
357 expectf(21.0, rval);
358
359 stat = GdipGetFamily(font, &family);
360 expect(Ok, stat);
361 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
362 expect(Ok, stat);
363 expect(2048, em_height);
364 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
365 expect(Ok, stat);
366 expect(2472, line_spacing);
367 GdipDeleteFontFamily(family);
368
370
371 memset(&lfa, 0, sizeof(lfa));
372 lfa.lfHeight = -25;
373 lstrcpyA(lfa.lfFaceName, "Tahoma");
375 expect(Ok, stat);
376 memset(&lfa2, 0xff, sizeof(lfa2));
377 stat = GdipGetLogFontA(font, graphics, &lfa2);
378 expect(Ok, stat);
379 expect(lfa.lfHeight, lfa2.lfHeight);
380
382 expect(Ok, stat);
384
385 stat = GdipGetFontHeight(font, graphics, &rval);
386 expect(Ok, stat);
387 expectf(30.175781, rval);
389 expect(Ok, stat);
390 expectf(25.0, rval);
391
392 stat = GdipGetFamily(font, &family);
393 expect(Ok, stat);
394 stat = GdipGetEmHeight(family, FontStyleRegular, &em_height);
395 expect(Ok, stat);
396 expect(2048, em_height);
397 stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing);
398 expect(Ok, stat);
399 expect(2472, line_spacing);
400 GdipDeleteFontFamily(family);
401
403 font = NULL;
404
405 /* The next test must be done with a font where tmHeight -
406 tmInternalLeading != tmAscent. Times New Roman is such a font,
407 so make sure we really have it before continuing. */
408 memset(&lfa, 0, sizeof(lfa));
409 lstrcpyA(lfa.lfFaceName, "Times New Roman");
410
412 expect(Ok, stat);
413
414 memset(&lfa2, 0, sizeof(lfa2));
415 stat = GdipGetLogFontA(font, graphics, &lfa2);
416 expect(Ok, stat);
417
419 font = NULL;
420
421 if (!lstrlenA(lfa.lfFaceName) || lstrcmpA(lfa.lfFaceName, lfa2.lfFaceName))
422 {
423 skip("Times New Roman not installed\n");
424 }
425 else
426 {
427 static const struct
428 {
429 INT input;
431 } test_sizes[] = {{12, 9.0}, {36, 32.0}, {48, 42.0}, {72, 63.0}, {144, 127.0}};
432
433 UINT i;
434
435 memset(&lfa, 0, sizeof(lfa));
436 lstrcpyA(lfa.lfFaceName, "Times New Roman");
437
438 for (i = 0; i < ARRAY_SIZE(test_sizes); ++i)
439 {
440 lfa.lfHeight = test_sizes[i].input;
441
443 expect(Ok, stat);
444
446 expect(Ok, stat);
448
450 font = NULL;
451 }
452 }
453
454 GdipDeleteGraphics(graphics);
455 ReleaseDC(0, hdc);
456}
float rval
Definition: cylfrac.c:48
@ FontStyleUnderline
Definition: gdiplusenums.h:305
@ FontStyleStrikeout
Definition: gdiplusenums.h:306
@ FontStyleItalic
Definition: gdiplusenums.h:303
GLenum GLenum GLenum input
Definition: glext.h:9031
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static void test_sizes(void)
Definition: toolbar.c:1354
BYTE lfStrikeOut
Definition: dimm.idl:49
BYTE lfClipPrecision
Definition: dimm.idl:52
BYTE lfUnderline
Definition: dimm.idl:48
BYTE lfQuality
Definition: dimm.idl:53
BYTE lfOutPrecision
Definition: dimm.idl:51
BYTE lfItalic
Definition: dimm.idl:47
BYTE lfPitchAndFamily
Definition: dimm.idl:54
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

◆ test_long_name()

static void test_long_name ( void  )
static

Definition at line 82 of file font.c.

83{
86 GpFontCollection *fonts;
88 INT num_families;
89 GpFontFamily *family, *cloned_family;
91 GpFont *font;
92
94 ok(stat == Ok, "GdipNewPrivateFontCollection failed: %d\n", stat);
95
96 create_testfontfile(L"wine_longname.ttf", 1, path);
97
99 ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed: %ld\n", GetLastError());
100
102 ok(stat == Ok, "GdipPrivateAddFontFile failed with open file handle: %d\n", stat);
103
105
106 if (stat != Ok) {
107 /* try again without opened file handle */
109 ok(stat == Ok, "GdipPrivateAddFontFile failed: %d\n", stat);
110 }
111
112 stat = GdipGetFontCollectionFamilyCount(fonts, &num_families);
113 ok(stat == Ok, "GdipGetFontCollectionFamilyCount failed: %d\n", stat);
114
115 ok(num_families == 1, "expected num_families to be 1, got %d\n", num_families);
116
117 stat = GdipGetFontCollectionFamilyList(fonts, num_families, &family, &num_families);
118 ok(stat == Ok, "GdipGetFontCollectionFamilyList failed: %d\n", stat);
119
121 ok(stat == Ok, "GdipGetFamilyName failed: %d\n", stat);
122
124 ok(stat == Ok, "GdipCreateFont failed: %d\n", stat);
125
126 stat = GdipCloneFontFamily(family, &cloned_family);
127 ok(stat == Ok, "GdipCloneFontFamily failed: %d\n", stat);
128 ok(family == cloned_family, "GdipCloneFontFamily returned new object\n");
129
130 /* Cleanup */
131
133 ok(stat == Ok, "GdipDeleteFont failed: %d\n", stat);
134
136 ok(stat == Ok, "GdipDeletePrivateFontCollection failed: %d\n", stat);
137
138 /* Cloned family survives after collection is deleted */
140 ok(stat == Ok, "GdipGetFamilyName failed: %d\n", stat);
141
142 stat = GdipDeleteFontFamily(cloned_family);
143 ok(stat == Ok, "GdipDeleteFontFamily failed: %d\n", stat);
144
146}
#define OPEN_EXISTING
Definition: compat.h:775
#define FILE_SHARE_READ
Definition: compat.h:136
GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection *collection, GDIPCONST WCHAR *name)
Definition: font.c:1095
#define DELETE_FONTFILE(filename)
Definition: font.c:75
static void create_testfontfile(const WCHAR *filename, int resource, WCHAR pathW[MAX_PATH])
Definition: font.c:57

Referenced by START_TEST().