2006-04-03 14:59:27 +02:00
|
|
|
/*
|
|
|
|
* Unit test suite for fonts
|
|
|
|
*
|
|
|
|
* Copyright 2002 Mike McCormack
|
|
|
|
* Copyright 2004 Dmitry Timoshkov
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-03 14:59:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2018-11-21 13:54:00 +01:00
|
|
|
#include <stdio.h>
|
2006-04-03 14:59:27 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2007-02-15 08:52:33 +01:00
|
|
|
#include "winnls.h"
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2018-01-30 23:41:00 +01:00
|
|
|
#include "wine/heap.h"
|
2006-04-03 14:59:27 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2017-03-17 09:44:33 +01:00
|
|
|
static inline BOOL match_off_by_n(int a, int b, unsigned int n)
|
|
|
|
{
|
|
|
|
return abs(a - b) <= n;
|
|
|
|
}
|
|
|
|
#define match_off_by_1(a, b, exact) match_off_by_n((a), (b), (exact) ? 0 : 1)
|
|
|
|
#define near_match(a, b) match_off_by_n((a), (b), 6)
|
2007-03-30 14:58:32 +02:00
|
|
|
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
|
|
|
|
|
2010-10-01 13:41:42 +02:00
|
|
|
static LONG (WINAPI *pGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height);
|
2011-01-14 12:27:56 +01:00
|
|
|
static DWORD (WINAPI *pGdiGetCodePage)(HDC hdc);
|
2011-12-12 11:14:09 +01:00
|
|
|
static BOOL (WINAPI *pGetCharABCWidthsFloatW)(HDC hdc, UINT first, UINT last, LPABCFLOAT abc);
|
2013-09-11 14:46:53 +02:00
|
|
|
static BOOL (WINAPI *pGetCharWidth32W)(HDC hdc, UINT first, UINT last, LPINT buffer);
|
2019-04-09 11:33:00 +02:00
|
|
|
static BOOL (WINAPI *pGetCharWidthInfo)(HDC hdc, void *);
|
2010-10-01 13:41:42 +02:00
|
|
|
static DWORD (WINAPI *pGetFontUnicodeRanges)(HDC hdc, LPGLYPHSET lpgs);
|
|
|
|
static DWORD (WINAPI *pGetGlyphIndicesW)(HDC hdc, LPCWSTR lpstr, INT count, LPWORD pgi, DWORD flags);
|
2012-12-18 17:41:42 +01:00
|
|
|
static BOOL (WINAPI *pGetTextExtentExPointI)(HDC hdc, const WORD *indices, INT count, INT max_ext,
|
|
|
|
LPINT nfit, LPINT dxs, LPSIZE size );
|
2010-10-01 13:41:42 +02:00
|
|
|
static BOOL (WINAPI *pGdiRealizationInfo)(HDC hdc, DWORD *);
|
2013-10-17 01:55:20 +02:00
|
|
|
static HFONT (WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *);
|
2010-10-01 13:41:42 +02:00
|
|
|
static HANDLE (WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD *);
|
|
|
|
static BOOL (WINAPI *pRemoveFontMemResourceEx)(HANDLE);
|
2011-08-30 04:59:42 +02:00
|
|
|
static INT (WINAPI *pAddFontResourceExA)(LPCSTR, DWORD, PVOID);
|
|
|
|
static BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR, DWORD, PVOID);
|
2015-08-13 16:39:19 +02:00
|
|
|
static BOOL (WINAPI *pGetFontRealizationInfo)(HDC hdc, DWORD *);
|
2018-11-21 13:54:01 +01:00
|
|
|
static BOOL (WINAPI *pGetFontFileInfo)(DWORD, DWORD, void *, SIZE_T, SIZE_T *);
|
2018-11-21 13:54:03 +01:00
|
|
|
static BOOL (WINAPI *pGetFontFileData)(DWORD, DWORD, UINT64, void *, DWORD);
|
2007-02-15 08:52:33 +01:00
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
static HMODULE hgdi32 = 0;
|
2011-02-03 12:06:44 +01:00
|
|
|
static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
|
2012-10-18 20:13:25 +02:00
|
|
|
static WORD system_lang_id;
|
2007-03-05 17:29:04 +01:00
|
|
|
|
2013-08-28 15:21:15 +02:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define GET_BE_WORD(x) (x)
|
|
|
|
#define GET_BE_DWORD(x) (x)
|
|
|
|
#else
|
|
|
|
#define GET_BE_WORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
|
|
|
|
#define GET_BE_DWORD(x) MAKELONG(GET_BE_WORD(HIWORD(x)), GET_BE_WORD(LOWORD(x)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MS_MAKE_TAG(ch0, ch1, ch2, ch3) \
|
|
|
|
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
|
|
|
|
((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
|
|
|
|
#define MS_OS2_TAG MS_MAKE_TAG('O','S','/','2')
|
|
|
|
#define MS_CMAP_TAG MS_MAKE_TAG('c','m','a','p')
|
|
|
|
#define MS_NAME_TAG MS_MAKE_TAG('n','a','m','e')
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
static void init(void)
|
|
|
|
{
|
|
|
|
hgdi32 = GetModuleHandleA("gdi32.dll");
|
|
|
|
|
|
|
|
pGdiGetCharDimensions = (void *)GetProcAddress(hgdi32, "GdiGetCharDimensions");
|
2011-01-14 12:27:56 +01:00
|
|
|
pGdiGetCodePage = (void *) GetProcAddress(hgdi32,"GdiGetCodePage");
|
2011-12-12 11:14:09 +01:00
|
|
|
pGetCharABCWidthsFloatW = (void *)GetProcAddress(hgdi32, "GetCharABCWidthsFloatW");
|
2013-09-11 14:46:53 +02:00
|
|
|
pGetCharWidth32W = (void *)GetProcAddress(hgdi32, "GetCharWidth32W");
|
2019-04-09 11:33:00 +02:00
|
|
|
pGetCharWidthInfo = (void *)GetProcAddress(hgdi32, "GetCharWidthInfo");
|
2007-03-05 17:29:04 +01:00
|
|
|
pGetFontUnicodeRanges = (void *)GetProcAddress(hgdi32, "GetFontUnicodeRanges");
|
|
|
|
pGetGlyphIndicesW = (void *)GetProcAddress(hgdi32, "GetGlyphIndicesW");
|
2012-12-18 17:41:42 +01:00
|
|
|
pGetTextExtentExPointI = (void *)GetProcAddress(hgdi32, "GetTextExtentExPointI");
|
2008-02-27 18:00:06 +01:00
|
|
|
pGdiRealizationInfo = (void *)GetProcAddress(hgdi32, "GdiRealizationInfo");
|
2010-06-11 17:39:40 +02:00
|
|
|
pCreateFontIndirectExA = (void *)GetProcAddress(hgdi32, "CreateFontIndirectExA");
|
2010-08-02 08:35:04 +02:00
|
|
|
pAddFontMemResourceEx = (void *)GetProcAddress(hgdi32, "AddFontMemResourceEx");
|
|
|
|
pRemoveFontMemResourceEx = (void *)GetProcAddress(hgdi32, "RemoveFontMemResourceEx");
|
2011-08-30 04:59:42 +02:00
|
|
|
pAddFontResourceExA = (void *)GetProcAddress(hgdi32, "AddFontResourceExA");
|
|
|
|
pRemoveFontResourceExA = (void *)GetProcAddress(hgdi32, "RemoveFontResourceExA");
|
2015-08-13 16:39:19 +02:00
|
|
|
pGetFontRealizationInfo = (void *)GetProcAddress(hgdi32, "GetFontRealizationInfo");
|
|
|
|
pGetFontFileInfo = (void *)GetProcAddress(hgdi32, "GetFontFileInfo");
|
|
|
|
pGetFontFileData = (void *)GetProcAddress(hgdi32, "GetFontFileData");
|
2012-10-18 20:13:25 +02:00
|
|
|
|
|
|
|
system_lang_id = PRIMARYLANGID(GetSystemDefaultLangID());
|
2007-03-05 17:29:04 +01:00
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK is_truetype_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2007-03-06 12:14:25 +01:00
|
|
|
{
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_truetype_font_installed(const char *name)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (!EnumFontFamiliesA(hdc, name, is_truetype_font_installed_proc, 0))
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK is_font_installed_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2006-09-20 13:43:10 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_font_installed(const char *name)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if(!EnumFontFamiliesA(hdc, name, is_font_installed_proc, 0))
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-28 15:21:08 +02:00
|
|
|
static void *get_res_data(const char *fontname, DWORD *rsrc_size)
|
|
|
|
{
|
|
|
|
HRSRC rsrc;
|
|
|
|
void *rsrc_data;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
rsrc = FindResourceA(GetModuleHandleA(NULL), fontname, (LPCSTR)RT_RCDATA);
|
2013-08-28 15:21:08 +02:00
|
|
|
if (!rsrc) return NULL;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
rsrc_data = LockResource(LoadResource(GetModuleHandleA(NULL), rsrc));
|
2013-08-28 15:21:08 +02:00
|
|
|
if (!rsrc_data) return NULL;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
*rsrc_size = SizeofResource(GetModuleHandleA(NULL), rsrc);
|
2013-08-28 15:21:08 +02:00
|
|
|
if (!*rsrc_size) return NULL;
|
|
|
|
|
|
|
|
return rsrc_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL write_tmp_file( const void *data, DWORD *size, char *tmp_name )
|
|
|
|
{
|
|
|
|
char tmp_path[MAX_PATH];
|
|
|
|
HANDLE hfile;
|
|
|
|
BOOL ret;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTempPathA(MAX_PATH, tmp_path);
|
|
|
|
GetTempFileNameA(tmp_path, "ttf", 0, tmp_name);
|
2013-08-28 15:21:08 +02:00
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
hfile = CreateFileA(tmp_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
2013-08-28 15:21:08 +02:00
|
|
|
if (hfile == INVALID_HANDLE_VALUE) return FALSE;
|
|
|
|
|
|
|
|
ret = WriteFile(hfile, data, *size, size, NULL);
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL write_ttf_file(const char *fontname, char *tmp_name)
|
|
|
|
{
|
|
|
|
void *rsrc_data;
|
|
|
|
DWORD rsrc_size;
|
|
|
|
|
|
|
|
rsrc_data = get_res_data( fontname, &rsrc_size );
|
|
|
|
if (!rsrc_data) return FALSE;
|
|
|
|
|
|
|
|
return write_tmp_file( rsrc_data, &rsrc_size, tmp_name );
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:59:27 +02:00
|
|
|
static void check_font(const char* test, const LOGFONTA* lf, HFONT hfont)
|
|
|
|
{
|
|
|
|
LOGFONTA getobj_lf;
|
|
|
|
int ret, minlen = 0;
|
|
|
|
|
|
|
|
if (!hfont)
|
|
|
|
return;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetObjectA(hfont, sizeof(getobj_lf), &getobj_lf);
|
2006-04-03 14:59:27 +02:00
|
|
|
/* NT4 tries to be clever and only returns the minimum length */
|
|
|
|
while (lf->lfFaceName[minlen] && minlen < LF_FACESIZE-1)
|
|
|
|
minlen++;
|
|
|
|
minlen += FIELD_OFFSET(LOGFONTA, lfFaceName) + 1;
|
2006-06-13 14:02:13 +02:00
|
|
|
ok(ret == sizeof(LOGFONTA) || ret == minlen, "%s: GetObject returned %d\n", test, ret);
|
2009-02-17 17:35:34 +01:00
|
|
|
ok(lf->lfHeight == getobj_lf.lfHeight ||
|
|
|
|
broken((SHORT)lf->lfHeight == getobj_lf.lfHeight), /* win9x */
|
|
|
|
"lfHeight: expect %08x got %08x\n", lf->lfHeight, getobj_lf.lfHeight);
|
|
|
|
ok(lf->lfWidth == getobj_lf.lfWidth ||
|
|
|
|
broken((SHORT)lf->lfWidth == getobj_lf.lfWidth), /* win9x */
|
|
|
|
"lfWidth: expect %08x got %08x\n", lf->lfWidth, getobj_lf.lfWidth);
|
|
|
|
ok(lf->lfEscapement == getobj_lf.lfEscapement ||
|
|
|
|
broken((SHORT)lf->lfEscapement == getobj_lf.lfEscapement), /* win9x */
|
|
|
|
"lfEscapement: expect %08x got %08x\n", lf->lfEscapement, getobj_lf.lfEscapement);
|
|
|
|
ok(lf->lfOrientation == getobj_lf.lfOrientation ||
|
|
|
|
broken((SHORT)lf->lfOrientation == getobj_lf.lfOrientation), /* win9x */
|
|
|
|
"lfOrientation: expect %08x got %08x\n", lf->lfOrientation, getobj_lf.lfOrientation);
|
|
|
|
ok(lf->lfWeight == getobj_lf.lfWeight ||
|
|
|
|
broken((SHORT)lf->lfWeight == getobj_lf.lfWeight), /* win9x */
|
|
|
|
"lfWeight: expect %08x got %08x\n", lf->lfWeight, getobj_lf.lfWeight);
|
2009-02-17 00:22:55 +01:00
|
|
|
ok(lf->lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf->lfItalic, getobj_lf.lfItalic);
|
|
|
|
ok(lf->lfUnderline == getobj_lf.lfUnderline, "lfUnderline: expect %02x got %02x\n", lf->lfUnderline, getobj_lf.lfUnderline);
|
|
|
|
ok(lf->lfStrikeOut == getobj_lf.lfStrikeOut, "lfStrikeOut: expect %02x got %02x\n", lf->lfStrikeOut, getobj_lf.lfStrikeOut);
|
|
|
|
ok(lf->lfCharSet == getobj_lf.lfCharSet, "lfCharSet: expect %02x got %02x\n", lf->lfCharSet, getobj_lf.lfCharSet);
|
|
|
|
ok(lf->lfOutPrecision == getobj_lf.lfOutPrecision, "lfOutPrecision: expect %02x got %02x\n", lf->lfOutPrecision, getobj_lf.lfOutPrecision);
|
|
|
|
ok(lf->lfClipPrecision == getobj_lf.lfClipPrecision, "lfClipPrecision: expect %02x got %02x\n", lf->lfClipPrecision, getobj_lf.lfClipPrecision);
|
|
|
|
ok(lf->lfQuality == getobj_lf.lfQuality, "lfQuality: expect %02x got %02x\n", lf->lfQuality, getobj_lf.lfQuality);
|
|
|
|
ok(lf->lfPitchAndFamily == getobj_lf.lfPitchAndFamily, "lfPitchAndFamily: expect %02x got %02x\n", lf->lfPitchAndFamily, getobj_lf.lfPitchAndFamily);
|
|
|
|
ok(!lstrcmpA(lf->lfFaceName, getobj_lf.lfFaceName) ||
|
|
|
|
broken(!memcmp(lf->lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */
|
2006-04-03 14:59:27 +02:00
|
|
|
"%s: font names don't match: %s != %s\n", test, lf->lfFaceName, getobj_lf.lfFaceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HFONT create_font(const char* test, const LOGFONTA* lf)
|
|
|
|
{
|
|
|
|
HFONT hfont = CreateFontIndirectA(lf);
|
|
|
|
ok(hfont != 0, "%s: CreateFontIndirect failed\n", test);
|
|
|
|
if (hfont)
|
|
|
|
check_font(test, lf, hfont);
|
|
|
|
return hfont;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_logfont(void)
|
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof lf);
|
|
|
|
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfWidth = 16;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
|
|
|
|
lstrcpyA(lf.lfFaceName, "Arial");
|
|
|
|
hfont = create_font("Arial", &lf);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
memset(&lf, 'A', sizeof(lf));
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
|
|
|
|
|
|
|
|
lf.lfFaceName[LF_FACESIZE - 1] = 0;
|
|
|
|
check_font("AAA...", &lf, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK font_enum_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2006-04-03 14:59:27 +02:00
|
|
|
{
|
|
|
|
if (type & RASTER_FONTTYPE)
|
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA *lf = (LOGFONTA *)lParam;
|
2006-04-03 14:59:27 +02:00
|
|
|
*lf = *elf;
|
|
|
|
return 0; /* stop enumeration */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1; /* continue enumeration */
|
|
|
|
}
|
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
static void compare_tm(const TEXTMETRICA *tm, const TEXTMETRICA *otm)
|
|
|
|
{
|
|
|
|
ok(tm->tmHeight == otm->tmHeight, "tmHeight %d != %d\n", tm->tmHeight, otm->tmHeight);
|
|
|
|
ok(tm->tmAscent == otm->tmAscent, "tmAscent %d != %d\n", tm->tmAscent, otm->tmAscent);
|
|
|
|
ok(tm->tmDescent == otm->tmDescent, "tmDescent %d != %d\n", tm->tmDescent, otm->tmDescent);
|
|
|
|
ok(tm->tmInternalLeading == otm->tmInternalLeading, "tmInternalLeading %d != %d\n", tm->tmInternalLeading, otm->tmInternalLeading);
|
|
|
|
ok(tm->tmExternalLeading == otm->tmExternalLeading, "tmExternalLeading %d != %d\n", tm->tmExternalLeading, otm->tmExternalLeading);
|
|
|
|
ok(tm->tmAveCharWidth == otm->tmAveCharWidth, "tmAveCharWidth %d != %d\n", tm->tmAveCharWidth, otm->tmAveCharWidth);
|
|
|
|
ok(tm->tmMaxCharWidth == otm->tmMaxCharWidth, "tmMaxCharWidth %d != %d\n", tm->tmMaxCharWidth, otm->tmMaxCharWidth);
|
|
|
|
ok(tm->tmWeight == otm->tmWeight, "tmWeight %d != %d\n", tm->tmWeight, otm->tmWeight);
|
|
|
|
ok(tm->tmOverhang == otm->tmOverhang, "tmOverhang %d != %d\n", tm->tmOverhang, otm->tmOverhang);
|
|
|
|
ok(tm->tmDigitizedAspectX == otm->tmDigitizedAspectX, "tmDigitizedAspectX %d != %d\n", tm->tmDigitizedAspectX, otm->tmDigitizedAspectX);
|
|
|
|
ok(tm->tmDigitizedAspectY == otm->tmDigitizedAspectY, "tmDigitizedAspectY %d != %d\n", tm->tmDigitizedAspectY, otm->tmDigitizedAspectY);
|
|
|
|
ok(tm->tmFirstChar == otm->tmFirstChar, "tmFirstChar %d != %d\n", tm->tmFirstChar, otm->tmFirstChar);
|
|
|
|
ok(tm->tmLastChar == otm->tmLastChar, "tmLastChar %d != %d\n", tm->tmLastChar, otm->tmLastChar);
|
|
|
|
ok(tm->tmDefaultChar == otm->tmDefaultChar, "tmDefaultChar %d != %d\n", tm->tmDefaultChar, otm->tmDefaultChar);
|
|
|
|
ok(tm->tmBreakChar == otm->tmBreakChar, "tmBreakChar %d != %d\n", tm->tmBreakChar, otm->tmBreakChar);
|
|
|
|
ok(tm->tmItalic == otm->tmItalic, "tmItalic %d != %d\n", tm->tmItalic, otm->tmItalic);
|
|
|
|
ok(tm->tmUnderlined == otm->tmUnderlined, "tmUnderlined %d != %d\n", tm->tmUnderlined, otm->tmUnderlined);
|
|
|
|
ok(tm->tmStruckOut == otm->tmStruckOut, "tmStruckOut %d != %d\n", tm->tmStruckOut, otm->tmStruckOut);
|
|
|
|
ok(tm->tmPitchAndFamily == otm->tmPitchAndFamily, "tmPitchAndFamily %d != %d\n", tm->tmPitchAndFamily, otm->tmPitchAndFamily);
|
|
|
|
ok(tm->tmCharSet == otm->tmCharSet, "tmCharSet %d != %d\n", tm->tmCharSet, otm->tmCharSet);
|
|
|
|
}
|
|
|
|
|
2008-04-03 14:55:49 +02:00
|
|
|
static void test_font_metrics(HDC hdc, HFONT hfont, LONG lfHeight,
|
|
|
|
LONG lfWidth, const char *test_str,
|
2006-04-03 14:59:27 +02:00
|
|
|
INT test_str_len, const TEXTMETRICA *tm_orig,
|
2008-01-08 08:55:34 +01:00
|
|
|
const SIZE *size_orig, INT width_of_A_orig,
|
2006-04-03 14:59:27 +02:00
|
|
|
INT scale_x, INT scale_y)
|
|
|
|
{
|
2008-01-08 08:55:34 +01:00
|
|
|
LOGFONTA lf;
|
2013-10-17 01:55:20 +02:00
|
|
|
OUTLINETEXTMETRICA otm;
|
2006-04-03 14:59:27 +02:00
|
|
|
TEXTMETRICA tm;
|
|
|
|
SIZE size;
|
2008-01-20 14:21:45 +01:00
|
|
|
INT width_of_A, cx, cy;
|
2008-06-24 09:13:31 +02:00
|
|
|
UINT ret;
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
if (!hfont)
|
|
|
|
return;
|
|
|
|
|
2008-10-06 15:26:48 +02:00
|
|
|
ok(GetCurrentObject(hdc, OBJ_FONT) == hfont, "hfont should be selected\n");
|
2008-01-08 08:55:34 +01:00
|
|
|
|
2008-10-06 15:26:48 +02:00
|
|
|
GetObjectA(hfont, sizeof(lf), &lf);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
if (GetOutlineTextMetricsA(hdc, 0, NULL))
|
|
|
|
{
|
|
|
|
otm.otmSize = sizeof(otm) / 2;
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm.otmSize, &otm);
|
|
|
|
ok(ret == sizeof(otm)/2 /* XP */ ||
|
|
|
|
ret == 1 /* Win9x */, "expected sizeof(otm)/2, got %u\n", ret);
|
|
|
|
|
|
|
|
memset(&otm, 0x1, sizeof(otm));
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm.otmSize, &otm);
|
|
|
|
ok(ret == sizeof(otm) /* XP */ ||
|
|
|
|
ret == 1 /* Win9x */, "expected sizeof(otm), got %u\n", ret);
|
|
|
|
|
|
|
|
memset(&tm, 0x2, sizeof(tm));
|
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
|
|
|
ok(ret, "GetTextMetricsA failed\n");
|
|
|
|
/* the structure size is aligned */
|
|
|
|
if (memcmp(&tm, &otm.otmTextMetrics, FIELD_OFFSET(TEXTMETRICA, tmCharSet) + 1))
|
|
|
|
{
|
|
|
|
ok(0, "tm != otm\n");
|
|
|
|
compare_tm(&tm, &otm.otmTextMetrics);
|
|
|
|
}
|
|
|
|
|
|
|
|
tm = otm.otmTextMetrics;
|
|
|
|
if (0) /* these metrics are scaled too, but with rounding errors */
|
|
|
|
{
|
|
|
|
ok(otm.otmAscent == tm.tmAscent, "ascent %d != %d\n", otm.otmAscent, tm.tmAscent);
|
|
|
|
ok(otm.otmDescent == -tm.tmDescent, "descent %d != %d\n", otm.otmDescent, -tm.tmDescent);
|
|
|
|
}
|
|
|
|
ok(otm.otmMacAscent == tm.tmAscent, "ascent %d != %d\n", otm.otmMacAscent, tm.tmAscent);
|
|
|
|
ok(otm.otmDescent < 0, "otm.otmDescent should be < 0\n");
|
|
|
|
ok(otm.otmMacDescent < 0, "otm.otmMacDescent should be < 0\n");
|
|
|
|
ok(tm.tmDescent > 0, "tm.tmDescent should be > 0\n");
|
|
|
|
ok(otm.otmMacDescent == -tm.tmDescent, "descent %d != %d\n", otm.otmMacDescent, -tm.tmDescent);
|
|
|
|
ok(otm.otmEMSquare == 2048, "expected 2048, got %d\n", otm.otmEMSquare);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
|
|
|
ok(ret, "GetTextMetricsA failed\n");
|
|
|
|
}
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2008-01-20 14:21:45 +01:00
|
|
|
cx = tm.tmAveCharWidth / tm_orig->tmAveCharWidth;
|
|
|
|
cy = tm.tmHeight / tm_orig->tmHeight;
|
2009-02-18 23:44:44 +01:00
|
|
|
ok(cx == scale_x && cy == scale_y, "height %d: expected scale_x %d, scale_y %d, got cx %d, cy %d\n",
|
|
|
|
lfHeight, scale_x, scale_y, cx, cy);
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(tm.tmHeight == tm_orig->tmHeight * scale_y, "height %d != %d\n", tm.tmHeight, tm_orig->tmHeight * scale_y);
|
|
|
|
ok(tm.tmAscent == tm_orig->tmAscent * scale_y, "ascent %d != %d\n", tm.tmAscent, tm_orig->tmAscent * scale_y);
|
|
|
|
ok(tm.tmDescent == tm_orig->tmDescent * scale_y, "descent %d != %d\n", tm.tmDescent, tm_orig->tmDescent * scale_y);
|
|
|
|
ok(near_match(tm.tmAveCharWidth, tm_orig->tmAveCharWidth * scale_x), "ave width %d != %d\n", tm.tmAveCharWidth, tm_orig->tmAveCharWidth * scale_x);
|
|
|
|
ok(near_match(tm.tmMaxCharWidth, tm_orig->tmMaxCharWidth * scale_x), "max width %d != %d\n", tm.tmMaxCharWidth, tm_orig->tmMaxCharWidth * scale_x);
|
2008-01-08 08:55:34 +01:00
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(lf.lfHeight == lfHeight, "lfHeight %d != %d\n", lf.lfHeight, lfHeight);
|
2008-04-03 14:55:49 +02:00
|
|
|
if (lf.lfHeight)
|
|
|
|
{
|
|
|
|
if (lf.lfWidth)
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(lf.lfWidth == tm.tmAveCharWidth, "lfWidth %d != tm %d\n", lf.lfWidth, tm.tmAveCharWidth);
|
2008-04-03 14:55:49 +02:00
|
|
|
}
|
|
|
|
else
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(lf.lfWidth == lfWidth, "lfWidth %d != %d\n", lf.lfWidth, lfWidth);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
GetTextExtentPoint32A(hdc, test_str, test_str_len, &size);
|
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(near_match(size.cx, size_orig->cx * scale_x), "cx %d != %d\n", size.cx, size_orig->cx * scale_x);
|
|
|
|
ok(size.cy == size_orig->cy * scale_y, "cy %d != %d\n", size.cy, size_orig->cy * scale_y);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2008-01-08 08:55:34 +01:00
|
|
|
GetCharWidthA(hdc, 'A', 'A', &width_of_A);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(near_match(width_of_A, width_of_A_orig * scale_x), "width A %d != %d\n", width_of_A, width_of_A_orig * scale_x);
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|
|
|
|
|
2008-01-08 08:55:34 +01:00
|
|
|
/* Test how GDI scales bitmap font metrics */
|
2006-04-03 14:59:27 +02:00
|
|
|
static void test_bitmap_font(void)
|
|
|
|
{
|
|
|
|
static const char test_str[11] = "Test String";
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA bitmap_lf;
|
|
|
|
HFONT hfont, old_hfont;
|
|
|
|
TEXTMETRICA tm_orig;
|
|
|
|
SIZE size_orig;
|
2008-04-03 14:55:49 +02:00
|
|
|
INT ret, i, width_orig, height_orig, scale, lfWidth;
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
hdc = CreateCompatibleDC(0);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
/* "System" has only 1 pixel size defined, otherwise the test breaks */
|
|
|
|
ret = EnumFontFamiliesA(hdc, "System", font_enum_proc, (LPARAM)&bitmap_lf);
|
|
|
|
if (ret)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
skip("no bitmap fonts were found, skipping the test\n");
|
|
|
|
return;
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|
|
|
|
|
2006-10-12 22:56:45 +02:00
|
|
|
trace("found bitmap font %s, height %d\n", bitmap_lf.lfFaceName, bitmap_lf.lfHeight);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
height_orig = bitmap_lf.lfHeight;
|
2008-04-03 14:55:49 +02:00
|
|
|
lfWidth = bitmap_lf.lfWidth;
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2008-04-03 14:55:49 +02:00
|
|
|
hfont = create_font("bitmap", &bitmap_lf);
|
2006-04-03 14:59:27 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
ok(GetTextMetricsA(hdc, &tm_orig), "GetTextMetricsA failed\n");
|
|
|
|
ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
|
|
|
|
ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
|
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
2008-04-03 14:55:49 +02:00
|
|
|
bitmap_lf.lfHeight = 0;
|
|
|
|
bitmap_lf.lfWidth = 4;
|
|
|
|
hfont = create_font("bitmap", &bitmap_lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-04-03 14:55:49 +02:00
|
|
|
test_font_metrics(hdc, hfont, 0, 4, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, 1);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-04-03 14:55:49 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
bitmap_lf.lfHeight = height_orig;
|
|
|
|
bitmap_lf.lfWidth = lfWidth;
|
|
|
|
|
2006-04-03 14:59:27 +02:00
|
|
|
/* test fractional scaling */
|
2009-02-20 15:40:44 +01:00
|
|
|
for (i = 1; i <= height_orig * 6; i++)
|
2006-04-03 14:59:27 +02:00
|
|
|
{
|
2008-01-20 14:21:45 +01:00
|
|
|
INT nearest_height;
|
|
|
|
|
|
|
|
bitmap_lf.lfHeight = i;
|
2006-04-03 14:59:27 +02:00
|
|
|
hfont = create_font("fractional", &bitmap_lf);
|
2008-01-20 14:21:45 +01:00
|
|
|
scale = (i + height_orig - 1) / height_orig;
|
|
|
|
nearest_height = scale * height_orig;
|
2009-02-20 15:40:44 +01:00
|
|
|
/* Only jump to the next height if the difference <= 25% original height */
|
|
|
|
if (scale > 2 && nearest_height - i > height_orig / 4) scale--;
|
2009-02-23 12:46:21 +01:00
|
|
|
/* The jump between unscaled and doubled is delayed by 1 in winnt+ but not in win9x,
|
|
|
|
so we'll not test this particular height. */
|
|
|
|
else if(scale == 2 && nearest_height - i == (height_orig / 4)) continue;
|
2009-02-20 15:40:44 +01:00
|
|
|
else if(scale == 2 && nearest_height - i > (height_orig / 4 - 1)) scale--;
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-04-03 14:55:49 +02:00
|
|
|
test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, scale);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test integer scaling 3x2 */
|
|
|
|
bitmap_lf.lfHeight = height_orig * 2;
|
|
|
|
bitmap_lf.lfWidth *= 3;
|
|
|
|
hfont = create_font("3x2", &bitmap_lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-04-03 14:55:49 +02:00
|
|
|
test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 2);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2006-04-03 14:59:27 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
/* test integer scaling 3x3 */
|
|
|
|
bitmap_lf.lfHeight = height_orig * 3;
|
|
|
|
bitmap_lf.lfWidth = 0;
|
|
|
|
hfont = create_font("3x3", &bitmap_lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-04-03 14:55:49 +02:00
|
|
|
test_font_metrics(hdc, hfont, bitmap_lf.lfHeight, 0, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 3);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2006-04-03 14:59:27 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
DeleteDC(hdc);
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
/* Test how GDI scales outline font metrics */
|
|
|
|
static void test_outline_font(void)
|
|
|
|
{
|
|
|
|
static const char test_str[11] = "Test String";
|
2008-10-06 15:27:13 +02:00
|
|
|
HDC hdc, hdc_2;
|
2008-06-24 09:13:31 +02:00
|
|
|
LOGFONTA lf;
|
2008-10-06 15:27:13 +02:00
|
|
|
HFONT hfont, old_hfont, old_hfont_2;
|
2008-06-24 09:13:31 +02:00
|
|
|
OUTLINETEXTMETRICA otm;
|
|
|
|
SIZE size_orig;
|
|
|
|
INT width_orig, height_orig, lfWidth;
|
|
|
|
XFORM xform;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
MAT2 mat2 = { {0x8000,0}, {0,0}, {0,0}, {0x8000,0} };
|
|
|
|
POINT pt;
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
hfont = create_font("outline", &lf);
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
ok(GetOutlineTextMetricsA(hdc, sizeof(otm), &otm), "GetTextMetricsA failed\n");
|
|
|
|
ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
|
|
|
|
ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
|
|
|
|
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, otm.otmTextMetrics.tmAveCharWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
/* font of otmEMSquare height helps to avoid a lot of rounding errors */
|
|
|
|
lf.lfHeight = otm.otmEMSquare;
|
|
|
|
lf.lfHeight = -lf.lfHeight;
|
|
|
|
hfont = create_font("outline", &lf);
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
ok(GetOutlineTextMetricsA(hdc, sizeof(otm), &otm), "GetTextMetricsA failed\n");
|
|
|
|
ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
|
|
|
|
ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
|
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
height_orig = otm.otmTextMetrics.tmHeight;
|
|
|
|
lfWidth = otm.otmTextMetrics.tmAveCharWidth;
|
|
|
|
|
|
|
|
/* test integer scaling 3x2 */
|
|
|
|
lf.lfHeight = height_orig * 2;
|
|
|
|
lf.lfWidth = lfWidth * 3;
|
|
|
|
hfont = create_font("3x2", &lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 3, 2);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
/* test integer scaling 3x3 */
|
|
|
|
lf.lfHeight = height_orig * 3;
|
|
|
|
lf.lfWidth = lfWidth * 3;
|
|
|
|
hfont = create_font("3x3", &lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 3, 3);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
/* test integer scaling 1x1 */
|
|
|
|
lf.lfHeight = height_orig * 1;
|
|
|
|
lf.lfWidth = lfWidth * 1;
|
|
|
|
hfont = create_font("1x1", &lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
/* test integer scaling 1x1 */
|
|
|
|
lf.lfHeight = height_orig;
|
|
|
|
lf.lfWidth = 0;
|
|
|
|
hfont = create_font("1x1", &lf);
|
2008-10-06 15:26:48 +02:00
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
|
|
|
/* with an identity matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
ok(gm.gmCellIncX == width_orig, "incX %d != %d\n", gm.gmCellIncX, width_orig);
|
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
/* with a custom matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat2);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
ok(gm.gmCellIncX == width_orig/2, "incX %d != %d\n", gm.gmCellIncX, width_orig/2);
|
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
|
2008-10-06 15:27:13 +02:00
|
|
|
/* Test that changing the DC transformation affects only the font
|
|
|
|
* selected on this DC and doesn't affect the same font selected on
|
|
|
|
* another DC.
|
|
|
|
*/
|
|
|
|
hdc_2 = CreateCompatibleDC(0);
|
|
|
|
old_hfont_2 = SelectObject(hdc_2, hfont);
|
|
|
|
test_font_metrics(hdc_2, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
SetMapMode(hdc, MM_ANISOTROPIC);
|
2008-10-06 15:27:13 +02:00
|
|
|
|
|
|
|
/* font metrics on another DC should be unchanged */
|
|
|
|
test_font_metrics(hdc_2, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
/* test restrictions of compatibility mode GM_COMPATIBLE */
|
|
|
|
/* part 1: rescaling only X should not change font scaling on screen.
|
|
|
|
So compressing the X axis by 2 is not done, and this
|
|
|
|
appears as X scaling of 2 that no one requested. */
|
|
|
|
SetWindowExtEx(hdc, 100, 100, NULL);
|
|
|
|
SetViewportExtEx(hdc, 50, 100, NULL);
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 2, 1);
|
2008-10-06 15:27:13 +02:00
|
|
|
/* font metrics on another DC should be unchanged */
|
|
|
|
test_font_metrics(hdc_2, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
2008-07-07 17:18:10 +02:00
|
|
|
|
|
|
|
/* part 2: rescaling only Y should change font scaling.
|
|
|
|
As also X is scaled by a factor of 2, but this is not
|
|
|
|
requested by the DC transformation, we get a scaling factor
|
|
|
|
of 2 in the X coordinate. */
|
|
|
|
SetViewportExtEx(hdc, 100, 200, NULL);
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 2, 1);
|
2008-10-06 15:27:13 +02:00
|
|
|
/* font metrics on another DC should be unchanged */
|
|
|
|
test_font_metrics(hdc_2, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
2008-07-07 17:18:10 +02:00
|
|
|
|
|
|
|
/* restore scaling */
|
|
|
|
SetMapMode(hdc, MM_TEXT);
|
|
|
|
|
2008-10-06 15:27:13 +02:00
|
|
|
/* font metrics on another DC should be unchanged */
|
|
|
|
test_font_metrics(hdc_2, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
|
|
|
SelectObject(hdc_2, old_hfont_2);
|
|
|
|
DeleteDC(hdc_2);
|
|
|
|
|
2008-06-24 09:13:31 +02:00
|
|
|
if (!SetGraphicsMode(hdc, GM_ADVANCED))
|
|
|
|
{
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
skip("GM_ADVANCED is not supported on this platform\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xform.eM11 = 20.0f;
|
|
|
|
xform.eM12 = 0.0f;
|
|
|
|
xform.eM21 = 0.0f;
|
|
|
|
xform.eM22 = 20.0f;
|
|
|
|
xform.eDx = 0.0f;
|
|
|
|
xform.eDy = 0.0f;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = SetWorldTransform(hdc, &xform);
|
|
|
|
ok(ret, "SetWorldTransform error %u\n", GetLastError());
|
|
|
|
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
|
|
|
/* with an identity matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
|
|
|
ok(gm.gmCellIncX == pt.x, "incX %d != %d\n", gm.gmCellIncX, pt.x);
|
|
|
|
ok(gm.gmCellIncX == 20 * width_orig, "incX %d != %d\n", gm.gmCellIncX, 20 * width_orig);
|
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
/* with a custom matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat2);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
|
|
|
ok(gm.gmCellIncX == pt.x/2, "incX %d != %d\n", gm.gmCellIncX, pt.x/2);
|
2008-07-21 10:15:16 +02:00
|
|
|
ok(near_match(gm.gmCellIncX, 10 * width_orig), "incX %d != %d\n", gm.gmCellIncX, 10 * width_orig);
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = SetMapMode(hdc, MM_LOMETRIC);
|
|
|
|
ok(ret == MM_TEXT, "expected MM_TEXT, got %d, error %u\n", ret, GetLastError());
|
|
|
|
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
|
|
|
/* with an identity matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
2008-07-31 17:16:50 +02:00
|
|
|
ok(near_match(gm.gmCellIncX, pt.x), "incX %d != %d\n", gm.gmCellIncX, pt.x);
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
/* with a custom matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat2);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
2008-07-31 17:16:50 +02:00
|
|
|
ok(near_match(gm.gmCellIncX, (pt.x + 1)/2), "incX %d != %d\n", gm.gmCellIncX, (pt.x + 1)/2);
|
2008-06-24 09:13:31 +02:00
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = SetMapMode(hdc, MM_TEXT);
|
|
|
|
ok(ret == MM_LOMETRIC, "expected MM_LOMETRIC, got %d, error %u\n", ret, GetLastError());
|
|
|
|
|
|
|
|
test_font_metrics(hdc, hfont, lf.lfHeight, lf.lfWidth, test_str, sizeof(test_str), &otm.otmTextMetrics, &size_orig, width_orig, 1, 1);
|
|
|
|
|
|
|
|
/* with an identity matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
|
|
|
ok(gm.gmCellIncX == pt.x, "incX %d != %d\n", gm.gmCellIncX, pt.x);
|
|
|
|
ok(gm.gmCellIncX == 20 * width_orig, "incX %d != %d\n", gm.gmCellIncX, 20 * width_orig);
|
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
/* with a custom matrix */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat2);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %d\n", GetLastError());
|
|
|
|
pt.x = width_orig; pt.y = 0;
|
|
|
|
LPtoDP(hdc, &pt, 1);
|
|
|
|
ok(gm.gmCellIncX == pt.x/2, "incX %d != %d\n", gm.gmCellIncX, pt.x/2);
|
|
|
|
ok(gm.gmCellIncX == 10 * width_orig, "incX %d != %d\n", gm.gmCellIncX, 10 * width_orig);
|
|
|
|
ok(gm.gmCellIncY == 0, "incY %d != 0\n", gm.gmCellIncY);
|
|
|
|
|
2008-10-06 15:26:48 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
2008-06-24 09:13:31 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK find_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2006-04-03 14:59:27 +02:00
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA *lf = (LOGFONTA *)lParam;
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
if (elf->lfHeight == lf->lfHeight && !strcmp(elf->lfFaceName, lf->lfFaceName))
|
|
|
|
{
|
|
|
|
*lf = *elf;
|
|
|
|
return 0; /* stop enumeration */
|
|
|
|
}
|
|
|
|
return 1; /* continue enumeration */
|
|
|
|
}
|
|
|
|
|
2012-10-18 20:11:04 +02:00
|
|
|
static BOOL is_CJK(void)
|
|
|
|
{
|
|
|
|
return (system_lang_id == LANG_CHINESE || system_lang_id == LANG_JAPANESE || system_lang_id == LANG_KOREAN);
|
|
|
|
}
|
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
#define FH_SCALE 0x80000000
|
2006-04-03 14:59:27 +02:00
|
|
|
static void test_bitmap_font_metrics(void)
|
|
|
|
{
|
2015-10-01 13:59:26 +02:00
|
|
|
static const WORD skip_rtl[] = {LANG_ARABIC, LANG_HEBREW, 0};
|
2006-04-03 14:59:27 +02:00
|
|
|
static const struct font_data
|
|
|
|
{
|
|
|
|
const char face_name[LF_FACESIZE];
|
|
|
|
int weight, height, ascent, descent, int_leading, ext_leading;
|
2009-02-19 13:34:34 +01:00
|
|
|
int ave_char_width, max_char_width, dpi;
|
2011-10-19 17:22:29 +02:00
|
|
|
BYTE first_char, last_char, def_char, break_char;
|
2006-09-21 11:43:16 +02:00
|
|
|
DWORD ansi_bitfield;
|
2015-10-01 13:59:26 +02:00
|
|
|
const WORD *skip_lang_id;
|
2012-04-10 15:54:37 +02:00
|
|
|
int scaled_height;
|
2006-04-03 14:59:27 +02:00
|
|
|
} fd[] =
|
|
|
|
{
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 13 },
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 13 },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl, 16 },
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 6, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 8, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 10, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 14, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2, 0, 16 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, FH_SCALE | 18, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC, 0, 16 },
|
|
|
|
|
2011-10-19 17:22:29 +02:00
|
|
|
{ "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 19, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 24, 96, 0x20, 0xff, 0x81, 0x40, FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 20, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 24, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 6, 0, 12, 24, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 25, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x81, 0x40, FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32, 96, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 17, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 25, 20, 5, 5, 0, 10, 21, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 25, 20, 5, 5, 0, 10, 21, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 6, 0, 12, 24, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 24, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 36, 29, 7, 6, 0, 15, 30, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 36, 29, 7, 6, 0, 15, 30, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 46, 37, 9, 6, 0, 20, 40, 120, 0x20, 0xff, 0x81, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Sans Serif", FW_NORMAL, 46, 37, 9, 6, 0, 20, 40, 120, 0x20, 0xff, 0x7f, 0x20, FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 16, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 18, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 19, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 17, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 22, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 23, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 23, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 26, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 27, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 33, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 34, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 14, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 13, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 18, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 15, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 23, 18, 5, 3, 0, 10, 21, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 23, 18, 5, 3, 0, 10, 19, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_NORMAL, 27, 21, 6, 4, 0, 12, 23, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_MEDIUM, 27, 22, 5, 2, 0, 12, 30, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 33, 26, 7, 3, 0, 14, 30, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "MS Serif", FW_MEDIUM, 32, 25, 7, 2, 0, 14, 32, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "MS Serif", FW_NORMAL, 43, 34, 9, 3, 0, 19, 39, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Courier", FW_NORMAL, 25, 20, 5, 0, 0, 15, 15, 120, 0x20, 0xff, 0x40, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 15, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "System", FW_NORMAL, 18, 16, 2, 0, 2, 8, 16, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2011-10-19 17:22:29 +02:00
|
|
|
|
|
|
|
{ "System", FW_BOLD, 20, 16, 4, 4, 0, 9, 14, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "System", FW_BOLD, 20, 16, 4, 4, 0, 9, 17, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 2, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 2, 4, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 5, 4, 1, 1, 0, 3, 4, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
|
2011-10-19 17:22:29 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 5, 4, 1, 1, 0, 2, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 5, 4, 1, 0, 0, 3, 6, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 13, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
|
2011-10-19 17:22:29 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
2012-10-18 20:11:41 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 0, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 7, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1, skip_rtl},
|
2011-10-19 17:22:29 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
2012-10-18 20:11:41 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 0, 0, 5, 10, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2, skip_rtl},
|
2011-10-19 17:22:29 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
2012-10-18 20:11:41 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 4, 9, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 0, 0, 6, 12, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2015-10-01 13:59:26 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC, skip_rtl},
|
2012-10-18 20:11:41 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 11, 9, 2, 2, 0, 4, 10, 96, 0x00, 0xff, 0x60, 0x00, FS_ARABIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "Small Fonts", FW_NORMAL, 11, 9, 2, 0, 0, 7, 14, 96, 0x20, 0xff, 0x80, 0x20, FS_JISJAPAN },
|
2011-10-19 17:22:29 +02:00
|
|
|
|
|
|
|
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 2, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 3, 2, 1, 0, 0, 1, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 5, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 6, 5, 1, 1, 0, 3, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 7, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 8, 7, 1, 1, 0, 4, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN2 | FS_CYRILLIC },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 9, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 12, 10, 2, 2, 0, 5, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 12, 10, 2, 2, 0, 6, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 13, 11, 2, 2, 0, 6, 12, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_JISJAPAN },
|
|
|
|
{ "Small Fonts", FW_NORMAL, 13, 11, 2, 2, 0, 6, 11, 120, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
|
|
|
|
|
|
|
{ "Fixedsys", FW_NORMAL, 15, 12, 3, 3, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 },
|
|
|
|
{ "Fixedsys", FW_NORMAL, 16, 12, 4, 3, 0, 8, 8, 96, 0x20, 0xff, 0x80, 0x20, FS_CYRILLIC },
|
2012-10-18 20:09:59 +02:00
|
|
|
{ "FixedSys", FW_NORMAL, 18, 16, 2, 0, 0, 8, 16, 96, 0x20, 0xff, 0xa0, 0x20, FS_JISJAPAN },
|
2009-02-19 13:34:34 +01:00
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
{ "Fixedsys", FW_NORMAL, 20, 16, 4, 2, 0, 10, 10, 120, 0x20, 0xff, 0x80, 0x20, FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC }
|
2006-09-21 11:43:16 +02:00
|
|
|
|
|
|
|
/* FIXME: add "Terminal" */
|
2006-04-03 14:59:27 +02:00
|
|
|
};
|
2012-04-10 15:54:37 +02:00
|
|
|
static const int font_log_pixels[] = { 96, 120 };
|
2006-04-03 14:59:27 +02:00
|
|
|
HDC hdc;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2006-04-03 14:59:27 +02:00
|
|
|
HFONT hfont, old_hfont;
|
2013-10-17 01:55:20 +02:00
|
|
|
TEXTMETRICA tm;
|
2012-04-10 15:54:37 +02:00
|
|
|
INT ret, i, expected_cs, screen_log_pixels, diff, font_res;
|
|
|
|
char face_name[LF_FACESIZE];
|
|
|
|
CHARSETINFO csi;
|
2011-01-23 17:42:29 +01:00
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
trace("system language id %04x\n", system_lang_id);
|
|
|
|
|
|
|
|
expected_cs = GetACP();
|
|
|
|
if (!TranslateCharsetInfo(ULongToPtr(expected_cs), &csi, TCI_SRCCODEPAGE))
|
|
|
|
{
|
|
|
|
skip("TranslateCharsetInfo failed for code page %d\n", expected_cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
expected_cs = csi.ciCharset;
|
|
|
|
trace("ACP %d -> charset %d\n", GetACP(), expected_cs);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
2016-02-09 15:24:28 +01:00
|
|
|
ok(hdc != NULL, "failed to create hdc\n");
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
trace("logpixelsX %d, logpixelsY %d\n", GetDeviceCaps(hdc, LOGPIXELSX),
|
|
|
|
GetDeviceCaps(hdc, LOGPIXELSY));
|
|
|
|
|
|
|
|
screen_log_pixels = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
|
|
diff = 32768;
|
|
|
|
font_res = 0;
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(font_log_pixels); i++)
|
2012-04-10 15:54:37 +02:00
|
|
|
{
|
|
|
|
int new_diff = abs(font_log_pixels[i] - screen_log_pixels);
|
|
|
|
if (new_diff < diff)
|
|
|
|
{
|
|
|
|
diff = new_diff;
|
|
|
|
font_res = font_log_pixels[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
trace("best font resolution is %d\n", font_res);
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(fd); i++)
|
2006-04-03 14:59:27 +02:00
|
|
|
{
|
2012-04-10 15:54:37 +02:00
|
|
|
int bit, height;
|
2006-09-21 11:43:16 +02:00
|
|
|
|
2006-04-03 14:59:27 +02:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
|
2012-04-10 15:54:37 +02:00
|
|
|
height = fd[i].height & ~FH_SCALE;
|
|
|
|
lf.lfHeight = height;
|
2006-04-03 14:59:27 +02:00
|
|
|
strcpy(lf.lfFaceName, fd[i].face_name);
|
2006-09-21 11:43:16 +02:00
|
|
|
|
|
|
|
for(bit = 0; bit < 32; bit++)
|
2006-04-03 14:59:27 +02:00
|
|
|
{
|
2012-06-01 06:49:05 +02:00
|
|
|
GLYPHMETRICS gm;
|
2006-09-21 11:43:16 +02:00
|
|
|
DWORD fs[2];
|
2011-01-02 18:50:17 +01:00
|
|
|
BOOL bRet;
|
2006-09-21 11:43:16 +02:00
|
|
|
|
|
|
|
fs[0] = 1L << bit;
|
|
|
|
fs[1] = 0;
|
|
|
|
if((fd[i].ansi_bitfield & fs[0]) == 0) continue;
|
|
|
|
if(!TranslateCharsetInfo( fs, &csi, TCI_SRCFONTSIG )) continue;
|
|
|
|
|
|
|
|
lf.lfCharSet = csi.ciCharset;
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesExA(hdc, &lf, find_font_proc, (LPARAM)&lf, 0);
|
2012-04-10 15:54:37 +02:00
|
|
|
if (fd[i].height & FH_SCALE)
|
|
|
|
ok(ret, "scaled font height %d should not be enumerated\n", height);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (font_res == fd[i].dpi && lf.lfCharSet == expected_cs)
|
|
|
|
{
|
2016-02-11 03:02:14 +01:00
|
|
|
todo_wine_if (ret) /* FIXME: Remove once Wine is fixed */
|
2012-04-10 15:54:37 +02:00
|
|
|
ok(!ret, "%s height %d charset %d dpi %d should be enumerated\n", lf.lfFaceName, lf.lfHeight, lf.lfCharSet, fd[i].dpi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret && !(fd[i].height & FH_SCALE))
|
|
|
|
continue;
|
2006-09-21 11:43:16 +02:00
|
|
|
|
|
|
|
hfont = create_font(lf.lfFaceName, &lf);
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2012-04-10 15:54:37 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextFaceA(hdc, sizeof(face_name), face_name);
|
2012-04-10 15:54:37 +02:00
|
|
|
ok(ret, "GetTextFace error %u\n", GetLastError());
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
if (strcmp(face_name, fd[i].face_name) != 0)
|
2012-04-10 15:54:37 +02:00
|
|
|
{
|
|
|
|
ok(ret != ANSI_CHARSET, "font charset should not be ANSI_CHARSET\n");
|
|
|
|
ok(ret != expected_cs, "font charset %d should not be %d\n", ret, expected_cs);
|
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-06-01 06:49:05 +02:00
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
2018-11-13 10:03:35 +01:00
|
|
|
todo_wine
|
2012-06-01 06:49:05 +02:00
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutline should fail for a bitmap font\n");
|
2018-11-13 10:03:35 +01:00
|
|
|
ret = GetLastError();
|
|
|
|
ok(ret == ERROR_CAN_NOT_COMPLETE || ret == 0xdeadbeef /* Win10 */, "Unexpected error %d.\n", ret);
|
2012-06-01 06:49:05 +02:00
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
bRet = GetTextMetricsA(hdc, &tm);
|
2012-06-01 06:49:05 +02:00
|
|
|
ok(bRet, "GetTextMetrics error %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetTextCharset(hdc);
|
2012-10-18 20:11:04 +02:00
|
|
|
if (is_CJK() && lf.lfCharSet == ANSI_CHARSET)
|
|
|
|
ok(ret == ANSI_CHARSET, "got charset %d, expected ANSI_CHARSETd\n", ret);
|
|
|
|
else
|
|
|
|
ok(ret == expected_cs, "got charset %d, expected %d\n", ret, expected_cs);
|
2012-04-10 15:54:37 +02:00
|
|
|
|
2009-02-19 13:34:34 +01:00
|
|
|
if(fd[i].dpi == tm.tmDigitizedAspectX)
|
|
|
|
{
|
2015-10-01 13:59:26 +02:00
|
|
|
int skipme = 0;
|
|
|
|
if (fd[i].skip_lang_id)
|
|
|
|
{
|
|
|
|
int si = 0;
|
|
|
|
skipme = 0;
|
|
|
|
while(!skipme && fd[i].skip_lang_id[si])
|
|
|
|
if (fd[i].skip_lang_id[si++] == system_lang_id)
|
|
|
|
skipme = 1;
|
|
|
|
}
|
|
|
|
if (!skipme)
|
2011-01-23 17:42:29 +01:00
|
|
|
{
|
2012-04-10 15:54:37 +02:00
|
|
|
ok(tm.tmWeight == fd[i].weight, "%s(%d): tm.tmWeight %d != %d\n", fd[i].face_name, height, tm.tmWeight, fd[i].weight);
|
|
|
|
if (fd[i].height & FH_SCALE)
|
|
|
|
ok(tm.tmHeight == fd[i].scaled_height, "%s(%d): tm.tmHeight %d != %d\n", fd[i].face_name, height, tm.tmHeight, fd[i].scaled_height);
|
|
|
|
else
|
|
|
|
ok(tm.tmHeight == fd[i].height, "%s(%d): tm.tmHeight %d != %d\n", fd[i].face_name, fd[i].height, tm.tmHeight, fd[i].height);
|
|
|
|
ok(tm.tmAscent == fd[i].ascent, "%s(%d): tm.tmAscent %d != %d\n", fd[i].face_name, height, tm.tmAscent, fd[i].ascent);
|
|
|
|
ok(tm.tmDescent == fd[i].descent, "%s(%d): tm.tmDescent %d != %d\n", fd[i].face_name, height, tm.tmDescent, fd[i].descent);
|
|
|
|
ok(tm.tmInternalLeading == fd[i].int_leading, "%s(%d): tm.tmInternalLeading %d != %d\n", fd[i].face_name, height, tm.tmInternalLeading, fd[i].int_leading);
|
|
|
|
ok(tm.tmExternalLeading == fd[i].ext_leading, "%s(%d): tm.tmExternalLeading %d != %d\n", fd[i].face_name, height, tm.tmExternalLeading, fd[i].ext_leading);
|
|
|
|
ok(tm.tmAveCharWidth == fd[i].ave_char_width, "%s(%d): tm.tmAveCharWidth %d != %d\n", fd[i].face_name, height, tm.tmAveCharWidth, fd[i].ave_char_width);
|
|
|
|
ok(tm.tmFirstChar == fd[i].first_char, "%s(%d): tm.tmFirstChar = %02x\n", fd[i].face_name, height, tm.tmFirstChar);
|
|
|
|
ok(tm.tmLastChar == fd[i].last_char, "%s(%d): tm.tmLastChar = %02x\n", fd[i].face_name, height, tm.tmLastChar);
|
|
|
|
/* Substitutions like MS Sans Serif,0=MS Sans Serif,204
|
|
|
|
make default char test fail */
|
|
|
|
if (tm.tmCharSet == lf.lfCharSet)
|
|
|
|
ok(tm.tmDefaultChar == fd[i].def_char, "%s(%d): tm.tmDefaultChar = %02x\n", fd[i].face_name, height, tm.tmDefaultChar);
|
|
|
|
ok(tm.tmBreakChar == fd[i].break_char, "%s(%d): tm.tmBreakChar = %02x\n", fd[i].face_name, height, tm.tmBreakChar);
|
|
|
|
ok(tm.tmCharSet == expected_cs || tm.tmCharSet == ANSI_CHARSET, "%s(%d): tm.tmCharSet %d != %d\n", fd[i].face_name, height, tm.tmCharSet, expected_cs);
|
2011-01-23 17:42:29 +01:00
|
|
|
|
|
|
|
/* Don't run the max char width test on System/ANSI_CHARSET. We have extra characters in our font
|
|
|
|
that make the max width bigger */
|
2013-06-17 12:00:53 +02:00
|
|
|
if ((strcmp(lf.lfFaceName, "System") || lf.lfCharSet != ANSI_CHARSET) && tm.tmDigitizedAspectX == 96)
|
2012-04-10 15:54:37 +02:00
|
|
|
ok(tm.tmMaxCharWidth == fd[i].max_char_width, "%s(%d): tm.tmMaxCharWidth %d != %d\n", fd[i].face_name, height, tm.tmMaxCharWidth, fd[i].max_char_width);
|
2011-01-23 17:42:29 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Skipping font metrics test for system langid 0x%x\n",
|
|
|
|
system_lang_id);
|
2009-02-19 13:34:34 +01:00
|
|
|
}
|
2006-09-21 11:43:16 +02:00
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GdiGetCharDimensions(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
LONG ret;
|
|
|
|
SIZE size;
|
|
|
|
LONG avgwidth, height;
|
|
|
|
static const char szAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
2007-03-05 17:29:12 +01:00
|
|
|
|
|
|
|
if (!pGdiGetCharDimensions)
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("GdiGetCharDimensions not available on this platform\n");
|
2007-03-05 17:29:12 +01:00
|
|
|
return;
|
|
|
|
}
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPointA(hdc, szAlphabet, strlen(szAlphabet), &size);
|
2006-04-03 14:59:27 +02:00
|
|
|
avgwidth = ((size.cx / 26) + 1) / 2;
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
ret = pGdiGetCharDimensions(hdc, &tm, &height);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %d instead of %d\n", avgwidth, ret);
|
|
|
|
ok(height == tm.tmHeight, "GdiGetCharDimensions should have set height to %d instead of %d\n", tm.tmHeight, height);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
ret = pGdiGetCharDimensions(hdc, &tm, NULL);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %d instead of %d\n", avgwidth, ret);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
ret = pGdiGetCharDimensions(hdc, NULL, NULL);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %d instead of %d\n", avgwidth, ret);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
height = 0;
|
2007-03-05 17:29:04 +01:00
|
|
|
ret = pGdiGetCharDimensions(hdc, NULL, &height);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %d instead of %d\n", avgwidth, ret);
|
|
|
|
ok(height == size.cy, "GdiGetCharDimensions should have set height to %d instead of %d\n", size.cy, height);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static int CALLBACK create_font_proc(const LOGFONTA *lpelfe,
|
|
|
|
const TEXTMETRICA *lpntme,
|
2011-01-13 11:17:45 +01:00
|
|
|
DWORD FontType, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (FontType & TRUETYPE_FONTTYPE)
|
|
|
|
{
|
|
|
|
HFONT hfont;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(lpelfe);
|
2011-01-13 11:17:45 +01:00
|
|
|
if (hfont)
|
|
|
|
{
|
|
|
|
*(HFONT *)lParam = hfont;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-02-04 13:02:07 +01:00
|
|
|
static void ABCWidths_helper(const char* description, HDC hdc, WORD *glyphs, const ABC *base_abci, const ABC *base_abcw, const ABCFLOAT *base_abcf)
|
2013-09-12 20:01:56 +02:00
|
|
|
{
|
|
|
|
ABC abc[1];
|
|
|
|
ABCFLOAT abcf[1];
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
|
2013-09-12 20:01:56 +02:00
|
|
|
ok(ret, "%s: GetCharABCWidthsI should have succeeded\n", description);
|
|
|
|
ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
|
2018-02-04 13:02:07 +01:00
|
|
|
ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
|
|
|
|
ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
|
2013-09-12 20:01:56 +02:00
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'i', 'i', abc);
|
2013-09-12 20:01:56 +02:00
|
|
|
ok(ret, "%s: GetCharABCWidthsW should have succeeded\n", description);
|
|
|
|
ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
|
2018-02-04 13:02:07 +01:00
|
|
|
ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
|
|
|
|
ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
|
2013-09-12 20:01:56 +02:00
|
|
|
|
|
|
|
ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
|
|
|
|
ok(ret, "%s: GetCharABCWidthsFloatW should have succeeded\n", description);
|
|
|
|
ok (abcf->abcfB > 0.0, "%s: abcfB should be positive\n", description);
|
2018-02-04 13:02:07 +01:00
|
|
|
ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
|
|
|
|
ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
|
2013-09-12 20:01:56 +02:00
|
|
|
}
|
|
|
|
|
2007-12-08 22:55:01 +01:00
|
|
|
static void test_GetCharABCWidths(void)
|
2006-04-08 22:27:34 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
2007-12-08 22:55:01 +01:00
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
2006-04-08 22:27:34 +02:00
|
|
|
ABC abc[1];
|
2013-09-12 20:01:56 +02:00
|
|
|
ABC abcw[1];
|
2011-12-12 11:14:09 +01:00
|
|
|
ABCFLOAT abcf[1];
|
2007-12-08 22:55:01 +01:00
|
|
|
WORD glyphs[1];
|
|
|
|
DWORD nb;
|
2013-09-12 20:01:56 +02:00
|
|
|
HWND hwnd;
|
2011-01-13 11:17:45 +01:00
|
|
|
static const struct
|
2011-02-01 17:37:09 +01:00
|
|
|
{
|
|
|
|
UINT first;
|
|
|
|
UINT last;
|
|
|
|
} range[] =
|
|
|
|
{
|
|
|
|
{0xff, 0xff},
|
|
|
|
{0x100, 0x100},
|
|
|
|
{0xff, 0x100},
|
|
|
|
{0x1ff, 0xff00},
|
|
|
|
{0xffff, 0xffff},
|
|
|
|
{0x10000, 0x10000},
|
|
|
|
{0xffff, 0x10000},
|
|
|
|
{0xffffff, 0xffffff},
|
|
|
|
{0x1000000, 0x1000000},
|
|
|
|
{0xffffff, 0x1000000},
|
2011-12-26 10:27:37 +01:00
|
|
|
{0xffffffff, 0xffffffff},
|
|
|
|
{0x00, 0xff}
|
2011-02-01 17:37:09 +01:00
|
|
|
};
|
|
|
|
static const struct
|
2011-01-13 11:17:45 +01:00
|
|
|
{
|
|
|
|
UINT cs;
|
|
|
|
UINT a;
|
|
|
|
UINT w;
|
2018-06-25 21:46:41 +02:00
|
|
|
BOOL r[ARRAY_SIZE(range)];
|
2011-01-13 11:17:45 +01:00
|
|
|
} c[] =
|
|
|
|
{
|
2011-12-26 10:27:37 +01:00
|
|
|
{ANSI_CHARSET, 0x30, 0x30,
|
|
|
|
{TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
|
|
|
|
{SHIFTJIS_CHARSET, 0x82a0, 0x3042,
|
|
|
|
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
|
|
|
|
{HANGEUL_CHARSET, 0x8141, 0xac02,
|
|
|
|
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
|
|
|
|
{GB2312_CHARSET, 0x8141, 0x4e04,
|
|
|
|
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}},
|
|
|
|
{CHINESEBIG5_CHARSET, 0xa142, 0x3001,
|
|
|
|
{TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE}}
|
2011-01-13 11:17:45 +01:00
|
|
|
};
|
|
|
|
UINT i;
|
2007-12-08 22:55:01 +01:00
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
if (!pGetCharABCWidthsFloatW)
|
2007-12-08 22:55:01 +01:00
|
|
|
{
|
2020-01-08 09:41:38 +01:00
|
|
|
win_skip("GetCharABCWidthsFloatW is not available on this platform\n");
|
2007-12-08 22:55:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "System");
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
|
2020-12-17 23:10:19 +01:00
|
|
|
nb = pGetGlyphIndicesW(hdc, L"i", 1, glyphs, 0);
|
2008-04-22 20:47:29 +02:00
|
|
|
ok(nb == 1, "GetGlyphIndicesW should have returned 1\n");
|
2007-12-08 22:55:01 +01:00
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsI(NULL, 0, 1, glyphs, abc);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(!ret, "GetCharABCWidthsI should have failed\n");
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsI(hdc, 0, 1, glyphs, NULL);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(!ret, "GetCharABCWidthsI should have failed\n");
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(ret, "GetCharABCWidthsI should have succeeded\n");
|
2006-04-08 22:27:34 +02:00
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(NULL, 'a', 'a', abc);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(!ret, "GetCharABCWidthsW should have failed\n");
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'a', 'a', NULL);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(!ret, "GetCharABCWidthsW should have failed\n");
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'a', 'a', abc);
|
2007-12-08 22:55:01 +01:00
|
|
|
ok(!ret, "GetCharABCWidthsW should have failed\n");
|
|
|
|
|
2011-12-12 11:14:09 +01:00
|
|
|
ret = pGetCharABCWidthsFloatW(NULL, 'a', 'a', abcf);
|
|
|
|
ok(!ret, "GetCharABCWidthsFloatW should have failed\n");
|
|
|
|
|
|
|
|
ret = pGetCharABCWidthsFloatW(hdc, 'a', 'a', NULL);
|
|
|
|
ok(!ret, "GetCharABCWidthsFloatW should have failed\n");
|
|
|
|
|
|
|
|
ret = pGetCharABCWidthsFloatW(hdc, 'a', 'a', abcf);
|
|
|
|
ok(ret, "GetCharABCWidthsFloatW should have succeeded\n");
|
|
|
|
|
2007-12-08 22:55:01 +01:00
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
2011-01-13 11:17:45 +01:00
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(c); ++i)
|
2011-01-13 11:17:45 +01:00
|
|
|
{
|
|
|
|
ABC a[2], w[2];
|
2011-01-16 15:00:16 +01:00
|
|
|
ABC full[256];
|
2011-02-01 17:37:09 +01:00
|
|
|
UINT code = 0x41, j;
|
2011-01-13 11:17:45 +01:00
|
|
|
|
|
|
|
lf.lfFaceName[0] = '\0';
|
|
|
|
lf.lfCharSet = c[i].cs;
|
|
|
|
lf.lfPitchAndFamily = 0;
|
2013-10-17 01:55:20 +02:00
|
|
|
if (EnumFontFamiliesExA(hdc, &lf, create_font_proc, (LPARAM)&hfont, 0))
|
2011-01-13 11:17:45 +01:00
|
|
|
{
|
|
|
|
skip("TrueType font for charset %u is not installed\n", c[i].cs);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(a, 0, sizeof a);
|
|
|
|
memset(w, 0, sizeof w);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
2020-01-08 09:41:38 +01:00
|
|
|
ok(GetCharABCWidthsA(hdc, c[i].a, c[i].a + 1, a) && GetCharABCWidthsW(hdc, c[i].w, c[i].w + 1, w)
|
|
|
|
&& !memcmp(a, w, sizeof(a)),
|
|
|
|
"GetCharABCWidthsA and GetCharABCWidthsW should return same widths. charset = %u\n", c[i].cs);
|
2011-01-16 15:00:16 +01:00
|
|
|
|
|
|
|
memset(a, 0xbb, sizeof a);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsA(hdc, code, code, a);
|
2011-01-16 15:00:16 +01:00
|
|
|
ok(ret, "GetCharABCWidthsA should have succeeded\n");
|
|
|
|
memset(full, 0xcc, sizeof full);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsA(hdc, 0x00, code, full);
|
2011-01-16 15:00:16 +01:00
|
|
|
ok(ret, "GetCharABCWidthsA should have succeeded\n");
|
|
|
|
ok(memcmp(&a[0], &full[code], sizeof(ABC)) == 0,
|
|
|
|
"GetCharABCWidthsA info should match. codepage = %u\n", c[i].cs);
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (j = 0; j < ARRAY_SIZE(range); ++j)
|
2011-02-01 17:37:09 +01:00
|
|
|
{
|
2011-12-26 10:27:37 +01:00
|
|
|
memset(full, 0xdd, sizeof full);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsA(hdc, range[j].first, range[j].last, full);
|
2011-02-01 17:37:09 +01:00
|
|
|
ok(ret == c[i].r[j], "GetCharABCWidthsA %x - %x should have %s\n",
|
|
|
|
range[j].first, range[j].last, c[i].r[j] ? "succeeded" : "failed");
|
2011-12-26 10:27:37 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
UINT last = range[j].last - range[j].first;
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsA(hdc, range[j].last, range[j].last, a);
|
2011-12-26 10:27:37 +01:00
|
|
|
ok(ret && memcmp(&full[last], &a[0], sizeof(ABC)) == 0,
|
|
|
|
"GetCharABCWidthsA %x should match. codepage = %u\n",
|
|
|
|
range[j].last, c[i].cs);
|
|
|
|
}
|
2011-02-01 17:37:09 +01:00
|
|
|
}
|
2011-01-26 17:08:57 +01:00
|
|
|
|
2011-01-13 11:17:45 +01:00
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2013-09-12 20:01:56 +02:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
2014-01-10 12:29:56 +01:00
|
|
|
lf.lfHeight = 200;
|
2013-10-02 13:42:35 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
|
|
|
|
/* test empty glyph's metrics */
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
ret = pGetCharABCWidthsFloatW(hdc, ' ', ' ', abcf);
|
|
|
|
ok(ret, "GetCharABCWidthsFloatW should have succeeded\n");
|
|
|
|
ok(abcf[0].abcfB == 1.0, "got %f\n", abcf[0].abcfB);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, ' ', ' ', abcw);
|
2013-10-02 13:42:35 +02:00
|
|
|
ok(ret, "GetCharABCWidthsW should have succeeded\n");
|
|
|
|
ok(abcw[0].abcB == 1, "got %u\n", abcw[0].abcB);
|
|
|
|
|
2014-01-10 12:29:56 +01:00
|
|
|
/* 1) prepare unrotated font metrics */
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'a', 'a', abcw);
|
2014-01-10 12:29:56 +01:00
|
|
|
ok(ret, "GetCharABCWidthsW should have succeeded\n");
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
/* 2) get rotated font metrics */
|
|
|
|
lf.lfEscapement = lf.lfOrientation = 900;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'a', 'a', abc);
|
2014-01-10 12:29:56 +01:00
|
|
|
ok(ret, "GetCharABCWidthsW should have succeeded\n");
|
|
|
|
|
|
|
|
/* 3) compare ABC results */
|
|
|
|
ok(match_off_by_1(abcw[0].abcA, abc[0].abcA, FALSE),
|
|
|
|
"got %d, expected %d (A)\n", abc[0].abcA, abcw[0].abcA);
|
|
|
|
ok(match_off_by_1(abcw[0].abcB, abc[0].abcB, FALSE),
|
|
|
|
"got %d, expected %d (B)\n", abc[0].abcB, abcw[0].abcB);
|
|
|
|
ok(match_off_by_1(abcw[0].abcC, abc[0].abcC, FALSE),
|
|
|
|
"got %d, expected %d (C)\n", abc[0].abcC, abcw[0].abcC);
|
|
|
|
|
2013-10-02 13:42:35 +02:00
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
2018-02-04 13:02:09 +01:00
|
|
|
|
|
|
|
/* test abcA == gmptGlyphOrigin.x && abcB == gmBlackBoxX
|
|
|
|
in various widths. */
|
|
|
|
for (i = 1; i <= 2; i++)
|
|
|
|
{
|
|
|
|
UINT j;
|
|
|
|
UINT code;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 20;
|
2020-11-09 15:07:13 +01:00
|
|
|
if (i == 1)
|
2018-02-04 13:02:09 +01:00
|
|
|
{
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
code = 'a';
|
2020-11-09 15:07:13 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-04 13:02:09 +01:00
|
|
|
strcpy(lf.lfFaceName, "Times New Roman");
|
|
|
|
lf.lfItalic = TRUE;
|
|
|
|
code = 'f';
|
|
|
|
}
|
|
|
|
if (!is_truetype_font_installed(lf.lfFaceName))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", lf.lfFaceName);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (j = 1; j <= 80; j++)
|
|
|
|
{
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
|
|
|
|
lf.lfWidth = j;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
nb = GetGlyphOutlineA(hdc, code, GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(nb, "GetGlyphOutlineA should have succeeded at width %d\n", i);
|
|
|
|
|
|
|
|
ret = GetCharABCWidthsA(hdc, code, code, abc);
|
|
|
|
ok(ret, "GetCharABCWidthsA should have succeeded at width %d\n", i);
|
|
|
|
|
|
|
|
ok(abc[0].abcA == gm.gmptGlyphOrigin.x,
|
|
|
|
"abcA(%d) and gmptGlyphOrigin.x(%d) values are different at width %d\n",
|
|
|
|
abc[0].abcA, gm.gmptGlyphOrigin.x, i);
|
|
|
|
ok(abc[0].abcB == gm.gmBlackBoxX,
|
|
|
|
"abcB(%d) and gmBlackBoxX(%d) values are different at width %d\n",
|
|
|
|
abc[0].abcB, gm.gmBlackBoxX, i);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
}
|
|
|
|
}
|
2013-10-02 13:42:35 +02:00
|
|
|
ReleaseDC(NULL, hdc);
|
2013-09-12 20:01:56 +02:00
|
|
|
|
2020-02-26 16:45:23 +01:00
|
|
|
/* ABC sign test for a variety of transforms */
|
2014-01-10 12:29:56 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
lf.lfHeight = 20;
|
2013-09-12 20:01:56 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-10-17 01:55:20 +02:00
|
|
|
hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
|
2013-09-12 20:01:56 +02:00
|
|
|
0, 0, 0, NULL);
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
SetMapMode(hdc, MM_ANISOTROPIC);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
2020-12-17 23:10:19 +01:00
|
|
|
nb = pGetGlyphIndicesW(hdc, L"i", 1, glyphs, 0);
|
2013-09-12 20:01:56 +02:00
|
|
|
ok(nb == 1, "GetGlyphIndicesW should have returned 1\n");
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
|
2013-09-12 20:01:56 +02:00
|
|
|
ok(ret, "GetCharABCWidthsI should have succeeded\n");
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, 'i', 'i', abcw);
|
2013-10-02 13:42:35 +02:00
|
|
|
ok(ret, "GetCharABCWidthsW should have succeeded\n");
|
2013-09-12 20:01:56 +02:00
|
|
|
ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
|
|
|
|
ok(ret, "GetCharABCWidthsFloatW should have succeeded\n");
|
|
|
|
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("LTR", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetWindowExtEx(hdc, -1, -1, NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("LTR -1 compatible", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("LTR -1 advanced", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetWindowExtEx(hdc, 1, 1, NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("LTR 1 compatible", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("LTR 1 advanced", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2020-02-26 16:45:23 +01:00
|
|
|
/* RTL layout */
|
2013-10-17 01:55:20 +02:00
|
|
|
hwnd = CreateWindowExA(WS_EX_LAYOUTRTL, "static", "", WS_POPUP, 0,0,100,100,
|
2013-09-12 20:01:56 +02:00
|
|
|
0, 0, 0, NULL);
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
SetMapMode(hdc, MM_ANISOTROPIC);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("RTL", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetWindowExtEx(hdc, -1, -1, NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("RTL -1 compatible", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("RTL -1 advanced", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetWindowExtEx(hdc, 1, 1, NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("RTL 1 compatible", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
2018-02-04 13:02:07 +01:00
|
|
|
ABCWidths_helper("RTL 1 advanced", hdc, glyphs, abc, abcw, abcf);
|
2013-09-12 20:01:56 +02:00
|
|
|
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
DeleteObject(hfont);
|
2006-04-08 22:27:34 +02:00
|
|
|
}
|
|
|
|
|
2006-04-03 14:59:27 +02:00
|
|
|
static void test_text_extents(void)
|
|
|
|
{
|
2020-12-17 23:10:19 +01:00
|
|
|
static const WCHAR wt[] = L"One\ntwo 3";
|
2006-07-12 02:57:06 +02:00
|
|
|
LPINT extents;
|
2013-07-22 15:07:36 +02:00
|
|
|
INT i, len, fit1, fit2, extents2[3];
|
2006-04-03 14:59:27 +02:00
|
|
|
LOGFONTA lf;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
|
|
|
SIZE sz;
|
2006-07-12 02:57:06 +02:00
|
|
|
SIZE sz1, sz2;
|
2011-10-11 16:46:19 +02:00
|
|
|
BOOL ret;
|
2006-04-03 14:59:27 +02:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextMetricsA(hdc, &tm);
|
2015-11-13 22:38:39 +01:00
|
|
|
ret = GetTextExtentPointA(hdc, "o", 1, &sz);
|
|
|
|
ok(ret, "got %d\n", ret);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(sz.cy == tm.tmHeight, "cy %d tmHeight %d\n", sz.cy, tm.tmHeight);
|
2006-04-03 14:59:27 +02:00
|
|
|
|
2015-11-13 22:38:39 +01:00
|
|
|
memset(&sz, 0xcc, sizeof(sz));
|
|
|
|
ret = GetTextExtentPointA(hdc, "o", 0, &sz);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy);
|
|
|
|
|
|
|
|
memset(&sz, 0xcc, sizeof(sz));
|
|
|
|
ret = GetTextExtentPointA(hdc, "", 0, &sz);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy);
|
|
|
|
|
2006-09-21 09:10:53 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
GetTextExtentExPointW(hdc, wt, 1, 1, &fit1, &fit2, &sz1);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("Skipping remainder of text extents test on a Win9x platform\n");
|
2006-09-27 16:43:23 +02:00
|
|
|
hfont = SelectObject(hdc, hfont);
|
2006-09-21 09:10:53 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-13 22:38:39 +01:00
|
|
|
memset(&sz, 0xcc, sizeof(sz));
|
|
|
|
ret = GetTextExtentPointW(hdc, wt, 0, &sz);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy);
|
|
|
|
|
|
|
|
memset(&sz, 0xcc, sizeof(sz));
|
2020-12-17 23:10:19 +01:00
|
|
|
ret = GetTextExtentPointW(hdc, L"", 0, &sz);
|
2015-11-13 22:38:39 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy);
|
|
|
|
|
2006-07-12 02:57:06 +02:00
|
|
|
len = lstrlenW(wt);
|
2007-04-25 00:57:55 +02:00
|
|
|
extents = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof extents[0]);
|
2006-07-12 02:57:06 +02:00
|
|
|
extents[0] = 1; /* So that the increasing sequence test will fail
|
|
|
|
if the extents array is untouched. */
|
|
|
|
GetTextExtentExPointW(hdc, wt, len, 32767, &fit1, extents, &sz1);
|
|
|
|
GetTextExtentPointW(hdc, wt, len, &sz2);
|
2006-09-20 15:02:36 +02:00
|
|
|
ok(sz1.cy == sz2.cy,
|
2006-10-12 22:56:45 +02:00
|
|
|
"cy from GetTextExtentExPointW (%d) and GetTextExtentPointW (%d) differ\n", sz1.cy, sz2.cy);
|
2006-09-21 11:11:28 +02:00
|
|
|
/* Because of the '\n' in the string GetTextExtentExPoint and
|
|
|
|
GetTextExtentPoint return different widths under Win2k, but
|
|
|
|
under WinXP they return the same width. So we don't test that
|
|
|
|
here. */
|
|
|
|
|
2006-07-12 02:57:06 +02:00
|
|
|
for (i = 1; i < len; ++i)
|
|
|
|
ok(extents[i-1] <= extents[i],
|
|
|
|
"GetTextExtentExPointW generated a non-increasing sequence of partial extents (at position %d)\n",
|
|
|
|
i);
|
|
|
|
ok(extents[len-1] == sz1.cx, "GetTextExtentExPointW extents and size don't match\n");
|
|
|
|
ok(0 <= fit1 && fit1 <= len, "GetTextExtentExPointW generated illegal value %d for fit\n", fit1);
|
|
|
|
ok(0 < fit1, "GetTextExtentExPointW says we can't even fit one letter in 32767 logical units\n");
|
|
|
|
GetTextExtentExPointW(hdc, wt, len, extents[2], &fit2, NULL, &sz2);
|
|
|
|
ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy, "GetTextExtentExPointW returned different sizes for the same string\n");
|
|
|
|
ok(fit2 == 3, "GetTextExtentExPointW extents isn't consistent with fit\n");
|
|
|
|
GetTextExtentExPointW(hdc, wt, len, extents[2]-1, &fit2, NULL, &sz2);
|
|
|
|
ok(fit2 == 2, "GetTextExtentExPointW extents isn't consistent with fit\n");
|
|
|
|
GetTextExtentExPointW(hdc, wt, 2, 0, NULL, extents + 2, &sz2);
|
|
|
|
ok(extents[0] == extents[2] && extents[1] == extents[3],
|
|
|
|
"GetTextExtentExPointW with lpnFit == NULL returns incorrect results\n");
|
|
|
|
GetTextExtentExPointW(hdc, wt, 2, 0, NULL, NULL, &sz1);
|
|
|
|
ok(sz1.cx == sz2.cx && sz1.cy == sz2.cy,
|
|
|
|
"GetTextExtentExPointW with lpnFit and alpDx both NULL returns incorrect results\n");
|
|
|
|
|
2011-10-11 16:46:19 +02:00
|
|
|
/* extents functions fail with -ve counts (the interesting case being -1) */
|
|
|
|
ret = GetTextExtentPointA(hdc, "o", -1, &sz);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
ret = GetTextExtentExPointA(hdc, "o", -1, 0, NULL, NULL, &sz);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
ret = GetTextExtentExPointW(hdc, wt, -1, 0, NULL, NULL, &sz1);
|
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
|
2011-10-23 11:23:06 +02:00
|
|
|
/* max_extent = 0 succeeds and returns zero */
|
|
|
|
fit1 = fit2 = -215;
|
|
|
|
ret = GetTextExtentExPointA(hdc, NULL, 0, 0, &fit1, NULL, &sz);
|
|
|
|
ok(ret == TRUE ||
|
|
|
|
broken(ret == FALSE), /* NT4, 2k */
|
|
|
|
"got %d\n", ret);
|
|
|
|
ok(fit1 == 0 ||
|
|
|
|
broken(fit1 == -215), /* NT4, 2k */
|
|
|
|
"fit = %d\n", fit1);
|
|
|
|
ret = GetTextExtentExPointW(hdc, NULL, 0, 0, &fit2, NULL, &sz1);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
|
|
|
ok(fit2 == 0, "fit = %d\n", fit2);
|
|
|
|
|
|
|
|
/* max_extent = -1 is interpreted as a very large width that will
|
|
|
|
* definitely fit our three characters */
|
|
|
|
fit1 = fit2 = -215;
|
|
|
|
ret = GetTextExtentExPointA(hdc, "One", 3, -1, &fit1, NULL, &sz);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok(fit1 == 3, "fit = %d\n", fit1);
|
2011-10-23 11:23:06 +02:00
|
|
|
ret = GetTextExtentExPointW(hdc, wt, 3, -1, &fit2, NULL, &sz);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok(fit2 == 3, "fit = %d\n", fit2);
|
2011-10-23 11:23:06 +02:00
|
|
|
|
|
|
|
/* max_extent = -2 is interpreted similarly, but the Ansi version
|
|
|
|
* rejects it while the Unicode one accepts it */
|
|
|
|
fit1 = fit2 = -215;
|
|
|
|
ret = GetTextExtentExPointA(hdc, "One", 3, -2, &fit1, NULL, &sz);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok(ret == FALSE, "got %d\n", ret);
|
|
|
|
ok(fit1 == -215, "fit = %d\n", fit1);
|
2011-10-23 11:23:06 +02:00
|
|
|
ret = GetTextExtentExPointW(hdc, wt, 3, -2, &fit2, NULL, &sz);
|
|
|
|
ok(ret == TRUE, "got %d\n", ret);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok(fit2 == 3, "fit = %d\n", fit2);
|
2011-10-23 11:23:06 +02:00
|
|
|
|
2006-09-27 16:43:23 +02:00
|
|
|
hfont = SelectObject(hdc, hfont);
|
2006-04-03 14:59:27 +02:00
|
|
|
DeleteObject(hfont);
|
2013-07-22 15:07:36 +02:00
|
|
|
|
|
|
|
/* non-MM_TEXT mapping mode */
|
|
|
|
lf.lfHeight = 2000;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
SetMapMode( hdc, MM_HIMETRIC );
|
|
|
|
ret = GetTextExtentExPointW(hdc, wt, 3, 0, NULL, extents, &sz);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(sz.cx == extents[2], "got %d vs %d\n", sz.cx, extents[2]);
|
|
|
|
|
|
|
|
ret = GetTextExtentExPointW(hdc, wt, 3, extents[1], &fit1, extents2, &sz2);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(fit1 == 2, "got %d\n", fit1);
|
|
|
|
ok(sz2.cx == sz.cx, "got %d vs %d\n", sz2.cx, sz.cx);
|
|
|
|
for(i = 0; i < 2; i++)
|
|
|
|
ok(extents2[i] == extents[i], "%d: %d, %d\n", i, extents2[i], extents[i]);
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
HeapFree(GetProcessHeap(), 0, extents);
|
2006-04-03 14:59:27 +02:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2020-12-08 13:09:21 +01:00
|
|
|
static void free_font(void *font)
|
|
|
|
{
|
|
|
|
UnmapViewOfFile(font);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *load_font(const char *font_name, DWORD *font_size)
|
|
|
|
{
|
|
|
|
char file_name[MAX_PATH];
|
|
|
|
HANDLE file, mapping;
|
|
|
|
void *font;
|
|
|
|
|
|
|
|
if (font_name[1] == ':')
|
|
|
|
strcpy(file_name, font_name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GetWindowsDirectoryA(file_name, sizeof(file_name))) return NULL;
|
|
|
|
strcat(file_name, "\\fonts\\");
|
|
|
|
strcat(file_name, font_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
file = CreateFileA(file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
|
|
|
|
if (file == INVALID_HANDLE_VALUE) return NULL;
|
|
|
|
|
|
|
|
*font_size = GetFileSize(file, NULL);
|
|
|
|
|
|
|
|
mapping = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
|
|
if (!mapping)
|
|
|
|
{
|
|
|
|
CloseHandle(file);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
font = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
|
|
|
|
|
|
|
|
CloseHandle(file);
|
|
|
|
CloseHandle(mapping);
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
static void test_GetGlyphIndices(void)
|
2006-08-23 16:49:13 +02:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
|
|
|
DWORD charcount;
|
|
|
|
LOGFONTA lf;
|
|
|
|
DWORD flags = 0;
|
2020-12-17 23:10:19 +01:00
|
|
|
WCHAR testtext[] = L"Test\xffff";
|
2020-12-21 13:32:45 +01:00
|
|
|
WCHAR c[] = { 0x25bc /* Black Down-Pointing Triangle */, 0x212a /* Kelvin Sign */ };
|
2006-08-23 16:49:13 +02:00
|
|
|
WORD glyphs[(sizeof(testtext)/2)-1];
|
2013-10-17 01:55:20 +02:00
|
|
|
TEXTMETRICA textm;
|
2008-03-30 21:43:15 +02:00
|
|
|
HFONT hOldFont;
|
2020-12-08 13:09:21 +01:00
|
|
|
HANDLE rsrc;
|
|
|
|
DWORD ret, font_size, num_fonts;
|
|
|
|
void *font;
|
|
|
|
char ttf_name[MAX_PATH];
|
2006-08-23 16:49:13 +02:00
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
if (!pGetGlyphIndicesW) {
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("GetGlyphIndicesW not available on platform\n");
|
2006-09-01 14:55:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-30 21:43:15 +02:00
|
|
|
hdc = GetDC(0);
|
|
|
|
|
2010-11-15 01:03:28 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "System");
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2020-12-21 13:32:45 +01:00
|
|
|
ok(hfont != 0, "CreateFontIndirect failed\n");
|
|
|
|
hOldFont = SelectObject(hdc, hfont);
|
|
|
|
ok(GetTextMetricsA(hdc, &textm), "GetTextMetrics failed\n");
|
2010-11-15 01:03:28 +01:00
|
|
|
if (textm.tmCharSet == ANSI_CHARSET)
|
|
|
|
{
|
|
|
|
flags |= GGI_MARK_NONEXISTING_GLYPHS;
|
|
|
|
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
|
|
|
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
|
|
|
|
ok((glyphs[4] == 0x001f || glyphs[4] == 0xffff /* Vista */), "GetGlyphIndicesW should have returned a nonexistent char not %04x\n", glyphs[4]);
|
|
|
|
flags = 0;
|
|
|
|
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
|
|
|
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
|
2020-12-21 13:32:45 +01:00
|
|
|
ok(glyphs[4] == textm.tmDefaultChar || glyphs[4] == 0x20 /* CJK Windows */,
|
|
|
|
"GetGlyphIndicesW should have returned a %04x not %04x\n", textm.tmDefaultChar, glyphs[4]);
|
2010-11-15 01:03:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
/* FIXME: Write tests for non-ANSI charsets. */
|
|
|
|
skip("GetGlyphIndices System font tests only for ANSI_CHARSET\n");
|
2008-03-30 21:43:15 +02:00
|
|
|
|
2020-12-21 13:32:45 +01:00
|
|
|
DeleteObject(SelectObject(hdc, hOldFont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "MS Sans Serif");
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirect failed\n");
|
|
|
|
hOldFont = SelectObject(hdc, hfont);
|
|
|
|
ok(GetTextMetricsA(hdc, &textm), "GetTextMetrics failed\n");
|
|
|
|
|
|
|
|
glyphs[0] = glyphs[1] = 0;
|
|
|
|
charcount = GetGlyphIndicesW(hdc, c, ARRAY_SIZE(c), glyphs, GGI_MARK_NONEXISTING_GLYPHS);
|
|
|
|
ok(charcount == ARRAY_SIZE(c), "got %u\n", charcount);
|
|
|
|
ok(glyphs[0] == 0x001f || glyphs[0] == 0xffff /* Vista */, "got %#x\n", glyphs[0]);
|
|
|
|
ok(glyphs[1] == 0x001f || glyphs[1] == 0xffff /* Vista */, "got %#x\n", glyphs[1]);
|
|
|
|
|
|
|
|
glyphs[0] = glyphs[1] = 0;
|
|
|
|
charcount = GetGlyphIndicesW(hdc, c, ARRAY_SIZE(c), glyphs, 0);
|
|
|
|
ok(charcount == ARRAY_SIZE(c), "got %u\n", charcount);
|
|
|
|
ok(glyphs[0] == textm.tmDefaultChar || glyphs[0] == 0x20 /* CJK Windows */, "got %#x\n", glyphs[0]);
|
|
|
|
ok(glyphs[1] == textm.tmDefaultChar || glyphs[1] == 0x20 /* CJK Windows */, "got %#x\n", glyphs[1]);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hOldFont));
|
|
|
|
|
2008-03-30 21:43:15 +02:00
|
|
|
if(!is_font_installed("Tahoma"))
|
2006-09-20 13:43:10 +02:00
|
|
|
{
|
2008-03-30 21:43:15 +02:00
|
|
|
skip("Tahoma is not installed so skipping this test\n");
|
2020-12-21 13:32:45 +01:00
|
|
|
ReleaseDC(0, hdc);
|
2006-09-20 13:43:10 +02:00
|
|
|
return;
|
|
|
|
}
|
2006-08-23 16:49:13 +02:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
2008-03-30 21:43:15 +02:00
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
2006-08-23 16:49:13 +02:00
|
|
|
lf.lfHeight = 20;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2008-03-30 21:43:15 +02:00
|
|
|
hOldFont = SelectObject(hdc, hfont);
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(GetTextMetricsA(hdc, &textm), "GetTextMetric failed\n");
|
2006-08-23 16:49:13 +02:00
|
|
|
flags |= GGI_MARK_NONEXISTING_GLYPHS;
|
2007-03-05 17:29:04 +01:00
|
|
|
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
2008-04-22 20:47:29 +02:00
|
|
|
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
|
|
|
|
ok(glyphs[4] == 0xffff, "GetGlyphIndicesW should have returned 0xffff char not %04x\n", glyphs[4]);
|
2006-08-23 16:49:13 +02:00
|
|
|
flags = 0;
|
2008-03-30 21:43:15 +02:00
|
|
|
testtext[0] = textm.tmDefaultChar;
|
2007-03-05 17:29:04 +01:00
|
|
|
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
2008-04-22 20:47:29 +02:00
|
|
|
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
|
2009-02-16 13:39:15 +01:00
|
|
|
ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
|
2008-04-22 20:47:29 +02:00
|
|
|
ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
|
2008-03-30 21:43:15 +02:00
|
|
|
DeleteObject(SelectObject(hdc, hOldFont));
|
2020-12-08 13:09:21 +01:00
|
|
|
|
|
|
|
ret = write_ttf_file("wine_nul.ttf", ttf_name);
|
|
|
|
ok(ret, "Failed to create test font file.\n");
|
|
|
|
font = load_font(ttf_name, &font_size);
|
|
|
|
ok(font != NULL, "Failed to map font file.\n");
|
|
|
|
num_fonts = 0;
|
|
|
|
rsrc = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
|
|
|
|
ok(ret != 0, "Failed to add resource, %d.\n", GetLastError());
|
|
|
|
ok(num_fonts == 1, "Unexpected number of fonts %u.\n", num_fonts);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "wine_nul");
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
flags = 0;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hOldFont = SelectObject(hdc, hfont);
|
|
|
|
ok(GetTextMetricsA(hdc, &textm), "GetTextMetric failed\n");
|
|
|
|
testtext[0] = 'T';
|
|
|
|
charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
|
|
|
|
ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
|
2020-12-08 13:09:22 +01:00
|
|
|
ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
|
|
|
|
ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
|
2020-12-08 13:09:21 +01:00
|
|
|
DeleteObject(SelectObject(hdc, hOldFont));
|
|
|
|
|
2020-12-21 13:32:45 +01:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
|
2020-12-08 13:09:21 +01:00
|
|
|
ret = pRemoveFontMemResourceEx(rsrc);
|
|
|
|
ok(ret, "RemoveFontMemResourceEx error %d\n", GetLastError());
|
|
|
|
free_font(font);
|
|
|
|
ret = DeleteFileA(ttf_name);
|
|
|
|
ok(ret, "Failed to delete font file, %d.\n", GetLastError());
|
2006-08-23 16:49:13 +02:00
|
|
|
}
|
|
|
|
|
2006-09-21 09:10:53 +02:00
|
|
|
static void test_GetKerningPairs(void)
|
|
|
|
{
|
|
|
|
static const struct kerning_data
|
|
|
|
{
|
|
|
|
const char face_name[LF_FACESIZE];
|
|
|
|
LONG height;
|
2006-09-27 16:43:23 +02:00
|
|
|
/* some interesting fields from OUTLINETEXTMETRIC */
|
|
|
|
LONG tmHeight, tmAscent, tmDescent;
|
|
|
|
UINT otmEMSquare;
|
|
|
|
INT otmAscent;
|
|
|
|
INT otmDescent;
|
|
|
|
UINT otmLineGap;
|
|
|
|
UINT otmsCapEmHeight;
|
|
|
|
UINT otmsXHeight;
|
|
|
|
INT otmMacAscent;
|
|
|
|
INT otmMacDescent;
|
|
|
|
UINT otmMacLineGap;
|
|
|
|
UINT otmusMinimumPPEM;
|
2006-09-21 09:10:53 +02:00
|
|
|
/* small subset of kerning pairs to test */
|
|
|
|
DWORD total_kern_pairs;
|
2006-09-27 16:43:23 +02:00
|
|
|
const KERNINGPAIR kern_pair[26];
|
2006-09-21 09:10:53 +02:00
|
|
|
} kd[] =
|
|
|
|
{
|
2006-09-27 16:43:23 +02:00
|
|
|
{"Arial", 12, 12, 9, 3,
|
|
|
|
2048, 7, -2, 1, 5, 2, 8, -2, 0, 9,
|
|
|
|
26,
|
|
|
|
{
|
|
|
|
{' ','A',-1},{' ','T',0},{' ','Y',0},{'1','1',-1},
|
|
|
|
{'A',' ',-1},{'A','T',-1},{'A','V',-1},{'A','W',0},
|
|
|
|
{'A','Y',-1},{'A','v',0},{'A','w',0},{'A','y',0},
|
|
|
|
{'F',',',-1},{'F','.',-1},{'F','A',-1},{'L',' ',0},
|
|
|
|
{'L','T',-1},{'L','V',-1},{'L','W',-1},{'L','Y',-1},
|
|
|
|
{915,912,+1},{915,913,-1},{910,912,+1},{910,913,-1},
|
|
|
|
{933,970,+1},{933,972,-1}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{"Arial", -34, 39, 32, 7,
|
|
|
|
2048, 25, -7, 5, 17, 9, 31, -7, 1, 9,
|
|
|
|
26,
|
2006-09-21 09:10:53 +02:00
|
|
|
{
|
|
|
|
{' ','A',-2},{' ','T',-1},{' ','Y',-1},{'1','1',-3},
|
|
|
|
{'A',' ',-2},{'A','T',-3},{'A','V',-3},{'A','W',-1},
|
|
|
|
{'A','Y',-3},{'A','v',-1},{'A','w',-1},{'A','y',-1},
|
|
|
|
{'F',',',-4},{'F','.',-4},{'F','A',-2},{'L',' ',-1},
|
2006-09-27 16:43:23 +02:00
|
|
|
{'L','T',-3},{'L','V',-3},{'L','W',-3},{'L','Y',-3},
|
|
|
|
{915,912,+3},{915,913,-3},{910,912,+3},{910,913,-3},
|
|
|
|
{933,970,+2},{933,972,-3}
|
2006-09-21 09:10:53 +02:00
|
|
|
}
|
|
|
|
},
|
2006-09-27 16:43:23 +02:00
|
|
|
{ "Arial", 120, 120, 97, 23,
|
|
|
|
2048, 79, -23, 16, 54, 27, 98, -23, 4, 9,
|
|
|
|
26,
|
2006-09-21 09:10:53 +02:00
|
|
|
{
|
|
|
|
{' ','A',-6},{' ','T',-2},{' ','Y',-2},{'1','1',-8},
|
|
|
|
{'A',' ',-6},{'A','T',-8},{'A','V',-8},{'A','W',-4},
|
|
|
|
{'A','Y',-8},{'A','v',-2},{'A','w',-2},{'A','y',-2},
|
|
|
|
{'F',',',-12},{'F','.',-12},{'F','A',-6},{'L',' ',-4},
|
2006-09-27 16:43:23 +02:00
|
|
|
{'L','T',-8},{'L','V',-8},{'L','W',-8},{'L','Y',-8},
|
|
|
|
{915,912,+9},{915,913,-10},{910,912,+9},{910,913,-8},
|
|
|
|
{933,970,+6},{933,972,-10}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#if 0 /* this set fails due to +1/-1 errors (rounding bug?), needs investigation. */
|
|
|
|
{ "Arial", 1024 /* usually 1/2 of EM Square */, 1024, 830, 194,
|
|
|
|
2048, 668, -193, 137, 459, 229, 830, -194, 30, 9,
|
|
|
|
26,
|
|
|
|
{
|
|
|
|
{' ','A',-51},{' ','T',-17},{' ','Y',-17},{'1','1',-68},
|
|
|
|
{'A',' ',-51},{'A','T',-68},{'A','V',-68},{'A','W',-34},
|
|
|
|
{'A','Y',-68},{'A','v',-17},{'A','w',-17},{'A','y',-17},
|
|
|
|
{'F',',',-102},{'F','.',-102},{'F','A',-51},{'L',' ',-34},
|
|
|
|
{'L','T',-68},{'L','V',-68},{'L','W',-68},{'L','Y',-68},
|
|
|
|
{915,912,+73},{915,913,-84},{910,912,+76},{910,913,-68},
|
|
|
|
{933,970,+54},{933,972,-83}
|
2006-09-21 09:10:53 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-27 16:43:23 +02:00
|
|
|
#endif
|
2006-09-21 09:10:53 +02:00
|
|
|
};
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2006-09-21 09:10:53 +02:00
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
KERNINGPAIR *kern_pair;
|
|
|
|
HDC hdc;
|
|
|
|
DWORD total_kern_pairs, ret, i, n, matches;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* GetKerningPairsA maps unicode set of kerning pairs to current code page
|
|
|
|
* which may render this test unusable, so we're trying to avoid that.
|
|
|
|
*/
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
GetKerningPairsW(hdc, 0, NULL);
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("Skipping the GetKerningPairs test on a Win9x platform\n");
|
2006-09-21 09:10:53 +02:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(kd); i++)
|
2006-09-21 09:10:53 +02:00
|
|
|
{
|
2006-09-27 16:43:23 +02:00
|
|
|
OUTLINETEXTMETRICW otm;
|
2011-01-02 18:50:17 +01:00
|
|
|
UINT uiRet;
|
2006-09-27 16:43:23 +02:00
|
|
|
|
2006-09-21 09:10:53 +02:00
|
|
|
if (!is_font_installed(kd[i].face_name))
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("%s is not installed so skipping this test\n", kd[i].face_name);
|
2006-09-21 09:10:53 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, kd[i].face_name);
|
|
|
|
lf.lfHeight = kd[i].height;
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2016-02-09 15:24:28 +01:00
|
|
|
ok(hfont != NULL, "failed to create a font, name %s\n", kd[i].face_name);
|
2006-09-21 09:10:53 +02:00
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
2006-09-27 16:43:23 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
otm.otmSize = sizeof(otm); /* just in case for Win9x compatibility */
|
2011-01-02 18:50:17 +01:00
|
|
|
uiRet = GetOutlineTextMetricsW(hdc, sizeof(otm), &otm);
|
|
|
|
ok(uiRet == sizeof(otm), "GetOutlineTextMetricsW error %d\n", GetLastError());
|
2006-09-27 16:43:23 +02:00
|
|
|
|
2013-08-28 15:21:10 +02:00
|
|
|
ok(match_off_by_1(kd[i].tmHeight, otm.otmTextMetrics.tmHeight, FALSE), "expected %d, got %d\n",
|
2006-09-27 16:43:23 +02:00
|
|
|
kd[i].tmHeight, otm.otmTextMetrics.tmHeight);
|
2013-08-28 15:21:10 +02:00
|
|
|
ok(match_off_by_1(kd[i].tmAscent, otm.otmTextMetrics.tmAscent, FALSE), "expected %d, got %d\n",
|
2006-09-27 16:43:23 +02:00
|
|
|
kd[i].tmAscent, otm.otmTextMetrics.tmAscent);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(kd[i].tmDescent == otm.otmTextMetrics.tmDescent, "expected %d, got %d\n",
|
2006-09-27 16:43:23 +02:00
|
|
|
kd[i].tmDescent, otm.otmTextMetrics.tmDescent);
|
|
|
|
|
|
|
|
ok(kd[i].otmEMSquare == otm.otmEMSquare, "expected %u, got %u\n",
|
|
|
|
kd[i].otmEMSquare, otm.otmEMSquare);
|
|
|
|
ok(kd[i].otmAscent == otm.otmAscent, "expected %d, got %d\n",
|
|
|
|
kd[i].otmAscent, otm.otmAscent);
|
|
|
|
ok(kd[i].otmDescent == otm.otmDescent, "expected %d, got %d\n",
|
|
|
|
kd[i].otmDescent, otm.otmDescent);
|
|
|
|
ok(kd[i].otmLineGap == otm.otmLineGap, "expected %u, got %u\n",
|
|
|
|
kd[i].otmLineGap, otm.otmLineGap);
|
2008-06-24 09:10:47 +02:00
|
|
|
ok(near_match(kd[i].otmMacDescent, otm.otmMacDescent), "expected %d, got %d\n",
|
|
|
|
kd[i].otmMacDescent, otm.otmMacDescent);
|
2010-05-18 13:53:18 +02:00
|
|
|
ok(near_match(kd[i].otmMacAscent, otm.otmMacAscent), "expected %d, got %d\n",
|
|
|
|
kd[i].otmMacAscent, otm.otmMacAscent);
|
2017-12-19 11:10:33 +01:00
|
|
|
todo_wine
|
2006-09-27 16:43:23 +02:00
|
|
|
ok(kd[i].otmsCapEmHeight == otm.otmsCapEmHeight, "expected %u, got %u\n",
|
|
|
|
kd[i].otmsCapEmHeight, otm.otmsCapEmHeight);
|
2017-12-19 11:10:33 +01:00
|
|
|
todo_wine
|
2006-09-27 16:43:23 +02:00
|
|
|
ok(kd[i].otmsXHeight == otm.otmsXHeight, "expected %u, got %u\n",
|
|
|
|
kd[i].otmsXHeight, otm.otmsXHeight);
|
2017-12-19 11:10:33 +01:00
|
|
|
ok(kd[i].otmMacLineGap == otm.otmMacLineGap, "expected %u, got %u\n",
|
2006-09-27 16:43:23 +02:00
|
|
|
kd[i].otmMacLineGap, otm.otmMacLineGap);
|
2017-12-19 11:10:33 +01:00
|
|
|
todo_wine
|
2006-09-27 16:43:23 +02:00
|
|
|
ok(kd[i].otmusMinimumPPEM == otm.otmusMinimumPPEM, "expected %u, got %u\n",
|
|
|
|
kd[i].otmusMinimumPPEM, otm.otmusMinimumPPEM);
|
|
|
|
|
2006-09-21 09:10:53 +02:00
|
|
|
total_kern_pairs = GetKerningPairsW(hdc, 0, NULL);
|
|
|
|
kern_pair = HeapAlloc(GetProcessHeap(), 0, total_kern_pairs * sizeof(*kern_pair));
|
|
|
|
|
2011-09-27 00:18:00 +02:00
|
|
|
/* Win98 (GetKerningPairsA) and XP behave differently here, the test
|
|
|
|
* passes on XP.
|
|
|
|
*/
|
2006-09-21 09:10:53 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetKerningPairsW(hdc, 0, kern_pair);
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
2011-09-27 00:18:00 +02:00
|
|
|
"got error %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
|
|
|
|
ok(ret == 0, "got %u, expected 0\n", ret);
|
2006-09-21 09:10:53 +02:00
|
|
|
|
|
|
|
ret = GetKerningPairsW(hdc, 100, NULL);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == total_kern_pairs, "got %u, expected %u\n", ret, total_kern_pairs);
|
2006-09-21 09:10:53 +02:00
|
|
|
|
|
|
|
ret = GetKerningPairsW(hdc, total_kern_pairs/2, kern_pair);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == total_kern_pairs/2, "got %u, expected %u\n", ret, total_kern_pairs/2);
|
2006-09-21 09:10:53 +02:00
|
|
|
|
|
|
|
ret = GetKerningPairsW(hdc, total_kern_pairs, kern_pair);
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(ret == total_kern_pairs, "got %u, expected %u\n", ret, total_kern_pairs);
|
2006-09-21 09:10:53 +02:00
|
|
|
|
|
|
|
matches = 0;
|
|
|
|
|
|
|
|
for (n = 0; n < ret; n++)
|
|
|
|
{
|
|
|
|
DWORD j;
|
2020-02-26 16:45:23 +01:00
|
|
|
|
2006-09-21 09:10:53 +02:00
|
|
|
for (j = 0; j < kd[i].total_kern_pairs; j++)
|
|
|
|
{
|
|
|
|
if (kern_pair[n].wFirst == kd[i].kern_pair[j].wFirst &&
|
2006-09-27 16:43:23 +02:00
|
|
|
kern_pair[n].wSecond == kd[i].kern_pair[j].wSecond)
|
2006-09-21 09:10:53 +02:00
|
|
|
{
|
2006-09-27 16:43:23 +02:00
|
|
|
ok(kern_pair[n].iKernAmount == kd[i].kern_pair[j].iKernAmount,
|
|
|
|
"pair %d:%d got %d, expected %d\n",
|
|
|
|
kern_pair[n].wFirst, kern_pair[n].wSecond,
|
|
|
|
kern_pair[n].iKernAmount, kd[i].kern_pair[j].iKernAmount);
|
2006-09-21 09:10:53 +02:00
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-12 22:56:45 +02:00
|
|
|
ok(matches == kd[i].total_kern_pairs, "got matches %u, expected %u\n",
|
2006-09-21 09:10:53 +02:00
|
|
|
matches, kd[i].total_kern_pairs);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, kern_pair);
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2013-08-28 15:21:09 +02:00
|
|
|
struct font_data
|
|
|
|
{
|
|
|
|
const char face_name[LF_FACESIZE];
|
|
|
|
int requested_height;
|
|
|
|
int weight, height, ascent, descent, int_leading, ext_leading, dpi;
|
2013-08-28 15:21:10 +02:00
|
|
|
BOOL exact;
|
2013-08-28 15:21:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void test_height( HDC hdc, const struct font_data *fd )
|
2010-05-18 13:53:18 +02:00
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2010-05-18 13:53:18 +02:00
|
|
|
HFONT hfont, old_hfont;
|
2013-10-17 01:55:20 +02:00
|
|
|
TEXTMETRICA tm;
|
2010-05-18 13:53:18 +02:00
|
|
|
INT ret, i;
|
|
|
|
|
2013-08-28 15:21:09 +02:00
|
|
|
for (i = 0; fd[i].face_name[0]; i++)
|
2010-05-18 13:53:18 +02:00
|
|
|
{
|
|
|
|
if (!is_truetype_font_installed(fd[i].face_name))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", fd[i].face_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = fd[i].requested_height;
|
|
|
|
lf.lfWeight = fd[i].weight;
|
|
|
|
strcpy(lf.lfFaceName, fd[i].face_name);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2016-02-09 15:24:28 +01:00
|
|
|
ok(hfont != NULL, "failed to create a font, name %s\n", fd[i].face_name);
|
2010-05-18 13:53:18 +02:00
|
|
|
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2010-05-18 13:53:18 +02:00
|
|
|
ok(ret, "GetTextMetrics error %d\n", GetLastError());
|
|
|
|
if(fd[i].dpi == tm.tmDigitizedAspectX)
|
|
|
|
{
|
|
|
|
ok(tm.tmWeight == fd[i].weight, "%s(%d): tm.tmWeight %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmWeight, fd[i].weight);
|
2013-08-28 15:21:10 +02:00
|
|
|
ok(match_off_by_1(tm.tmHeight, fd[i].height, fd[i].exact), "%s(%d): tm.tmHeight %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmHeight, fd[i].height);
|
|
|
|
ok(match_off_by_1(tm.tmAscent, fd[i].ascent, fd[i].exact), "%s(%d): tm.tmAscent %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmAscent, fd[i].ascent);
|
|
|
|
ok(match_off_by_1(tm.tmDescent, fd[i].descent, fd[i].exact), "%s(%d): tm.tmDescent %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmDescent, fd[i].descent);
|
2013-08-28 15:21:14 +02:00
|
|
|
ok(match_off_by_1(tm.tmInternalLeading, fd[i].int_leading, fd[i].exact), "%s(%d): tm.tmInternalLeading %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmInternalLeading, fd[i].int_leading);
|
2010-05-18 13:53:18 +02:00
|
|
|
ok(tm.tmExternalLeading == fd[i].ext_leading, "%s(%d): tm.tmExternalLeading %d != %d\n", fd[i].face_name, fd[i].requested_height, tm.tmExternalLeading, fd[i].ext_leading);
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(hdc, old_hfont);
|
2015-07-17 11:23:14 +02:00
|
|
|
/* force GDI to use new font, otherwise Windows leaks the font reference */
|
|
|
|
GetTextMetricsA(hdc, &tm);
|
2010-05-18 13:53:18 +02:00
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
2013-08-28 15:21:09 +02:00
|
|
|
}
|
|
|
|
|
2013-08-28 15:21:15 +02:00
|
|
|
static void *find_ttf_table( void *ttf, DWORD size, DWORD tag )
|
|
|
|
{
|
|
|
|
WORD i, num_tables = GET_BE_WORD(*((WORD *)ttf + 2));
|
|
|
|
DWORD *table = (DWORD *)ttf + 3;
|
|
|
|
|
|
|
|
for (i = 0; i < num_tables; i++)
|
|
|
|
{
|
|
|
|
if (table[0] == tag)
|
|
|
|
return (BYTE *)ttf + GET_BE_DWORD(table[2]);
|
|
|
|
table += 4;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_height_selection_vdmx( HDC hdc )
|
|
|
|
{
|
|
|
|
static const struct font_data charset_0[] = /* doesn't use VDMX */
|
|
|
|
{
|
|
|
|
{ "wine_vdmx", 10, FW_NORMAL, 10, 8, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 11, FW_NORMAL, 11, 9, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 12, FW_NORMAL, 12, 10, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 13, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 14, FW_NORMAL, 14, 12, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 15, FW_NORMAL, 15, 12, 3, 3, 0, 96, FALSE },
|
|
|
|
{ "wine_vdmx", 16, FW_NORMAL, 16, 13, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 17, FW_NORMAL, 17, 14, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 18, FW_NORMAL, 18, 15, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 19, FW_NORMAL, 19, 16, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 20, FW_NORMAL, 20, 17, 3, 4, 0, 96, FALSE },
|
|
|
|
{ "wine_vdmx", 21, FW_NORMAL, 21, 17, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 22, FW_NORMAL, 22, 18, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 23, FW_NORMAL, 23, 19, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 24, FW_NORMAL, 24, 20, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 25, FW_NORMAL, 25, 21, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 26, FW_NORMAL, 26, 22, 4, 5, 0, 96, FALSE },
|
|
|
|
{ "wine_vdmx", 27, FW_NORMAL, 27, 22, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 28, FW_NORMAL, 28, 23, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 29, FW_NORMAL, 29, 24, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 30, FW_NORMAL, 30, 25, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 31, FW_NORMAL, 31, 26, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 32, FW_NORMAL, 32, 27, 5, 6, 0, 96, FALSE },
|
|
|
|
{ "wine_vdmx", 48, FW_NORMAL, 48, 40, 8, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 64, FW_NORMAL, 64, 53, 11, 11, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 96, FW_NORMAL, 96, 80, 16, 17, 0, 96, FALSE },
|
|
|
|
{ "wine_vdmx", -10, FW_NORMAL, 12, 10, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -11, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -12, FW_NORMAL, 14, 12, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -13, FW_NORMAL, 16, 13, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -14, FW_NORMAL, 17, 14, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -15, FW_NORMAL, 18, 15, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -16, FW_NORMAL, 19, 16, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -17, FW_NORMAL, 21, 17, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -18, FW_NORMAL, 22, 18, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -19, FW_NORMAL, 23, 19, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -20, FW_NORMAL, 24, 20, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -21, FW_NORMAL, 25, 21, 4, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -22, FW_NORMAL, 27, 22, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -23, FW_NORMAL, 28, 23, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -24, FW_NORMAL, 29, 24, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -25, FW_NORMAL, 30, 25, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -26, FW_NORMAL, 31, 26, 5, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -27, FW_NORMAL, 33, 27, 6, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -28, FW_NORMAL, 34, 28, 6, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -29, FW_NORMAL, 35, 29, 6, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -30, FW_NORMAL, 36, 30, 6, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -31, FW_NORMAL, 37, 31, 6, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -32, FW_NORMAL, 39, 32, 7, 7, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -48, FW_NORMAL, 58, 48, 10, 10, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -64, FW_NORMAL, 77, 64, 13, 13, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -96, FW_NORMAL, 116, 96, 20, 20, 0, 96, TRUE },
|
|
|
|
{ "", 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct font_data charset_1[] = /* Uses VDMX */
|
|
|
|
{
|
|
|
|
{ "wine_vdmx", 10, FW_NORMAL, 10, 8, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 11, FW_NORMAL, 11, 9, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 12, FW_NORMAL, 12, 10, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 13, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 14, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 15, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 16, FW_NORMAL, 16, 13, 3, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 17, FW_NORMAL, 16, 13, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 18, FW_NORMAL, 16, 13, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 19, FW_NORMAL, 19, 15, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 20, FW_NORMAL, 20, 16, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 21, FW_NORMAL, 21, 17, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 22, FW_NORMAL, 22, 18, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 23, FW_NORMAL, 23, 19, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 24, FW_NORMAL, 23, 19, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 25, FW_NORMAL, 25, 21, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 26, FW_NORMAL, 26, 22, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 27, FW_NORMAL, 27, 23, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 28, FW_NORMAL, 27, 23, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 29, FW_NORMAL, 29, 24, 5, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 30, FW_NORMAL, 29, 24, 5, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 31, FW_NORMAL, 29, 24, 5, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 32, FW_NORMAL, 32, 26, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 48, FW_NORMAL, 48, 40, 8, 10, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 64, FW_NORMAL, 64, 54, 10, 13, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", 96, FW_NORMAL, 95, 79, 16, 18, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -10, FW_NORMAL, 12, 10, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -11, FW_NORMAL, 13, 11, 2, 2, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -12, FW_NORMAL, 16, 13, 3, 4, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -13, FW_NORMAL, 16, 13, 3, 3, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -14, FW_NORMAL, 19, 15, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -15, FW_NORMAL, 20, 16, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -16, FW_NORMAL, 21, 17, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -17, FW_NORMAL, 22, 18, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -18, FW_NORMAL, 23, 19, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -19, FW_NORMAL, 25, 21, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -20, FW_NORMAL, 26, 22, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -21, FW_NORMAL, 27, 23, 4, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -22, FW_NORMAL, 27, 23, 4, 5, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -23, FW_NORMAL, 29, 24, 5, 6, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -24, FW_NORMAL, 32, 26, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -25, FW_NORMAL, 32, 26, 6, 7, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -26, FW_NORMAL, 33, 27, 6, 7, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -27, FW_NORMAL, 35, 29, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -28, FW_NORMAL, 36, 30, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -29, FW_NORMAL, 36, 30, 6, 7, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -30, FW_NORMAL, 38, 32, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -31, FW_NORMAL, 39, 33, 6, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -32, FW_NORMAL, 40, 33, 7, 8, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -48, FW_NORMAL, 60, 50, 10, 12, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -64, FW_NORMAL, 81, 67, 14, 17, 0, 96, TRUE },
|
|
|
|
{ "wine_vdmx", -96, FW_NORMAL, 119, 99, 20, 23, 0, 96, TRUE },
|
|
|
|
{ "", 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct vdmx_data
|
|
|
|
{
|
|
|
|
WORD version;
|
|
|
|
BYTE bCharSet;
|
|
|
|
const struct font_data *fd;
|
|
|
|
} data[] =
|
|
|
|
{
|
|
|
|
{ 0, 0, charset_0 },
|
|
|
|
{ 0, 1, charset_1 },
|
|
|
|
{ 1, 0, charset_0 },
|
|
|
|
{ 1, 1, charset_1 }
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
DWORD size, num;
|
|
|
|
WORD *vdmx_header;
|
|
|
|
BYTE *ratio_rec;
|
|
|
|
char ttf_name[MAX_PATH];
|
|
|
|
void *res, *copy;
|
2015-07-17 11:23:14 +02:00
|
|
|
BOOL ret;
|
2013-08-28 15:21:15 +02:00
|
|
|
|
|
|
|
if (!pAddFontResourceExA)
|
|
|
|
{
|
|
|
|
win_skip("AddFontResourceExA unavailable\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(data); i++)
|
2013-08-28 15:21:15 +02:00
|
|
|
{
|
|
|
|
res = get_res_data( "wine_vdmx.ttf", &size );
|
|
|
|
|
|
|
|
copy = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
memcpy( copy, res, size );
|
|
|
|
vdmx_header = find_ttf_table( copy, size, MS_MAKE_TAG('V','D','M','X') );
|
|
|
|
vdmx_header[0] = GET_BE_WORD( data[i].version );
|
|
|
|
ok( GET_BE_WORD( vdmx_header[1] ) == 1, "got %04x\n", GET_BE_WORD( vdmx_header[1] ) );
|
|
|
|
ok( GET_BE_WORD( vdmx_header[2] ) == 1, "got %04x\n", GET_BE_WORD( vdmx_header[2] ) );
|
|
|
|
ratio_rec = (BYTE *)&vdmx_header[3];
|
|
|
|
ratio_rec[0] = data[i].bCharSet;
|
|
|
|
|
|
|
|
write_tmp_file( copy, &size, ttf_name );
|
|
|
|
HeapFree( GetProcessHeap(), 0, copy );
|
|
|
|
|
|
|
|
ok( !is_truetype_font_installed("wine_vdmx"), "Already installed\n" );
|
|
|
|
num = pAddFontResourceExA( ttf_name, FR_PRIVATE, 0 );
|
|
|
|
if (!num) win_skip("Unable to add ttf font resource\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok( is_truetype_font_installed("wine_vdmx"), "Not installed\n" );
|
|
|
|
test_height( hdc, data[i].fd );
|
|
|
|
pRemoveFontResourceExA( ttf_name, FR_PRIVATE, 0 );
|
|
|
|
}
|
2015-07-17 11:23:14 +02:00
|
|
|
ret = DeleteFileA( ttf_name );
|
|
|
|
ok(ret || broken(!ret && GetLastError() == ERROR_ACCESS_DENIED),
|
|
|
|
"DeleteFile error %d\n", GetLastError());
|
2013-08-28 15:21:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 15:21:09 +02:00
|
|
|
static void test_height_selection(void)
|
|
|
|
{
|
|
|
|
static const struct font_data tahoma[] =
|
|
|
|
{
|
2013-08-28 15:21:10 +02:00
|
|
|
{"Tahoma", -12, FW_NORMAL, 14, 12, 2, 2, 0, 96, TRUE },
|
|
|
|
{"Tahoma", -24, FW_NORMAL, 29, 24, 5, 5, 0, 96, TRUE },
|
|
|
|
{"Tahoma", -48, FW_NORMAL, 58, 48, 10, 10, 0, 96, TRUE },
|
|
|
|
{"Tahoma", -96, FW_NORMAL, 116, 96, 20, 20, 0, 96, TRUE },
|
|
|
|
{"Tahoma", -192, FW_NORMAL, 232, 192, 40, 40, 0, 96, TRUE },
|
|
|
|
{"Tahoma", 12, FW_NORMAL, 12, 10, 2, 2, 0, 96, TRUE },
|
2013-08-28 15:21:14 +02:00
|
|
|
{"Tahoma", 24, FW_NORMAL, 24, 20, 4, 4, 0, 96, TRUE },
|
2013-08-28 15:21:10 +02:00
|
|
|
{"Tahoma", 48, FW_NORMAL, 48, 40, 8, 8, 0, 96, TRUE },
|
|
|
|
{"Tahoma", 96, FW_NORMAL, 96, 80, 16, 17, 0, 96, FALSE },
|
2013-08-28 15:21:14 +02:00
|
|
|
{"Tahoma", 192, FW_NORMAL, 192, 159, 33, 33, 0, 96, TRUE },
|
2013-08-28 15:21:10 +02:00
|
|
|
{"", 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
2013-08-28 15:21:09 +02:00
|
|
|
};
|
|
|
|
HDC hdc = CreateCompatibleDC(0);
|
2016-02-09 15:24:28 +01:00
|
|
|
ok(hdc != NULL, "failed to create hdc\n");
|
2013-08-28 15:21:09 +02:00
|
|
|
|
|
|
|
test_height( hdc, tahoma );
|
2013-08-28 15:21:15 +02:00
|
|
|
test_height_selection_vdmx( hdc );
|
2010-05-18 13:53:18 +02:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2016-02-09 15:24:27 +01:00
|
|
|
static UINT get_font_fsselection(LOGFONTA *lf)
|
|
|
|
{
|
|
|
|
OUTLINETEXTMETRICA *otm;
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
DWORD ret, otm_size;
|
|
|
|
UINT fsSelection;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont = CreateFontIndirectA(lf);
|
|
|
|
ok(hfont != NULL, "failed to create a font\n");
|
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
|
|
|
|
otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
|
|
|
|
otm->otmSize = sizeof(*otm);
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
|
|
|
|
ok(ret == otm->otmSize, "expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
|
|
|
|
fsSelection = otm->otmfsSelection;
|
|
|
|
HeapFree(GetProcessHeap(), 0, otm);
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
|
|
|
|
return fsSelection;
|
|
|
|
}
|
|
|
|
|
2007-02-02 11:18:15 +01:00
|
|
|
static void test_GetOutlineTextMetrics(void)
|
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
OUTLINETEXTMETRICA *otm;
|
|
|
|
LOGFONTA lf;
|
2007-02-02 11:18:15 +01:00
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
HDC hdc;
|
|
|
|
DWORD ret, otm_size;
|
2009-01-09 18:08:50 +01:00
|
|
|
LPSTR unset_ptr;
|
2016-02-09 15:24:27 +01:00
|
|
|
UINT fsSelection;
|
|
|
|
|
2016-02-09 20:43:10 +01:00
|
|
|
/* check fsSelection field with bold simulation */
|
2016-02-09 15:24:27 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
2016-02-09 20:43:10 +01:00
|
|
|
strcpy(lf.lfFaceName, "Wingdings");
|
|
|
|
lf.lfCharSet = SYMBOL_CHARSET;
|
|
|
|
|
|
|
|
/* regular face */
|
|
|
|
fsSelection = get_font_fsselection(&lf);
|
|
|
|
ok((fsSelection & (1 << 5)) == 0, "got 0x%x\n", fsSelection);
|
|
|
|
|
|
|
|
/* face with bold simulation */
|
|
|
|
lf.lfWeight = FW_BOLD;
|
|
|
|
fsSelection = get_font_fsselection(&lf);
|
|
|
|
ok((fsSelection & (1 << 5)) != 0, "got 0x%x\n", fsSelection);
|
2016-02-09 15:24:27 +01:00
|
|
|
|
2016-02-09 20:43:10 +01:00
|
|
|
/* check fsSelection field with oblique simulation */
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
2016-02-09 15:24:27 +01:00
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfPitchAndFamily = DEFAULT_PITCH;
|
|
|
|
lf.lfQuality = PROOF_QUALITY;
|
|
|
|
|
|
|
|
/* regular face */
|
|
|
|
fsSelection = get_font_fsselection(&lf);
|
|
|
|
ok((fsSelection & 1) == 0, "got 0x%x\n", fsSelection);
|
|
|
|
|
|
|
|
lf.lfItalic = 1;
|
|
|
|
/* face with oblique simulation */
|
|
|
|
fsSelection = get_font_fsselection(&lf);
|
|
|
|
ok((fsSelection & 1) == 1, "got 0x%x\n", fsSelection);
|
2007-02-02 11:18:15 +01:00
|
|
|
|
|
|
|
if (!is_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-15 08:52:33 +01:00
|
|
|
hdc = GetDC(0);
|
|
|
|
|
2007-02-02 11:18:15 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfPitchAndFamily = DEFAULT_PITCH;
|
|
|
|
lf.lfQuality = PROOF_QUALITY;
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2016-02-09 15:24:27 +01:00
|
|
|
ok(hfont != NULL, "failed to create a font\n");
|
2007-02-02 11:18:15 +01:00
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
2013-10-17 01:55:20 +02:00
|
|
|
otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
|
2007-02-02 11:18:15 +01:00
|
|
|
|
|
|
|
otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
|
|
|
|
|
|
|
|
memset(otm, 0xAA, otm_size);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
otm->otmSize = sizeof(*otm); /* just in case for Win9x compatibility */
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
|
2007-02-02 11:18:15 +01:00
|
|
|
ok(ret == 1 /* Win9x */ ||
|
|
|
|
ret == otm->otmSize /* XP*/,
|
|
|
|
"expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
|
|
|
|
if (ret != 1) /* Win9x doesn't care about pointing beyond of the buffer */
|
|
|
|
{
|
|
|
|
ok(otm->otmpFamilyName == NULL, "expected NULL got %p\n", otm->otmpFamilyName);
|
|
|
|
ok(otm->otmpFaceName == NULL, "expected NULL got %p\n", otm->otmpFaceName);
|
|
|
|
ok(otm->otmpStyleName == NULL, "expected NULL got %p\n", otm->otmpStyleName);
|
|
|
|
ok(otm->otmpFullName == NULL, "expected NULL got %p\n", otm->otmpFullName);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(otm, 0xAA, otm_size);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
otm->otmSize = otm_size; /* just in case for Win9x compatibility */
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
|
2007-02-02 11:18:15 +01:00
|
|
|
ok(ret == 1 /* Win9x */ ||
|
|
|
|
ret == otm->otmSize /* XP*/,
|
|
|
|
"expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
|
|
|
|
if (ret != 1) /* Win9x doesn't care about pointing beyond of the buffer */
|
|
|
|
{
|
|
|
|
ok(otm->otmpFamilyName != NULL, "expected not NULL got %p\n", otm->otmpFamilyName);
|
|
|
|
ok(otm->otmpFaceName != NULL, "expected not NULL got %p\n", otm->otmpFaceName);
|
|
|
|
ok(otm->otmpStyleName != NULL, "expected not NULL got %p\n", otm->otmpStyleName);
|
|
|
|
ok(otm->otmpFullName != NULL, "expected not NULL got %p\n", otm->otmpFullName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ask about truncated data */
|
|
|
|
memset(otm, 0xAA, otm_size);
|
2009-01-09 18:08:50 +01:00
|
|
|
memset(&unset_ptr, 0xAA, sizeof(unset_ptr));
|
2007-02-02 11:18:15 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
otm->otmSize = sizeof(*otm) - sizeof(LPSTR); /* just in case for Win9x compatibility */
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
|
2007-02-02 11:18:15 +01:00
|
|
|
ok(ret == 1 /* Win9x */ ||
|
|
|
|
ret == otm->otmSize /* XP*/,
|
|
|
|
"expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
|
|
|
|
if (ret != 1) /* Win9x doesn't care about pointing beyond of the buffer */
|
|
|
|
{
|
|
|
|
ok(otm->otmpFamilyName == NULL, "expected NULL got %p\n", otm->otmpFamilyName);
|
|
|
|
ok(otm->otmpFaceName == NULL, "expected NULL got %p\n", otm->otmpFaceName);
|
|
|
|
ok(otm->otmpStyleName == NULL, "expected NULL got %p\n", otm->otmpStyleName);
|
|
|
|
}
|
2009-01-09 18:08:50 +01:00
|
|
|
ok(otm->otmpFullName == unset_ptr, "expected %p got %p\n", unset_ptr, otm->otmpFullName);
|
2007-02-02 11:18:15 +01:00
|
|
|
|
2015-07-21 01:38:05 +02:00
|
|
|
/* check handling of NULL pointer */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm_size, NULL);
|
|
|
|
ok(ret == otm_size, "expected %u, got %u, error %d\n", otm_size, ret, GetLastError());
|
|
|
|
|
2007-02-02 11:18:15 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, otm);
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2013-12-21 14:32:24 +01:00
|
|
|
static void testJustification(HDC hdc, PCSTR str, RECT *clientArea)
|
2007-02-08 16:12:08 +01:00
|
|
|
{
|
2010-05-02 20:53:58 +02:00
|
|
|
INT y,
|
2007-02-08 16:12:08 +01:00
|
|
|
breakCount,
|
|
|
|
areaWidth = clientArea->right - clientArea->left,
|
|
|
|
nErrors = 0, e;
|
2013-12-21 14:32:24 +01:00
|
|
|
const char *pFirstChar, *pLastChar;
|
2007-02-08 16:12:08 +01:00
|
|
|
SIZE size;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
struct err
|
|
|
|
{
|
2013-12-21 14:32:24 +01:00
|
|
|
const char *start;
|
2012-12-11 16:52:43 +01:00
|
|
|
int len;
|
2007-02-08 16:12:08 +01:00
|
|
|
int GetTextExtentExPointWWidth;
|
2012-12-11 16:52:43 +01:00
|
|
|
} error[20];
|
2007-02-08 16:12:08 +01:00
|
|
|
|
|
|
|
GetTextMetricsA(hdc, &tm);
|
|
|
|
y = clientArea->top;
|
|
|
|
do {
|
|
|
|
breakCount = 0;
|
|
|
|
while (*str == tm.tmBreakChar) str++; /* skip leading break chars */
|
|
|
|
pFirstChar = str;
|
|
|
|
|
|
|
|
do {
|
|
|
|
pLastChar = str;
|
|
|
|
|
|
|
|
/* if not at the end of the string, ... */
|
|
|
|
if (*str == '\0') break;
|
|
|
|
/* ... add the next word to the current extent */
|
|
|
|
while (*str != '\0' && *str++ != tm.tmBreakChar);
|
|
|
|
breakCount++;
|
|
|
|
SetTextJustification(hdc, 0, 0);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, pFirstChar, str - pFirstChar - 1, &size);
|
2007-02-08 16:12:08 +01:00
|
|
|
} while ((int) size.cx < areaWidth);
|
|
|
|
|
|
|
|
/* ignore trailing break chars */
|
|
|
|
breakCount--;
|
|
|
|
while (*(pLastChar - 1) == tm.tmBreakChar)
|
|
|
|
{
|
|
|
|
pLastChar--;
|
|
|
|
breakCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*str == '\0' || breakCount <= 0) pLastChar = str;
|
|
|
|
|
|
|
|
SetTextJustification(hdc, 0, 0);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, pFirstChar, pLastChar - pFirstChar, &size);
|
2007-02-08 16:12:08 +01:00
|
|
|
|
|
|
|
/* do not justify the last extent */
|
|
|
|
if (*str != '\0' && breakCount > 0)
|
|
|
|
{
|
|
|
|
SetTextJustification(hdc, areaWidth - size.cx, breakCount);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, pFirstChar, pLastChar - pFirstChar, &size);
|
2018-06-25 21:46:41 +02:00
|
|
|
if (size.cx != areaWidth && nErrors < ARRAY_SIZE(error) - 1)
|
2012-12-11 16:52:43 +01:00
|
|
|
{
|
|
|
|
error[nErrors].start = pFirstChar;
|
|
|
|
error[nErrors].len = pLastChar - pFirstChar;
|
|
|
|
error[nErrors].GetTextExtentExPointWWidth = size.cx;
|
|
|
|
nErrors++;
|
|
|
|
}
|
2007-02-08 16:12:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
y += size.cy;
|
|
|
|
str = pLastChar;
|
|
|
|
} while (*str && y < clientArea->bottom);
|
|
|
|
|
|
|
|
for (e = 0; e < nErrors; e++)
|
|
|
|
{
|
|
|
|
/* The width returned by GetTextExtentPoint32() is exactly the same
|
|
|
|
returned by GetTextExtentExPointW() - see dlls/gdi32/font.c */
|
|
|
|
ok(error[e].GetTextExtentExPointWWidth == areaWidth,
|
2012-12-11 16:52:43 +01:00
|
|
|
"GetTextExtentPointW() for \"%.*s\" should have returned a width of %d, not %d.\n",
|
|
|
|
error[e].len, error[e].start, areaWidth, error[e].GetTextExtentExPointWWidth);
|
2007-02-08 16:12:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SetTextJustification(void)
|
|
|
|
{
|
2007-02-15 19:41:34 +01:00
|
|
|
HDC hdc;
|
|
|
|
RECT clientArea;
|
2007-02-08 16:12:08 +01:00
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
2007-02-15 19:41:34 +01:00
|
|
|
HWND hwnd;
|
2012-12-18 17:41:42 +01:00
|
|
|
SIZE size, expect;
|
|
|
|
int i;
|
|
|
|
WORD indices[2];
|
2013-12-21 14:32:24 +01:00
|
|
|
static const char testText[] =
|
2007-02-08 16:12:08 +01:00
|
|
|
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
|
|
|
|
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
|
|
|
|
"enim ad minim veniam, quis nostrud exercitation ullamco laboris "
|
|
|
|
"nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
|
|
|
|
"reprehenderit in voluptate velit esse cillum dolore eu fugiat "
|
|
|
|
"nulla pariatur. Excepteur sint occaecat cupidatat non proident, "
|
|
|
|
"sunt in culpa qui officia deserunt mollit anim id est laborum.";
|
|
|
|
|
2007-02-15 19:41:34 +01:00
|
|
|
hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0, 400,400, 0, 0, 0, NULL);
|
|
|
|
GetClientRect( hwnd, &clientArea );
|
|
|
|
hdc = GetDC( hwnd );
|
|
|
|
|
2014-04-11 06:45:59 +02:00
|
|
|
if (!is_font_installed("Times New Roman"))
|
|
|
|
{
|
|
|
|
skip("Times New Roman is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-08 16:12:08 +01:00
|
|
|
memset(&lf, 0, sizeof lf);
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lstrcpyA(lf.lfFaceName, "Times New Roman");
|
|
|
|
hfont = create_font("Times New Roman", &lf);
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
testJustification(hdc, testText, &clientArea);
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
if (!pGetTextExtentExPointI) goto done;
|
|
|
|
GetGlyphIndicesA( hdc, "A ", 2, indices, 0 );
|
2012-12-18 17:41:42 +01:00
|
|
|
|
|
|
|
SetTextJustification(hdc, 0, 0);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 1, &expect);
|
|
|
|
GetTextExtentPoint32A(hdc, " ", 3, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == 3 * expect.cx, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 4, 1);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 1, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == expect.cx + 4, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 9, 2);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 2, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == 2 * expect.cx + 9, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 7, 3);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 3, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == 3 * expect.cx + 7, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 7, 3);
|
|
|
|
SetTextCharacterExtra(hdc, 2 );
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 3, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == 3 * (expect.cx + 2) + 7, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 0, 0);
|
|
|
|
SetTextCharacterExtra(hdc, 0);
|
|
|
|
size.cx = size.cy = 1234;
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, " ", 0, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == 0 && size.cy == 0, "wrong size %d,%d\n", size.cx, size.cy );
|
|
|
|
pGetTextExtentExPointI(hdc, indices, 2, -1, NULL, NULL, &expect);
|
|
|
|
SetTextJustification(hdc, 5, 1);
|
|
|
|
pGetTextExtentExPointI(hdc, indices, 2, -1, NULL, NULL, &size);
|
|
|
|
ok( size.cx == expect.cx + 5, "wrong size %d/%d\n", size.cx, expect.cx );
|
|
|
|
SetTextJustification(hdc, 0, 0);
|
|
|
|
|
2012-12-11 16:52:43 +01:00
|
|
|
SetMapMode( hdc, MM_ANISOTROPIC );
|
|
|
|
SetWindowExtEx( hdc, 2, 2, NULL );
|
|
|
|
GetClientRect( hwnd, &clientArea );
|
|
|
|
DPtoLP( hdc, (POINT *)&clientArea, 2 );
|
|
|
|
testJustification(hdc, testText, &clientArea);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, "A", 1, &expect);
|
2012-12-18 17:41:42 +01:00
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
SetTextCharacterExtra(hdc, i);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, "A", 1, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == expect.cx + i, "wrong size %d/%d+%d\n", size.cx, expect.cx, i );
|
|
|
|
}
|
|
|
|
SetTextCharacterExtra(hdc, 0);
|
|
|
|
pGetTextExtentExPointI(hdc, indices, 1, -1, NULL, NULL, &expect);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
SetTextCharacterExtra(hdc, i);
|
|
|
|
pGetTextExtentExPointI(hdc, indices, 1, -1, NULL, NULL, &size);
|
|
|
|
ok( size.cx == expect.cx + i, "wrong size %d/%d+%d\n", size.cx, expect.cx, i );
|
|
|
|
}
|
|
|
|
SetTextCharacterExtra(hdc, 0);
|
|
|
|
|
2012-12-11 16:52:43 +01:00
|
|
|
SetViewportExtEx( hdc, 3, 3, NULL );
|
|
|
|
GetClientRect( hwnd, &clientArea );
|
|
|
|
DPtoLP( hdc, (POINT *)&clientArea, 2 );
|
|
|
|
testJustification(hdc, testText, &clientArea);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, "A", 1, &expect);
|
2012-12-18 17:41:42 +01:00
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
SetTextCharacterExtra(hdc, i);
|
2013-10-17 01:55:20 +02:00
|
|
|
GetTextExtentPoint32A(hdc, "A", 1, &size);
|
2012-12-18 17:41:42 +01:00
|
|
|
ok( size.cx == expect.cx + i, "wrong size %d/%d+%d\n", size.cx, expect.cx, i );
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2007-02-08 16:12:08 +01:00
|
|
|
DeleteObject(hfont);
|
2007-02-15 19:41:34 +01:00
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
2007-02-08 16:12:08 +01:00
|
|
|
}
|
|
|
|
|
2007-02-20 09:35:19 +01:00
|
|
|
static BOOL get_glyph_indices(INT charset, UINT code_page, WORD *idx, UINT count, BOOL unicode)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
CHARSETINFO csi;
|
|
|
|
FONTSIGNATURE fs;
|
|
|
|
INT cs;
|
|
|
|
DWORD i, ret;
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
assert(count <= 128);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
|
|
|
|
lf.lfCharSet = charset;
|
|
|
|
lf.lfHeight = 10;
|
|
|
|
lstrcpyA(lf.lfFaceName, "Arial");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
cs = GetTextCharsetInfo(hdc, &fs, 0);
|
|
|
|
ok(cs == charset, "expected %d, got %d\n", charset, cs);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-06-20 00:59:57 +02:00
|
|
|
ret = GetTextFaceA(hdc, sizeof(name), name);
|
|
|
|
ok(ret, "GetTextFaceA error %u\n", GetLastError());
|
2007-02-20 09:35:19 +01:00
|
|
|
|
|
|
|
if (charset == SYMBOL_CHARSET)
|
|
|
|
{
|
|
|
|
ok(strcmp("Arial", name), "face name should NOT be Arial\n");
|
2015-09-07 23:52:55 +02:00
|
|
|
ok(fs.fsCsb[0] & (1u << 31), "symbol encoding should be available\n");
|
2007-02-20 09:35:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(!strcmp("Arial", name), "face name should be Arial, not %s\n", name);
|
2015-09-07 23:52:55 +02:00
|
|
|
ok(!(fs.fsCsb[0] & (1u << 31)), "symbol encoding should NOT be available\n");
|
2007-02-20 09:35:19 +01:00
|
|
|
}
|
|
|
|
|
2009-01-03 20:13:29 +01:00
|
|
|
if (!TranslateCharsetInfo((DWORD *)(INT_PTR)cs, &csi, TCI_SRCCHARSET))
|
2007-02-20 09:35:19 +01:00
|
|
|
{
|
|
|
|
trace("Can't find codepage for charset %d\n", cs);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ok(csi.ciACP == code_page, "expected %d, got %d\n", code_page, csi.ciACP);
|
|
|
|
|
2011-01-11 13:07:03 +01:00
|
|
|
if (pGdiGetCodePage != NULL && pGdiGetCodePage(hdc) != code_page)
|
|
|
|
{
|
|
|
|
skip("Font code page %d, looking for code page %d\n",
|
|
|
|
pGdiGetCodePage(hdc), code_page);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-02-20 09:35:19 +01:00
|
|
|
if (unicode)
|
|
|
|
{
|
|
|
|
char ansi_buf[128];
|
|
|
|
WCHAR unicode_buf[128];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) ansi_buf[i] = (BYTE)(i + 128);
|
|
|
|
|
|
|
|
MultiByteToWideChar(code_page, 0, ansi_buf, count, unicode_buf, count);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pGetGlyphIndicesW(hdc, unicode_buf, count, idx, 0);
|
2011-01-11 13:07:03 +01:00
|
|
|
ok(ret == count, "GetGlyphIndicesW expected %d got %d, error %u\n",
|
|
|
|
count, ret, GetLastError());
|
2007-02-20 09:35:19 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char ansi_buf[128];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) ansi_buf[i] = (BYTE)(i + 128);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetGlyphIndicesA(hdc, ansi_buf, count, idx, 0);
|
2011-01-11 13:07:03 +01:00
|
|
|
ok(ret == count, "GetGlyphIndicesA expected %d got %d, error %u\n",
|
|
|
|
count, ret, GetLastError());
|
2007-02-20 09:35:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-02-15 08:52:33 +01:00
|
|
|
static void test_font_charset(void)
|
|
|
|
{
|
|
|
|
static struct charset_data
|
|
|
|
{
|
|
|
|
INT charset;
|
|
|
|
UINT code_page;
|
|
|
|
WORD font_idxA[128], font_idxW[128];
|
|
|
|
} cd[] =
|
|
|
|
{
|
|
|
|
{ ANSI_CHARSET, 1252 },
|
2007-02-15 16:14:01 +01:00
|
|
|
{ RUSSIAN_CHARSET, 1251 },
|
|
|
|
{ SYMBOL_CHARSET, CP_SYMBOL } /* keep it as the last one */
|
2007-02-15 08:52:33 +01:00
|
|
|
};
|
|
|
|
int i;
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
if (!pGetGlyphIndicesW)
|
2007-02-15 08:52:33 +01:00
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("Skipping the font charset test on a Win9x platform\n");
|
2007-02-15 08:52:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(cd); i++)
|
2007-02-15 08:52:33 +01:00
|
|
|
{
|
2007-02-15 16:14:01 +01:00
|
|
|
if (cd[i].charset == SYMBOL_CHARSET)
|
|
|
|
{
|
|
|
|
if (!is_font_installed("Symbol") && !is_font_installed("Wingdings"))
|
|
|
|
{
|
|
|
|
skip("Symbol or Wingdings is not installed\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-11 13:07:03 +01:00
|
|
|
if (get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxA, 128, FALSE) &&
|
|
|
|
get_glyph_indices(cd[i].charset, cd[i].code_page, cd[i].font_idxW, 128, TRUE))
|
|
|
|
ok(!memcmp(cd[i].font_idxA, cd[i].font_idxW, 128*sizeof(WORD)), "%d: indices don't match\n", i);
|
2007-02-15 08:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(memcmp(cd[0].font_idxW, cd[1].font_idxW, 128*sizeof(WORD)), "0 vs 1: indices shouldn't match\n");
|
2007-02-15 16:14:01 +01:00
|
|
|
if (i > 2)
|
|
|
|
{
|
|
|
|
ok(memcmp(cd[0].font_idxW, cd[2].font_idxW, 128*sizeof(WORD)), "0 vs 2: indices shouldn't match\n");
|
|
|
|
ok(memcmp(cd[1].font_idxW, cd[2].font_idxW, 128*sizeof(WORD)), "1 vs 2: indices shouldn't match\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Symbol or Wingdings is not installed\n");
|
2007-02-15 08:52:33 +01:00
|
|
|
}
|
|
|
|
|
2013-02-26 02:31:20 +01:00
|
|
|
static void test_GdiGetCodePage(void)
|
|
|
|
{
|
|
|
|
static const struct _matching_data
|
|
|
|
{
|
|
|
|
UINT current_codepage;
|
|
|
|
LPCSTR lfFaceName;
|
|
|
|
UCHAR lfCharSet;
|
|
|
|
UINT expected_codepage;
|
|
|
|
} matching_data[] = {
|
|
|
|
{1251, "Arial", ANSI_CHARSET, 1252},
|
|
|
|
{1251, "Tahoma", ANSI_CHARSET, 1252},
|
|
|
|
|
|
|
|
{1252, "Arial", ANSI_CHARSET, 1252},
|
|
|
|
{1252, "Tahoma", ANSI_CHARSET, 1252},
|
|
|
|
|
|
|
|
{1253, "Arial", ANSI_CHARSET, 1252},
|
|
|
|
{1253, "Tahoma", ANSI_CHARSET, 1252},
|
|
|
|
|
|
|
|
{ 932, "Arial", ANSI_CHARSET, 1252}, /* Japanese Windows returns 1252, not 932 */
|
|
|
|
{ 932, "Tahoma", ANSI_CHARSET, 1252},
|
|
|
|
{ 932, "MS UI Gothic", ANSI_CHARSET, 1252},
|
|
|
|
|
|
|
|
{ 936, "Arial", ANSI_CHARSET, 936},
|
|
|
|
{ 936, "Tahoma", ANSI_CHARSET, 936},
|
|
|
|
{ 936, "Simsun", ANSI_CHARSET, 936},
|
|
|
|
|
|
|
|
{ 949, "Arial", ANSI_CHARSET, 949},
|
|
|
|
{ 949, "Tahoma", ANSI_CHARSET, 949},
|
|
|
|
{ 949, "Gulim", ANSI_CHARSET, 949},
|
|
|
|
|
|
|
|
{ 950, "Arial", ANSI_CHARSET, 950},
|
|
|
|
{ 950, "Tahoma", ANSI_CHARSET, 950},
|
|
|
|
{ 950, "PMingLiU", ANSI_CHARSET, 950},
|
|
|
|
};
|
|
|
|
HDC hdc;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2013-02-26 02:31:20 +01:00
|
|
|
HFONT hfont;
|
2020-02-26 16:45:23 +01:00
|
|
|
UINT acp;
|
2013-02-26 02:31:20 +01:00
|
|
|
DWORD codepage;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!pGdiGetCodePage)
|
|
|
|
{
|
|
|
|
skip("GdiGetCodePage not available on this platform\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
acp = GetACP();
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(matching_data); i++)
|
2013-02-26 02:31:20 +01:00
|
|
|
{
|
|
|
|
/* only test data matched current locale codepage */
|
|
|
|
if (matching_data[i].current_codepage != acp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!is_font_installed(matching_data[i].lfFaceName))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", matching_data[i].lfFaceName);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -16;
|
|
|
|
lf.lfCharSet = matching_data[i].lfCharSet;
|
|
|
|
lstrcpyA(lf.lfFaceName, matching_data[i].lfFaceName);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
codepage = pGdiGetCodePage(hdc);
|
|
|
|
ok(codepage == matching_data[i].expected_codepage,
|
|
|
|
"GdiGetCodePage should have returned %d, got %d\n", matching_data[i].expected_codepage, codepage);
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
2014-06-10 10:48:38 +02:00
|
|
|
|
|
|
|
/* CLIP_DFA_DISABLE turns off the font association */
|
|
|
|
lf.lfClipPrecision = CLIP_DFA_DISABLE;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
codepage = pGdiGetCodePage(hdc);
|
|
|
|
ok(codepage == 1252, "GdiGetCodePage returned %d\n", codepage);
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
2013-02-26 02:31:20 +01:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-01 20:30:12 +01:00
|
|
|
static void test_GetFontUnicodeRanges(void)
|
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont, hfont_old;
|
2007-03-06 12:14:25 +01:00
|
|
|
DWORD size;
|
2007-03-01 20:30:12 +01:00
|
|
|
GLYPHSET *gs;
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
if (!pGetFontUnicodeRanges)
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("GetFontUnicodeRanges not available before W2K\n");
|
2007-03-05 17:29:04 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-01 20:30:12 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lstrcpyA(lf.lfFaceName, "Arial");
|
|
|
|
hfont = create_font("Arial", &lf);
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
size = pGetFontUnicodeRanges(NULL, NULL);
|
2007-03-01 20:30:12 +01:00
|
|
|
ok(!size, "GetFontUnicodeRanges succeeded unexpectedly\n");
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
size = pGetFontUnicodeRanges(hdc, NULL);
|
2007-03-01 20:30:12 +01:00
|
|
|
ok(size, "GetFontUnicodeRanges failed unexpectedly\n");
|
|
|
|
|
2020-02-26 16:45:23 +01:00
|
|
|
gs = heap_alloc_zero(size);
|
2007-03-01 20:30:12 +01:00
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
size = pGetFontUnicodeRanges(hdc, gs);
|
2007-03-01 20:30:12 +01:00
|
|
|
ok(size, "GetFontUnicodeRanges failed\n");
|
2020-02-26 16:45:23 +01:00
|
|
|
ok(gs->cRanges, "Unexpected ranges count.\n");
|
2011-09-26 23:41:14 +02:00
|
|
|
|
2020-02-26 16:45:23 +01:00
|
|
|
heap_free(gs);
|
2007-03-01 20:30:12 +01:00
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2007-03-06 12:14:25 +01:00
|
|
|
struct enum_font_data
|
|
|
|
{
|
2016-04-14 12:12:35 +02:00
|
|
|
int total, size;
|
|
|
|
LOGFONTA *lf;
|
2007-03-06 12:14:25 +01:00
|
|
|
};
|
|
|
|
|
2012-09-07 12:39:51 +02:00
|
|
|
struct enum_fullname_data
|
|
|
|
{
|
2016-04-14 12:12:35 +02:00
|
|
|
int total, size;
|
|
|
|
ENUMLOGFONTA *elf;
|
2012-09-07 12:39:51 +02:00
|
|
|
};
|
|
|
|
|
2020-09-17 19:30:42 +02:00
|
|
|
struct enum_fullname_data_w
|
|
|
|
{
|
|
|
|
int total, size;
|
|
|
|
ENUMLOGFONTW *elf;
|
|
|
|
};
|
|
|
|
|
2008-06-27 14:56:02 +02:00
|
|
|
struct enum_font_dataW
|
|
|
|
{
|
2016-04-14 12:12:35 +02:00
|
|
|
int total, size;
|
|
|
|
LOGFONTW *lf;
|
2008-06-27 14:56:02 +02:00
|
|
|
};
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK arial_enum_proc(const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
|
2007-03-06 12:14:25 +01:00
|
|
|
{
|
|
|
|
struct enum_font_data *efd = (struct enum_font_data *)lParam;
|
2013-10-17 01:55:20 +02:00
|
|
|
const NEWTEXTMETRICA *ntm = (const NEWTEXTMETRICA *)tm;
|
2007-03-06 12:14:25 +01:00
|
|
|
|
2008-11-06 08:10:17 +01:00
|
|
|
ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
|
|
|
|
|
2007-03-06 12:14:25 +01:00
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
2012-04-24 10:03:35 +02:00
|
|
|
|
|
|
|
ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efd->total >= efd->size)
|
|
|
|
{
|
|
|
|
efd->size = max( (efd->total + 1) * 2, 256 );
|
|
|
|
efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
|
|
|
|
if (!efd->lf) return 0;
|
|
|
|
}
|
|
|
|
efd->lf[efd->total++] = *lf;
|
2007-03-06 12:14:25 +01:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-06-27 14:56:02 +02:00
|
|
|
static INT CALLBACK arial_enum_procw(const LOGFONTW *lf, const TEXTMETRICW *tm, DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct enum_font_dataW *efd = (struct enum_font_dataW *)lParam;
|
2012-04-24 10:03:35 +02:00
|
|
|
const NEWTEXTMETRICW *ntm = (const NEWTEXTMETRICW *)tm;
|
2008-06-27 14:56:02 +02:00
|
|
|
|
2008-11-06 08:10:17 +01:00
|
|
|
ok(lf->lfHeight == tm->tmHeight, "lfHeight %d != tmHeight %d\n", lf->lfHeight, tm->tmHeight);
|
2008-06-27 14:56:02 +02:00
|
|
|
|
2008-11-06 08:10:17 +01:00
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
2012-04-24 10:03:35 +02:00
|
|
|
|
|
|
|
ok(ntm->ntmCellHeight + ntm->ntmCellHeight/5 >= ntm->ntmSizeEM, "ntmCellHeight %d should be close to ntmSizeEM %d\n", ntm->ntmCellHeight, ntm->ntmSizeEM);
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efd->total >= efd->size)
|
|
|
|
{
|
|
|
|
efd->size = max( (efd->total + 1) * 2, 256 );
|
|
|
|
efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
|
|
|
|
if (!efd->lf) return 0;
|
|
|
|
}
|
|
|
|
efd->lf[efd->total++] = *lf;
|
2008-06-27 14:56:02 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-03-06 12:14:25 +01:00
|
|
|
static void get_charset_stats(struct enum_font_data *efd,
|
|
|
|
int *ansi_charset, int *symbol_charset,
|
|
|
|
int *russian_charset)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*ansi_charset = 0;
|
|
|
|
*symbol_charset = 0;
|
|
|
|
*russian_charset = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < efd->total; i++)
|
|
|
|
{
|
|
|
|
switch (efd->lf[i].lfCharSet)
|
|
|
|
{
|
|
|
|
case ANSI_CHARSET:
|
|
|
|
(*ansi_charset)++;
|
|
|
|
break;
|
|
|
|
case SYMBOL_CHARSET:
|
|
|
|
(*symbol_charset)++;
|
|
|
|
break;
|
|
|
|
case RUSSIAN_CHARSET:
|
|
|
|
(*russian_charset)++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-27 14:56:02 +02:00
|
|
|
static void get_charset_statsW(struct enum_font_dataW *efd,
|
|
|
|
int *ansi_charset, int *symbol_charset,
|
|
|
|
int *russian_charset)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*ansi_charset = 0;
|
|
|
|
*symbol_charset = 0;
|
|
|
|
*russian_charset = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < efd->total; i++)
|
|
|
|
{
|
|
|
|
switch (efd->lf[i].lfCharSet)
|
|
|
|
{
|
|
|
|
case ANSI_CHARSET:
|
|
|
|
(*ansi_charset)++;
|
|
|
|
break;
|
|
|
|
case SYMBOL_CHARSET:
|
|
|
|
(*symbol_charset)++;
|
|
|
|
break;
|
|
|
|
case RUSSIAN_CHARSET:
|
|
|
|
(*russian_charset)++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-06 12:14:25 +01:00
|
|
|
static void test_EnumFontFamilies(const char *font_name, INT font_charset)
|
|
|
|
{
|
|
|
|
struct enum_font_data efd;
|
2008-06-27 14:56:02 +02:00
|
|
|
struct enum_font_dataW efdw;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2007-03-06 12:14:25 +01:00
|
|
|
HDC hdc;
|
|
|
|
int i, ret, ansi_charset, symbol_charset, russian_charset;
|
|
|
|
|
|
|
|
if (*font_name && !is_truetype_font_installed(font_name))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", font_name);
|
|
|
|
return;
|
|
|
|
}
|
2016-04-14 12:12:35 +02:00
|
|
|
memset( &efd, 0, sizeof(efd) );
|
|
|
|
memset( &efdw, 0, sizeof(efdw) );
|
2007-03-06 12:14:25 +01:00
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
/* Observed behaviour: EnumFontFamilies enumerates aliases like "Arial Cyr"
|
|
|
|
* while EnumFontFamiliesEx doesn't.
|
|
|
|
*/
|
|
|
|
if (!*font_name && font_charset == DEFAULT_CHARSET) /* do it only once */
|
|
|
|
{
|
2008-06-27 14:56:02 +02:00
|
|
|
/*
|
|
|
|
* Use EnumFontFamiliesW since win98 crashes when the
|
|
|
|
* second parameter is NULL using EnumFontFamilies
|
|
|
|
*/
|
2008-11-06 08:10:17 +01:00
|
|
|
efdw.total = 0;
|
2007-03-06 12:14:25 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-06-27 14:56:02 +02:00
|
|
|
ret = EnumFontFamiliesW(hdc, NULL, arial_enum_procw, (LPARAM)&efdw);
|
|
|
|
ok(ret || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "EnumFontFamiliesW error %u\n", GetLastError());
|
|
|
|
if(ret)
|
|
|
|
{
|
|
|
|
get_charset_statsW(&efdw, &ansi_charset, &symbol_charset, &russian_charset);
|
2008-11-06 08:10:17 +01:00
|
|
|
ok(efdw.total > 0, "fonts enumerated: NULL\n");
|
2008-06-27 14:56:02 +02:00
|
|
|
ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
|
|
|
|
ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
|
2009-04-27 19:48:17 +02:00
|
|
|
ok(russian_charset > 0 ||
|
|
|
|
broken(russian_charset == 0), /* NT4 */
|
|
|
|
"NULL family should enumerate RUSSIAN_CHARSET\n");
|
2008-06-27 14:56:02 +02:00
|
|
|
}
|
2008-01-15 09:02:29 +01:00
|
|
|
|
2008-11-06 08:10:17 +01:00
|
|
|
efdw.total = 0;
|
2008-01-15 09:02:29 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-06-27 14:56:02 +02:00
|
|
|
ret = EnumFontFamiliesExW(hdc, NULL, arial_enum_procw, (LPARAM)&efdw, 0);
|
|
|
|
ok(ret || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "EnumFontFamiliesExW error %u\n", GetLastError());
|
|
|
|
if(ret)
|
|
|
|
{
|
|
|
|
get_charset_statsW(&efdw, &ansi_charset, &symbol_charset, &russian_charset);
|
2008-11-06 08:10:17 +01:00
|
|
|
ok(efdw.total > 0, "fonts enumerated: NULL\n");
|
2008-06-27 14:56:02 +02:00
|
|
|
ok(ansi_charset > 0, "NULL family should enumerate ANSI_CHARSET\n");
|
|
|
|
ok(symbol_charset > 0, "NULL family should enumerate SYMBOL_CHARSET\n");
|
|
|
|
ok(russian_charset > 0, "NULL family should enumerate RUSSIAN_CHARSET\n");
|
|
|
|
}
|
2007-03-06 12:14:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
efd.total = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, font_name, arial_enum_proc, (LPARAM)&efd);
|
2007-03-06 12:14:25 +01:00
|
|
|
ok(ret, "EnumFontFamilies error %u\n", GetLastError());
|
|
|
|
get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
|
|
|
|
if (*font_name)
|
|
|
|
ok(efd.total > 0, "no fonts enumerated: %s\n", font_name);
|
|
|
|
else
|
|
|
|
ok(!efd.total, "no fonts should be enumerated for empty font_name\n");
|
|
|
|
for (i = 0; i < efd.total; i++)
|
|
|
|
{
|
2016-08-05 16:00:51 +02:00
|
|
|
/* FIXME: remove completely once Wine is fixed */
|
|
|
|
todo_wine_if(efd.lf[i].lfCharSet != font_charset)
|
2007-03-06 12:14:25 +01:00
|
|
|
ok(efd.lf[i].lfCharSet == font_charset, "%d: got charset %d\n", i, efd.lf[i].lfCharSet);
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(!strcmp(efd.lf[i].lfFaceName, font_name), "expected %s, got %s\n",
|
2007-03-06 12:14:25 +01:00
|
|
|
font_name, efd.lf[i].lfFaceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, font_name);
|
2007-03-06 12:14:25 +01:00
|
|
|
efd.total = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesExA(hdc, &lf, arial_enum_proc, (LPARAM)&efd, 0);
|
2007-03-06 12:14:25 +01:00
|
|
|
ok(ret, "EnumFontFamiliesEx error %u\n", GetLastError());
|
|
|
|
get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
|
|
|
|
if (font_charset == SYMBOL_CHARSET)
|
|
|
|
{
|
|
|
|
if (*font_name)
|
|
|
|
ok(efd.total == 0, "no fonts should be enumerated: %s ANSI_CHARSET\n", font_name);
|
|
|
|
else
|
|
|
|
ok(efd.total > 0, "no fonts enumerated: %s\n", font_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(efd.total > 0, "no fonts enumerated: %s ANSI_CHARSET\n", font_name);
|
|
|
|
for (i = 0; i < efd.total; i++)
|
|
|
|
{
|
|
|
|
ok(efd.lf[i].lfCharSet == ANSI_CHARSET, "%d: got charset %d\n", i, efd.lf[i].lfCharSet);
|
|
|
|
if (*font_name)
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(!strcmp(efd.lf[i].lfFaceName, font_name), "expected %s, got %s\n",
|
2007-03-06 12:14:25 +01:00
|
|
|
font_name, efd.lf[i].lfFaceName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DEFAULT_CHARSET should enumerate all available charsets */
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, font_name);
|
2007-03-06 12:14:25 +01:00
|
|
|
efd.total = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &lf, arial_enum_proc, (LPARAM)&efd, 0);
|
2007-03-06 12:14:25 +01:00
|
|
|
ok(ret, "EnumFontFamiliesEx error %u\n", GetLastError());
|
|
|
|
get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
|
|
|
|
ok(efd.total > 0, "no fonts enumerated: %s DEFAULT_CHARSET\n", font_name);
|
|
|
|
for (i = 0; i < efd.total; i++)
|
|
|
|
{
|
|
|
|
if (*font_name)
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(!strcmp(efd.lf[i].lfFaceName, font_name), "expected %s, got %s\n",
|
2007-03-06 12:14:25 +01:00
|
|
|
font_name, efd.lf[i].lfFaceName);
|
|
|
|
}
|
|
|
|
if (*font_name)
|
|
|
|
{
|
|
|
|
switch (font_charset)
|
|
|
|
{
|
|
|
|
case ANSI_CHARSET:
|
|
|
|
ok(ansi_charset > 0,
|
|
|
|
"ANSI_CHARSET should enumerate ANSI_CHARSET for %s\n", font_name);
|
|
|
|
ok(!symbol_charset,
|
|
|
|
"ANSI_CHARSET should NOT enumerate SYMBOL_CHARSET for %s\n", font_name);
|
|
|
|
ok(russian_charset > 0,
|
|
|
|
"ANSI_CHARSET should enumerate RUSSIAN_CHARSET for %s\n", font_name);
|
|
|
|
break;
|
|
|
|
case SYMBOL_CHARSET:
|
|
|
|
ok(!ansi_charset,
|
|
|
|
"SYMBOL_CHARSET should NOT enumerate ANSI_CHARSET for %s\n", font_name);
|
|
|
|
ok(symbol_charset,
|
|
|
|
"SYMBOL_CHARSET should enumerate SYMBOL_CHARSET for %s\n", font_name);
|
|
|
|
ok(!russian_charset,
|
|
|
|
"SYMBOL_CHARSET should NOT enumerate RUSSIAN_CHARSET for %s\n", font_name);
|
|
|
|
break;
|
|
|
|
case DEFAULT_CHARSET:
|
|
|
|
ok(ansi_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate ANSI_CHARSET for %s\n", font_name);
|
|
|
|
ok(symbol_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate SYMBOL_CHARSET for %s\n", font_name);
|
|
|
|
ok(russian_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate RUSSIAN_CHARSET for %s\n", font_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(ansi_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate ANSI_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
ok(symbol_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate SYMBOL_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
ok(russian_charset > 0,
|
|
|
|
"DEFAULT_CHARSET should enumerate RUSSIAN_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = SYMBOL_CHARSET;
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, font_name);
|
2007-03-06 12:14:25 +01:00
|
|
|
efd.total = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &lf, arial_enum_proc, (LPARAM)&efd, 0);
|
2007-03-06 12:14:25 +01:00
|
|
|
ok(ret, "EnumFontFamiliesEx error %u\n", GetLastError());
|
|
|
|
get_charset_stats(&efd, &ansi_charset, &symbol_charset, &russian_charset);
|
|
|
|
if (*font_name && font_charset == ANSI_CHARSET)
|
|
|
|
ok(efd.total == 0, "no fonts should be enumerated: %s SYMBOL_CHARSET\n", font_name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(efd.total > 0, "no fonts enumerated: %s SYMBOL_CHARSET\n", font_name);
|
|
|
|
for (i = 0; i < efd.total; i++)
|
|
|
|
{
|
|
|
|
ok(efd.lf[i].lfCharSet == SYMBOL_CHARSET, "%d: got charset %d\n", i, efd.lf[i].lfCharSet);
|
|
|
|
if (*font_name)
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(!strcmp(efd.lf[i].lfFaceName, font_name), "expected %s, got %s\n",
|
2007-03-06 12:14:25 +01:00
|
|
|
font_name, efd.lf[i].lfFaceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(!ansi_charset,
|
|
|
|
"SYMBOL_CHARSET should NOT enumerate ANSI_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
ok(symbol_charset > 0,
|
|
|
|
"SYMBOL_CHARSET should enumerate SYMBOL_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
ok(!russian_charset,
|
|
|
|
"SYMBOL_CHARSET should NOT enumerate RUSSIAN_CHARSET for %s\n", *font_name ? font_name : "<empty>");
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
2016-04-14 12:12:35 +02:00
|
|
|
|
|
|
|
heap_free( efd.lf );
|
|
|
|
heap_free( efdw.lf );
|
2007-03-06 12:14:25 +01:00
|
|
|
}
|
|
|
|
|
2014-02-19 13:02:02 +01:00
|
|
|
static INT CALLBACK enum_multi_charset_font_proc(const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
const NEWTEXTMETRICEXA *ntm = (const NEWTEXTMETRICEXA *)tm;
|
|
|
|
LOGFONTA *target = (LOGFONTA *)lParam;
|
|
|
|
const DWORD valid_bits = 0x003f01ff;
|
|
|
|
CHARSETINFO csi;
|
|
|
|
DWORD fs;
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return TRUE;
|
|
|
|
|
|
|
|
if (TranslateCharsetInfo(ULongToPtr(target->lfCharSet), &csi, TCI_SRCCHARSET)) {
|
|
|
|
fs = ntm->ntmFontSig.fsCsb[0] & valid_bits;
|
2014-03-06 17:22:19 +01:00
|
|
|
if ((fs & csi.fs.fsCsb[0]) && (fs & ~csi.fs.fsCsb[0]) && (fs & FS_LATIN1)) {
|
2014-02-19 13:02:02 +01:00
|
|
|
*target = *lf;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_font_data_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2011-04-01 14:19:52 +02:00
|
|
|
{
|
|
|
|
struct enum_font_data *efd = (struct enum_font_data *)lParam;
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efd->total >= efd->size)
|
|
|
|
{
|
|
|
|
efd->size = max( (efd->total + 1) * 2, 256 );
|
|
|
|
efd->lf = heap_realloc( efd->lf, efd->size * sizeof(*efd->lf) );
|
|
|
|
if (!efd->lf) return 0;
|
|
|
|
}
|
|
|
|
efd->lf[efd->total++] = *lf;
|
2011-04-01 14:19:52 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_fullname_data_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2012-09-07 12:39:51 +02:00
|
|
|
{
|
|
|
|
struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efnd->total >= efnd->size)
|
|
|
|
{
|
|
|
|
efnd->size = max( (efnd->total + 1) * 2, 256 );
|
|
|
|
efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
|
|
|
|
if (!efnd->elf) return 0;
|
|
|
|
}
|
|
|
|
efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-09-17 19:30:42 +02:00
|
|
|
static INT CALLBACK enum_fullname_data_proc_w( const LOGFONTW *lf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam )
|
|
|
|
{
|
|
|
|
struct enum_fullname_data_w *efnd = (struct enum_fullname_data_w *)lParam;
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
|
|
|
if (efnd->total >= efnd->size)
|
|
|
|
{
|
|
|
|
efnd->size = max( (efnd->total + 1) * 2, 256 );
|
|
|
|
efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
|
|
|
|
if (!efnd->elf) return 0;
|
|
|
|
}
|
|
|
|
efnd->elf[efnd->total++] = *(ENUMLOGFONTW *)lf;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-04-01 14:19:52 +02:00
|
|
|
static void test_EnumFontFamiliesEx_default_charset(void)
|
|
|
|
{
|
|
|
|
struct enum_font_data efd;
|
2014-02-19 13:02:02 +01:00
|
|
|
LOGFONTA target, enum_font;
|
2014-03-06 17:22:19 +01:00
|
|
|
UINT acp;
|
2011-04-01 14:19:52 +02:00
|
|
|
HDC hdc;
|
2014-02-19 13:02:02 +01:00
|
|
|
CHARSETINFO csi;
|
2011-04-01 14:19:52 +02:00
|
|
|
|
2014-03-06 17:22:19 +01:00
|
|
|
acp = GetACP();
|
|
|
|
if (!TranslateCharsetInfo(ULongToPtr(acp), &csi, TCI_SRCCODEPAGE)) {
|
|
|
|
skip("TranslateCharsetInfo failed for code page %u.\n", acp);
|
2011-04-01 14:19:52 +02:00
|
|
|
return;
|
2014-02-19 13:02:02 +01:00
|
|
|
}
|
2011-04-01 14:19:52 +02:00
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
memset(&enum_font, 0, sizeof(enum_font));
|
2014-02-19 13:02:02 +01:00
|
|
|
enum_font.lfCharSet = csi.ciCharset;
|
|
|
|
target.lfFaceName[0] = '\0';
|
|
|
|
target.lfCharSet = csi.ciCharset;
|
|
|
|
EnumFontFamiliesExA(hdc, &enum_font, enum_multi_charset_font_proc, (LPARAM)&target, 0);
|
|
|
|
if (target.lfFaceName[0] == '\0') {
|
|
|
|
skip("suitable font isn't found for charset %d.\n", enum_font.lfCharSet);
|
|
|
|
return;
|
|
|
|
}
|
2014-03-06 17:22:19 +01:00
|
|
|
if (acp == 874 || acp == 1255 || acp == 1256) {
|
|
|
|
/* these codepage use complex script, expecting ANSI_CHARSET here. */
|
|
|
|
target.lfCharSet = ANSI_CHARSET;
|
|
|
|
}
|
2014-02-19 13:02:02 +01:00
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
memset(&efd, 0, sizeof(efd));
|
2014-02-19 13:02:02 +01:00
|
|
|
memset(&enum_font, 0, sizeof(enum_font));
|
|
|
|
strcpy(enum_font.lfFaceName, target.lfFaceName);
|
2011-04-01 14:19:52 +02:00
|
|
|
enum_font.lfCharSet = DEFAULT_CHARSET;
|
2013-10-17 01:55:20 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &enum_font, enum_font_data_proc, (LPARAM)&efd, 0);
|
2011-04-01 14:19:52 +02:00
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efd.total < 2)
|
2014-02-19 13:02:02 +01:00
|
|
|
ok(0, "EnumFontFamilies is broken. Expected >= 2, got %d.\n", efd.total);
|
2016-04-14 12:12:35 +02:00
|
|
|
else
|
|
|
|
ok(efd.lf[0].lfCharSet == target.lfCharSet,
|
|
|
|
"(%s) got charset %d expected %d\n",
|
|
|
|
efd.lf[0].lfFaceName, efd.lf[0].lfCharSet, target.lfCharSet);
|
2011-04-01 14:19:52 +02:00
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
heap_free(efd.lf);
|
2011-04-01 14:19:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-07 14:24:47 +02:00
|
|
|
static void test_negative_width(HDC hdc, const LOGFONTA *lf)
|
|
|
|
{
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
DWORD ret;
|
|
|
|
GLYPHMETRICS gm1, gm2;
|
|
|
|
LOGFONTA lf2 = *lf;
|
|
|
|
WORD idx;
|
|
|
|
|
|
|
|
/* negative widths are handled just as positive ones */
|
|
|
|
lf2.lfWidth = -lf->lfWidth;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirect error %u\n", GetLastError());
|
|
|
|
check_font("original", lf, hfont);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetGlyphIndicesA(hdc, "x", 1, &idx, GGI_MARK_NONEXISTING_GLYPHS);
|
2008-04-07 14:24:47 +02:00
|
|
|
if (ret == GDI_ERROR || idx == 0xffff)
|
|
|
|
{
|
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
2008-04-13 07:08:44 +02:00
|
|
|
skip("Font %s doesn't contain 'x', skipping the test\n", lf->lfFaceName);
|
2008-04-07 14:24:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* filling with 0xaa causes false pass under WINEDEBUG=warn+heap */
|
|
|
|
memset(&gm1, 0xab, sizeof(gm1));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'x', GGO_METRICS, &gm1, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutline error 0x%x\n", GetLastError());
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(&lf2);
|
|
|
|
ok(hfont != 0, "CreateFontIndirect error %u\n", GetLastError());
|
|
|
|
check_font("negative width", &lf2, hfont);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
memset(&gm2, 0xbb, sizeof(gm2));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'x', GGO_METRICS, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutline error 0x%x\n", GetLastError());
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
ok(gm1.gmBlackBoxX == gm2.gmBlackBoxX &&
|
|
|
|
gm1.gmBlackBoxY == gm2.gmBlackBoxY &&
|
|
|
|
gm1.gmptGlyphOrigin.x == gm2.gmptGlyphOrigin.x &&
|
|
|
|
gm1.gmptGlyphOrigin.y == gm2.gmptGlyphOrigin.y &&
|
|
|
|
gm1.gmCellIncX == gm2.gmCellIncX &&
|
|
|
|
gm1.gmCellIncY == gm2.gmCellIncY,
|
|
|
|
"gm1=%d,%d,%d,%d,%d,%d gm2=%d,%d,%d,%d,%d,%d\n",
|
|
|
|
gm1.gmBlackBoxX, gm1.gmBlackBoxY, gm1.gmptGlyphOrigin.x,
|
|
|
|
gm1.gmptGlyphOrigin.y, gm1.gmCellIncX, gm1.gmCellIncY,
|
|
|
|
gm2.gmBlackBoxX, gm2.gmBlackBoxY, gm2.gmptGlyphOrigin.x,
|
|
|
|
gm2.gmptGlyphOrigin.y, gm2.gmCellIncX, gm2.gmCellIncY);
|
|
|
|
}
|
|
|
|
|
2007-03-15 07:12:09 +01:00
|
|
|
/* PANOSE is 10 bytes in size, need to pack the structure properly */
|
|
|
|
#include "pshpack2.h"
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
SHORT xAvgCharWidth;
|
|
|
|
USHORT usWeightClass;
|
|
|
|
USHORT usWidthClass;
|
|
|
|
SHORT fsType;
|
|
|
|
SHORT ySubscriptXSize;
|
|
|
|
SHORT ySubscriptYSize;
|
|
|
|
SHORT ySubscriptXOffset;
|
|
|
|
SHORT ySubscriptYOffset;
|
|
|
|
SHORT ySuperscriptXSize;
|
|
|
|
SHORT ySuperscriptYSize;
|
|
|
|
SHORT ySuperscriptXOffset;
|
|
|
|
SHORT ySuperscriptYOffset;
|
|
|
|
SHORT yStrikeoutSize;
|
|
|
|
SHORT yStrikeoutPosition;
|
|
|
|
SHORT sFamilyClass;
|
|
|
|
PANOSE panose;
|
|
|
|
ULONG ulUnicodeRange1;
|
|
|
|
ULONG ulUnicodeRange2;
|
|
|
|
ULONG ulUnicodeRange3;
|
|
|
|
ULONG ulUnicodeRange4;
|
|
|
|
CHAR achVendID[4];
|
|
|
|
USHORT fsSelection;
|
|
|
|
USHORT usFirstCharIndex;
|
|
|
|
USHORT usLastCharIndex;
|
|
|
|
/* According to the Apple spec, original version didn't have the below fields,
|
2011-08-03 23:50:18 +02:00
|
|
|
* version numbers were taken from the OpenType spec.
|
2007-03-15 07:12:09 +01:00
|
|
|
*/
|
|
|
|
/* version 0 (TrueType 1.5) */
|
|
|
|
USHORT sTypoAscender;
|
|
|
|
USHORT sTypoDescender;
|
|
|
|
USHORT sTypoLineGap;
|
|
|
|
USHORT usWinAscent;
|
|
|
|
USHORT usWinDescent;
|
|
|
|
/* version 1 (TrueType 1.66) */
|
|
|
|
ULONG ulCodePageRange1;
|
|
|
|
ULONG ulCodePageRange2;
|
|
|
|
/* version 2 (OpenType 1.2) */
|
|
|
|
SHORT sxHeight;
|
|
|
|
SHORT sCapHeight;
|
|
|
|
USHORT usDefaultChar;
|
|
|
|
USHORT usBreakChar;
|
|
|
|
USHORT usMaxContext;
|
2015-09-10 13:47:11 +02:00
|
|
|
/* version 4 (OpenType 1.6) */
|
|
|
|
USHORT usLowerOpticalPointSize;
|
|
|
|
USHORT usUpperOpticalPointSize;
|
|
|
|
} TT_OS2_V4;
|
2007-03-15 07:12:09 +01:00
|
|
|
#include "poppack.h"
|
|
|
|
|
2015-09-10 13:47:11 +02:00
|
|
|
#define TT_OS2_V0_SIZE (FIELD_OFFSET(TT_OS2_V4, ulCodePageRange1))
|
|
|
|
|
2009-02-16 13:39:15 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
USHORT num_tables;
|
|
|
|
} cmap_header;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT plat_id;
|
|
|
|
USHORT enc_id;
|
|
|
|
ULONG offset;
|
|
|
|
} cmap_encoding_record;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT format;
|
|
|
|
USHORT length;
|
|
|
|
USHORT language;
|
|
|
|
|
|
|
|
BYTE glyph_ids[256];
|
|
|
|
} cmap_format_0;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT format;
|
|
|
|
USHORT length;
|
|
|
|
USHORT language;
|
|
|
|
|
|
|
|
USHORT seg_countx2;
|
|
|
|
USHORT search_range;
|
|
|
|
USHORT entry_selector;
|
|
|
|
USHORT range_shift;
|
|
|
|
|
|
|
|
USHORT end_count[1]; /* this is a variable-sized array of length seg_countx2 / 2 */
|
|
|
|
/* Then follows:
|
|
|
|
USHORT pad;
|
|
|
|
USHORT start_count[seg_countx2 / 2];
|
|
|
|
USHORT id_delta[seg_countx2 / 2];
|
|
|
|
USHORT id_range_offset[seg_countx2 / 2];
|
|
|
|
USHORT glyph_ids[];
|
|
|
|
*/
|
|
|
|
} cmap_format_4;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT end_count;
|
|
|
|
USHORT start_count;
|
|
|
|
USHORT id_delta;
|
|
|
|
USHORT id_range_offset;
|
|
|
|
} cmap_format_4_seg;
|
2007-03-15 07:12:09 +01:00
|
|
|
|
2015-09-10 13:47:11 +02:00
|
|
|
static void expect_ff(const TEXTMETRICA *tmA, const TT_OS2_V4 *os2, WORD family, const char *name)
|
2009-02-11 14:49:52 +01:00
|
|
|
{
|
2011-01-09 21:48:57 +01:00
|
|
|
ok((tmA->tmPitchAndFamily & 0xf0) == family ||
|
|
|
|
broken(PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_ENGLISH),
|
|
|
|
"%s: expected family %02x got %02x. panose %d-%d-%d-%d-...\n",
|
2009-02-12 13:30:45 +01:00
|
|
|
name, family, tmA->tmPitchAndFamily, os2->panose.bFamilyType, os2->panose.bSerifStyle,
|
2009-02-11 14:49:52 +01:00
|
|
|
os2->panose.bWeight, os2->panose.bProportion);
|
2009-02-16 13:39:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_first_last_from_cmap0(void *ptr, DWORD *first, DWORD *last)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
cmap_format_0 *cmap = (cmap_format_0*)ptr;
|
|
|
|
|
|
|
|
*first = 256;
|
|
|
|
|
|
|
|
for(i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
if(cmap->glyph_ids[i] == 0) continue;
|
|
|
|
*last = i;
|
|
|
|
if(*first == 256) *first = i;
|
|
|
|
}
|
|
|
|
if(*first == 256) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_seg4(cmap_format_4 *cmap, USHORT seg_num, cmap_format_4_seg *seg)
|
|
|
|
{
|
|
|
|
USHORT segs = GET_BE_WORD(cmap->seg_countx2) / 2;
|
|
|
|
seg->end_count = GET_BE_WORD(cmap->end_count[seg_num]);
|
|
|
|
seg->start_count = GET_BE_WORD(cmap->end_count[segs + 1 + seg_num]);
|
|
|
|
seg->id_delta = GET_BE_WORD(cmap->end_count[2 * segs + 1 + seg_num]);
|
|
|
|
seg->id_range_offset = GET_BE_WORD(cmap->end_count[3 * segs + 1 + seg_num]);
|
|
|
|
}
|
|
|
|
|
2009-07-31 15:21:23 +02:00
|
|
|
static BOOL get_first_last_from_cmap4(void *ptr, DWORD *first, DWORD *last, DWORD limit)
|
2009-02-16 13:39:15 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
cmap_format_4 *cmap = (cmap_format_4*)ptr;
|
|
|
|
USHORT seg_count = GET_BE_WORD(cmap->seg_countx2) / 2;
|
|
|
|
|
|
|
|
*first = 0x10000;
|
|
|
|
|
|
|
|
for(i = 0; i < seg_count; i++)
|
|
|
|
{
|
|
|
|
cmap_format_4_seg seg;
|
|
|
|
|
|
|
|
get_seg4(cmap, i, &seg);
|
|
|
|
|
2014-05-23 12:33:54 +02:00
|
|
|
if(seg.start_count > 0xfffe) break;
|
|
|
|
|
|
|
|
if(*first == 0x10000) *first = seg.start_count;
|
|
|
|
|
|
|
|
*last = min(seg.end_count, 0xfffe);
|
2009-02-16 13:39:15 +01:00
|
|
|
}
|
2009-02-11 14:49:52 +01:00
|
|
|
|
2009-02-16 13:39:15 +01:00
|
|
|
if(*first == 0x10000) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *get_cmap(cmap_header *header, USHORT plat_id, USHORT enc_id)
|
|
|
|
{
|
|
|
|
USHORT i;
|
|
|
|
cmap_encoding_record *record = (cmap_encoding_record *)(header + 1);
|
|
|
|
|
|
|
|
for(i = 0; i < GET_BE_WORD(header->num_tables); i++)
|
|
|
|
{
|
|
|
|
if(GET_BE_WORD(record->plat_id) == plat_id && GET_BE_WORD(record->enc_id) == enc_id)
|
|
|
|
return (BYTE *)header + GET_BE_DWORD(record->offset);
|
|
|
|
record++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
cmap_none,
|
|
|
|
cmap_ms_unicode,
|
|
|
|
cmap_ms_symbol
|
|
|
|
} cmap_type;
|
|
|
|
|
|
|
|
static BOOL get_first_last_from_cmap(HDC hdc, DWORD *first, DWORD *last, cmap_type *cmap_type)
|
2009-02-16 13:39:15 +01:00
|
|
|
{
|
|
|
|
LONG size, ret;
|
|
|
|
cmap_header *header;
|
|
|
|
void *cmap;
|
|
|
|
BOOL r = FALSE;
|
|
|
|
WORD format;
|
|
|
|
|
|
|
|
size = GetFontData(hdc, MS_CMAP_TAG, 0, NULL, 0);
|
|
|
|
ok(size != GDI_ERROR, "no cmap table found\n");
|
|
|
|
if(size == GDI_ERROR) return FALSE;
|
|
|
|
|
|
|
|
header = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
ret = GetFontData(hdc, MS_CMAP_TAG, 0, header, size);
|
|
|
|
ok(ret == size, "GetFontData should return %u not %u\n", size, ret);
|
|
|
|
ok(GET_BE_WORD(header->version) == 0, "got cmap version %d\n", GET_BE_WORD(header->version));
|
|
|
|
|
|
|
|
cmap = get_cmap(header, 3, 1);
|
2009-02-18 11:33:12 +01:00
|
|
|
if(cmap)
|
|
|
|
*cmap_type = cmap_ms_unicode;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmap = get_cmap(header, 3, 0);
|
|
|
|
if(cmap) *cmap_type = cmap_ms_symbol;
|
|
|
|
}
|
|
|
|
if(!cmap)
|
|
|
|
{
|
|
|
|
*cmap_type = cmap_none;
|
|
|
|
goto end;
|
|
|
|
}
|
2009-02-16 13:39:15 +01:00
|
|
|
|
|
|
|
format = GET_BE_WORD(*(WORD *)cmap);
|
|
|
|
switch(format)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
r = get_first_last_from_cmap0(cmap, first, last);
|
|
|
|
break;
|
|
|
|
case 4:
|
2009-07-31 15:21:23 +02:00
|
|
|
r = get_first_last_from_cmap4(cmap, first, last, size);
|
2009-02-16 13:39:15 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("unhandled cmap format %d\n", format);
|
2009-02-16 13:39:15 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, header);
|
|
|
|
return r;
|
2009-02-11 14:49:52 +01:00
|
|
|
}
|
|
|
|
|
2014-07-10 06:59:13 +02:00
|
|
|
#define TT_PLATFORM_APPLE_UNICODE 0
|
|
|
|
#define TT_PLATFORM_MACINTOSH 1
|
2011-05-10 22:38:05 +02:00
|
|
|
#define TT_PLATFORM_MICROSOFT 3
|
2014-07-10 06:59:13 +02:00
|
|
|
#define TT_APPLE_ID_DEFAULT 0
|
|
|
|
#define TT_APPLE_ID_ISO_10646 2
|
|
|
|
#define TT_APPLE_ID_UNICODE_2_0 3
|
2012-09-10 19:06:19 +02:00
|
|
|
#define TT_MS_ID_SYMBOL_CS 0
|
2011-05-10 22:38:05 +02:00
|
|
|
#define TT_MS_ID_UNICODE_CS 1
|
|
|
|
#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
|
2012-09-07 12:39:51 +02:00
|
|
|
#define TT_NAME_ID_FONT_FAMILY 1
|
|
|
|
#define TT_NAME_ID_FONT_SUBFAMILY 2
|
|
|
|
#define TT_NAME_ID_UNIQUE_ID 3
|
2011-05-10 22:38:05 +02:00
|
|
|
#define TT_NAME_ID_FULL_NAME 4
|
2014-07-10 06:59:13 +02:00
|
|
|
#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
|
|
|
|
|
|
|
|
typedef struct sfnt_name
|
|
|
|
{
|
|
|
|
USHORT platform_id;
|
|
|
|
USHORT encoding_id;
|
|
|
|
USHORT language_id;
|
|
|
|
USHORT name_id;
|
|
|
|
USHORT length;
|
|
|
|
USHORT offset;
|
|
|
|
} sfnt_name;
|
|
|
|
|
|
|
|
static const LANGID mac_langid_table[] =
|
|
|
|
{
|
|
|
|
MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ENGLISH */
|
|
|
|
MAKELANGID(LANG_FRENCH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_FRENCH */
|
|
|
|
MAKELANGID(LANG_GERMAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GERMAN */
|
|
|
|
MAKELANGID(LANG_ITALIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ITALIAN */
|
|
|
|
MAKELANGID(LANG_DUTCH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_DUTCH */
|
|
|
|
MAKELANGID(LANG_SWEDISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SWEDISH */
|
|
|
|
MAKELANGID(LANG_SPANISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SPANISH */
|
|
|
|
MAKELANGID(LANG_DANISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_DANISH */
|
|
|
|
MAKELANGID(LANG_PORTUGUESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_PORTUGUESE */
|
|
|
|
MAKELANGID(LANG_NORWEGIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_NORWEGIAN */
|
|
|
|
MAKELANGID(LANG_HEBREW,SUBLANG_DEFAULT), /* TT_MAC_LANGID_HEBREW */
|
|
|
|
MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_JAPANESE */
|
|
|
|
MAKELANGID(LANG_ARABIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ARABIC */
|
|
|
|
MAKELANGID(LANG_FINNISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_FINNISH */
|
|
|
|
MAKELANGID(LANG_GREEK,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GREEK */
|
|
|
|
MAKELANGID(LANG_ICELANDIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ICELANDIC */
|
|
|
|
MAKELANGID(LANG_MALTESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MALTESE */
|
|
|
|
MAKELANGID(LANG_TURKISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TURKISH */
|
|
|
|
MAKELANGID(LANG_CROATIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_CROATIAN */
|
|
|
|
MAKELANGID(LANG_CHINESE_TRADITIONAL,SUBLANG_DEFAULT), /* TT_MAC_LANGID_CHINESE_TRADITIONAL */
|
|
|
|
MAKELANGID(LANG_URDU,SUBLANG_DEFAULT), /* TT_MAC_LANGID_URDU */
|
|
|
|
MAKELANGID(LANG_HINDI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_HINDI */
|
|
|
|
MAKELANGID(LANG_THAI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_THAI */
|
|
|
|
MAKELANGID(LANG_KOREAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KOREAN */
|
|
|
|
MAKELANGID(LANG_LITHUANIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_LITHUANIAN */
|
|
|
|
MAKELANGID(LANG_POLISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_POLISH */
|
|
|
|
MAKELANGID(LANG_HUNGARIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_HUNGARIAN */
|
|
|
|
MAKELANGID(LANG_ESTONIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ESTONIAN */
|
|
|
|
MAKELANGID(LANG_LATVIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_LETTISH */
|
|
|
|
MAKELANGID(LANG_SAMI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SAAMISK */
|
|
|
|
MAKELANGID(LANG_FAEROESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_FAEROESE */
|
|
|
|
MAKELANGID(LANG_FARSI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_FARSI */
|
|
|
|
MAKELANGID(LANG_RUSSIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_RUSSIAN */
|
|
|
|
MAKELANGID(LANG_CHINESE_SIMPLIFIED,SUBLANG_DEFAULT), /* TT_MAC_LANGID_CHINESE_SIMPLIFIED */
|
|
|
|
MAKELANGID(LANG_DUTCH,SUBLANG_DUTCH_BELGIAN), /* TT_MAC_LANGID_FLEMISH */
|
|
|
|
MAKELANGID(LANG_IRISH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_IRISH */
|
|
|
|
MAKELANGID(LANG_ALBANIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ALBANIAN */
|
|
|
|
MAKELANGID(LANG_ROMANIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ROMANIAN */
|
|
|
|
MAKELANGID(LANG_CZECH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_CZECH */
|
|
|
|
MAKELANGID(LANG_SLOVAK,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SLOVAK */
|
|
|
|
MAKELANGID(LANG_SLOVENIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SLOVENIAN */
|
|
|
|
0, /* TT_MAC_LANGID_YIDDISH */
|
|
|
|
MAKELANGID(LANG_SERBIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SERBIAN */
|
|
|
|
MAKELANGID(LANG_MACEDONIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MACEDONIAN */
|
|
|
|
MAKELANGID(LANG_BULGARIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_BULGARIAN */
|
|
|
|
MAKELANGID(LANG_UKRAINIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_UKRAINIAN */
|
|
|
|
MAKELANGID(LANG_BELARUSIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_BYELORUSSIAN */
|
|
|
|
MAKELANGID(LANG_UZBEK,SUBLANG_DEFAULT), /* TT_MAC_LANGID_UZBEK */
|
|
|
|
MAKELANGID(LANG_KAZAK,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KAZAKH */
|
|
|
|
MAKELANGID(LANG_AZERI,SUBLANG_AZERI_CYRILLIC), /* TT_MAC_LANGID_AZERBAIJANI */
|
|
|
|
0, /* TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT */
|
|
|
|
MAKELANGID(LANG_ARMENIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ARMENIAN */
|
|
|
|
MAKELANGID(LANG_GEORGIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GEORGIAN */
|
|
|
|
0, /* TT_MAC_LANGID_MOLDAVIAN */
|
|
|
|
MAKELANGID(LANG_KYRGYZ,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KIRGHIZ */
|
|
|
|
MAKELANGID(LANG_TAJIK,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TAJIKI */
|
|
|
|
MAKELANGID(LANG_TURKMEN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TURKMEN */
|
|
|
|
MAKELANGID(LANG_MONGOLIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MONGOLIAN */
|
|
|
|
MAKELANGID(LANG_MONGOLIAN,SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA), /* TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT */
|
|
|
|
MAKELANGID(LANG_PASHTO,SUBLANG_DEFAULT), /* TT_MAC_LANGID_PASHTO */
|
|
|
|
0, /* TT_MAC_LANGID_KURDISH */
|
|
|
|
MAKELANGID(LANG_KASHMIRI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KASHMIRI */
|
|
|
|
MAKELANGID(LANG_SINDHI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SINDHI */
|
|
|
|
MAKELANGID(LANG_TIBETAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TIBETAN */
|
|
|
|
MAKELANGID(LANG_NEPALI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_NEPALI */
|
|
|
|
MAKELANGID(LANG_SANSKRIT,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SANSKRIT */
|
|
|
|
MAKELANGID(LANG_MARATHI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MARATHI */
|
|
|
|
MAKELANGID(LANG_BENGALI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_BENGALI */
|
|
|
|
MAKELANGID(LANG_ASSAMESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ASSAMESE */
|
|
|
|
MAKELANGID(LANG_GUJARATI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GUJARATI */
|
|
|
|
MAKELANGID(LANG_PUNJABI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_PUNJABI */
|
|
|
|
MAKELANGID(LANG_ORIYA,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ORIYA */
|
|
|
|
MAKELANGID(LANG_MALAYALAM,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MALAYALAM */
|
|
|
|
MAKELANGID(LANG_KANNADA,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KANNADA */
|
|
|
|
MAKELANGID(LANG_TAMIL,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TAMIL */
|
|
|
|
MAKELANGID(LANG_TELUGU,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TELUGU */
|
|
|
|
MAKELANGID(LANG_SINHALESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SINHALESE */
|
|
|
|
0, /* TT_MAC_LANGID_BURMESE */
|
|
|
|
MAKELANGID(LANG_KHMER,SUBLANG_DEFAULT), /* TT_MAC_LANGID_KHMER */
|
|
|
|
MAKELANGID(LANG_LAO,SUBLANG_DEFAULT), /* TT_MAC_LANGID_LAO */
|
|
|
|
MAKELANGID(LANG_VIETNAMESE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_VIETNAMESE */
|
|
|
|
MAKELANGID(LANG_INDONESIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_INDONESIAN */
|
|
|
|
0, /* TT_MAC_LANGID_TAGALOG */
|
|
|
|
MAKELANGID(LANG_MALAY,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MALAY_ROMAN_SCRIPT */
|
|
|
|
0, /* TT_MAC_LANGID_MALAY_ARABIC_SCRIPT */
|
|
|
|
MAKELANGID(LANG_AMHARIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_AMHARIC */
|
|
|
|
MAKELANGID(LANG_TIGRIGNA,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TIGRINYA */
|
|
|
|
0, /* TT_MAC_LANGID_GALLA */
|
|
|
|
0, /* TT_MAC_LANGID_SOMALI */
|
|
|
|
MAKELANGID(LANG_SWAHILI,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SWAHILI */
|
|
|
|
0, /* TT_MAC_LANGID_RUANDA */
|
|
|
|
0, /* TT_MAC_LANGID_RUNDI */
|
|
|
|
0, /* TT_MAC_LANGID_CHEWA */
|
|
|
|
MAKELANGID(LANG_MALAGASY,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MALAGASY */
|
|
|
|
MAKELANGID(LANG_ESPERANTO,SUBLANG_DEFAULT), /* TT_MAC_LANGID_ESPERANTO */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 95-111 */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 112-127 */
|
|
|
|
MAKELANGID(LANG_WELSH,SUBLANG_DEFAULT), /* TT_MAC_LANGID_WELSH */
|
|
|
|
MAKELANGID(LANG_BASQUE,SUBLANG_DEFAULT), /* TT_MAC_LANGID_BASQUE */
|
|
|
|
MAKELANGID(LANG_CATALAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_CATALAN */
|
|
|
|
0, /* TT_MAC_LANGID_LATIN */
|
|
|
|
MAKELANGID(LANG_QUECHUA,SUBLANG_DEFAULT), /* TT_MAC_LANGID_QUECHUA */
|
|
|
|
0, /* TT_MAC_LANGID_GUARANI */
|
|
|
|
0, /* TT_MAC_LANGID_AYMARA */
|
|
|
|
MAKELANGID(LANG_TATAR,SUBLANG_DEFAULT), /* TT_MAC_LANGID_TATAR */
|
|
|
|
MAKELANGID(LANG_UIGHUR,SUBLANG_DEFAULT), /* TT_MAC_LANGID_UIGHUR */
|
|
|
|
0, /* TT_MAC_LANGID_DZONGKHA */
|
|
|
|
0, /* TT_MAC_LANGID_JAVANESE */
|
|
|
|
0, /* TT_MAC_LANGID_SUNDANESE */
|
|
|
|
MAKELANGID(LANG_GALICIAN,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GALICIAN */
|
|
|
|
MAKELANGID(LANG_AFRIKAANS,SUBLANG_DEFAULT), /* TT_MAC_LANGID_AFRIKAANS */
|
|
|
|
MAKELANGID(LANG_BRETON,SUBLANG_DEFAULT), /* TT_MAC_LANGID_BRETON */
|
|
|
|
MAKELANGID(LANG_INUKTITUT,SUBLANG_DEFAULT), /* TT_MAC_LANGID_INUKTITUT */
|
|
|
|
MAKELANGID(LANG_SCOTTISH_GAELIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_SCOTTISH_GAELIC */
|
|
|
|
MAKELANGID(LANG_MANX_GAELIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_MANX_GAELIC */
|
|
|
|
MAKELANGID(LANG_IRISH,SUBLANG_IRISH_IRELAND), /* TT_MAC_LANGID_IRISH_GAELIC */
|
|
|
|
0, /* TT_MAC_LANGID_TONGAN */
|
|
|
|
0, /* TT_MAC_LANGID_GREEK_POLYTONIC */
|
|
|
|
MAKELANGID(LANG_GREENLANDIC,SUBLANG_DEFAULT), /* TT_MAC_LANGID_GREELANDIC */
|
|
|
|
MAKELANGID(LANG_AZERI,SUBLANG_AZERI_LATIN), /* TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT */
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline WORD get_mac_code_page( const sfnt_name *name )
|
|
|
|
{
|
|
|
|
if (GET_BE_WORD(name->encoding_id) == TT_MAC_ID_SIMPLIFIED_CHINESE) return 10008; /* special case */
|
|
|
|
return 10000 + GET_BE_WORD(name->encoding_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int match_name_table_language( const sfnt_name *name, LANGID lang )
|
|
|
|
{
|
|
|
|
LANGID name_lang;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
switch (GET_BE_WORD(name->platform_id))
|
|
|
|
{
|
|
|
|
case TT_PLATFORM_MICROSOFT:
|
|
|
|
res += 5; /* prefer the Microsoft name */
|
|
|
|
switch (GET_BE_WORD(name->encoding_id))
|
|
|
|
{
|
|
|
|
case TT_MS_ID_UNICODE_CS:
|
|
|
|
case TT_MS_ID_SYMBOL_CS:
|
|
|
|
name_lang = GET_BE_WORD(name->language_id);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TT_PLATFORM_MACINTOSH:
|
|
|
|
if (!IsValidCodePage( get_mac_code_page( name ))) return 0;
|
2018-06-25 21:46:41 +02:00
|
|
|
if (GET_BE_WORD(name->language_id) >= ARRAY_SIZE(mac_langid_table)) return 0;
|
2014-07-10 06:59:13 +02:00
|
|
|
name_lang = mac_langid_table[GET_BE_WORD(name->language_id)];
|
|
|
|
break;
|
|
|
|
case TT_PLATFORM_APPLE_UNICODE:
|
|
|
|
res += 2; /* prefer Unicode encodings */
|
|
|
|
switch (GET_BE_WORD(name->encoding_id))
|
|
|
|
{
|
|
|
|
case TT_APPLE_ID_DEFAULT:
|
|
|
|
case TT_APPLE_ID_ISO_10646:
|
|
|
|
case TT_APPLE_ID_UNICODE_2_0:
|
2018-06-25 21:46:41 +02:00
|
|
|
if (GET_BE_WORD(name->language_id) >= ARRAY_SIZE(mac_langid_table)) return 0;
|
2014-07-10 06:59:13 +02:00
|
|
|
name_lang = mac_langid_table[GET_BE_WORD(name->language_id)];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (name_lang == lang) res += 30;
|
|
|
|
else if (PRIMARYLANGID( name_lang ) == PRIMARYLANGID( lang )) res += 20;
|
|
|
|
else if (name_lang == MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT )) res += 10;
|
|
|
|
return res;
|
|
|
|
}
|
2011-05-10 22:38:05 +02:00
|
|
|
|
2012-09-07 12:41:02 +02:00
|
|
|
static BOOL get_ttf_nametable_entry(HDC hdc, WORD name_id, WCHAR *out_buf, SIZE_T out_size, LCID language_id)
|
2011-05-10 22:38:05 +02:00
|
|
|
{
|
|
|
|
struct sfnt_name_header
|
|
|
|
{
|
|
|
|
USHORT format;
|
|
|
|
USHORT number_of_record;
|
|
|
|
USHORT storage_offset;
|
|
|
|
} *header;
|
2014-07-10 06:59:13 +02:00
|
|
|
sfnt_name *entry;
|
2011-05-10 22:38:05 +02:00
|
|
|
BOOL r = FALSE;
|
|
|
|
LONG size, offset, length;
|
|
|
|
LONG c, ret;
|
|
|
|
WCHAR *name;
|
|
|
|
BYTE *data;
|
|
|
|
USHORT i;
|
2014-07-10 06:59:13 +02:00
|
|
|
int res, best_lang = 0, best_index = -1;
|
2011-05-10 22:38:05 +02:00
|
|
|
|
|
|
|
size = GetFontData(hdc, MS_NAME_TAG, 0, NULL, 0);
|
|
|
|
ok(size != GDI_ERROR, "no name table found\n");
|
|
|
|
if(size == GDI_ERROR) return FALSE;
|
|
|
|
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
ret = GetFontData(hdc, MS_NAME_TAG, 0, data, size);
|
|
|
|
ok(ret == size, "GetFontData should return %u not %u\n", size, ret);
|
|
|
|
|
|
|
|
header = (void *)data;
|
|
|
|
header->format = GET_BE_WORD(header->format);
|
|
|
|
header->number_of_record = GET_BE_WORD(header->number_of_record);
|
|
|
|
header->storage_offset = GET_BE_WORD(header->storage_offset);
|
|
|
|
if (header->format != 0)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("got format %u\n", header->format);
|
2011-05-10 22:38:05 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (header->number_of_record == 0 || sizeof(*header) + header->number_of_record * sizeof(*entry) > size)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("number records out of range: %d\n", header->number_of_record);
|
2011-05-10 22:38:05 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (header->storage_offset >= size)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("storage_offset %u > size %u\n", header->storage_offset, size);
|
2011-05-10 22:38:05 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = (void *)&header[1];
|
|
|
|
for (i = 0; i < header->number_of_record; i++)
|
|
|
|
{
|
2014-07-10 06:59:13 +02:00
|
|
|
if (GET_BE_WORD(entry[i].name_id) != name_id) continue;
|
|
|
|
res = match_name_table_language( &entry[i], language_id);
|
|
|
|
if (res > best_lang)
|
2011-05-10 22:38:05 +02:00
|
|
|
{
|
2014-07-10 06:59:13 +02:00
|
|
|
best_lang = res;
|
|
|
|
best_index = i;
|
2011-05-10 22:38:05 +02:00
|
|
|
}
|
2014-07-10 06:59:13 +02:00
|
|
|
}
|
2011-05-10 22:38:05 +02:00
|
|
|
|
2014-07-10 06:59:13 +02:00
|
|
|
offset = header->storage_offset + GET_BE_WORD(entry[best_index].offset);
|
|
|
|
length = GET_BE_WORD(entry[best_index].length);
|
|
|
|
if (offset + length > size)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("entry %d is out of range\n", best_index);
|
2014-07-10 06:59:13 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (length >= out_size)
|
|
|
|
{
|
2020-02-26 16:45:23 +01:00
|
|
|
skip("buffer too small for entry %d\n", best_index);
|
2014-07-10 06:59:13 +02:00
|
|
|
goto out;
|
|
|
|
}
|
2011-05-10 22:38:05 +02:00
|
|
|
|
2014-07-10 06:59:13 +02:00
|
|
|
name = (WCHAR *)(data + offset);
|
|
|
|
for (c = 0; c < length / 2; c++)
|
|
|
|
out_buf[c] = GET_BE_WORD(name[c]);
|
|
|
|
out_buf[c] = 0;
|
2011-05-10 22:38:05 +02:00
|
|
|
|
2014-07-10 06:59:13 +02:00
|
|
|
r = TRUE;
|
2011-05-10 22:38:05 +02:00
|
|
|
|
|
|
|
out:
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static void test_text_metrics(const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
|
2007-03-15 07:12:09 +01:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
TEXTMETRICA tmA;
|
2015-09-10 13:47:11 +02:00
|
|
|
TT_OS2_V4 tt_os2;
|
2007-03-15 07:12:09 +01:00
|
|
|
LONG size, ret;
|
|
|
|
const char *font_name = lf->lfFaceName;
|
2009-02-16 13:39:15 +01:00
|
|
|
DWORD cmap_first = 0, cmap_last = 0;
|
2012-05-08 12:29:02 +02:00
|
|
|
UINT ascent, descent, cell_height;
|
2009-02-18 11:33:12 +01:00
|
|
|
cmap_type cmap_type;
|
2011-01-09 21:48:57 +01:00
|
|
|
BOOL sys_lang_non_english;
|
2007-03-15 07:12:09 +01:00
|
|
|
|
2011-01-09 21:48:57 +01:00
|
|
|
sys_lang_non_english = PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_ENGLISH;
|
2007-03-15 07:12:09 +01:00
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirect error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
size = GetFontData(hdc, MS_OS2_TAG, 0, NULL, 0);
|
|
|
|
if (size == GDI_ERROR)
|
|
|
|
{
|
|
|
|
trace("OS/2 chunk was not found\n");
|
|
|
|
goto end_of_test;
|
|
|
|
}
|
|
|
|
if (size > sizeof(tt_os2))
|
|
|
|
{
|
|
|
|
trace("got too large OS/2 chunk of size %u\n", size);
|
|
|
|
size = sizeof(tt_os2);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&tt_os2, 0, sizeof(tt_os2));
|
|
|
|
ret = GetFontData(hdc, MS_OS2_TAG, 0, &tt_os2, size);
|
2015-09-10 13:47:11 +02:00
|
|
|
ok(ret >= TT_OS2_V0_SIZE && ret <= size, "GetFontData should return size from [%u,%u] not %u\n", TT_OS2_V0_SIZE,
|
|
|
|
size, ret);
|
2007-03-15 07:12:09 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetTextMetricsA(hdc, &tmA);
|
|
|
|
ok(ret, "GetTextMetricsA error %u\n", GetLastError());
|
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
if(!get_first_last_from_cmap(hdc, &cmap_first, &cmap_last, &cmap_type))
|
2007-03-15 07:12:09 +01:00
|
|
|
{
|
2013-05-29 13:53:51 +02:00
|
|
|
skip("%s is not a Windows font, OS/2 metrics may be invalid.\n",font_name);
|
2007-03-15 07:12:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-16 13:39:15 +01:00
|
|
|
USHORT expect_first_A, expect_last_A, expect_break_A, expect_default_A;
|
|
|
|
USHORT expect_first_W, expect_last_W, expect_break_W, expect_default_W;
|
|
|
|
UINT os2_first_char, os2_last_char, default_char, break_char;
|
|
|
|
USHORT version;
|
|
|
|
TEXTMETRICW tmW;
|
2007-06-21 11:10:42 +02:00
|
|
|
|
2013-05-29 13:53:51 +02:00
|
|
|
ascent = GET_BE_WORD(tt_os2.usWinAscent);
|
2015-09-27 21:52:56 +02:00
|
|
|
descent = abs((SHORT)GET_BE_WORD(tt_os2.usWinDescent));
|
2013-05-29 13:53:51 +02:00
|
|
|
cell_height = ascent + descent;
|
|
|
|
ok(ntm->ntmCellHeight == cell_height, "%s: ntmCellHeight %u != %u, os2.usWinAscent/os2.usWinDescent %u/%u\n",
|
|
|
|
font_name, ntm->ntmCellHeight, cell_height, ascent, descent);
|
|
|
|
|
2021-04-06 14:34:21 +02:00
|
|
|
/* NEWTEXTMETRIC's scaling method is different from TEXTMETRIC's */
|
|
|
|
#define SCALE_NTM(value) (MulDiv(ntm->tmHeight, (value), cell_height))
|
|
|
|
size = MulDiv(32, ntm->ntmCellHeight, ntm->ntmSizeEM);
|
|
|
|
ok(ntm->tmHeight == size, "%s: ntm->tmHeight %d != %d (%u/%u)\n",
|
|
|
|
font_name, ntm->tmHeight, size, ntm->ntmCellHeight, ntm->ntmSizeEM);
|
|
|
|
size = SCALE_NTM(ntm->ntmAvgWidth);
|
|
|
|
ok(ntm->tmAveCharWidth == size, "%s: ntm->tmAveCharWidth %d != %d (%u/%u,%d)\n",
|
|
|
|
font_name, ntm->tmAveCharWidth, size, ntm->ntmAvgWidth, cell_height, ntm->tmHeight);
|
|
|
|
size = SCALE_NTM(ascent);
|
|
|
|
ok(ntm->tmAscent == size, "%s: ntm->tmAscent %d != %d (%u/%u,%d)\n",
|
|
|
|
font_name, ntm->tmAscent, size, ascent, cell_height, ntm->tmHeight);
|
|
|
|
size = ntm->tmHeight - ntm->tmAscent;
|
|
|
|
ok(ntm->tmDescent == size, "%s: ntm->tmDescent %d != %d (%u/%u,%d)\n",
|
|
|
|
font_name, ntm->tmDescent, size, descent, cell_height, ntm->tmHeight);
|
|
|
|
size = SCALE_NTM(cell_height - ntm->ntmSizeEM);
|
|
|
|
ok(ntm->tmInternalLeading == size, "%s: ntm->tmInternalLeading %d != %d (%u/%u,%d)\n",
|
|
|
|
font_name, ntm->tmInternalLeading, size, cell_height - ntm->ntmSizeEM, cell_height, ntm->tmHeight);
|
|
|
|
#undef SCALE_NTM
|
|
|
|
|
2009-02-16 13:39:15 +01:00
|
|
|
version = GET_BE_WORD(tt_os2.version);
|
|
|
|
|
|
|
|
os2_first_char = GET_BE_WORD(tt_os2.usFirstCharIndex);
|
|
|
|
os2_last_char = GET_BE_WORD(tt_os2.usLastCharIndex);
|
|
|
|
default_char = GET_BE_WORD(tt_os2.usDefaultChar);
|
|
|
|
break_char = GET_BE_WORD(tt_os2.usBreakChar);
|
2007-03-15 07:12:09 +01:00
|
|
|
|
2015-05-08 17:45:33 +02:00
|
|
|
if (winetest_debug > 1)
|
|
|
|
trace("font %s charset %u: %x-%x (%x-%x) default %x break %x OS/2 version %u vendor %4.4s\n",
|
|
|
|
font_name, lf->lfCharSet, os2_first_char, os2_last_char, cmap_first, cmap_last,
|
|
|
|
default_char, break_char, version, (LPCSTR)&tt_os2.achVendID);
|
2009-02-16 13:39:15 +01:00
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
if (cmap_type == cmap_ms_symbol || (cmap_first >= 0xf000 && cmap_first < 0xf100))
|
2007-06-21 11:10:42 +02:00
|
|
|
{
|
2009-02-16 13:39:15 +01:00
|
|
|
expect_first_W = 0;
|
2009-02-17 12:49:02 +01:00
|
|
|
switch(GetACP())
|
|
|
|
{
|
2014-05-07 15:51:11 +02:00
|
|
|
case 1255: /* Hebrew */
|
|
|
|
expect_last_W = 0xf896;
|
|
|
|
break;
|
2009-02-17 12:49:02 +01:00
|
|
|
case 1257: /* Baltic */
|
|
|
|
expect_last_W = 0xf8fd;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
expect_last_W = 0xf0ff;
|
|
|
|
}
|
2009-02-16 13:39:15 +01:00
|
|
|
expect_break_W = 0x20;
|
|
|
|
expect_default_W = expect_break_W - 1;
|
|
|
|
expect_first_A = 0x1e;
|
|
|
|
expect_last_A = min(os2_last_char - os2_first_char + 0x20, 0xff);
|
2007-06-21 11:10:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-16 13:39:15 +01:00
|
|
|
expect_first_W = cmap_first;
|
2014-05-23 12:33:54 +02:00
|
|
|
expect_last_W = cmap_last;
|
2009-02-16 13:39:15 +01:00
|
|
|
if(os2_first_char <= 1)
|
|
|
|
expect_break_W = os2_first_char + 2;
|
|
|
|
else if(os2_first_char > 0xff)
|
|
|
|
expect_break_W = 0x20;
|
|
|
|
else
|
|
|
|
expect_break_W = os2_first_char;
|
|
|
|
expect_default_W = expect_break_W - 1;
|
|
|
|
expect_first_A = expect_default_W - 1;
|
|
|
|
expect_last_A = min(expect_last_W, 0xff);
|
|
|
|
}
|
|
|
|
expect_break_A = expect_break_W;
|
|
|
|
expect_default_A = expect_default_W;
|
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
/* Wine currently uses SYMBOL_CHARSET to identify whether the ANSI metrics need special handling */
|
2016-02-11 03:02:14 +01:00
|
|
|
todo_wine_if(cmap_type != cmap_ms_symbol && tmA.tmCharSet == SYMBOL_CHARSET && expect_first_A != 0x1e)
|
2009-02-18 11:33:12 +01:00
|
|
|
ok(tmA.tmFirstChar == expect_first_A ||
|
|
|
|
tmA.tmFirstChar == expect_first_A + 1 /* win9x */,
|
|
|
|
"A: tmFirstChar for %s got %02x expected %02x\n", font_name, tmA.tmFirstChar, expect_first_A);
|
2011-01-14 12:27:56 +01:00
|
|
|
if (pGdiGetCodePage == NULL || ! IsDBCSLeadByteEx(pGdiGetCodePage(hdc), tmA.tmLastChar))
|
|
|
|
ok(tmA.tmLastChar == expect_last_A ||
|
|
|
|
tmA.tmLastChar == 0xff /* win9x */,
|
|
|
|
"A: tmLastChar for %s got %02x expected %02x\n", font_name, tmA.tmLastChar, expect_last_A);
|
|
|
|
else
|
|
|
|
skip("tmLastChar is DBCS lead byte\n");
|
2009-02-16 13:39:15 +01:00
|
|
|
ok(tmA.tmBreakChar == expect_break_A, "A: tmBreakChar for %s got %02x expected %02x\n",
|
|
|
|
font_name, tmA.tmBreakChar, expect_break_A);
|
2011-01-09 21:48:57 +01:00
|
|
|
ok(tmA.tmDefaultChar == expect_default_A || broken(sys_lang_non_english),
|
|
|
|
"A: tmDefaultChar for %s got %02x expected %02x\n",
|
2009-02-16 13:39:15 +01:00
|
|
|
font_name, tmA.tmDefaultChar, expect_default_A);
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetTextMetricsW(hdc, &tmW);
|
|
|
|
ok(ret || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
|
|
|
|
"GetTextMetricsW error %u\n", GetLastError());
|
|
|
|
if (ret)
|
|
|
|
{
|
2009-02-18 11:33:12 +01:00
|
|
|
/* Wine uses the os2 first char */
|
2016-02-11 03:02:14 +01:00
|
|
|
todo_wine_if(cmap_first != os2_first_char && cmap_type != cmap_ms_symbol)
|
2009-02-16 13:39:15 +01:00
|
|
|
ok(tmW.tmFirstChar == expect_first_W, "W: tmFirstChar for %s got %02x expected %02x\n",
|
|
|
|
font_name, tmW.tmFirstChar, expect_first_W);
|
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
/* Wine uses the os2 last char */
|
2016-02-11 03:02:14 +01:00
|
|
|
todo_wine_if(expect_last_W != os2_last_char && cmap_type != cmap_ms_symbol)
|
2009-02-16 13:39:15 +01:00
|
|
|
ok(tmW.tmLastChar == expect_last_W, "W: tmLastChar for %s got %02x expected %02x\n",
|
|
|
|
font_name, tmW.tmLastChar, expect_last_W);
|
|
|
|
ok(tmW.tmBreakChar == expect_break_W, "W: tmBreakChar for %s got %02x expected %02x\n",
|
|
|
|
font_name, tmW.tmBreakChar, expect_break_W);
|
2011-01-09 21:48:57 +01:00
|
|
|
ok(tmW.tmDefaultChar == expect_default_W || broken(sys_lang_non_english),
|
|
|
|
"W: tmDefaultChar for %s got %02x expected %02x\n",
|
2009-02-16 13:39:15 +01:00
|
|
|
font_name, tmW.tmDefaultChar, expect_default_W);
|
|
|
|
|
|
|
|
/* Test the aspect ratio while we have tmW */
|
|
|
|
ret = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
ok(tmW.tmDigitizedAspectX == ret, "W: tmDigitizedAspectX %u != %u\n",
|
|
|
|
tmW.tmDigitizedAspectX, ret);
|
|
|
|
ret = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
|
|
ok(tmW.tmDigitizedAspectX == ret, "W: tmDigitizedAspectY %u != %u\n",
|
|
|
|
tmW.tmDigitizedAspectX, ret);
|
2007-06-21 11:10:42 +02:00
|
|
|
}
|
2007-03-15 07:12:09 +01:00
|
|
|
}
|
|
|
|
|
2009-02-11 14:49:52 +01:00
|
|
|
/* test FF_ values */
|
|
|
|
switch(tt_os2.panose.bFamilyType)
|
|
|
|
{
|
|
|
|
case PAN_ANY:
|
|
|
|
case PAN_NO_FIT:
|
|
|
|
case PAN_FAMILY_TEXT_DISPLAY:
|
|
|
|
case PAN_FAMILY_PICTORIAL:
|
|
|
|
default:
|
2009-02-19 11:41:34 +01:00
|
|
|
if((tmA.tmPitchAndFamily & 1) == 0 || /* fixed */
|
|
|
|
tt_os2.panose.bProportion == PAN_PROP_MONOSPACED)
|
2009-02-11 14:49:52 +01:00
|
|
|
{
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_MODERN, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch(tt_os2.panose.bSerifStyle)
|
|
|
|
{
|
|
|
|
case PAN_ANY:
|
|
|
|
case PAN_NO_FIT:
|
|
|
|
default:
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_DONTCARE, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_SERIF_COVE:
|
|
|
|
case PAN_SERIF_OBTUSE_COVE:
|
|
|
|
case PAN_SERIF_SQUARE_COVE:
|
|
|
|
case PAN_SERIF_OBTUSE_SQUARE_COVE:
|
|
|
|
case PAN_SERIF_SQUARE:
|
|
|
|
case PAN_SERIF_THIN:
|
|
|
|
case PAN_SERIF_BONE:
|
|
|
|
case PAN_SERIF_EXAGGERATED:
|
|
|
|
case PAN_SERIF_TRIANGLE:
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_ROMAN, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_SERIF_NORMAL_SANS:
|
|
|
|
case PAN_SERIF_OBTUSE_SANS:
|
|
|
|
case PAN_SERIF_PERP_SANS:
|
|
|
|
case PAN_SERIF_FLARED:
|
|
|
|
case PAN_SERIF_ROUNDED:
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_SWISS, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_FAMILY_SCRIPT:
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_SCRIPT, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_FAMILY_DECORATIVE:
|
2009-02-12 13:30:45 +01:00
|
|
|
expect_ff(&tmA, &tt_os2, FF_DECORATIVE, font_name);
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-07 14:24:47 +02:00
|
|
|
test_negative_width(hdc, lf);
|
|
|
|
|
2007-03-15 07:12:09 +01:00
|
|
|
end_of_test:
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_truetype_font_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2007-03-15 07:12:09 +01:00
|
|
|
{
|
|
|
|
INT *enumed = (INT *)lParam;
|
|
|
|
|
|
|
|
if (type == TRUETYPE_FONTTYPE)
|
|
|
|
{
|
|
|
|
(*enumed)++;
|
2013-10-17 01:55:20 +02:00
|
|
|
test_text_metrics(lf, (const NEWTEXTMETRICA *)ntm);
|
2007-03-15 07:12:09 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetTextMetrics(void)
|
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
INT enumed;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
enumed = 0;
|
|
|
|
EnumFontFamiliesExA(hdc, &lf, enum_truetype_font_proc, (LPARAM)&enumed, 0);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2007-07-31 18:57:34 +02:00
|
|
|
static void test_nonexistent_font(void)
|
2007-07-05 16:27:20 +02:00
|
|
|
{
|
2008-06-22 15:41:47 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int charset;
|
|
|
|
} font_subst[] =
|
|
|
|
{
|
|
|
|
{ "Times New Roman Baltic", 186 },
|
|
|
|
{ "Times New Roman CE", 238 },
|
|
|
|
{ "Times New Roman CYR", 204 },
|
|
|
|
{ "Times New Roman Greek", 161 },
|
|
|
|
{ "Times New Roman TUR", 162 }
|
|
|
|
};
|
2015-07-17 11:23:14 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int charset;
|
|
|
|
} shell_subst[] =
|
|
|
|
{
|
|
|
|
{ "MS Shell Dlg", 186 },
|
|
|
|
{ "MS Shell Dlg", 238 },
|
|
|
|
{ "MS Shell Dlg", 204 },
|
|
|
|
{ "MS Shell Dlg", 161 },
|
|
|
|
{ "MS Shell Dlg", 162 }
|
|
|
|
};
|
2007-07-05 16:27:20 +02:00
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont;
|
2008-05-13 15:10:05 +02:00
|
|
|
CHARSETINFO csi;
|
2015-07-17 11:23:14 +02:00
|
|
|
INT cs, expected_cs, i, ret;
|
2007-07-05 16:27:20 +02:00
|
|
|
char buf[LF_FACESIZE];
|
|
|
|
|
2008-05-13 15:10:05 +02:00
|
|
|
expected_cs = GetACP();
|
|
|
|
if (!TranslateCharsetInfo(ULongToPtr(expected_cs), &csi, TCI_SRCCODEPAGE))
|
|
|
|
{
|
|
|
|
skip("TranslateCharsetInfo failed for code page %d\n", expected_cs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
expected_cs = csi.ciCharset;
|
|
|
|
trace("ACP %d -> charset %d\n", GetACP(), expected_cs);
|
|
|
|
|
2015-07-17 11:23:14 +02:00
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(shell_subst); i++)
|
2015-07-17 11:23:14 +02:00
|
|
|
{
|
|
|
|
ret = is_font_installed(shell_subst[i].name);
|
|
|
|
ok(ret || broken(!ret) /* win2000 */, "%s should be enumerated\n", shell_subst[i].name);
|
|
|
|
ret = is_truetype_font_installed(shell_subst[i].name);
|
|
|
|
ok(ret || broken(!ret) /* win2000 */, "%s should be enumerated\n", shell_subst[i].name);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_REGULAR;
|
|
|
|
strcpy(lf.lfFaceName, shell_subst[i].name);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, shell_subst[i].name), "expected %s, got %s\n", shell_subst[i].name, buf);
|
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d for font %s\n", cs, shell_subst[i].name);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
strcpy(lf.lfFaceName, shell_subst[i].name);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, shell_subst[i].name), "expected %s, got %s\n", shell_subst[i].name, buf);
|
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
ok(cs == expected_cs || cs == ANSI_CHARSET, "expected %d, got %d for font %s\n", expected_cs, cs, shell_subst[i].name);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Arial") ||
|
|
|
|
!is_truetype_font_installed("Times New Roman"))
|
|
|
|
{
|
|
|
|
DeleteDC(hdc);
|
|
|
|
skip("Arial or Times New Roman not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
2007-07-05 16:27:20 +02:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 100;
|
|
|
|
lf.lfWeight = FW_REGULAR;
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfPitchAndFamily = FF_SWISS;
|
2007-07-31 18:57:34 +02:00
|
|
|
strcpy(lf.lfFaceName, "Nonexistent font");
|
2007-07-05 16:27:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, "Arial"), "Got %s\n", buf);
|
2008-05-13 15:10:05 +02:00
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
|
2007-07-05 16:27:20 +02:00
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
2008-05-13 15:10:05 +02:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
strcpy(lf.lfFaceName, "Nonexistent font");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
todo_wine /* Wine uses Arial for all substitutions */
|
|
|
|
ok(!lstrcmpiA(buf, "Nonexistent font") /* XP, Vista */ ||
|
2008-05-19 09:24:06 +02:00
|
|
|
!lstrcmpiA(buf, "MS Serif") || /* Win9x */
|
|
|
|
!lstrcmpiA(buf, "MS Sans Serif"), /* win2k3 */
|
|
|
|
"Got %s\n", buf);
|
2008-05-13 15:10:05 +02:00
|
|
|
cs = GetTextCharset(hdc);
|
2011-01-12 14:11:43 +01:00
|
|
|
ok(cs == expected_cs || cs == ANSI_CHARSET, "expected %d, got %d\n", expected_cs, cs);
|
2008-05-13 15:10:05 +02:00
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_REGULAR;
|
|
|
|
strcpy(lf.lfFaceName, "Nonexistent font");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, "Arial") /* XP, Vista */ ||
|
|
|
|
!lstrcmpiA(buf, "Times New Roman") /* Win9x */, "Got %s\n", buf);
|
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
strcpy(lf.lfFaceName, "Times New Roman");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, "Times New Roman"), "Got %s\n", buf);
|
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d\n", cs);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(font_subst); i++)
|
2008-06-22 15:41:47 +02:00
|
|
|
{
|
2015-07-17 11:23:14 +02:00
|
|
|
ret = is_font_installed(font_subst[i].name);
|
|
|
|
todo_wine
|
|
|
|
ok(ret || broken(!ret && !i) /* win2000 doesn't have Times New Roman Baltic substitution */,
|
|
|
|
"%s should be enumerated\n", font_subst[i].name);
|
|
|
|
ret = is_truetype_font_installed(font_subst[i].name);
|
|
|
|
todo_wine
|
|
|
|
ok(ret || broken(!ret && !i) /* win2000 doesn't have Times New Roman Baltic substitution */,
|
|
|
|
"%s should be enumerated\n", font_subst[i].name);
|
|
|
|
|
2008-06-22 15:41:47 +02:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_REGULAR;
|
|
|
|
strcpy(lf.lfFaceName, font_subst[i].name);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
cs = GetTextCharset(hdc);
|
|
|
|
if (font_subst[i].charset == expected_cs)
|
|
|
|
{
|
2009-02-18 23:52:22 +01:00
|
|
|
ok(cs == expected_cs, "expected %d, got %d for font %s\n", expected_cs, cs, font_subst[i].name);
|
2008-06-22 15:41:47 +02:00
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, font_subst[i].name), "expected %s, got %s\n", font_subst[i].name, buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-18 23:52:22 +01:00
|
|
|
ok(cs == ANSI_CHARSET, "expected ANSI_CHARSET, got %d for font %s\n", cs, font_subst[i].name);
|
2008-06-22 15:41:47 +02:00
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, "Arial") /* XP, Vista */ ||
|
2009-02-18 23:52:22 +01:00
|
|
|
!lstrcmpiA(buf, "Times New Roman") /* Win9x */, "got %s for font %s\n", buf, font_subst[i].name);
|
2008-06-22 15:41:47 +02:00
|
|
|
}
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = -13;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
strcpy(lf.lfFaceName, font_subst[i].name);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
GetTextFaceA(hdc, sizeof(buf), buf);
|
|
|
|
ok(!lstrcmpiA(buf, "Arial") /* Wine */ ||
|
|
|
|
!lstrcmpiA(buf, font_subst[i].name) /* XP, Vista */ ||
|
|
|
|
!lstrcmpiA(buf, "MS Serif") /* Win9x */ ||
|
|
|
|
!lstrcmpiA(buf, "MS Sans Serif"), /* win2k3 */
|
2009-02-18 23:52:22 +01:00
|
|
|
"got %s for font %s\n", buf, font_subst[i].name);
|
2008-06-22 15:41:47 +02:00
|
|
|
cs = GetTextCharset(hdc);
|
2011-01-12 14:11:43 +01:00
|
|
|
ok(cs == expected_cs || cs == ANSI_CHARSET, "expected %d, got %d for font %s\n", expected_cs, cs, font_subst[i].name);
|
2008-06-22 15:41:47 +02:00
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
}
|
2008-05-13 15:10:05 +02:00
|
|
|
|
2015-07-17 11:23:14 +02:00
|
|
|
DeleteDC(hdc);
|
2007-07-05 16:27:20 +02:00
|
|
|
}
|
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
struct font_realization_info
|
2008-02-27 18:00:06 +01:00
|
|
|
{
|
2018-11-21 13:54:01 +01:00
|
|
|
DWORD size;
|
|
|
|
DWORD flags;
|
|
|
|
DWORD cache_num;
|
|
|
|
DWORD instance_id;
|
|
|
|
DWORD unk;
|
|
|
|
WORD face_index;
|
|
|
|
WORD simulations;
|
|
|
|
};
|
2015-08-29 18:53:40 +02:00
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
struct file_info
|
|
|
|
{
|
|
|
|
FILETIME time;
|
|
|
|
LARGE_INTEGER size;
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
};
|
|
|
|
|
|
|
|
static void test_RealizationInfo(void)
|
|
|
|
{
|
2015-08-29 18:53:40 +02:00
|
|
|
struct realization_info_t
|
|
|
|
{
|
|
|
|
DWORD flags;
|
|
|
|
DWORD cache_num;
|
|
|
|
DWORD instance_id;
|
|
|
|
};
|
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
struct file_info file_info;
|
2008-02-27 18:00:06 +01:00
|
|
|
HDC hdc;
|
2018-11-21 13:54:01 +01:00
|
|
|
DWORD info[4], info2[32], read;
|
2008-02-27 18:00:06 +01:00
|
|
|
HFONT hfont, hfont_old;
|
2018-11-21 13:54:01 +01:00
|
|
|
SIZE_T needed;
|
2008-02-27 18:00:06 +01:00
|
|
|
LOGFONTA lf;
|
2015-08-13 16:39:19 +02:00
|
|
|
HANDLE h;
|
|
|
|
BYTE file[16], data[14];
|
|
|
|
FILETIME time;
|
|
|
|
LARGE_INTEGER size;
|
2018-11-21 13:54:01 +01:00
|
|
|
BOOL r;
|
2008-02-27 18:00:06 +01:00
|
|
|
|
|
|
|
if(!pGdiRealizationInfo)
|
|
|
|
{
|
2009-02-24 00:03:32 +01:00
|
|
|
win_skip("GdiRealizationInfo not available\n");
|
2008-02-27 18:00:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
memset(info, 0xcc, sizeof(info));
|
|
|
|
r = pGdiRealizationInfo(hdc, info);
|
|
|
|
ok(r != 0, "ret 0\n");
|
2009-02-16 15:07:29 +01:00
|
|
|
ok((info[0] & 0xf) == 1, "info[0] = %x for the system font\n", info[0]);
|
2008-03-01 21:13:04 +01:00
|
|
|
ok(info[3] == 0xcccccccc, "structure longer than 3 dwords\n");
|
2008-02-27 18:00:06 +01:00
|
|
|
|
2015-10-04 11:48:48 +02:00
|
|
|
if (!is_truetype_font_installed("Tahoma"))
|
2008-02-27 18:00:06 +01:00
|
|
|
{
|
|
|
|
skip("skipping GdiRealizationInfo with truetype font\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
2015-10-04 11:48:48 +02:00
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
2008-02-27 18:00:06 +01:00
|
|
|
lf.lfHeight = 20;
|
2015-10-08 20:13:57 +02:00
|
|
|
lf.lfWeight = FW_BOLD;
|
|
|
|
lf.lfItalic = 1;
|
2008-02-27 18:00:06 +01:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
memset(info, 0xcc, sizeof(info));
|
|
|
|
r = pGdiRealizationInfo(hdc, info);
|
|
|
|
ok(r != 0, "ret 0\n");
|
2009-02-16 15:07:29 +01:00
|
|
|
ok((info[0] & 0xf) == 3, "info[0] = %x for arial\n", info[0]);
|
2008-03-01 21:13:04 +01:00
|
|
|
ok(info[3] == 0xcccccccc, "structure longer than 3 dwords\n");
|
2008-02-27 18:00:06 +01:00
|
|
|
|
2015-08-13 16:39:19 +02:00
|
|
|
if (pGetFontRealizationInfo)
|
|
|
|
{
|
2015-08-29 18:53:40 +02:00
|
|
|
struct font_realization_info *fri = (struct font_realization_info*)info2;
|
|
|
|
struct realization_info_t *ri = (struct realization_info_t*)info;
|
|
|
|
|
2015-08-13 16:39:19 +02:00
|
|
|
/* The first DWORD represents a struct size. On a
|
|
|
|
newly rebooted system setting this to < 16 results
|
|
|
|
in GetFontRealizationInfo failing. However there
|
|
|
|
appears to be some caching going on which results
|
|
|
|
in calls after a successful call also succeeding even
|
|
|
|
if the size < 16. This means we can't reliably test
|
|
|
|
this behaviour. */
|
|
|
|
|
|
|
|
memset(info2, 0xcc, sizeof(info2));
|
|
|
|
info2[0] = 16;
|
|
|
|
r = pGetFontRealizationInfo(hdc, info2);
|
|
|
|
ok(r != 0, "ret 0\n");
|
|
|
|
/* We may get the '24' version here if that has been previously
|
|
|
|
requested. */
|
2015-08-29 18:53:40 +02:00
|
|
|
ok(fri->size == 16 || fri->size == 24, "got %d\n", info2[0]);
|
|
|
|
ok(fri->flags == ri->flags, "flags mismatch\n");
|
|
|
|
ok(fri->cache_num == ri->cache_num, "cache_num mismatch\n");
|
|
|
|
ok(fri->instance_id == ri->instance_id, "instance id mismatch\n");
|
|
|
|
ok(info2[6] == 0xcccccccc, "got wrong dword 6, 0x%08x\n", info2[6]);
|
2015-08-13 16:39:19 +02:00
|
|
|
|
|
|
|
memset(info2, 0xcc, sizeof(info2));
|
|
|
|
info2[0] = 28;
|
|
|
|
r = pGetFontRealizationInfo(hdc, info2);
|
|
|
|
ok(r == FALSE, "got %d\n", r);
|
|
|
|
|
|
|
|
memset(info2, 0xcc, sizeof(info2));
|
|
|
|
info2[0] = 24;
|
|
|
|
r = pGetFontRealizationInfo(hdc, info2);
|
|
|
|
ok(r != 0, "ret 0\n");
|
2015-08-29 18:53:40 +02:00
|
|
|
ok(fri->size == 24, "got %d\n", fri->size);
|
|
|
|
ok(fri->flags == ri->flags, "flags mismatch\n");
|
|
|
|
ok(fri->cache_num == ri->cache_num, "cache_num mismatch\n");
|
|
|
|
ok(fri->instance_id == ri->instance_id, "instance id mismatch\n");
|
2015-10-08 20:13:57 +02:00
|
|
|
ok(fri->simulations == 0x2, "got simulations flags 0x%04x\n", fri->simulations);
|
2015-08-29 18:53:40 +02:00
|
|
|
ok(fri->face_index == 0, "got wrong face index %u\n", fri->face_index);
|
2015-08-13 16:39:19 +02:00
|
|
|
ok(info2[6] == 0xcccccccc, "structure longer than 6 dwords\n");
|
|
|
|
|
|
|
|
/* Test GetFontFileInfo() */
|
2015-10-04 11:48:48 +02:00
|
|
|
/* invalid font id */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
r = pGetFontFileInfo(0xabababab, 0, &file_info, sizeof(file_info), &needed);
|
|
|
|
ok(r == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "ret %d gle %d\n", r, GetLastError());
|
|
|
|
|
|
|
|
needed = 0;
|
2015-08-29 18:53:40 +02:00
|
|
|
r = pGetFontFileInfo(fri->instance_id, 0, &file_info, sizeof(file_info), &needed);
|
2018-11-21 13:54:01 +01:00
|
|
|
ok(r != 0, "Failed to get font file info, error %d.\n", GetLastError());
|
2015-08-13 16:39:19 +02:00
|
|
|
|
2015-08-20 11:50:24 +02:00
|
|
|
if (r)
|
|
|
|
{
|
2018-11-21 13:54:01 +01:00
|
|
|
ok(needed > 0 && needed < sizeof(file_info), "Unexpected required size.\n");
|
2015-10-04 11:48:48 +02:00
|
|
|
|
2015-08-20 11:50:24 +02:00
|
|
|
h = CreateFileW(file_info.path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
|
|
|
ok(h != INVALID_HANDLE_VALUE, "Unable to open file %d\n", GetLastError());
|
|
|
|
|
|
|
|
GetFileTime(h, NULL, NULL, &time);
|
|
|
|
ok(!CompareFileTime(&file_info.time, &time), "time mismatch\n");
|
|
|
|
GetFileSizeEx(h, &size);
|
|
|
|
ok(file_info.size.QuadPart == size.QuadPart, "size mismatch\n");
|
|
|
|
|
|
|
|
/* Read first 16 bytes from the file */
|
|
|
|
ReadFile(h, file, sizeof(file), &read, NULL);
|
|
|
|
CloseHandle(h);
|
2015-10-04 11:48:48 +02:00
|
|
|
|
|
|
|
/* shorter buffer */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
r = pGetFontFileInfo(fri->instance_id, 0, &file_info, needed - 1, &needed);
|
|
|
|
ok(r == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "ret %d gle %d\n", r, GetLastError());
|
2015-08-20 11:50:24 +02:00
|
|
|
}
|
2015-08-13 16:39:19 +02:00
|
|
|
|
|
|
|
/* Get bytes 2 - 16 using GetFontFileData */
|
2015-08-29 18:53:40 +02:00
|
|
|
r = pGetFontFileData(fri->instance_id, 0, 2, data, sizeof(data));
|
2015-08-13 16:39:19 +02:00
|
|
|
ok(r != 0, "ret 0 gle %d\n", GetLastError());
|
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
ok(!memcmp(data, file + 2, sizeof(data)), "mismatch\n");
|
2015-08-13 16:39:19 +02:00
|
|
|
}
|
|
|
|
|
2008-02-27 18:00:06 +01:00
|
|
|
DeleteObject(SelectObject(hdc, hfont_old));
|
|
|
|
|
|
|
|
end:
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2008-06-20 00:59:57 +02:00
|
|
|
/* Tests on XP SP2 show that the ANSI version of GetTextFace does NOT include
|
|
|
|
the nul in the count of characters copied when the face name buffer is not
|
|
|
|
NULL, whereas it does if the buffer is NULL. Further, the Unicode version
|
|
|
|
always includes it. */
|
|
|
|
static void test_GetTextFace(void)
|
|
|
|
{
|
|
|
|
static const char faceA[] = "Tahoma";
|
2020-12-17 23:10:19 +01:00
|
|
|
static const WCHAR faceW[] = L"Tahoma";
|
2008-06-20 00:59:57 +02:00
|
|
|
LOGFONTA fA = {0};
|
|
|
|
LOGFONTW fW = {0};
|
|
|
|
char bufA[LF_FACESIZE];
|
|
|
|
WCHAR bufW[LF_FACESIZE];
|
|
|
|
HFONT f, g;
|
|
|
|
HDC dc;
|
|
|
|
int n;
|
|
|
|
|
2008-09-19 12:07:32 +02:00
|
|
|
if(!is_font_installed("Tahoma"))
|
|
|
|
{
|
|
|
|
skip("Tahoma is not installed so skipping this test\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-20 00:59:57 +02:00
|
|
|
/* 'A' case. */
|
|
|
|
memcpy(fA.lfFaceName, faceA, sizeof faceA);
|
|
|
|
f = CreateFontIndirectA(&fA);
|
|
|
|
ok(f != NULL, "CreateFontIndirectA failed\n");
|
|
|
|
|
|
|
|
dc = GetDC(NULL);
|
|
|
|
g = SelectObject(dc, f);
|
|
|
|
n = GetTextFaceA(dc, sizeof bufA, bufA);
|
|
|
|
ok(n == sizeof faceA - 1, "GetTextFaceA returned %d\n", n);
|
|
|
|
ok(lstrcmpA(faceA, bufA) == 0, "GetTextFaceA\n");
|
|
|
|
|
|
|
|
/* Play with the count arg. */
|
|
|
|
bufA[0] = 'x';
|
|
|
|
n = GetTextFaceA(dc, 0, bufA);
|
|
|
|
ok(n == 0, "GetTextFaceA returned %d\n", n);
|
|
|
|
ok(bufA[0] == 'x', "GetTextFaceA buf[0] == %d\n", bufA[0]);
|
|
|
|
|
|
|
|
bufA[0] = 'x';
|
|
|
|
n = GetTextFaceA(dc, 1, bufA);
|
|
|
|
ok(n == 0, "GetTextFaceA returned %d\n", n);
|
|
|
|
ok(bufA[0] == '\0', "GetTextFaceA buf[0] == %d\n", bufA[0]);
|
|
|
|
|
|
|
|
bufA[0] = 'x'; bufA[1] = 'y';
|
|
|
|
n = GetTextFaceA(dc, 2, bufA);
|
|
|
|
ok(n == 1, "GetTextFaceA returned %d\n", n);
|
|
|
|
ok(bufA[0] == faceA[0] && bufA[1] == '\0', "GetTextFaceA didn't copy\n");
|
|
|
|
|
|
|
|
n = GetTextFaceA(dc, 0, NULL);
|
2009-02-16 23:30:07 +01:00
|
|
|
ok(n == sizeof faceA ||
|
|
|
|
broken(n == 0), /* win98, winMe */
|
|
|
|
"GetTextFaceA returned %d\n", n);
|
2008-06-20 00:59:57 +02:00
|
|
|
|
|
|
|
DeleteObject(SelectObject(dc, g));
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
|
|
|
|
/* 'W' case. */
|
|
|
|
memcpy(fW.lfFaceName, faceW, sizeof faceW);
|
2008-07-31 19:13:07 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-06-20 00:59:57 +02:00
|
|
|
f = CreateFontIndirectW(&fW);
|
2008-07-31 19:13:07 +02:00
|
|
|
if (!f && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
win_skip("CreateFontIndirectW is not implemented\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-06-20 00:59:57 +02:00
|
|
|
ok(f != NULL, "CreateFontIndirectW failed\n");
|
|
|
|
|
|
|
|
dc = GetDC(NULL);
|
|
|
|
g = SelectObject(dc, f);
|
2018-06-25 21:46:41 +02:00
|
|
|
n = GetTextFaceW(dc, ARRAY_SIZE(bufW), bufW);
|
|
|
|
ok(n == ARRAY_SIZE(faceW), "GetTextFaceW returned %d\n", n);
|
2008-06-20 00:59:57 +02:00
|
|
|
ok(lstrcmpW(faceW, bufW) == 0, "GetTextFaceW\n");
|
|
|
|
|
|
|
|
/* Play with the count arg. */
|
|
|
|
bufW[0] = 'x';
|
|
|
|
n = GetTextFaceW(dc, 0, bufW);
|
|
|
|
ok(n == 0, "GetTextFaceW returned %d\n", n);
|
|
|
|
ok(bufW[0] == 'x', "GetTextFaceW buf[0] == %d\n", bufW[0]);
|
|
|
|
|
|
|
|
bufW[0] = 'x';
|
|
|
|
n = GetTextFaceW(dc, 1, bufW);
|
|
|
|
ok(n == 1, "GetTextFaceW returned %d\n", n);
|
|
|
|
ok(bufW[0] == '\0', "GetTextFaceW buf[0] == %d\n", bufW[0]);
|
|
|
|
|
|
|
|
bufW[0] = 'x'; bufW[1] = 'y';
|
|
|
|
n = GetTextFaceW(dc, 2, bufW);
|
|
|
|
ok(n == 2, "GetTextFaceW returned %d\n", n);
|
|
|
|
ok(bufW[0] == faceW[0] && bufW[1] == '\0', "GetTextFaceW didn't copy\n");
|
|
|
|
|
|
|
|
n = GetTextFaceW(dc, 0, NULL);
|
2018-06-25 21:46:41 +02:00
|
|
|
ok(n == ARRAY_SIZE(faceW), "GetTextFaceW returned %d\n", n);
|
2008-06-20 00:59:57 +02:00
|
|
|
|
|
|
|
DeleteObject(SelectObject(dc, g));
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
}
|
|
|
|
|
2008-07-22 02:54:01 +02:00
|
|
|
static void test_orientation(void)
|
|
|
|
{
|
|
|
|
static const char test_str[11] = "Test String";
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, old_hfont;
|
|
|
|
SIZE size;
|
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lstrcpyA(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lf.lfOrientation = lf.lfEscapement = 900;
|
|
|
|
hfont = create_font("orientation", &lf);
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
ok(GetTextExtentExPointA(hdc, test_str, sizeof(test_str), 32767, NULL, NULL, &size), "GetTextExtentExPointA failed\n");
|
2008-07-22 02:54:42 +02:00
|
|
|
ok(near_match(311, size.cx), "cx should be about 311, got %d\n", size.cx);
|
2008-07-22 02:54:01 +02:00
|
|
|
ok(near_match(75, size.cy), "cy should be about 75, got %d\n", size.cy);
|
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2009-12-30 11:44:21 +01:00
|
|
|
static void test_oemcharset(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
2010-01-18 10:08:26 +01:00
|
|
|
LOGFONTA lf, clf;
|
2009-12-30 11:44:21 +01:00
|
|
|
HFONT hfont, old_hfont;
|
|
|
|
int charset;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ZeroMemory(&lf, sizeof(lf));
|
|
|
|
lf.lfHeight = 12;
|
|
|
|
lf.lfCharSet = OEM_CHARSET;
|
|
|
|
lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
|
|
|
|
lstrcpyA(lf.lfFaceName, "Terminal");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
charset = GetTextCharset(hdc);
|
|
|
|
todo_wine
|
|
|
|
ok(charset == OEM_CHARSET, "expected %d charset, got %d\n", OEM_CHARSET, charset);
|
2010-01-18 10:08:26 +01:00
|
|
|
hfont = SelectObject(hdc, old_hfont);
|
|
|
|
GetObjectA(hfont, sizeof(clf), &clf);
|
|
|
|
ok(!lstrcmpA(clf.lfFaceName, lf.lfFaceName), "expected %s face name, got %s\n", lf.lfFaceName, clf.lfFaceName);
|
|
|
|
ok(clf.lfPitchAndFamily == lf.lfPitchAndFamily, "expected %x family, got %x\n", lf.lfPitchAndFamily, clf.lfPitchAndFamily);
|
|
|
|
ok(clf.lfCharSet == lf.lfCharSet, "expected %d charset, got %d\n", lf.lfCharSet, clf.lfCharSet);
|
|
|
|
ok(clf.lfHeight == lf.lfHeight, "expected %d height, got %d\n", lf.lfHeight, clf.lfHeight);
|
2009-12-30 11:44:21 +01:00
|
|
|
DeleteObject(hfont);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static int CALLBACK create_fixed_pitch_font_proc(const LOGFONTA *lpelfe,
|
|
|
|
const TEXTMETRICA *lpntme,
|
2013-02-07 14:13:04 +01:00
|
|
|
DWORD FontType, LPARAM lParam)
|
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
const NEWTEXTMETRICEXA *lpntmex = (const NEWTEXTMETRICEXA *)lpntme;
|
2013-02-07 14:13:04 +01:00
|
|
|
CHARSETINFO csi;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf = *lpelfe;
|
2013-02-07 14:13:04 +01:00
|
|
|
HFONT hfont;
|
2013-10-08 17:12:17 +02:00
|
|
|
DWORD found_subset;
|
2013-02-07 14:13:04 +01:00
|
|
|
|
|
|
|
/* skip bitmap, proportional or vertical font */
|
|
|
|
if ((FontType & TRUETYPE_FONTTYPE) == 0 ||
|
|
|
|
(lf.lfPitchAndFamily & 0xf) != FIXED_PITCH ||
|
|
|
|
lf.lfFaceName[0] == '@')
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* skip linked font */
|
|
|
|
if (!TranslateCharsetInfo((DWORD*)(INT_PTR)lpelfe->lfCharSet, &csi, TCI_SRCCHARSET) ||
|
|
|
|
(lpntmex->ntmFontSig.fsCsb[0] & csi.fs.fsCsb[0]) == 0)
|
|
|
|
return 1;
|
|
|
|
|
2013-10-08 17:12:17 +02:00
|
|
|
/* skip linked font, like SimSun-ExtB */
|
|
|
|
switch (lpelfe->lfCharSet) {
|
|
|
|
case SHIFTJIS_CHARSET:
|
|
|
|
found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 17); /* Hiragana */
|
|
|
|
break;
|
|
|
|
case GB2312_CHARSET:
|
|
|
|
case CHINESEBIG5_CHARSET:
|
|
|
|
found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 16); /* CJK Symbols And Punctuation */
|
|
|
|
break;
|
|
|
|
case HANGEUL_CHARSET:
|
|
|
|
found_subset = lpntmex->ntmFontSig.fsUsb[1] & (1 << 24); /* Hangul Syllables */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
found_subset = lpntmex->ntmFontSig.fsUsb[0] & (1 << 0); /* Basic Latin */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!found_subset)
|
|
|
|
return 1;
|
|
|
|
|
2013-02-07 14:13:04 +01:00
|
|
|
/* test with an odd height */
|
|
|
|
lf.lfHeight = -19;
|
|
|
|
lf.lfWidth = 0;
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-02-07 14:13:04 +01:00
|
|
|
if (hfont)
|
|
|
|
{
|
|
|
|
*(HFONT *)lParam = hfont;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-02-03 10:55:19 +01:00
|
|
|
static void test_GetGlyphOutline(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
2011-02-03 12:06:59 +01:00
|
|
|
GLYPHMETRICS gm, gm2;
|
2009-02-03 10:55:19 +01:00
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, old_hfont;
|
2011-02-03 12:06:59 +01:00
|
|
|
INT ret, ret2;
|
2013-09-19 17:57:46 +02:00
|
|
|
const UINT fmt[] = { GGO_METRICS, GGO_BITMAP, GGO_GRAY2_BITMAP,
|
|
|
|
GGO_GRAY4_BITMAP, GGO_GRAY8_BITMAP };
|
2011-02-03 12:06:59 +01:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
UINT cs;
|
|
|
|
UINT a;
|
|
|
|
UINT w;
|
|
|
|
} c[] =
|
|
|
|
{
|
|
|
|
{ANSI_CHARSET, 0x30, 0x30},
|
|
|
|
{SHIFTJIS_CHARSET, 0x82a0, 0x3042},
|
|
|
|
{HANGEUL_CHARSET, 0x8141, 0xac02},
|
|
|
|
{GB2312_CHARSET, 0x8141, 0x4e04},
|
|
|
|
{CHINESEBIG5_CHARSET, 0xa142, 0x3001}
|
|
|
|
};
|
|
|
|
UINT i;
|
2009-02-03 10:55:19 +01:00
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Tahoma"))
|
|
|
|
{
|
|
|
|
skip("Tahoma is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lstrcpyA(lf.lfFaceName, "Tahoma");
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, NULL);
|
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutlineA should fail\n");
|
2009-02-16 23:37:25 +01:00
|
|
|
ok(GetLastError() == 0xdeadbeef ||
|
|
|
|
GetLastError() == ERROR_INVALID_PARAMETER, /* win98, winMe */
|
|
|
|
"expected 0xdeadbeef, got %u\n", GetLastError());
|
2009-02-03 10:55:19 +01:00
|
|
|
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW error %u\n", GetLastError());
|
|
|
|
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, 'A', GGO_METRICS, &gm, 0, NULL, NULL);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutlineW should fail\n");
|
|
|
|
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2009-03-30 19:47:29 +02:00
|
|
|
/* test for needed buffer size request on space char */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, ' ', GGO_NATIVE, &gm, 0, NULL, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
2014-10-09 18:00:56 +02:00
|
|
|
{
|
2009-03-30 19:47:29 +02:00
|
|
|
ok(ret == 0, "GetGlyphOutlineW should return 0 buffer size for space char\n");
|
2014-10-09 18:00:56 +02:00
|
|
|
ok(gm.gmBlackBoxX == 1, "Expected 1, got %u\n", gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 1, "Expected 1, got %u\n", gm.gmBlackBoxY);
|
|
|
|
}
|
2009-03-30 19:47:29 +02:00
|
|
|
|
|
|
|
/* requesting buffer size for space char + error */
|
|
|
|
memset(&gm, 0, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(0, ' ', GGO_NATIVE, &gm, 0, NULL, NULL);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutlineW should return GDI_ERROR\n");
|
|
|
|
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
|
2014-10-09 18:00:56 +02:00
|
|
|
ok(gm.gmBlackBoxX == 0, "Expected 0, got %u\n", gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 0, "Expected 0, got %u\n", gm.gmBlackBoxY);
|
2009-03-30 19:47:29 +02:00
|
|
|
}
|
|
|
|
|
2014-10-09 18:00:56 +02:00
|
|
|
/* test GetGlyphOutline with a buffer too small */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineA(hdc, 'A', GGO_NATIVE, &gm, sizeof(i), &i, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutlineW should return an error when the buffer size is too small.\n");
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(fmt); ++i)
|
2013-09-19 17:57:46 +02:00
|
|
|
{
|
|
|
|
DWORD dummy;
|
|
|
|
|
|
|
|
memset(&gm, 0xab, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, ' ', fmt[i], &gm, 0, NULL, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
if (fmt[i] == GGO_METRICS)
|
|
|
|
ok(ret != GDI_ERROR, "%2d:GetGlyphOutlineW should succeed, got %d\n", fmt[i], ret);
|
|
|
|
else
|
|
|
|
ok(ret == 0, "%2d:GetGlyphOutlineW should return 0, got %d\n", fmt[i], ret);
|
2013-10-01 15:03:18 +02:00
|
|
|
ok(gm.gmBlackBoxX == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxY);
|
2013-09-19 17:57:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&gm, 0xab, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, ' ', fmt[i], &gm, 0, &dummy, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
if (fmt[i] == GGO_METRICS)
|
|
|
|
ok(ret != GDI_ERROR, "%2d:GetGlyphOutlineW should succeed, got %d\n", fmt[i], ret);
|
|
|
|
else
|
|
|
|
ok(ret == 0, "%2d:GetGlyphOutlineW should return 0, got %d\n", fmt[i], ret);
|
2013-10-01 15:03:18 +02:00
|
|
|
ok(gm.gmBlackBoxX == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxY);
|
2013-09-19 17:57:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&gm, 0xab, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, ' ', fmt[i], &gm, sizeof(dummy), NULL, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
if (fmt[i] == GGO_METRICS)
|
|
|
|
ok(ret != GDI_ERROR, "%2d:GetGlyphOutlineW should succeed, got %d\n", fmt[i], ret);
|
|
|
|
else
|
|
|
|
ok(ret == 0, "%2d:GetGlyphOutlineW should return 0, got %d\n", fmt[i], ret);
|
2013-10-01 15:03:18 +02:00
|
|
|
ok(gm.gmBlackBoxX == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxY);
|
2013-09-19 17:57:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&gm, 0xab, sizeof(gm));
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = GetGlyphOutlineW(hdc, ' ', fmt[i], &gm, sizeof(dummy), &dummy, &mat);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
if (fmt[i] == GGO_METRICS) {
|
|
|
|
ok(ret != GDI_ERROR, "%2d:GetGlyphOutlineW should succeed, got %d\n", fmt[i], ret);
|
2013-10-01 15:03:18 +02:00
|
|
|
ok(gm.gmBlackBoxX == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxX);
|
|
|
|
ok(gm.gmBlackBoxY == 1, "%2d:expected 1, got %u\n", fmt[i], gm.gmBlackBoxY);
|
2013-09-19 17:57:46 +02:00
|
|
|
}
|
|
|
|
else
|
2013-10-03 17:56:17 +02:00
|
|
|
{
|
2013-09-25 17:47:59 +02:00
|
|
|
ok(ret == GDI_ERROR, "%2d:GetGlyphOutlineW should return GDI_ERROR, got %d\n", fmt[i], ret);
|
2013-10-03 17:56:17 +02:00
|
|
|
memset(&gm2, 0xab, sizeof(gm2));
|
|
|
|
ok(memcmp(&gm, &gm2, sizeof(GLYPHMETRICS)) == 0,
|
|
|
|
"%2d:GLYPHMETRICS shouldn't be touched on error\n", fmt[i]);
|
|
|
|
}
|
2013-09-19 17:57:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-03 10:55:19 +01:00
|
|
|
SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
2011-02-03 12:06:59 +01:00
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(c); ++i)
|
2011-02-03 12:06:59 +01:00
|
|
|
{
|
2013-02-07 14:13:04 +01:00
|
|
|
static const MAT2 rotate_mat = {{0, 0}, {0, -1}, {0, 1}, {0, 0}};
|
2013-10-17 01:55:20 +02:00
|
|
|
TEXTMETRICA tm;
|
2013-02-07 14:13:04 +01:00
|
|
|
|
2011-02-03 12:06:59 +01:00
|
|
|
lf.lfFaceName[0] = '\0';
|
|
|
|
lf.lfCharSet = c[i].cs;
|
|
|
|
lf.lfPitchAndFamily = 0;
|
2013-10-17 01:55:20 +02:00
|
|
|
if (EnumFontFamiliesExA(hdc, &lf, create_font_proc, (LPARAM)&hfont, 0))
|
2011-02-03 12:06:59 +01:00
|
|
|
{
|
|
|
|
skip("TrueType font for charset %u is not installed\n", c[i].cs);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_hfont = SelectObject(hdc, hfont);
|
|
|
|
|
2019-09-16 15:59:50 +02:00
|
|
|
/* expected to ignore superfluous bytes (single-byte character) */
|
2011-02-03 12:06:59 +01:00
|
|
|
ret = GetGlyphOutlineA(hdc, 0x8041, GGO_BITMAP, &gm, 0, NULL, &mat);
|
|
|
|
ret2 = GetGlyphOutlineA(hdc, 0x41, GGO_BITMAP, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret == ret2 && memcmp(&gm, &gm2, sizeof gm) == 0, "%d %d\n", ret, ret2);
|
|
|
|
|
2011-05-04 12:58:13 +02:00
|
|
|
ret = GetGlyphOutlineA(hdc, 0xcc8041, GGO_BITMAP, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret == ret2 && memcmp(&gm, &gm2, sizeof gm) == 0,
|
|
|
|
"Expected to ignore superfluous bytes, got %d %d\n", ret, ret2);
|
|
|
|
|
|
|
|
/* expected to ignore superfluous bytes (double-byte character) */
|
2011-02-03 12:06:59 +01:00
|
|
|
ret = GetGlyphOutlineA(hdc, c[i].a, GGO_BITMAP, &gm, 0, NULL, &mat);
|
2011-05-04 12:58:13 +02:00
|
|
|
ret2 = GetGlyphOutlineA(hdc, c[i].a | 0xdead0000, GGO_BITMAP, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret == ret2 && memcmp(&gm, &gm2, sizeof gm) == 0,
|
|
|
|
"Expected to ignore superfluous bytes, got %d %d\n", ret, ret2);
|
|
|
|
|
|
|
|
/* expected to match wide-char version results */
|
2011-02-03 12:06:59 +01:00
|
|
|
ret2 = GetGlyphOutlineW(hdc, c[i].w, GGO_BITMAP, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret == ret2 && memcmp(&gm, &gm2, sizeof gm) == 0, "%d %d\n", ret, ret2);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
if (EnumFontFamiliesExA(hdc, &lf, create_fixed_pitch_font_proc, (LPARAM)&hfont, 0))
|
2013-02-07 14:13:04 +01:00
|
|
|
{
|
|
|
|
skip("Fixed-pitch TrueType font for charset %u is not available\n", c[i].cs);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
if (c[i].a <= 0xff)
|
|
|
|
{
|
|
|
|
DeleteObject(SelectObject(hdc, old_hfont));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetObjectA(hfont, sizeof lf, &lf);
|
2013-02-07 14:13:04 +01:00
|
|
|
ok(ret > 0, "GetObject error %u\n", GetLastError());
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2013-03-14 12:08:18 +01:00
|
|
|
ok(ret, "GetTextMetrics error %u\n", GetLastError());
|
2013-02-07 14:13:04 +01:00
|
|
|
ret = GetGlyphOutlineA(hdc, c[i].a, GGO_METRICS, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %u\n", GetLastError());
|
2013-03-14 12:08:18 +01:00
|
|
|
ok(gm2.gmCellIncX == tm.tmAveCharWidth * 2 || broken(gm2.gmCellIncX == -lf.lfHeight),
|
2013-02-07 14:13:04 +01:00
|
|
|
"expected %d, got %d (%s:%d)\n",
|
2013-03-14 12:08:18 +01:00
|
|
|
tm.tmAveCharWidth * 2, gm2.gmCellIncX, lf.lfFaceName, lf.lfCharSet);
|
2013-02-07 14:13:04 +01:00
|
|
|
|
|
|
|
ret = GetGlyphOutlineA(hdc, c[i].a, GGO_METRICS, &gm2, 0, NULL, &rotate_mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %u\n", GetLastError());
|
|
|
|
ok(gm2.gmCellIncY == -lf.lfHeight,
|
|
|
|
"expected %d, got %d (%s:%d)\n",
|
|
|
|
-lf.lfHeight, gm2.gmCellIncY, lf.lfFaceName, lf.lfCharSet);
|
|
|
|
|
|
|
|
lf.lfItalic = TRUE;
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-02-07 14:13:04 +01:00
|
|
|
ok(hfont != NULL, "CreateFontIndirect error %u\n", GetLastError());
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2013-03-14 12:08:18 +01:00
|
|
|
ok(ret, "GetTextMetrics error %u\n", GetLastError());
|
2013-02-07 14:13:04 +01:00
|
|
|
ret = GetGlyphOutlineA(hdc, c[i].a, GGO_METRICS, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %u\n", GetLastError());
|
2013-03-14 12:08:18 +01:00
|
|
|
ok(gm2.gmCellIncX == tm.tmAveCharWidth * 2 || broken(gm2.gmCellIncX == -lf.lfHeight),
|
2013-02-07 14:13:04 +01:00
|
|
|
"expected %d, got %d (%s:%d)\n",
|
2013-03-14 12:08:18 +01:00
|
|
|
tm.tmAveCharWidth * 2, gm2.gmCellIncX, lf.lfFaceName, lf.lfCharSet);
|
2013-02-07 14:13:04 +01:00
|
|
|
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfEscapement = lf.lfOrientation = 2700;
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-02-07 14:13:04 +01:00
|
|
|
ok(hfont != NULL, "CreateFontIndirect error %u\n", GetLastError());
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
ret = GetGlyphOutlineA(hdc, c[i].a, GGO_METRICS, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineA error %u\n", GetLastError());
|
|
|
|
ok(gm2.gmCellIncY == -lf.lfHeight,
|
|
|
|
"expected %d, got %d (%s:%d)\n",
|
|
|
|
-lf.lfHeight, gm2.gmCellIncY, lf.lfFaceName, lf.lfCharSet);
|
|
|
|
|
2011-02-03 12:06:59 +01:00
|
|
|
hfont = SelectObject(hdc, old_hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2009-02-03 10:55:19 +01:00
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2009-06-25 09:40:46 +02:00
|
|
|
/* bug #9995: there is a limit to the character width that can be specified */
|
2009-10-07 10:50:32 +02:00
|
|
|
static void test_GetTextMetrics2(const char *fontname, int font_height)
|
2009-06-25 09:40:46 +02:00
|
|
|
{
|
|
|
|
HFONT of, hf;
|
|
|
|
HDC hdc;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
BOOL ret;
|
2020-02-26 16:45:23 +01:00
|
|
|
int ave_width, height, width, ratio;
|
2009-06-25 09:40:46 +02:00
|
|
|
|
|
|
|
if (!is_truetype_font_installed( fontname)) {
|
|
|
|
skip("%s is not installed\n", fontname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok( hdc != NULL, "CreateCompatibleDC failed\n");
|
|
|
|
/* select width = 0 */
|
2009-10-07 10:50:32 +02:00
|
|
|
hf = CreateFontA(font_height, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE,
|
2009-06-25 09:40:46 +02:00
|
|
|
DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_LH_ANGLES,
|
|
|
|
DEFAULT_QUALITY, VARIABLE_PITCH,
|
|
|
|
fontname);
|
2010-05-18 13:53:18 +02:00
|
|
|
ok( hf != NULL, "CreateFontA(%s, %d) failed\n", fontname, font_height);
|
2009-06-25 09:40:46 +02:00
|
|
|
of = SelectObject( hdc, hf);
|
|
|
|
ret = GetTextMetricsA( hdc, &tm);
|
2009-06-26 11:52:35 +02:00
|
|
|
ok(ret, "GetTextMetricsA error %u\n", GetLastError());
|
2009-10-07 10:50:32 +02:00
|
|
|
height = tm.tmHeight;
|
|
|
|
ave_width = tm.tmAveCharWidth;
|
2009-06-25 09:40:46 +02:00
|
|
|
SelectObject( hdc, of);
|
|
|
|
DeleteObject( hf);
|
2009-10-07 10:50:32 +02:00
|
|
|
|
|
|
|
for (width = ave_width * 2; /* nothing*/; width += ave_width)
|
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
hf = CreateFontA(height, width, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE,
|
2009-10-07 10:50:32 +02:00
|
|
|
DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_LH_ANGLES,
|
|
|
|
DEFAULT_QUALITY, VARIABLE_PITCH, fontname);
|
|
|
|
ok(hf != 0, "CreateFont failed\n");
|
|
|
|
of = SelectObject(hdc, hf);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2009-10-07 10:50:32 +02:00
|
|
|
ok(ret, "GetTextMetrics error %u\n", GetLastError());
|
|
|
|
SelectObject(hdc, of);
|
|
|
|
DeleteObject(hf);
|
|
|
|
|
2013-08-28 15:21:10 +02:00
|
|
|
if (match_off_by_1(tm.tmAveCharWidth, ave_width, FALSE) || width / height > 200)
|
2009-10-07 10:50:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-06-25 09:40:46 +02:00
|
|
|
DeleteDC(hdc);
|
2009-10-07 10:50:32 +02:00
|
|
|
|
|
|
|
ratio = width / height;
|
|
|
|
|
|
|
|
ok(ratio >= 90 && ratio <= 110, "expected width/height ratio 90-110, got %d\n", ratio);
|
2009-06-25 09:40:46 +02:00
|
|
|
}
|
|
|
|
|
2018-07-16 09:30:57 +02:00
|
|
|
static void test_GetCharacterPlacement(void)
|
|
|
|
{
|
|
|
|
GCP_RESULTSA result;
|
|
|
|
DWORD size, size2;
|
|
|
|
WCHAR glyphs[20];
|
2020-02-17 16:28:51 +01:00
|
|
|
int pos[20];
|
2018-07-16 09:30:57 +02:00
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok(!!hdc, "CreateCompatibleDC failed\n");
|
|
|
|
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
result.lStructSize = sizeof(result);
|
2020-02-17 16:28:51 +01:00
|
|
|
result.lpCaretPos = pos;
|
2018-07-16 09:30:57 +02:00
|
|
|
result.lpGlyphs = glyphs;
|
|
|
|
result.nGlyphs = 20;
|
|
|
|
|
2020-02-17 16:28:51 +01:00
|
|
|
pos[0] = -1;
|
|
|
|
glyphs[0] = '!';
|
2018-07-16 09:30:57 +02:00
|
|
|
size = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, &result, 0);
|
|
|
|
ok(size, "GetCharacterPlacementA failed!\n");
|
2020-02-17 16:28:51 +01:00
|
|
|
ok(result.nGlyphs == 9, "Unexpected number of glyphs %u\n", result.nGlyphs);
|
|
|
|
ok(glyphs[0] == 'W', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
|
|
|
|
ok(pos[0] == 0, "Unexpected caret position %d\n", pos[0]);
|
|
|
|
|
|
|
|
pos[0] = -1;
|
|
|
|
glyphs[0] = '!';
|
|
|
|
result.nGlyphs = 20;
|
|
|
|
size2 = GetCharacterPlacementA(hdc, "Wine Test", 0, 0, &result, 0);
|
|
|
|
ok(!size2, "Expected GetCharacterPlacementA to fail\n");
|
2020-02-17 16:28:52 +01:00
|
|
|
ok(result.nGlyphs == 20, "Unexpected number of glyphs %u\n", result.nGlyphs);
|
2020-02-17 16:28:51 +01:00
|
|
|
ok(glyphs[0] == '!', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
|
2020-02-17 16:28:52 +01:00
|
|
|
ok(pos[0] == -1, "Unexpected caret position %d\n", pos[0]);
|
2018-07-16 09:30:57 +02:00
|
|
|
|
|
|
|
size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 0, NULL, 0);
|
|
|
|
ok(size2, "GetCharacterPlacementA failed!\n");
|
|
|
|
ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
|
|
|
|
|
|
|
|
size2 = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, NULL, GCP_REORDER);
|
|
|
|
ok(size2, "GetCharacterPlacementA failed!\n");
|
|
|
|
ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
|
|
|
|
|
2020-02-17 16:28:51 +01:00
|
|
|
pos[0] = -1;
|
|
|
|
glyphs[0] = '!';
|
|
|
|
result.nGlyphs = 20;
|
2018-07-16 09:30:57 +02:00
|
|
|
size = GetCharacterPlacementA(hdc, "Wine Test", 9, 1024, &result, GCP_REORDER);
|
|
|
|
ok(size, "GetCharacterPlacementA failed!\n");
|
|
|
|
ok(size == size2, "GetCharacterPlacementA returned different result: %u vs %u\n", size2, size);
|
2020-02-17 16:28:51 +01:00
|
|
|
ok(result.nGlyphs == 9, "Unexpected number of glyphs %u\n", result.nGlyphs);
|
|
|
|
ok(glyphs[0] == 'W', "Unexpected first glyph %s\n", wine_dbgstr_wn(glyphs, 1));
|
|
|
|
todo_wine ok(pos[0] == 0, "Unexpected caret position %d\n", pos[0]);
|
2018-07-16 09:30:57 +02:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:02:10 +01:00
|
|
|
static void test_CreateFontIndirect(void)
|
2009-11-13 23:05:20 +01:00
|
|
|
{
|
|
|
|
LOGFONTA lf, getobj_lf;
|
2009-11-17 17:43:54 +01:00
|
|
|
int ret, i;
|
2009-11-13 23:05:20 +01:00
|
|
|
HFONT hfont;
|
2009-12-12 17:32:19 +01:00
|
|
|
char TestName[][16] = {"Arial", "Arial Bold", "Arial Italic", "Arial Baltic"};
|
2009-11-13 23:05:20 +01:00
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfWidth = 16;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(TestName); i++)
|
2009-11-17 17:43:54 +01:00
|
|
|
{
|
|
|
|
lstrcpyA(lf.lfFaceName, TestName[i]);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA failed\n");
|
2010-05-22 10:35:07 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetObjectA(hfont, sizeof(getobj_lf), &getobj_lf);
|
2010-05-22 10:35:07 +02:00
|
|
|
ok(ret, "GetObject failed: %d\n", GetLastError());
|
2009-11-17 17:43:54 +01:00
|
|
|
ok(lf.lfItalic == getobj_lf.lfItalic, "lfItalic: expect %02x got %02x\n", lf.lfItalic, getobj_lf.lfItalic);
|
|
|
|
ok(lf.lfWeight == getobj_lf.lfWeight ||
|
|
|
|
broken((SHORT)lf.lfWeight == getobj_lf.lfWeight), /* win9x */
|
|
|
|
"lfWeight: expect %08x got %08x\n", lf.lfWeight, getobj_lf.lfWeight);
|
|
|
|
ok(!lstrcmpA(lf.lfFaceName, getobj_lf.lfFaceName) ||
|
|
|
|
broken(!memcmp(lf.lfFaceName, getobj_lf.lfFaceName, LF_FACESIZE-1)), /* win9x doesn't ensure '\0' termination */
|
|
|
|
"font names don't match: %s != %s\n", lf.lfFaceName, getobj_lf.lfFaceName);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
2009-11-13 23:05:20 +01:00
|
|
|
}
|
|
|
|
|
2010-06-11 17:39:40 +02:00
|
|
|
static void test_CreateFontIndirectEx(void)
|
|
|
|
{
|
|
|
|
ENUMLOGFONTEXDVA lfex;
|
|
|
|
HFONT hfont;
|
|
|
|
|
|
|
|
if (!pCreateFontIndirectExA)
|
|
|
|
{
|
|
|
|
win_skip("CreateFontIndirectExA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = pCreateFontIndirectExA(NULL);
|
|
|
|
ok(hfont == NULL, "got %p\n", hfont);
|
|
|
|
ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError());
|
|
|
|
|
|
|
|
memset(&lfex, 0, sizeof(lfex));
|
|
|
|
lstrcpyA(lfex.elfEnumLogfontEx.elfLogFont.lfFaceName, "Arial");
|
|
|
|
hfont = pCreateFontIndirectExA(&lfex);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectEx failed\n");
|
|
|
|
if (hfont)
|
|
|
|
check_font("Arial", &lfex.elfEnumLogfontEx.elfLogFont, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
static void test_realization_info(const char *name, DWORD size, BOOL is_memory_resource)
|
|
|
|
{
|
|
|
|
struct font_realization_info info;
|
|
|
|
struct file_info file_info;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
SIZE_T needed;
|
|
|
|
LOGFONTA lf;
|
|
|
|
BYTE *data;
|
|
|
|
BOOL ret;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
if (!pGetFontRealizationInfo)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
strcpy(lf.lfFaceName, name);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "Failed to create a font, %u.\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "Failed to select font.\n");
|
|
|
|
|
|
|
|
memset(&info, 0xcc, sizeof(info));
|
|
|
|
info.size = sizeof(info);
|
|
|
|
ret = pGetFontRealizationInfo(hdc, (DWORD *)&info);
|
|
|
|
ok(ret != 0, "Unexpected return value %d.\n", ret);
|
|
|
|
|
|
|
|
ok((info.flags & 0xf) == 0x3, "Unexpected flags %#x.\n", info.flags);
|
|
|
|
ok(info.cache_num != 0, "Unexpected cache num %u.\n", info.cache_num);
|
|
|
|
ok(info.instance_id != 0, "Unexpected instance id %u.\n", info.instance_id);
|
|
|
|
ok(info.simulations == 0, "Unexpected simulations %#x.\n", info.simulations);
|
|
|
|
ok(info.face_index == 0, "Unexpected face index %u.\n", info.face_index);
|
|
|
|
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, NULL, 0, NULL);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected return value %d, error %d.\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
|
|
|
|
needed = 0;
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, NULL, 0, &needed);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected return value %d, error %d.\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, &file_info, 0, NULL);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected return value %d, error %d.\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, &file_info, needed - 1, NULL);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected return value %d, error %d.\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, &file_info, needed, NULL);
|
|
|
|
ok(ret != 0, "Failed to get font file info, ret %d gle %d.\n", ret, GetLastError());
|
|
|
|
|
|
|
|
memset(&file_info, 0xcc, sizeof(file_info));
|
|
|
|
ret = pGetFontFileInfo(info.instance_id, 0, &file_info, sizeof(file_info), NULL);
|
|
|
|
ok(ret != 0, "Failed to get font file info, ret %d gle %d.\n", ret, GetLastError());
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(is_memory_resource ? file_info.size.QuadPart == size : file_info.size.QuadPart > 0, "Unexpected file size.\n");
|
|
|
|
ok(is_memory_resource ? !file_info.path[0] : file_info.path[0], "Unexpected file path %s.\n",
|
|
|
|
wine_dbgstr_w(file_info.path));
|
|
|
|
}
|
|
|
|
|
|
|
|
size = file_info.size.LowPart;
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, size + 16);
|
|
|
|
|
|
|
|
memset(data, 0xcc, size);
|
|
|
|
ret = pGetFontFileData(info.instance_id, 0, 0, data, size);
|
|
|
|
ok(ret != 0, "Failed to get font file data, %d\n", GetLastError());
|
|
|
|
ok(*(DWORD *)data == 0x00000100, "Unexpected sfnt header version %#x.\n", *(DWORD *)data);
|
|
|
|
ok(*(WORD *)(data + 4) == 0x0e00, "Unexpected table count %#x.\n", *(WORD *)(data + 4));
|
|
|
|
|
|
|
|
/* Larger than font data size. */
|
|
|
|
memset(data, 0xcc, size);
|
|
|
|
ret = pGetFontFileData(info.instance_id, 0, 0, data, size + 16);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected return value %d, error %d\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
ok(*(DWORD *)data == 0xcccccccc, "Unexpected buffer contents %#x.\n", *(DWORD *)data);
|
|
|
|
|
|
|
|
/* With offset. */
|
|
|
|
memset(data, 0xcc, size);
|
|
|
|
ret = pGetFontFileData(info.instance_id, 0, 16, data, size - 16);
|
|
|
|
ok(ret != 0, "Failed to get font file data, %d\n", GetLastError());
|
|
|
|
ok(*(DWORD *)data == 0x1000000, "Unexpected buffer contents %#x.\n", *(DWORD *)data);
|
|
|
|
|
|
|
|
memset(data, 0xcc, size);
|
|
|
|
ret = pGetFontFileData(info.instance_id, 0, 16, data, size);
|
|
|
|
ok(ret == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected return value %d, error %d\n",
|
|
|
|
ret, GetLastError());
|
|
|
|
ok(*(DWORD *)data == 0xcccccccc, "Unexpected buffer contents %#x.\n", *(DWORD *)data);
|
|
|
|
|
|
|
|
/* Zero buffer size. */
|
|
|
|
memset(data, 0xcc, size);
|
|
|
|
ret = pGetFontFileData(info.instance_id, 0, 16, data, 0);
|
2018-11-21 13:54:03 +01:00
|
|
|
todo_wine
|
2018-11-21 13:54:01 +01:00
|
|
|
ok(ret == 0 && GetLastError() == ERROR_NOACCESS, "Unexpected return value %d, error %d\n", ret, GetLastError());
|
|
|
|
ok(*(DWORD *)data == 0xcccccccc, "Unexpected buffer contents %#x.\n", *(DWORD *)data);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
2018-11-21 13:54:03 +01:00
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2010-08-02 08:35:04 +02:00
|
|
|
static void test_AddFontMemResource(void)
|
|
|
|
{
|
2018-11-21 13:54:01 +01:00
|
|
|
char ttf_name[MAX_PATH];
|
2010-08-02 08:35:04 +02:00
|
|
|
void *font;
|
|
|
|
DWORD font_size, num_fonts;
|
|
|
|
HANDLE ret;
|
2011-01-02 18:50:17 +01:00
|
|
|
BOOL bRet;
|
2010-08-02 08:35:04 +02:00
|
|
|
|
|
|
|
if (!pAddFontMemResourceEx || !pRemoveFontMemResourceEx)
|
|
|
|
{
|
|
|
|
win_skip("AddFontMemResourceEx is not available on this platform\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(NULL, 0, NULL, NULL);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(NULL, 10, NULL, NULL);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(NULL, 0, NULL, &num_fonts);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(NULL, 10, NULL, &num_fonts);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2018-11-21 13:54:01 +01:00
|
|
|
/* Now with scalable font */
|
|
|
|
bRet = write_ttf_file("wine_test.ttf", ttf_name);
|
|
|
|
ok(bRet, "Failed to create test font file.\n");
|
|
|
|
|
|
|
|
font = load_font(ttf_name, &font_size);
|
|
|
|
ok(font != NULL, "Failed to map font file.\n");
|
|
|
|
|
|
|
|
bRet = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!bRet, "Font wine_test should not be enumerated.\n");
|
|
|
|
|
|
|
|
num_fonts = 0;
|
|
|
|
ret = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
|
|
|
|
ok(ret != 0, "Failed to add resource, %d.\n", GetLastError());
|
|
|
|
ok(num_fonts == 1, "Unexpected number of fonts %u.\n", num_fonts);
|
|
|
|
|
|
|
|
bRet = is_truetype_font_installed("wine_test");
|
|
|
|
todo_wine
|
|
|
|
ok(!bRet, "Font wine_test should not be enumerated.\n");
|
|
|
|
|
|
|
|
test_realization_info("wine_test", font_size, TRUE);
|
|
|
|
|
|
|
|
bRet = pRemoveFontMemResourceEx(ret);
|
|
|
|
ok(bRet, "RemoveFontMemResourceEx error %d\n", GetLastError());
|
|
|
|
|
|
|
|
free_font(font);
|
|
|
|
|
|
|
|
bRet = DeleteFileA(ttf_name);
|
|
|
|
ok(bRet, "Failed to delete font file, %d.\n", GetLastError());
|
|
|
|
|
|
|
|
font = load_font("sserife.fon", &font_size);
|
|
|
|
if (!font)
|
|
|
|
{
|
|
|
|
skip("Unable to locate and load font sserife.fon\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(font, 0, NULL, NULL);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(font, 10, NULL, NULL);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
num_fonts = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(font, 0, NULL, &num_fonts);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
|
|
|
ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
|
2010-08-03 14:07:59 +02:00
|
|
|
|
2010-11-10 13:38:55 +01:00
|
|
|
if (0) /* hangs under windows 2000 */
|
|
|
|
{
|
2010-08-03 14:07:59 +02:00
|
|
|
num_fonts = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(font, 10, NULL, &num_fonts);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
|
|
|
ok(GetLastError() == 0xdeadbeef,
|
|
|
|
"Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
|
|
|
GetLastError());
|
|
|
|
ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
|
|
|
|
}
|
|
|
|
|
2010-08-02 08:35:04 +02:00
|
|
|
num_fonts = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
|
|
|
|
ok(ret != 0, "AddFontMemResourceEx error %d\n", GetLastError());
|
|
|
|
ok(num_fonts != 0xdeadbeef, "number of loaded fonts should not be 0xdeadbeef\n");
|
|
|
|
ok(num_fonts != 0, "number of loaded fonts should not be 0\n");
|
|
|
|
|
|
|
|
free_font(font);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2011-01-02 18:50:17 +01:00
|
|
|
bRet = pRemoveFontMemResourceEx(ret);
|
|
|
|
ok(bRet, "RemoveFontMemResourceEx error %d\n", GetLastError());
|
2010-08-02 08:35:04 +02:00
|
|
|
|
|
|
|
/* test invalid pointer to number of loaded fonts */
|
|
|
|
font = load_font("sserife.fon", &font_size);
|
|
|
|
ok(font != NULL, "Unable to locate and load font sserife.fon\n");
|
|
|
|
|
2010-08-03 14:07:59 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2010-08-02 08:35:04 +02:00
|
|
|
ret = pAddFontMemResourceEx(font, font_size, NULL, (void *)0xdeadbeef);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
2010-08-03 14:07:59 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef,
|
|
|
|
"Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-02 08:35:04 +02:00
|
|
|
|
2010-08-03 14:07:59 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2010-08-02 08:35:04 +02:00
|
|
|
ret = pAddFontMemResourceEx(font, font_size, NULL, NULL);
|
|
|
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
2010-08-03 14:07:59 +02:00
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
|
|
|
GetLastError());
|
2010-08-02 08:35:04 +02:00
|
|
|
|
|
|
|
free_font(font);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_fonts_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
|
2011-02-14 10:55:03 +01:00
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA *lf;
|
2011-02-14 10:55:03 +01:00
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
|
|
|
ok(ntm->tmWeight == elf->lfWeight, "expected %d got %d\n", ntm->tmWeight, elf->lfWeight);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
lf = (LOGFONTA *)lparam;
|
2011-02-14 10:55:03 +01:00
|
|
|
*lf = *elf;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_all_fonts_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
|
2011-02-14 10:55:03 +01:00
|
|
|
{
|
|
|
|
int ret;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA *lf;
|
2011-02-14 10:55:03 +01:00
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
lf = (LOGFONTA *)lparam;
|
2011-02-14 10:55:03 +01:00
|
|
|
ret = strcmp(lf->lfFaceName, elf->lfFaceName);
|
|
|
|
if(ret == 0)
|
|
|
|
{
|
|
|
|
ok(ntm->tmWeight == elf->lfWeight, "expected %d got %d\n", ntm->tmWeight, elf->lfWeight);
|
|
|
|
*lf = *elf;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK enum_with_magic_retval_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam)
|
2012-03-14 15:15:13 +01:00
|
|
|
{
|
|
|
|
return lparam;
|
|
|
|
}
|
|
|
|
|
2011-02-14 10:55:03 +01:00
|
|
|
static void test_EnumFonts(void)
|
|
|
|
{
|
|
|
|
int ret;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2011-02-14 10:55:03 +01:00
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
if (!is_truetype_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Windows uses localized font face names, so Arial Bold won't be found */
|
|
|
|
if (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH)
|
|
|
|
{
|
|
|
|
skip("User locale is not English, skipping the test\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
2012-03-14 15:15:13 +01:00
|
|
|
/* check that the enumproc's retval is returned */
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, NULL, enum_with_magic_retval_proc, 0xcafe);
|
2012-03-14 15:15:13 +01:00
|
|
|
ok(ret == 0xcafe, "got %08x\n", ret);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, "Arial", enum_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(!ret, "font Arial is not enumerated\n");
|
|
|
|
ret = strcmp(lf.lfFaceName, "Arial");
|
|
|
|
ok(!ret, "expected Arial got %s\n", lf.lfFaceName);
|
|
|
|
ok(lf.lfWeight == FW_NORMAL, "expected FW_NORMAL got %d\n", lf.lfWeight);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
ret = EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(!ret, "font Arial is not enumerated\n");
|
|
|
|
ret = strcmp(lf.lfFaceName, "Arial");
|
|
|
|
ok(!ret, "expected Arial got %s\n", lf.lfFaceName);
|
|
|
|
ok(lf.lfWeight == FW_NORMAL, "expected FW_NORMAL got %d\n", lf.lfWeight);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, "Arial Bold", enum_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(!ret, "font Arial Bold is not enumerated\n");
|
|
|
|
ret = strcmp(lf.lfFaceName, "Arial");
|
|
|
|
ok(!ret, "expected Arial got %s\n", lf.lfFaceName);
|
|
|
|
ok(lf.lfWeight == FW_BOLD, "expected FW_BOLD got %d\n", lf.lfWeight);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, "Arial Bold");
|
|
|
|
ret = EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(ret, "font Arial Bold should not be enumerated\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, "Arial Bold Italic", enum_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(!ret, "font Arial Bold Italic is not enumerated\n");
|
|
|
|
ret = strcmp(lf.lfFaceName, "Arial");
|
|
|
|
ok(!ret, "expected Arial got %s\n", lf.lfFaceName);
|
|
|
|
ok(lf.lfWeight == FW_BOLD, "expected FW_BOLD got %d\n", lf.lfWeight);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, "Arial Bold Italic");
|
|
|
|
ret = EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(ret, "font Arial Bold Italic should not be enumerated\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = EnumFontFamiliesA(hdc, "Arial Italic Bold", enum_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(ret, "font Arial Italic Bold should not be enumerated\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, "Arial Italic Bold");
|
|
|
|
ret = EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf);
|
2011-02-14 10:55:03 +01:00
|
|
|
ok(ret, "font Arial Italic Bold should not be enumerated\n");
|
|
|
|
|
2015-07-17 11:23:14 +02:00
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT CALLBACK enum_ms_shell_dlg_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
|
|
|
|
|
|
|
|
if (0) /* Disabled to limit console spam */
|
|
|
|
trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
|
|
|
|
lf->lfFaceName, lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
if (strcmp(lf->lfFaceName, "MS Shell Dlg") != 0) return 1;
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efnd->total >= efnd->size)
|
|
|
|
{
|
|
|
|
efnd->size = max( (efnd->total + 1) * 2, 256 );
|
|
|
|
efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
|
|
|
|
if (!efnd->elf) return 0;
|
|
|
|
}
|
2015-07-17 11:23:14 +02:00
|
|
|
efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT CALLBACK enum_ms_shell_dlg2_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
struct enum_fullname_data *efnd = (struct enum_fullname_data *)lParam;
|
|
|
|
|
|
|
|
if (0) /* Disabled to limit console spam */
|
|
|
|
trace("enumed font \"%s\", charset %d, height %d, weight %d, italic %d\n",
|
|
|
|
lf->lfFaceName, lf->lfCharSet, lf->lfHeight, lf->lfWeight, lf->lfItalic);
|
|
|
|
|
|
|
|
if (type != TRUETYPE_FONTTYPE) return 1;
|
|
|
|
if (strcmp(lf->lfFaceName, "MS Shell Dlg 2") != 0) return 1;
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
if (efnd->total >= efnd->size)
|
|
|
|
{
|
|
|
|
efnd->size = max( (efnd->total + 1) * 2, 256 );
|
|
|
|
efnd->elf = heap_realloc( efnd->elf, efnd->size * sizeof(*efnd->elf) );
|
|
|
|
if (!efnd->elf) return 0;
|
|
|
|
}
|
2015-07-17 11:23:14 +02:00
|
|
|
efnd->elf[efnd->total++] = *(ENUMLOGFONTA *)lf;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_EnumFonts_subst(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
struct enum_fullname_data efnd;
|
|
|
|
|
|
|
|
ret = is_font_installed("MS Shell Dlg");
|
|
|
|
ok(ret, "MS Shell Dlg should be enumerated\n");
|
|
|
|
ret = is_truetype_font_installed("MS Shell Dlg");
|
|
|
|
ok(ret, "MS Shell Dlg should be enumerated as a TrueType font\n");
|
|
|
|
|
|
|
|
ret = is_font_installed("MS Shell Dlg 2");
|
|
|
|
ok(ret, "MS Shell Dlg 2 should be enumerated\n");
|
|
|
|
ret = is_truetype_font_installed("MS Shell Dlg 2");
|
|
|
|
ok(ret, "MS Shell Dlg 2 should be enumerated as a TrueType font\n");
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
|
|
|
ret = EnumFontFamiliesExA(hdc, NULL, enum_ms_shell_dlg_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(ret, "MS Shell Dlg should not be enumerated\n");
|
|
|
|
ok(!efnd.total, "MS Shell Dlg should not be enumerated\n");
|
|
|
|
|
2014-05-12 06:05:12 +02:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
efnd.total = 0;
|
2014-05-12 06:05:12 +02:00
|
|
|
strcpy(lf.lfFaceName, "MS Shell Dlg");
|
2015-07-17 11:23:14 +02:00
|
|
|
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(!ret, "MS Shell Dlg should be enumerated\n");
|
|
|
|
ok(efnd.total > 0, "MS Shell Dlg should be enumerated\n");
|
2017-04-05 10:35:07 +02:00
|
|
|
if (efnd.total)
|
|
|
|
{
|
|
|
|
ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg");
|
|
|
|
ok(!ret, "expected MS Shell Dlg, got %s\n", efnd.elf[0].elfLogFont.lfFaceName);
|
|
|
|
ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg");
|
|
|
|
ok(ret, "did not expect MS Shell Dlg\n");
|
|
|
|
}
|
2014-05-12 06:05:12 +02:00
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
efnd.total = 0;
|
2015-07-17 11:23:14 +02:00
|
|
|
ret = EnumFontFamiliesExA(hdc, NULL, enum_ms_shell_dlg2_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(ret, "MS Shell Dlg 2 should not be enumerated\n");
|
|
|
|
ok(!efnd.total, "MS Shell Dlg 2 should not be enumerated\n");
|
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
efnd.total = 0;
|
2014-05-12 06:05:12 +02:00
|
|
|
strcpy(lf.lfFaceName, "MS Shell Dlg 2");
|
2015-07-17 11:23:14 +02:00
|
|
|
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg2_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(!ret, "MS Shell Dlg 2 should be enumerated\n");
|
|
|
|
ok(efnd.total > 0, "MS Shell Dlg 2 should be enumerated\n");
|
2017-04-05 10:35:07 +02:00
|
|
|
if (efnd.total)
|
|
|
|
{
|
|
|
|
ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg 2");
|
|
|
|
ok(!ret, "expected MS Shell Dlg 2, got %s\n", efnd.elf[0].elfLogFont.lfFaceName);
|
|
|
|
ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg 2");
|
|
|
|
ok(ret, "did not expect MS Shell Dlg 2\n");
|
|
|
|
}
|
2014-05-12 06:05:12 +02:00
|
|
|
|
2016-04-14 12:12:35 +02:00
|
|
|
heap_free(efnd.elf);
|
2011-02-14 10:55:03 +01:00
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK is_font_installed_fullname_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm, DWORD type, LPARAM lParam)
|
2011-08-23 22:11:58 +02:00
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
const ENUMLOGFONTA *elf = (const ENUMLOGFONTA *)lf;
|
2011-08-23 22:11:58 +02:00
|
|
|
const char *fullname = (const char *)lParam;
|
|
|
|
|
|
|
|
if (!strcmp((const char *)elf->elfFullName, fullname)) return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_font_installed_fullname(const char *family, const char *fullname)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if(!EnumFontFamiliesA(hdc, family, is_font_installed_fullname_proc, (LPARAM)fullname))
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-10 22:38:05 +02:00
|
|
|
static void test_fullname(void)
|
|
|
|
{
|
2011-08-23 22:11:59 +02:00
|
|
|
static const char *TestName[] = {"Lucida Sans Demibold Roman", "Lucida Sans Italic", "Lucida Sans Regular"};
|
2012-09-07 12:39:51 +02:00
|
|
|
WCHAR bufW[LF_FULLFACESIZE];
|
|
|
|
char bufA[LF_FULLFACESIZE];
|
2011-05-10 22:38:05 +02:00
|
|
|
HFONT hfont, of;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
int i;
|
2012-09-07 12:39:51 +02:00
|
|
|
DWORD ret;
|
2011-05-10 22:38:05 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok(hdc != NULL, "CreateCompatibleDC failed\n");
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfWidth = 16;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(TestName); i++)
|
2011-05-10 22:38:05 +02:00
|
|
|
{
|
2011-08-23 22:11:58 +02:00
|
|
|
if (!is_font_installed_fullname("Lucida Sans", TestName[i]))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", TestName[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-05-10 22:38:05 +02:00
|
|
|
lstrcpyA(lf.lfFaceName, TestName[i]);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA failed\n");
|
|
|
|
|
|
|
|
of = SelectObject(hdc, hfont);
|
2012-09-07 12:39:51 +02:00
|
|
|
bufW[0] = 0;
|
|
|
|
bufA[0] = 0;
|
2012-09-07 12:41:02 +02:00
|
|
|
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, sizeof(bufW), TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
2012-09-07 12:39:51 +02:00
|
|
|
ok(ret, "face full name could not be read\n");
|
2012-09-07 20:34:33 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, sizeof(bufA), NULL, FALSE);
|
2012-09-07 12:39:51 +02:00
|
|
|
ok(!lstrcmpA(bufA, TestName[i]), "font full names don't match: %s != %s\n", TestName[i], bufA);
|
|
|
|
SelectObject(hdc, of);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2012-09-12 15:53:38 +02:00
|
|
|
static WCHAR *prepend_at(WCHAR *family)
|
|
|
|
{
|
|
|
|
if (!family)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memmove(family + 1, family, (lstrlenW(family) + 1) * sizeof(WCHAR));
|
|
|
|
family[0] = '@';
|
|
|
|
return family;
|
|
|
|
}
|
|
|
|
|
2012-09-07 12:39:51 +02:00
|
|
|
static void test_fullname2_helper(const char *Family)
|
|
|
|
{
|
|
|
|
char *FamilyName, *FaceName, *StyleName, *otmStr;
|
|
|
|
struct enum_fullname_data efnd;
|
|
|
|
WCHAR *bufW;
|
|
|
|
char *bufA;
|
|
|
|
HFONT hfont, of;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
int i;
|
|
|
|
DWORD otm_size, ret, buf_size;
|
|
|
|
OUTLINETEXTMETRICA *otm;
|
2012-09-12 15:48:45 +02:00
|
|
|
BOOL want_vertical, get_vertical;
|
|
|
|
want_vertical = ( Family[0] == '@' );
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok(hdc != NULL, "CreateCompatibleDC failed\n");
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfWidth = 16;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
2013-10-17 01:55:20 +02:00
|
|
|
strcpy(lf.lfFaceName, Family);
|
2016-04-14 12:12:35 +02:00
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
2012-09-07 12:39:51 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &lf, enum_fullname_data_proc, (LPARAM)&efnd, 0);
|
|
|
|
if (efnd.total == 0)
|
|
|
|
skip("%s is not installed\n", lf.lfFaceName);
|
|
|
|
|
|
|
|
for (i = 0; i < efnd.total; i++)
|
|
|
|
{
|
|
|
|
FamilyName = (char *)efnd.elf[i].elfLogFont.lfFaceName;
|
|
|
|
FaceName = (char *)efnd.elf[i].elfFullName;
|
|
|
|
StyleName = (char *)efnd.elf[i].elfStyle;
|
|
|
|
|
2012-09-12 15:48:45 +02:00
|
|
|
get_vertical = ( FamilyName[0] == '@' );
|
2012-09-12 15:51:24 +02:00
|
|
|
ok(get_vertical == want_vertical, "Vertical flags don't match: %s %s\n", Family, FamilyName);
|
2012-09-12 15:48:45 +02:00
|
|
|
|
2012-09-07 12:39:51 +02:00
|
|
|
lstrcpyA(lf.lfFaceName, FaceName);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA failed\n");
|
|
|
|
|
|
|
|
of = SelectObject(hdc, hfont);
|
|
|
|
buf_size = GetFontData(hdc, MS_NAME_TAG, 0, NULL, 0);
|
|
|
|
ok(buf_size != GDI_ERROR, "no name table found\n");
|
|
|
|
if (buf_size == GDI_ERROR) continue;
|
|
|
|
|
|
|
|
bufW = HeapAlloc(GetProcessHeap(), 0, buf_size);
|
|
|
|
bufA = HeapAlloc(GetProcessHeap(), 0, buf_size);
|
|
|
|
|
|
|
|
otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
|
|
|
|
otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
|
|
|
|
memset(otm, 0, otm_size);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm_size, otm);
|
2012-09-07 12:39:51 +02:00
|
|
|
ok(ret != 0, "GetOutlineTextMetrics fails!\n");
|
|
|
|
if (ret == 0) continue;
|
|
|
|
|
|
|
|
bufW[0] = 0;
|
|
|
|
bufA[0] = 0;
|
2012-09-07 12:41:02 +02:00
|
|
|
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_FAMILY, bufW, buf_size, GetSystemDefaultLangID());
|
2014-06-13 10:12:28 +02:00
|
|
|
if (!ret) ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_FAMILY, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
|
|
|
ok(ret, "%s: FAMILY (family name) could not be read\n", FamilyName);
|
2012-09-12 15:53:38 +02:00
|
|
|
if (want_vertical) bufW = prepend_at(bufW);
|
2012-09-07 12:39:51 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
|
|
|
|
ok(!lstrcmpA(FamilyName, bufA), "font family names don't match: returned %s, expect %s\n", FamilyName, bufA);
|
|
|
|
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFamilyName;
|
2012-09-12 15:55:15 +02:00
|
|
|
ok(!lstrcmpA(FamilyName, otmStr), "FamilyName %s doesn't match otmpFamilyName %s\n", FamilyName, otmStr);
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
bufW[0] = 0;
|
|
|
|
bufA[0] = 0;
|
2012-09-07 12:41:02 +02:00
|
|
|
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, buf_size, GetSystemDefaultLangID());
|
2014-06-13 10:12:28 +02:00
|
|
|
if (!ret) ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
2012-09-07 12:39:51 +02:00
|
|
|
ok(ret, "FULL_NAME (face name) could not be read\n");
|
2012-09-12 15:53:38 +02:00
|
|
|
if (want_vertical) bufW = prepend_at(bufW);
|
2012-09-07 12:39:51 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
|
2014-06-13 10:12:28 +02:00
|
|
|
ok(!lstrcmpA(FaceName, bufA), "%s: font face names don't match: returned %s, expect %s\n", FamilyName, FaceName, bufA);
|
2012-09-07 12:39:51 +02:00
|
|
|
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFaceName;
|
2014-06-13 10:12:28 +02:00
|
|
|
ok(!lstrcmpA(FaceName, otmStr), "%s: FaceName %s doesn't match otmpFaceName %s\n", FamilyName, FaceName, otmStr);
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
bufW[0] = 0;
|
|
|
|
bufA[0] = 0;
|
2012-09-10 19:05:57 +02:00
|
|
|
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_SUBFAMILY, bufW, buf_size, GetSystemDefaultLangID());
|
2014-06-13 10:12:28 +02:00
|
|
|
if (!ret) ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_SUBFAMILY, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
|
|
|
ok(ret, "%s: SUBFAMILY (style name) could not be read\n", FamilyName);
|
2012-09-07 12:39:51 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
|
2014-06-13 10:12:28 +02:00
|
|
|
ok(!lstrcmpA(StyleName, bufA), "%s: style names don't match: returned %s, expect %s\n", FamilyName, StyleName, bufA);
|
2012-09-07 12:39:51 +02:00
|
|
|
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpStyleName;
|
2014-06-13 10:12:28 +02:00
|
|
|
ok(!lstrcmpA(StyleName, otmStr), "%s: StyleName %s doesn't match otmpStyleName %s\n", FamilyName, StyleName, otmStr);
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
bufW[0] = 0;
|
|
|
|
bufA[0] = 0;
|
2012-09-12 15:42:04 +02:00
|
|
|
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_UNIQUE_ID, bufW, buf_size, GetSystemDefaultLangID());
|
2014-06-13 10:12:28 +02:00
|
|
|
if (!ret) ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_UNIQUE_ID, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
|
|
|
ok(ret, "%s: UNIQUE_ID (full name) could not be read\n", FamilyName);
|
2012-09-07 12:39:51 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
|
|
|
|
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFullName;
|
2014-06-13 10:12:28 +02:00
|
|
|
ok(!lstrcmpA(otmStr, bufA), "%s: UNIQUE ID (full name) doesn't match: returned %s, expect %s\n", FamilyName, otmStr, bufA);
|
2012-09-07 12:39:51 +02:00
|
|
|
|
2011-05-10 22:38:05 +02:00
|
|
|
SelectObject(hdc, of);
|
|
|
|
DeleteObject(hfont);
|
2012-09-07 12:39:51 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, otm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufA);
|
2011-05-10 22:38:05 +02:00
|
|
|
}
|
2016-04-14 12:12:35 +02:00
|
|
|
heap_free(efnd.elf);
|
2011-05-10 22:38:05 +02:00
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2012-09-07 12:39:51 +02:00
|
|
|
static void test_fullname2(void)
|
|
|
|
{
|
2012-09-12 15:48:45 +02:00
|
|
|
test_fullname2_helper("Arial");
|
|
|
|
test_fullname2_helper("DejaVu Sans");
|
2012-09-07 12:39:51 +02:00
|
|
|
test_fullname2_helper("Lucida Sans");
|
2012-09-12 15:48:45 +02:00
|
|
|
test_fullname2_helper("Tahoma");
|
2012-09-10 19:06:19 +02:00
|
|
|
test_fullname2_helper("Webdings");
|
|
|
|
test_fullname2_helper("Wingdings");
|
2012-09-12 15:48:45 +02:00
|
|
|
test_fullname2_helper("SimSun");
|
|
|
|
test_fullname2_helper("NSimSun");
|
|
|
|
test_fullname2_helper("MingLiu");
|
|
|
|
test_fullname2_helper("PMingLiu");
|
|
|
|
test_fullname2_helper("WenQuanYi Micro Hei");
|
|
|
|
test_fullname2_helper("MS UI Gothic");
|
|
|
|
test_fullname2_helper("Ume UI Gothic");
|
|
|
|
test_fullname2_helper("MS Gothic");
|
|
|
|
test_fullname2_helper("Ume Gothic");
|
|
|
|
test_fullname2_helper("MS PGothic");
|
|
|
|
test_fullname2_helper("Ume P Gothic");
|
|
|
|
test_fullname2_helper("Gulim");
|
|
|
|
test_fullname2_helper("Batang");
|
|
|
|
test_fullname2_helper("UnBatang");
|
|
|
|
test_fullname2_helper("UnDotum");
|
2012-09-12 15:53:38 +02:00
|
|
|
test_fullname2_helper("@SimSun");
|
|
|
|
test_fullname2_helper("@NSimSun");
|
|
|
|
test_fullname2_helper("@MingLiu");
|
|
|
|
test_fullname2_helper("@PMingLiu");
|
|
|
|
test_fullname2_helper("@WenQuanYi Micro Hei");
|
|
|
|
test_fullname2_helper("@MS UI Gothic");
|
|
|
|
test_fullname2_helper("@Ume UI Gothic");
|
|
|
|
test_fullname2_helper("@MS Gothic");
|
|
|
|
test_fullname2_helper("@Ume Gothic");
|
|
|
|
test_fullname2_helper("@MS PGothic");
|
|
|
|
test_fullname2_helper("@Ume P Gothic");
|
|
|
|
test_fullname2_helper("@Gulim");
|
|
|
|
test_fullname2_helper("@Batang");
|
|
|
|
test_fullname2_helper("@UnBatang");
|
|
|
|
test_fullname2_helper("@UnDotum");
|
2012-09-12 15:48:45 +02:00
|
|
|
|
2012-09-07 12:39:51 +02:00
|
|
|
}
|
|
|
|
|
2012-11-13 16:51:51 +01:00
|
|
|
static void test_GetGlyphOutline_empty_contour(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
TTPOLYGONHEADER *header;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
char buf[1024];
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lstrcpyA(lf.lfFaceName, "wine_test");
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0xa8, GGO_NATIVE, &gm, 0, NULL, &mat);
|
|
|
|
ok(ret == 228, "GetGlyphOutline returned %d, expected 228\n", ret);
|
|
|
|
|
|
|
|
header = (TTPOLYGONHEADER*)buf;
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0xa8, GGO_NATIVE, &gm, sizeof(buf), buf, &mat);
|
|
|
|
ok(ret == 228, "GetGlyphOutline returned %d, expected 228\n", ret);
|
|
|
|
ok(header->cb == 36, "header->cb = %d, expected 36\n", header->cb);
|
|
|
|
ok(header->dwType == TT_POLYGON_TYPE, "header->dwType = %d, expected TT_POLYGON_TYPE\n", header->dwType);
|
|
|
|
header = (TTPOLYGONHEADER*)((char*)header+header->cb);
|
|
|
|
ok(header->cb == 96, "header->cb = %d, expected 96\n", header->cb);
|
|
|
|
header = (TTPOLYGONHEADER*)((char*)header+header->cb);
|
|
|
|
ok(header->cb == 96, "header->cb = %d, expected 96\n", header->cb);
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2013-04-30 09:20:57 +02:00
|
|
|
static void test_GetGlyphOutline_metric_clipping(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
TEXTMETRICA tm;
|
2014-05-23 12:33:54 +02:00
|
|
|
TEXTMETRICW tmW;
|
2013-04-30 09:20:57 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lstrcpyA(lf.lfFaceName, "wine_test");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2013-04-30 09:20:57 +02:00
|
|
|
ok(ret, "GetTextMetrics error %u\n", GetLastError());
|
|
|
|
|
|
|
|
GetGlyphOutlineA(hdc, 'A', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(gm.gmptGlyphOrigin.y <= tm.tmAscent,
|
|
|
|
"Glyph top(%d) exceeds ascent(%d)\n",
|
|
|
|
gm.gmptGlyphOrigin.y, tm.tmAscent);
|
|
|
|
GetGlyphOutlineA(hdc, 'D', GGO_METRICS, &gm, 0, NULL, &mat);
|
|
|
|
ok(gm.gmptGlyphOrigin.y - gm.gmBlackBoxY >= -tm.tmDescent,
|
|
|
|
"Glyph bottom(%d) exceeds descent(%d)\n",
|
|
|
|
gm.gmptGlyphOrigin.y - gm.gmBlackBoxY, -tm.tmDescent);
|
|
|
|
|
2014-05-23 12:33:54 +02:00
|
|
|
/* Test tmLastChar - wine_test has code points fffb-fffe mapped to glyph 0 */
|
|
|
|
GetTextMetricsW(hdc, &tmW);
|
|
|
|
todo_wine
|
|
|
|
ok( tmW.tmLastChar == 0xfffe, "got %04x\n", tmW.tmLastChar);
|
|
|
|
|
2013-04-30 09:20:57 +02:00
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2020-09-28 11:16:49 +02:00
|
|
|
static void test_GetGlyphOutline_character(void)
|
|
|
|
{
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
DWORD ret;
|
|
|
|
GLYPHMETRICS gm1, gm2, gmn;
|
|
|
|
char test_chars[] = { 'A', 'D', '!', '\0' };
|
|
|
|
char *current_char;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lstrcpyA(lf.lfFaceName, "wine_test");
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_old != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 'Z', GGO_METRICS, &gmn, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed to default to .notdef for character 'Z'\n");
|
|
|
|
|
|
|
|
for (current_char = test_chars; *current_char != '\0'; current_char++)
|
|
|
|
{
|
|
|
|
ret = GetGlyphOutlineW(hdc, *current_char, GGO_METRICS, &gm1, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed for '%c'\n", *current_char);
|
|
|
|
ok(memcmp(&gm1, &gmn, sizeof(gmn)) != 0, "the test character '%c' matches .notdef\n", *current_char);
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0x10000 + *current_char, GGO_METRICS, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed for 0x10000 + '%c'\n", *current_char);
|
|
|
|
ok(memcmp(&gm1, &gm2, sizeof(gmn)) == 0, "GetGlyphOutlineW returned wrong metrics for character 0x10000 + '%c'\n", *current_char);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0x3, GGO_METRICS|GGO_GLYPH_INDEX, &gm1, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed for glyph index 0x3\n");
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0xFFFF, GGO_METRICS|GGO_GLYPH_INDEX, &gm2, 0, NULL, &mat);
|
2020-11-25 19:43:25 +01:00
|
|
|
ok(ret == GDI_ERROR, "GetGlyphOutlineW for nonexistent glyph index 0xFFFF has succeeded\n");
|
2020-09-28 11:16:49 +02:00
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0x10003, GGO_METRICS|GGO_GLYPH_INDEX, &gm2, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW for index 0x10003 has failed\n");
|
|
|
|
ok(memcmp(&gm1, &gm2, sizeof(gmn)) == 0, "GetGlyphOutlineW returned wrong metrics for glyph 0x10003\n");
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2017-03-05 11:44:58 +01:00
|
|
|
static void test_fstype_fixup(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
DWORD ret;
|
|
|
|
OUTLINETEXTMETRICA *otm;
|
|
|
|
DWORD otm_size;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfHeight = 72;
|
|
|
|
lstrcpyA(lf.lfFaceName, "wine_test");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != 0, "CreateFontIndirectA error %u\n", GetLastError());
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
otm_size = GetOutlineTextMetricsA(hdc, 0, NULL);
|
|
|
|
otm = HeapAlloc(GetProcessHeap(), 0, otm_size);
|
|
|
|
otm->otmSize = sizeof(*otm);
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, otm->otmSize, otm);
|
|
|
|
ok(ret == otm->otmSize, "expected %u, got %u, error %d\n", otm->otmSize, ret, GetLastError());
|
|
|
|
|
|
|
|
/* Test font has fsType set to 0x7fff, test that reserved bits are filtered out,
|
|
|
|
valid bits are 1, 2, 3, 8, 9. */
|
|
|
|
ok((otm->otmfsType & ~0x30e) == 0, "fsType %#x\n", otm->otmfsType);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, otm);
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2011-08-30 04:59:42 +02:00
|
|
|
static void test_CreateScalableFontResource(void)
|
|
|
|
{
|
|
|
|
char ttf_name[MAX_PATH];
|
|
|
|
char tmp_path[MAX_PATH];
|
|
|
|
char fot_name[MAX_PATH];
|
|
|
|
char *file_part;
|
|
|
|
DWORD ret;
|
2013-03-04 11:35:50 +01:00
|
|
|
int i;
|
2011-08-30 04:59:42 +02:00
|
|
|
|
|
|
|
if (!pAddFontResourceExA || !pRemoveFontResourceExA)
|
|
|
|
{
|
|
|
|
win_skip("AddFontResourceExA is not available on this platform\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:44:00 +01:00
|
|
|
if (!write_ttf_file("wine_test.ttf", ttf_name))
|
2011-08-30 04:59:42 +02:00
|
|
|
{
|
|
|
|
skip("Failed to create ttf file for testing\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace("created %s\n", ttf_name);
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTempPathA(MAX_PATH, tmp_path);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret, "GetTempPath() error %d\n", GetLastError());
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTempFileNameA(tmp_path, "fot", 0, fot_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret, "GetTempFileName() error %d\n", GetLastError());
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetFileAttributesA(fot_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret != INVALID_FILE_ATTRIBUTES, "file %s does not exist\n", fot_name);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, ttf_name, NULL);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "CreateScalableFontResource() should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, ttf_name, "");
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "CreateScalableFontResource() should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
|
|
|
|
|
|
|
file_part = strrchr(ttf_name, '\\');
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, file_part, tmp_path);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "CreateScalableFontResource() should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_FILE_EXISTS, "not expected error %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, "random file name", tmp_path);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "CreateScalableFontResource() should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, NULL, ttf_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "CreateScalableFontResource() should fail\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = DeleteFileA(fot_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret, "DeleteFile() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
|
|
|
|
|
|
|
/* test public font resource */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(0, fot_name, ttf_name, NULL);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(ret, "font wine_test should be enumerated\n");
|
|
|
|
|
2012-11-13 16:51:51 +01:00
|
|
|
test_GetGlyphOutline_empty_contour();
|
2013-04-30 09:20:57 +02:00
|
|
|
test_GetGlyphOutline_metric_clipping();
|
2020-09-28 11:16:49 +02:00
|
|
|
test_GetGlyphOutline_character();
|
2017-03-05 11:44:58 +01:00
|
|
|
test_fstype_fixup();
|
2012-11-13 16:51:51 +01:00
|
|
|
|
2011-08-30 04:59:42 +02:00
|
|
|
ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
|
|
|
|
ok(!ret, "RemoveFontResourceEx() with not matching flags should fail\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
|
|
|
|
2013-03-04 11:35:50 +01:00
|
|
|
/* test refcounting */
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
DeleteFileA(fot_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
|
|
|
|
/* test hidden font resource */
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = CreateScalableFontResourceA(1, fot_name, ttf_name, NULL);
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(ret, "CreateScalableFontResource() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pAddFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
2013-01-15 12:54:02 +01:00
|
|
|
todo_wine
|
2011-08-30 04:59:42 +02:00
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
|
|
|
/* XP allows removing a private font added with 0 flags */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
|
|
|
|
|
|
|
ret = is_truetype_font_installed("wine_test");
|
|
|
|
ok(!ret, "font wine_test should not be enumerated\n");
|
|
|
|
|
|
|
|
ret = pRemoveFontResourceExA(fot_name, 0, 0);
|
|
|
|
ok(!ret, "RemoveFontResourceEx() should fail\n");
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
DeleteFileA(fot_name);
|
|
|
|
DeleteFileA(ttf_name);
|
2011-08-30 04:59:42 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 11:08:03 +01:00
|
|
|
static void check_vertical_font(const char *name, BOOL *installed, BOOL *selected, GLYPHMETRICS *gm, WORD *gi)
|
2011-12-13 11:44:00 +01:00
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
HDC hdc;
|
|
|
|
char facename[100];
|
|
|
|
DWORD ret;
|
2012-01-10 11:08:03 +01:00
|
|
|
static const WCHAR str[] = { 0x2025 };
|
2011-12-13 11:44:00 +01:00
|
|
|
|
|
|
|
*installed = is_truetype_font_installed(name);
|
|
|
|
|
|
|
|
lf.lfHeight = -18;
|
|
|
|
lf.lfWidth = 0;
|
|
|
|
lf.lfEscapement = 0;
|
|
|
|
lf.lfOrientation = 0;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
|
|
|
lf.lfItalic = 0;
|
|
|
|
lf.lfUnderline = 0;
|
|
|
|
lf.lfStrikeOut = 0;
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
|
|
|
|
strcpy(lf.lfFaceName, name);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != NULL, "CreateFontIndirectA failed\n");
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
ret = GetTextFaceA(hdc, sizeof facename, facename);
|
|
|
|
ok(ret, "GetTextFaceA failed\n");
|
|
|
|
*selected = !strcmp(facename, name);
|
|
|
|
|
|
|
|
ret = GetGlyphOutlineW(hdc, 0x2025, GGO_METRICS, gm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
|
|
|
|
if (!*selected)
|
|
|
|
memset(gm, 0, sizeof *gm);
|
|
|
|
|
2012-01-10 11:08:03 +01:00
|
|
|
ret = pGetGlyphIndicesW(hdc, str, 1, gi, 0);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphIndicesW failed\n");
|
|
|
|
|
2011-12-13 11:44:00 +01:00
|
|
|
SelectObject(hdc, hfont_prev);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2014-01-10 12:29:59 +01:00
|
|
|
static void check_vertical_metrics(const char *face)
|
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
HDC hdc;
|
|
|
|
DWORD ret;
|
|
|
|
GLYPHMETRICS rgm, vgm;
|
|
|
|
const UINT code = 0x5EAD, height = 1000;
|
|
|
|
WORD idx;
|
2018-02-04 13:02:11 +01:00
|
|
|
ABC abc, vabc;
|
2014-01-10 12:29:59 +01:00
|
|
|
OUTLINETEXTMETRICA otm;
|
|
|
|
USHORT numOfLongVerMetrics;
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, face);
|
|
|
|
lf.lfHeight = -height;
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfEscapement = lf.lfOrientation = 900;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ret = GetGlyphOutlineW(hdc, code, GGO_METRICS, &rgm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
|
|
|
|
ret = GetCharABCWidthsW(hdc, code, code, &abc);
|
|
|
|
ok(ret, "GetCharABCWidthsW failed\n");
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "@");
|
|
|
|
strcat(lf.lfFaceName, face);
|
|
|
|
lf.lfHeight = -height;
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ret = GetGlyphOutlineW(hdc, code, GGO_METRICS, &vgm, 0, NULL, &mat);
|
|
|
|
ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n");
|
2018-02-04 13:02:11 +01:00
|
|
|
ret = GetCharABCWidthsW(hdc, code, code, &vabc);
|
|
|
|
ok(ret, "GetCharABCWidthsW failed\n");
|
2018-02-04 13:02:13 +01:00
|
|
|
ok(vabc.abcA == vgm.gmptGlyphOrigin.x, "expected %d, got %d\n",
|
2018-02-04 13:02:11 +01:00
|
|
|
vabc.abcA, vgm.gmptGlyphOrigin.x);
|
2018-02-04 13:02:13 +01:00
|
|
|
ok(vabc.abcB == vgm.gmBlackBoxX, "expected %d, got %d\n",
|
2018-02-04 13:02:11 +01:00
|
|
|
vabc.abcB, vgm.gmBlackBoxX);
|
|
|
|
ok(vabc.abcA + vabc.abcB + vabc.abcC == vgm.gmCellIncX,
|
|
|
|
"expected %d, got %d\n",
|
|
|
|
vabc.abcA + vabc.abcB + vabc.abcC, vgm.gmCellIncX);
|
2014-01-10 12:29:59 +01:00
|
|
|
|
|
|
|
memset(&otm, 0, sizeof(otm));
|
|
|
|
otm.otmSize = sizeof(otm);
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, sizeof(otm), &otm);
|
|
|
|
ok(ret != 0, "GetOutlineTextMetricsA failed\n");
|
|
|
|
|
|
|
|
if (GetFontData(hdc, MS_MAKE_TAG('v','h','e','a'), sizeof(SHORT) * 17,
|
|
|
|
&numOfLongVerMetrics, sizeof(numOfLongVerMetrics)) != GDI_ERROR) {
|
|
|
|
int offset;
|
|
|
|
SHORT topSideBearing;
|
2014-02-19 13:02:04 +01:00
|
|
|
|
|
|
|
if (!pGetGlyphIndicesW) {
|
|
|
|
win_skip("GetGlyphIndices is not available on this platform\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = pGetGlyphIndicesW(hdc, (LPCWSTR)&code, 1, &idx, 0);
|
|
|
|
ok(ret != 0, "GetGlyphIndicesW failed\n");
|
|
|
|
numOfLongVerMetrics = GET_BE_WORD(numOfLongVerMetrics);
|
|
|
|
if (numOfLongVerMetrics > idx)
|
|
|
|
offset = idx * 2 + 1;
|
|
|
|
else
|
|
|
|
offset = numOfLongVerMetrics * 2 + (idx - numOfLongVerMetrics);
|
|
|
|
ret = GetFontData(hdc, MS_MAKE_TAG('v','m','t','x'), offset * sizeof(SHORT),
|
|
|
|
&topSideBearing, sizeof(SHORT));
|
|
|
|
ok(ret != GDI_ERROR, "GetFontData(vmtx) failed\n");
|
|
|
|
topSideBearing = GET_BE_WORD(topSideBearing);
|
|
|
|
ok(match_off_by_1(vgm.gmptGlyphOrigin.x,
|
|
|
|
MulDiv(topSideBearing, height, otm.otmEMSquare), FALSE),
|
|
|
|
"expected %d, got %d\n",
|
|
|
|
MulDiv(topSideBearing, height, otm.otmEMSquare), vgm.gmptGlyphOrigin.x);
|
|
|
|
}
|
2014-01-10 12:29:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(vgm.gmptGlyphOrigin.x == rgm.gmptGlyphOrigin.x + vgm.gmCellIncX + otm.otmDescent,
|
|
|
|
"got %d, expected rgm.origin.x(%d) + vgm.cellIncX(%d) + descent(%d)\n",
|
|
|
|
vgm.gmptGlyphOrigin.x, rgm.gmptGlyphOrigin.x, vgm.gmCellIncX, otm.otmDescent);
|
|
|
|
}
|
|
|
|
|
2014-02-19 13:02:00 +01:00
|
|
|
ok(vgm.gmptGlyphOrigin.y == abc.abcA + abc.abcB + otm.otmDescent ||
|
|
|
|
broken(vgm.gmptGlyphOrigin.y == abc.abcA + abc.abcB - otm.otmTextMetrics.tmDescent) /* win2k */,
|
2014-01-10 12:29:59 +01:00
|
|
|
"got %d, expected abcA(%d) + abcB(%u) + descent(%d)\n",
|
|
|
|
(INT)vgm.gmptGlyphOrigin.y, abc.abcA, abc.abcB, otm.otmDescent);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:44:00 +01:00
|
|
|
static void test_vertical_font(void)
|
|
|
|
{
|
|
|
|
char ttf_name[MAX_PATH];
|
2014-01-10 12:29:59 +01:00
|
|
|
int num, i;
|
2011-12-13 11:44:00 +01:00
|
|
|
BOOL ret, installed, selected;
|
|
|
|
GLYPHMETRICS gm;
|
2012-01-10 11:08:03 +01:00
|
|
|
WORD hgi, vgi;
|
2014-01-10 12:29:59 +01:00
|
|
|
const char* face_list[] = {
|
|
|
|
"@WineTestVertical", /* has vmtx table */
|
|
|
|
"@Ume Gothic", /* doesn't have vmtx table */
|
|
|
|
"@MS UI Gothic", /* has vmtx table, available on native */
|
|
|
|
};
|
2011-12-13 11:44:00 +01:00
|
|
|
|
2012-01-10 11:08:03 +01:00
|
|
|
if (!pAddFontResourceExA || !pRemoveFontResourceExA || !pGetGlyphIndicesW)
|
2011-12-13 11:44:00 +01:00
|
|
|
{
|
2012-01-10 11:08:03 +01:00
|
|
|
win_skip("AddFontResourceExA or GetGlyphIndicesW is not available on this platform\n");
|
2011-12-13 11:44:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_ttf_file("vertical.ttf", ttf_name))
|
|
|
|
{
|
|
|
|
skip("Failed to create ttf file for testing\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
num = pAddFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(num == 2, "AddFontResourceExA should add 2 fonts from vertical.ttf\n");
|
|
|
|
|
2013-05-17 21:32:23 +02:00
|
|
|
check_vertical_font("WineTestVertical", &installed, &selected, &gm, &hgi);
|
|
|
|
ok(installed, "WineTestVertical is not installed\n");
|
|
|
|
ok(selected, "WineTestVertical is not selected\n");
|
2011-12-13 11:44:00 +01:00
|
|
|
ok(gm.gmBlackBoxX > gm.gmBlackBoxY,
|
|
|
|
"gmBlackBoxX(%u) should be greater than gmBlackBoxY(%u) if horizontal\n",
|
|
|
|
gm.gmBlackBoxX, gm.gmBlackBoxY);
|
|
|
|
|
2013-05-17 21:32:23 +02:00
|
|
|
check_vertical_font("@WineTestVertical", &installed, &selected, &gm, &vgi);
|
|
|
|
ok(installed, "@WineTestVertical is not installed\n");
|
|
|
|
ok(selected, "@WineTestVertical is not selected\n");
|
2013-06-04 16:05:50 +02:00
|
|
|
ok(gm.gmBlackBoxX > gm.gmBlackBoxY,
|
2011-12-13 11:44:00 +01:00
|
|
|
"gmBlackBoxX(%u) should be less than gmBlackBoxY(%u) if vertical\n",
|
|
|
|
gm.gmBlackBoxX, gm.gmBlackBoxY);
|
|
|
|
|
2013-05-17 21:32:39 +02:00
|
|
|
ok(hgi != vgi, "same glyph h:%u v:%u\n", hgi, vgi);
|
2012-01-10 11:08:03 +01:00
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(face_list); i++) {
|
2014-01-10 12:29:59 +01:00
|
|
|
const char* face = face_list[i];
|
|
|
|
if (!is_truetype_font_installed(face)) {
|
|
|
|
skip("%s is not installed\n", face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
check_vertical_metrics(&face[1]);
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:44:00 +01:00
|
|
|
ret = pRemoveFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() error %d\n", GetLastError());
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
DeleteFileA(ttf_name);
|
2011-12-13 11:44:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static INT CALLBACK has_vertical_font_proc(const LOGFONTA *lf, const TEXTMETRICA *ntm,
|
2012-02-08 17:32:58 +01:00
|
|
|
DWORD type, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if (lf->lfFaceName[0] == '@') {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_east_asian_font_selection(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
UINT charset[] = { SHIFTJIS_CHARSET, HANGEUL_CHARSET, JOHAB_CHARSET,
|
|
|
|
GB2312_CHARSET, CHINESEBIG5_CHARSET };
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(charset); i++)
|
2012-02-08 17:32:58 +01:00
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
|
|
|
char face_name[LF_FACESIZE];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof lf);
|
|
|
|
lf.lfFaceName[0] = '\0';
|
|
|
|
lf.lfCharSet = charset[i];
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
if (EnumFontFamiliesExA(hdc, &lf, has_vertical_font_proc, 0, 0))
|
2012-02-08 17:32:58 +01:00
|
|
|
{
|
|
|
|
skip("Vertical font for charset %u is not installed\n", charset[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
memset(face_name, 0, sizeof face_name);
|
|
|
|
ret = GetTextFaceA(hdc, sizeof face_name, face_name);
|
2012-02-08 17:33:00 +01:00
|
|
|
ok(ret && face_name[0] != '@',
|
2012-02-08 17:32:58 +01:00
|
|
|
"expected non-vertical face for charset %u, got %s\n", charset[i], face_name);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof lf);
|
|
|
|
strcpy(lf.lfFaceName, "@");
|
|
|
|
lf.lfCharSet = charset[i];
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
memset(face_name, 0, sizeof face_name);
|
|
|
|
ret = GetTextFaceA(hdc, sizeof face_name, face_name);
|
|
|
|
ok(ret && face_name[0] == '@',
|
|
|
|
"expected vertical face for charset %u, got %s\n", charset[i], face_name);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
}
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
static int get_font_dpi(const LOGFONTA *lf, int *height)
|
2012-06-04 05:05:25 +02:00
|
|
|
{
|
|
|
|
HDC hdc = CreateCompatibleDC(0);
|
|
|
|
HFONT hfont;
|
2013-10-17 01:55:20 +02:00
|
|
|
TEXTMETRICA tm;
|
2012-06-04 05:05:25 +02:00
|
|
|
int ret;
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(lf);
|
2012-06-04 05:05:25 +02:00
|
|
|
ok(hfont != 0, "CreateFontIndirect failed\n");
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont);
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
2012-06-04 05:05:25 +02:00
|
|
|
ok(ret, "GetTextMetrics failed\n");
|
|
|
|
ret = tm.tmDigitizedAspectX;
|
2013-06-17 12:01:39 +02:00
|
|
|
if (height) *height = tm.tmHeight;
|
2012-06-04 05:05:25 +02:00
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_stock_fonts(void)
|
|
|
|
{
|
2012-06-16 16:15:51 +02:00
|
|
|
static const int font[] =
|
|
|
|
{
|
|
|
|
ANSI_FIXED_FONT, ANSI_VAR_FONT, SYSTEM_FONT, DEVICE_DEFAULT_FONT, DEFAULT_GUI_FONT
|
|
|
|
/* SYSTEM_FIXED_FONT, OEM_FIXED_FONT */
|
|
|
|
};
|
2012-06-04 05:05:25 +02:00
|
|
|
static const struct test_data
|
|
|
|
{
|
2013-06-17 12:01:39 +02:00
|
|
|
int charset, weight, height, height_pixels, dpi;
|
2012-06-04 05:05:25 +02:00
|
|
|
const char face_name[LF_FACESIZE];
|
2015-06-18 10:45:35 +02:00
|
|
|
WORD lang_id;
|
2019-01-14 16:02:26 +01:00
|
|
|
} td[][17] =
|
2012-06-04 05:05:25 +02:00
|
|
|
{
|
2012-06-16 16:15:51 +02:00
|
|
|
{ /* ANSI_FIXED_FONT */
|
2015-06-18 10:45:35 +02:00
|
|
|
{ ANSI_CHARSET, FW_NORMAL, 12, 12, 96, "Courier", LANG_ARABIC },
|
2015-10-02 16:00:11 +02:00
|
|
|
{ ANSI_CHARSET, FW_NORMAL, 12, 12, 96, "Courier", LANG_HEBREW},
|
2013-06-17 12:01:39 +02:00
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, 12, 13, 96, "Courier" },
|
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, 12, 13, 120, "Courier" },
|
2012-06-16 16:15:51 +02:00
|
|
|
{ 0 }
|
|
|
|
},
|
|
|
|
{ /* ANSI_VAR_FONT */
|
2013-06-17 12:01:39 +02:00
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, 12, 13, 96, "MS Sans Serif" },
|
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, 12, 13, 120, "MS Sans Serif" },
|
2012-06-16 16:15:51 +02:00
|
|
|
{ 0 }
|
|
|
|
},
|
|
|
|
{ /* SYSTEM_FONT */
|
2013-06-17 12:01:39 +02:00
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, 18, 18, 96, "System" },
|
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, 22, 22, 120, "System" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, 16, 16, 96, "System" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, 20, 20, 120, "System" },
|
|
|
|
{ DEFAULT_CHARSET, FW_BOLD, 16, 16, 96, "System" },
|
|
|
|
{ DEFAULT_CHARSET, FW_BOLD, 20, 20, 120, "System" },
|
2012-06-16 16:15:51 +02:00
|
|
|
{ 0 }
|
|
|
|
},
|
|
|
|
{ /* DEVICE_DEFAULT_FONT */
|
2013-06-17 12:01:39 +02:00
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, 18, 18, 96, "System" },
|
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, 22, 22, 120, "System" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, 16, 16, 96, "System" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, 20, 20, 120, "System" },
|
|
|
|
{ DEFAULT_CHARSET, FW_BOLD, 16, 16, 96, "System" },
|
|
|
|
{ DEFAULT_CHARSET, FW_BOLD, 20, 20, 120, "System" },
|
2012-06-16 16:15:51 +02:00
|
|
|
{ 0 }
|
|
|
|
},
|
|
|
|
{ /* DEFAULT_GUI_FONT */
|
2015-06-19 10:24:23 +02:00
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, -11, 13, 96, "MS Shell Dlg" },
|
2019-01-14 16:02:26 +01:00
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, -13, 16, 120, "MS Shell Dlg" },
|
2013-06-17 12:01:39 +02:00
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, -12, 15, 96, "?MS UI Gothic" },
|
|
|
|
{ SHIFTJIS_CHARSET, FW_NORMAL, -15, 18, 120, "?MS UI Gothic" },
|
2019-01-14 16:02:26 +01:00
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, -11, 13, 96, "MS Shell Dlg" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, -13, 16, 120, "MS Shell Dlg" },
|
2013-06-17 12:01:39 +02:00
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, -12, 15, 96, "?Gulim" },
|
|
|
|
{ HANGEUL_CHARSET, FW_NORMAL, -15, 18, 120, "?Gulim" },
|
2019-01-14 16:02:26 +01:00
|
|
|
{ GB2312_CHARSET, FW_NORMAL, -11, 13, 96, "MS Shell Dlg" },
|
|
|
|
{ GB2312_CHARSET, FW_NORMAL, -13, 16, 120, "MS Shell Dlg" },
|
2013-06-17 12:01:39 +02:00
|
|
|
{ GB2312_CHARSET, FW_NORMAL, -12, 15, 96, "?SimHei" },
|
|
|
|
{ GB2312_CHARSET, FW_NORMAL, -15, 18, 120, "?SimHei" },
|
|
|
|
{ CHINESEBIG5_CHARSET, FW_NORMAL, -12, 15, 96, "?MingLiU" },
|
|
|
|
{ CHINESEBIG5_CHARSET, FW_NORMAL, -15, 18, 120, "?MingLiU" },
|
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, -11, 13, 96, "MS Shell Dlg" },
|
|
|
|
{ DEFAULT_CHARSET, FW_NORMAL, -13, 16, 120, "MS Shell Dlg" },
|
2012-06-16 16:15:51 +02:00
|
|
|
{ 0 }
|
|
|
|
}
|
2012-06-04 05:05:25 +02:00
|
|
|
};
|
2012-06-16 16:15:51 +02:00
|
|
|
int i, j;
|
2012-06-04 05:05:25 +02:00
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(font); i++)
|
2012-06-04 05:05:25 +02:00
|
|
|
{
|
|
|
|
HFONT hfont;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2013-06-17 12:01:39 +02:00
|
|
|
int ret, height;
|
2012-06-04 05:05:25 +02:00
|
|
|
|
2012-06-16 16:15:51 +02:00
|
|
|
hfont = GetStockObject(font[i]);
|
|
|
|
ok(hfont != 0, "%d: GetStockObject(%d) failed\n", i, font[i]);
|
2012-06-04 05:05:25 +02:00
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
ret = GetObjectA(hfont, sizeof(lf), &lf);
|
2012-06-04 05:05:25 +02:00
|
|
|
if (ret != sizeof(lf))
|
|
|
|
{
|
|
|
|
/* NT4 */
|
|
|
|
win_skip("%d: GetObject returned %d instead of sizeof(LOGFONT)\n", i, ret);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-06-16 16:15:51 +02:00
|
|
|
for (j = 0; td[i][j].face_name[0] != 0; j++)
|
2012-06-04 05:05:25 +02:00
|
|
|
{
|
2015-06-18 10:45:35 +02:00
|
|
|
if ((lf.lfCharSet != td[i][j].charset && td[i][j].charset != DEFAULT_CHARSET) ||
|
2015-06-19 10:24:23 +02:00
|
|
|
(system_lang_id != td[i][j].lang_id && td[i][j].lang_id != LANG_NEUTRAL) ||
|
|
|
|
(td[i][j].face_name[0] != '?' && strcmp(lf.lfFaceName, td[i][j].face_name)))
|
2012-06-16 16:15:51 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-04 05:05:25 +02:00
|
|
|
|
2013-06-17 12:01:39 +02:00
|
|
|
ret = get_font_dpi(&lf, &height);
|
2012-06-16 16:15:51 +02:00
|
|
|
if (ret != td[i][j].dpi)
|
|
|
|
{
|
|
|
|
trace("%d(%d): font %s %d dpi doesn't match test data %d\n",
|
|
|
|
i, j, lf.lfFaceName, ret, td[i][j].dpi);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-06-17 12:01:39 +02:00
|
|
|
/* FIXME: Remove once Wine is fixed */
|
2016-02-11 03:02:14 +01:00
|
|
|
todo_wine_if (td[i][j].dpi != 96 &&
|
2013-06-17 12:02:25 +02:00
|
|
|
/* MS Sans Serif for 120 dpi and higher should include 12 pixel bitmap set */
|
|
|
|
((!strcmp(td[i][j].face_name, "MS Sans Serif") && td[i][j].height == 12) ||
|
|
|
|
/* System for 120 dpi and higher should include 20 pixel bitmap set */
|
|
|
|
(!strcmp(td[i][j].face_name, "System") && td[i][j].height > 16)))
|
2013-06-17 12:01:39 +02:00
|
|
|
ok(height == td[i][j].height_pixels, "%d(%d): expected height %d, got %d\n", i, j, td[i][j].height_pixels, height);
|
|
|
|
|
2012-06-16 16:15:51 +02:00
|
|
|
ok(td[i][j].weight == lf.lfWeight, "%d(%d): expected lfWeight %d, got %d\n", i, j, td[i][j].weight, lf.lfWeight);
|
|
|
|
ok(td[i][j].height == lf.lfHeight, "%d(%d): expected lfHeight %d, got %d\n", i, j, td[i][j].height, lf.lfHeight);
|
|
|
|
if (td[i][j].face_name[0] == '?')
|
|
|
|
{
|
|
|
|
/* Wine doesn't have this font, skip this case for now.
|
|
|
|
Actually, the face name is localized on Windows and varies
|
|
|
|
dpending on Windows versions (e.g. Japanese NT4 vs win2k). */
|
|
|
|
trace("%d(%d): default gui font is %s\n", i, j, lf.lfFaceName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-17 01:55:20 +02:00
|
|
|
ok(!strcmp(td[i][j].face_name, lf.lfFaceName), "%d(%d): expected lfFaceName %s, got %s\n", i, j, td[i][j].face_name, lf.lfFaceName);
|
2012-06-16 16:15:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-06-04 05:05:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-08 14:11:20 +02:00
|
|
|
static void test_max_height(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
2013-10-17 01:55:20 +02:00
|
|
|
LOGFONTA lf;
|
2013-05-08 14:11:20 +02:00
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
TEXTMETRICA tm1, tm;
|
|
|
|
BOOL r;
|
|
|
|
LONG invalid_height[] = { -65536, -123456, 123456 };
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
memset(&tm1, 0, sizeof(tm1));
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
lf.lfHeight = -1;
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
/* get 1 ppem value */
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-05-08 14:11:20 +02:00
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
2013-10-17 01:55:20 +02:00
|
|
|
r = GetTextMetricsA(hdc, &tm1);
|
2013-05-08 14:11:20 +02:00
|
|
|
ok(r, "GetTextMetrics failed\n");
|
|
|
|
ok(tm1.tmHeight > 0, "expected a positive value, got %d\n", tm1.tmHeight);
|
|
|
|
ok(tm1.tmAveCharWidth > 0, "expected a positive value, got %d\n", tm1.tmHeight);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_old));
|
|
|
|
|
|
|
|
/* test the largest value */
|
|
|
|
lf.lfHeight = -((1 << 16) - 1);
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-05-08 14:11:20 +02:00
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
memset(&tm, 0, sizeof(tm));
|
2013-10-17 01:55:20 +02:00
|
|
|
r = GetTextMetricsA(hdc, &tm);
|
2013-05-08 14:11:20 +02:00
|
|
|
ok(r, "GetTextMetrics failed\n");
|
|
|
|
ok(tm.tmHeight > tm1.tmHeight,
|
|
|
|
"expected greater than 1 ppem value (%d), got %d\n", tm1.tmHeight, tm.tmHeight);
|
|
|
|
ok(tm.tmAveCharWidth > tm1.tmAveCharWidth,
|
|
|
|
"expected greater than 1 ppem value (%d), got %d\n", tm1.tmAveCharWidth, tm.tmAveCharWidth);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_old));
|
|
|
|
|
|
|
|
/* test an invalid value */
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(invalid_height); i++) {
|
2013-05-08 14:11:20 +02:00
|
|
|
lf.lfHeight = invalid_height[i];
|
2013-10-17 01:55:20 +02:00
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-05-08 14:11:20 +02:00
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
memset(&tm, 0, sizeof(tm));
|
2013-10-17 01:55:20 +02:00
|
|
|
r = GetTextMetricsA(hdc, &tm);
|
2013-05-08 14:11:20 +02:00
|
|
|
ok(r, "GetTextMetrics failed\n");
|
|
|
|
ok(tm.tmHeight == tm1.tmHeight,
|
|
|
|
"expected 1 ppem value (%d), got %d\n", tm1.tmHeight, tm.tmHeight);
|
|
|
|
ok(tm.tmAveCharWidth == tm1.tmAveCharWidth,
|
|
|
|
"expected 1 ppem value (%d), got %d\n", tm1.tmAveCharWidth, tm.tmAveCharWidth);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_old));
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-18 14:42:00 +02:00
|
|
|
static void test_vertical_order(void)
|
|
|
|
{
|
|
|
|
struct enum_font_data efd;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HDC hdc;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok(hdc != NULL, "CreateCompatibleDC failed\n");
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
lf.lfHeight = 16;
|
|
|
|
lf.lfWidth = 16;
|
|
|
|
lf.lfQuality = DEFAULT_QUALITY;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfWeight = FW_DONTCARE;
|
2016-04-14 12:12:35 +02:00
|
|
|
memset( &efd, 0, sizeof(efd) );
|
2013-06-18 14:42:00 +02:00
|
|
|
EnumFontFamiliesExA(hdc, &lf, enum_font_data_proc, (LPARAM)&efd, 0);
|
|
|
|
for (i = 0; i < efd.total; i++)
|
|
|
|
{
|
|
|
|
if (efd.lf[i].lfFaceName[0] != '@') continue;
|
|
|
|
for (j = 0; j < efd.total; j++)
|
|
|
|
{
|
|
|
|
if (!strcmp(efd.lf[i].lfFaceName + 1, efd.lf[j].lfFaceName))
|
|
|
|
{
|
|
|
|
ok(i > j,"Found vertical font %s before its horizontal version\n", efd.lf[i].lfFaceName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 12:12:35 +02:00
|
|
|
heap_free( efd.lf );
|
2013-06-18 14:42:00 +02:00
|
|
|
DeleteDC( hdc );
|
|
|
|
}
|
|
|
|
|
2013-09-11 14:46:53 +02:00
|
|
|
static void test_GetCharWidth32(void)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont;
|
|
|
|
INT bufferA;
|
|
|
|
INT bufferW;
|
|
|
|
HWND hwnd;
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
if (!pGetCharWidth32W)
|
2013-09-11 14:46:53 +02:00
|
|
|
{
|
2020-01-08 09:41:38 +01:00
|
|
|
win_skip("GetCharWidth32W not available on this platform\n");
|
2013-09-11 14:46:53 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "System");
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hdc = GetDC(0);
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharWidth32A(hdc, 'a', 'a', &bufferA);
|
2013-09-11 14:46:53 +02:00
|
|
|
ok(ret, "GetCharWidth32A should have succeeded\n");
|
|
|
|
ok (bufferA == bufferW, "Widths should be the same\n");
|
|
|
|
ok (bufferA > 0," Width should be greater than zero\n");
|
|
|
|
|
|
|
|
hfont = SelectObject(hdc, hfont);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
lf.lfHeight = 20;
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
2013-10-17 01:55:20 +02:00
|
|
|
hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
|
2013-09-11 14:46:53 +02:00
|
|
|
0, 0, 0, NULL);
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
SetMapMode( hdc, MM_ANISOTROPIC );
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetWindowExtEx(hdc, -1,-1,NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
2018-02-04 13:02:07 +01:00
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
2013-09-11 14:46:53 +02:00
|
|
|
SetWindowExtEx(hdc, 1,1,NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2013-10-17 01:55:20 +02:00
|
|
|
hwnd = CreateWindowExA(WS_EX_LAYOUTRTL, "static", "", WS_POPUP, 0,0,100,100,
|
2013-09-11 14:46:53 +02:00
|
|
|
0, 0, 0, NULL);
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
SetMapMode( hdc, MM_ANISOTROPIC );
|
|
|
|
SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetWindowExtEx(hdc, -1,-1,NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetWindowExtEx(hdc, 1,1,NULL);
|
|
|
|
SetGraphicsMode(hdc, GM_COMPATIBLE);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
ret = pGetCharWidth32W(hdc, 'a', 'a', &bufferW);
|
|
|
|
ok(ret, "GetCharWidth32W should have succeeded\n");
|
2018-02-04 13:02:07 +01:00
|
|
|
ok (bufferW > 0," Width should be greater than zero\n");
|
2013-09-11 14:46:53 +02:00
|
|
|
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
2013-06-18 14:42:00 +02:00
|
|
|
|
2013-10-17 14:25:06 +02:00
|
|
|
static void test_fake_bold_font(void)
|
|
|
|
{
|
2015-12-31 05:33:13 +01:00
|
|
|
static const MAT2 x2_mat = { {0,2}, {0,0}, {0,0}, {0,2} };
|
2013-10-17 14:25:06 +02:00
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
BOOL ret;
|
2015-12-31 05:33:12 +01:00
|
|
|
struct glyph_data {
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
ABC abc;
|
|
|
|
INT w;
|
2015-12-31 05:33:13 +01:00
|
|
|
GLYPHMETRICS gm;
|
2018-02-18 13:34:40 +01:00
|
|
|
} data[4];
|
2015-12-31 05:33:12 +01:00
|
|
|
int i;
|
2015-12-31 05:33:13 +01:00
|
|
|
DWORD r;
|
2013-10-17 14:25:06 +02:00
|
|
|
|
|
|
|
/* Test outline font */
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Wingdings");
|
|
|
|
lf.lfCharSet = SYMBOL_CHARSET;
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
2015-12-31 05:33:12 +01:00
|
|
|
for (i = 0; i <= 1; i++)
|
|
|
|
{
|
|
|
|
HFONT hfont, hfont_old;
|
2013-10-17 14:25:06 +02:00
|
|
|
|
2015-12-31 05:33:12 +01:00
|
|
|
lf.lfWeight = i ? FW_BOLD : FW_NORMAL;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
2013-10-17 14:25:06 +02:00
|
|
|
|
2015-12-31 05:33:12 +01:00
|
|
|
ret = GetTextMetricsA(hdc, &data[i].tm);
|
|
|
|
ok(ret, "got %d\n", ret);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharABCWidthsA(hdc, 0x76, 0x76, &data[i].abc);
|
2015-12-31 05:33:12 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
data[i].w = data[i].abc.abcA + data[i].abc.abcB + data[i].abc.abcC;
|
2015-12-31 05:33:13 +01:00
|
|
|
r = GetGlyphOutlineA(hdc, 0x76, GGO_METRICS, &data[i].gm, 0, NULL, &x2_mat);
|
|
|
|
ok(r != GDI_ERROR, "got %d\n", ret);
|
2013-10-17 14:25:06 +02:00
|
|
|
|
2015-12-31 05:33:12 +01:00
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
2013-10-17 14:25:06 +02:00
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
/* compare results (outline) */
|
2015-12-31 05:33:12 +01:00
|
|
|
ok(data[0].tm.tmHeight == data[1].tm.tmHeight,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmHeight, data[1].tm.tmHeight);
|
|
|
|
ok(data[0].tm.tmAscent == data[1].tm.tmAscent,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmAscent, data[1].tm.tmAscent);
|
|
|
|
ok(data[0].tm.tmDescent == data[1].tm.tmDescent,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmDescent, data[1].tm.tmDescent);
|
|
|
|
ok(data[0].tm.tmAveCharWidth + 1 == data[1].tm.tmAveCharWidth,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmAveCharWidth + 1, data[1].tm.tmAveCharWidth);
|
|
|
|
ok(data[0].tm.tmMaxCharWidth + 1 == data[1].tm.tmMaxCharWidth,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmMaxCharWidth + 1, data[1].tm.tmMaxCharWidth);
|
|
|
|
ok(data[0].tm.tmOverhang == data[1].tm.tmOverhang,
|
|
|
|
"expected %d, got %d\n", data[0].tm.tmOverhang, data[1].tm.tmOverhang);
|
|
|
|
ok(data[0].w + 1 == data[1].w,
|
|
|
|
"expected %d, got %d\n", data[0].w + 1, data[1].w);
|
2013-10-17 14:25:06 +02:00
|
|
|
|
2016-01-13 15:09:08 +01:00
|
|
|
ok(data[0].gm.gmCellIncX + 1 == data[1].gm.gmCellIncX,
|
2015-12-31 05:33:13 +01:00
|
|
|
"expected %d, got %d\n", data[0].gm.gmCellIncX + 1, data[1].gm.gmCellIncX);
|
|
|
|
ok(data[0].gm.gmCellIncY == data[1].gm.gmCellIncY,
|
|
|
|
"expected %d, got %d\n", data[0].gm.gmCellIncY, data[1].gm.gmCellIncY);
|
2018-02-18 13:34:40 +01:00
|
|
|
|
|
|
|
/* Test bitmap font */
|
|
|
|
memset(&data, 0xaa, sizeof(data));
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Courier");
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
|
|
|
|
lf.lfWeight = (i % 2) ? FW_BOLD : FW_NORMAL;
|
|
|
|
lf.lfHeight = (i > 1) ? data[0].tm.tmHeight * x2_mat.eM11.value : 0;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
ret = GetTextMetricsA(hdc, &data[i].tm);
|
|
|
|
ok(ret, "got %d\n", ret);
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetCharWidth32A(hdc, 0x76, 0x76, &data[i].w);
|
2018-02-18 13:34:40 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
}
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
/* compare results (bitmap) */
|
|
|
|
for (i = 0; i < 4; i+=2)
|
|
|
|
{
|
|
|
|
int diff = (i > 1) ? x2_mat.eM11.value : 1;
|
|
|
|
if (data[i].tm.tmPitchAndFamily & TMPF_TRUETYPE)
|
|
|
|
{
|
|
|
|
skip("TrueType font is selected (expected a bitmap one)\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ok(data[i].tm.tmHeight == data[i+1].tm.tmHeight,
|
|
|
|
"expected %d, got %d\n", data[i].tm.tmHeight, data[i+1].tm.tmHeight);
|
|
|
|
ok(data[i].tm.tmAscent == data[i+1].tm.tmAscent,
|
|
|
|
"expected %d, got %d\n", data[i].tm.tmAscent, data[i+1].tm.tmAscent);
|
|
|
|
ok(data[i].tm.tmDescent == data[i+1].tm.tmDescent,
|
|
|
|
"expected %d, got %d\n", data[i].tm.tmDescent, data[i+1].tm.tmDescent);
|
|
|
|
ok(data[i+1].tm.tmAveCharWidth - data[i].tm.tmAveCharWidth == diff,
|
|
|
|
"expected %d, got %d\n", diff, data[i+1].tm.tmAveCharWidth - data[i].tm.tmAveCharWidth);
|
|
|
|
ok(data[i+1].tm.tmMaxCharWidth - data[i].tm.tmMaxCharWidth == diff,
|
|
|
|
"expected %d, got %d\n", diff, data[i+1].tm.tmMaxCharWidth - data[i].tm.tmMaxCharWidth);
|
|
|
|
ok(data[i].tm.tmOverhang == 0,
|
|
|
|
"expected 0, got %d\n", data[i].tm.tmOverhang);
|
|
|
|
ok(data[i+1].tm.tmOverhang == 1,
|
|
|
|
"expected 1, got %d\n", data[i+1].tm.tmOverhang);
|
|
|
|
ok(data[i].w + 1 == data[i+1].w,
|
|
|
|
"expected %d, got %d\n", data[i].w + 1, data[i+1].w);
|
|
|
|
}
|
2013-10-17 14:25:06 +02:00
|
|
|
}
|
|
|
|
|
2013-12-11 13:11:17 +01:00
|
|
|
static void test_bitmap_font_glyph_index(void)
|
|
|
|
{
|
2020-12-17 23:10:19 +01:00
|
|
|
const WCHAR text[] = L"#!/bin/sh";
|
2013-12-11 13:11:17 +01:00
|
|
|
const struct {
|
|
|
|
LPCSTR face;
|
|
|
|
BYTE charset;
|
|
|
|
} bitmap_font_list[] = {
|
|
|
|
{ "Courier", ANSI_CHARSET },
|
|
|
|
{ "Small Fonts", ANSI_CHARSET },
|
|
|
|
{ "Fixedsys", DEFAULT_CHARSET },
|
|
|
|
{ "System", DEFAULT_CHARSET }
|
|
|
|
};
|
|
|
|
HDC hdc;
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hFont;
|
|
|
|
CHAR facename[LF_FACESIZE];
|
|
|
|
BITMAPINFO bmi;
|
|
|
|
HBITMAP hBmp[2];
|
|
|
|
void *pixels[2];
|
|
|
|
int i, j;
|
|
|
|
DWORD ret;
|
|
|
|
BITMAP bmp;
|
|
|
|
TEXTMETRICA tm;
|
|
|
|
CHARSETINFO ci;
|
|
|
|
BYTE chr = '\xA9';
|
|
|
|
|
2020-01-08 09:41:38 +01:00
|
|
|
if (!pGetGlyphIndicesW) {
|
2014-02-19 13:02:04 +01:00
|
|
|
win_skip("GetGlyphIndices is unavailable\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-11 13:11:17 +01:00
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ok(hdc != NULL, "CreateCompatibleDC failed\n");
|
|
|
|
|
|
|
|
memset(&bmi, 0, sizeof(bmi));
|
|
|
|
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
bmi.bmiHeader.biBitCount = 32;
|
|
|
|
bmi.bmiHeader.biPlanes = 1;
|
|
|
|
bmi.bmiHeader.biWidth = 128;
|
|
|
|
bmi.bmiHeader.biHeight = 32;
|
|
|
|
bmi.bmiHeader.biCompression = BI_RGB;
|
|
|
|
|
2018-06-25 21:46:41 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(bitmap_font_list); i++) {
|
2013-12-11 13:11:17 +01:00
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfCharSet = bitmap_font_list[i].charset;
|
|
|
|
strcpy(lf.lfFaceName, bitmap_font_list[i].face);
|
|
|
|
hFont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hFont != NULL, "Can't create font (%s:%d)\n", lf.lfFaceName, lf.lfCharSet);
|
|
|
|
hFont = SelectObject(hdc, hFont);
|
|
|
|
ret = GetTextMetricsA(hdc, &tm);
|
|
|
|
ok(ret, "GetTextMetric failed\n");
|
|
|
|
ret = GetTextFaceA(hdc, sizeof(facename), facename);
|
|
|
|
ok(ret, "GetTextFace failed\n");
|
|
|
|
if (tm.tmPitchAndFamily & TMPF_TRUETYPE) {
|
|
|
|
skip("TrueType font (%s) was selected for \"%s\"\n", facename, bitmap_font_list[i].face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (lstrcmpiA(facename, lf.lfFaceName) != 0) {
|
|
|
|
skip("expected %s, got %s\n", lf.lfFaceName, facename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
HBITMAP hBmpPrev;
|
|
|
|
hBmp[j] = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &pixels[j], NULL, 0);
|
|
|
|
ok(hBmp[j] != NULL, "Can't create DIB\n");
|
|
|
|
hBmpPrev = SelectObject(hdc, hBmp[j]);
|
|
|
|
switch (j) {
|
|
|
|
case 0:
|
|
|
|
ret = ExtTextOutW(hdc, 0, 0, 0, NULL, text, lstrlenW(text), NULL);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
int len = lstrlenW(text);
|
|
|
|
LPWORD indices = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WORD));
|
2014-02-19 13:02:04 +01:00
|
|
|
ret = pGetGlyphIndicesW(hdc, text, len, indices, 0);
|
2013-12-11 13:11:17 +01:00
|
|
|
ok(ret, "GetGlyphIndices failed\n");
|
|
|
|
ok(memcmp(indices, text, sizeof(WORD) * len) == 0,
|
|
|
|
"Glyph indices and text are different for %s:%d\n", lf.lfFaceName, tm.tmCharSet);
|
|
|
|
ret = ExtTextOutW(hdc, 0, 0, ETO_GLYPH_INDEX, NULL, indices, len, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, indices);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(ret, "ExtTextOutW failed\n");
|
|
|
|
SelectObject(hdc, hBmpPrev);
|
|
|
|
}
|
|
|
|
|
|
|
|
GetObjectA(hBmp[0], sizeof(bmp), &bmp);
|
|
|
|
ok(memcmp(pixels[0], pixels[1], bmp.bmHeight * bmp.bmWidthBytes) == 0,
|
|
|
|
"Images are different (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
|
|
|
|
|
|
|
|
ret = TranslateCharsetInfo((LPDWORD)(DWORD_PTR)tm.tmCharSet, &ci, TCI_SRCCHARSET);
|
|
|
|
if (!ret) {
|
|
|
|
skip("Can't get charset info for (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
if (IsDBCSLeadByteEx(ci.ciACP, chr)) {
|
|
|
|
skip("High-ascii character is not defined in codepage %d\n", ci.ciACP);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
HBITMAP hBmpPrev;
|
|
|
|
WORD code;
|
|
|
|
hBmpPrev = SelectObject(hdc, hBmp[j]);
|
|
|
|
switch (j) {
|
|
|
|
case 0:
|
|
|
|
ret = ExtTextOutA(hdc, 100, 0, 0, NULL, (LPCSTR)&chr, 1, NULL);
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-01-08 09:41:38 +01:00
|
|
|
ret = GetGlyphIndicesA(hdc, (LPCSTR)&chr, 1, &code, 0);
|
2013-12-11 13:11:17 +01:00
|
|
|
ok(ret, "GetGlyphIndices failed\n");
|
|
|
|
ok(code == chr, "expected %02x, got %02x (%s:%d)\n", chr, code, lf.lfFaceName, tm.tmCharSet);
|
|
|
|
ret = ExtTextOutA(hdc, 100, 0, ETO_GLYPH_INDEX, NULL, (LPCSTR)&code, 1, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ok(ret, "ExtTextOutA failed\n");
|
|
|
|
SelectObject(hdc, hBmpPrev);
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(memcmp(pixels[0], pixels[1], bmp.bmHeight * bmp.bmWidthBytes) == 0,
|
|
|
|
"Images are different (%s:%d)\n", lf.lfFaceName, tm.tmCharSet);
|
|
|
|
next:
|
|
|
|
for (j = 0; j < 2; j++)
|
|
|
|
DeleteObject(hBmp[j]);
|
|
|
|
hFont = SelectObject(hdc, hFont);
|
|
|
|
DeleteObject(hFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2017-04-12 23:47:39 +02:00
|
|
|
static void test_GetCharWidthI(void)
|
|
|
|
{
|
|
|
|
static const char *teststr = "wine ";
|
|
|
|
HFONT hfont, prev_hfont;
|
|
|
|
WORD glyphs[5];
|
|
|
|
INT widths[5];
|
|
|
|
LOGFONTA lf;
|
|
|
|
ABC abc[5];
|
|
|
|
int len, i;
|
|
|
|
DWORD nb;
|
|
|
|
BOOL ret;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
lf.lfHeight = -20;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
prev_hfont = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
len = strlen(teststr);
|
|
|
|
nb = GetGlyphIndicesA(hdc, teststr, len, glyphs, 0);
|
|
|
|
ok(nb == len, "\n");
|
|
|
|
|
|
|
|
memset(abc, 0xcc, sizeof(abc));
|
|
|
|
ret = GetCharABCWidthsI(hdc, 0, len, glyphs, abc);
|
|
|
|
ok(ret, "GetCharABCWidthsI failed\n");
|
|
|
|
|
|
|
|
memset(widths, 0xcc, sizeof(widths));
|
|
|
|
ret = GetCharWidthI(hdc, 0, len, glyphs, widths);
|
|
|
|
ok(ret, "GetCharWidthI failed\n");
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
ok(widths[i] == abc[i].abcA + abc[i].abcB + abc[i].abcC, "%u, glyph %u, got width %d\n",
|
|
|
|
i, glyphs[i], widths[i]);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, prev_hfont));
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2017-11-26 14:33:17 +01:00
|
|
|
static INT CALLBACK long_enum_proc(const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lparam)
|
|
|
|
{
|
|
|
|
BOOL *found_font = (BOOL *)lparam;
|
|
|
|
*found_font = TRUE;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_long_names(void)
|
|
|
|
{
|
|
|
|
char ttf_name[MAX_PATH];
|
|
|
|
LOGFONTA font = {0};
|
|
|
|
HFONT handle_font;
|
|
|
|
BOOL found_font;
|
|
|
|
int ret;
|
|
|
|
HDC dc;
|
|
|
|
|
|
|
|
if (!write_ttf_file("wine_longname.ttf", ttf_name))
|
|
|
|
{
|
|
|
|
skip("Failed to create ttf file for testing\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dc = GetDC(NULL);
|
|
|
|
|
|
|
|
ret = AddFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "wine_3_this_is_a_very_long_name");
|
|
|
|
found_font = FALSE;
|
|
|
|
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
|
|
|
|
ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n");
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "wine_2_this_is_a_very_long_name");
|
|
|
|
found_font = FALSE;
|
|
|
|
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
|
|
|
|
ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n");
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "wine_1_this_is_a_very_long_name");
|
|
|
|
found_font = FALSE;
|
|
|
|
EnumFontFamiliesExA(dc, &font, long_enum_proc, (LPARAM)&found_font, 0);
|
|
|
|
ok(found_font == FALSE, "EnumFontFamiliesExA must not find font.\n");
|
|
|
|
|
|
|
|
handle_font = CreateFontIndirectA(&font);
|
|
|
|
ok(handle_font != NULL, "CreateFontIndirectA failed\n");
|
|
|
|
DeleteObject(handle_font);
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
DeleteFileA(ttf_name);
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
}
|
|
|
|
|
2020-09-07 15:18:53 +02:00
|
|
|
static void test_ttf_names(void)
|
|
|
|
{
|
|
|
|
struct enum_fullname_data efnd;
|
|
|
|
char ttf_name[MAX_PATH], ttf_name_bold[MAX_PATH];
|
|
|
|
LOGFONTA font = {0};
|
|
|
|
HFONT handle_font;
|
|
|
|
int ret;
|
|
|
|
HDC dc;
|
|
|
|
|
|
|
|
if (!write_ttf_file("wine_ttfnames.ttf", ttf_name))
|
|
|
|
{
|
|
|
|
skip("Failed to create ttf file for testing\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_ttf_file("wine_ttfnames_bold.ttf", ttf_name_bold))
|
|
|
|
{
|
|
|
|
skip("Failed to create ttf file for testing\n");
|
|
|
|
DeleteFileA(ttf_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = AddFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
ret = AddFontResourceExA(ttf_name_bold, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "AddFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
dc = GetDC(NULL);
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "Wine_TTF_Names_Long_Family1_Con");
|
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
|
|
|
EnumFontFamiliesExA(dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(efnd.total == 0, "EnumFontFamiliesExA must not find font.\n");
|
|
|
|
|
|
|
|
/* Windows doesn't match with Typographic/Preferred Family tags */
|
|
|
|
strcpy(font.lfFaceName, "Wine TTF Names Long Family1");
|
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
|
|
|
EnumFontFamiliesExA(dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(efnd.total == 0, "EnumFontFamiliesExA must not find font.\n");
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "Wine TTF Names Long Family1 Ext");
|
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
|
|
|
EnumFontFamiliesExA(dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(efnd.total == 2, "EnumFontFamiliesExA found %d fonts, expected 2.\n", efnd.total);
|
|
|
|
|
|
|
|
strcpy(font.lfFaceName, "Wine TTF Names Long Family1 Con");
|
|
|
|
memset(&efnd, 0, sizeof(efnd));
|
|
|
|
EnumFontFamiliesExA(dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0);
|
|
|
|
ok(efnd.total == 2, "EnumFontFamiliesExA found %d fonts, expected 2.\n", efnd.total);
|
|
|
|
|
|
|
|
handle_font = CreateFontIndirectA(&font);
|
|
|
|
ok(handle_font != NULL, "CreateFontIndirectA failed\n");
|
|
|
|
DeleteObject(handle_font);
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA(ttf_name_bold, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
DeleteFileA(ttf_name_bold);
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA(ttf_name, FR_PRIVATE, 0);
|
|
|
|
ok(ret, "RemoveFontResourceEx() failed\n");
|
|
|
|
|
|
|
|
DeleteFileA(ttf_name);
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
}
|
|
|
|
|
2020-09-17 19:30:42 +02:00
|
|
|
static void test_lang_names(void)
|
|
|
|
{
|
2020-12-17 23:10:19 +01:00
|
|
|
static const WCHAR name_cond_ja_w[] = L"\x30d5\x30a9\x30f3\x30c8\x540d Cond (ja)";
|
|
|
|
static const WCHAR name_cond_ja_reg_w[] = L"\x30d5\x30a9\x30f3\x30c8\x540d Cond (ja) Reg";
|
|
|
|
static const WCHAR name_cond_ja_reg_ja_w[] = L"\x30d5\x30a9\x30f3\x30c8\x540d Cond (ja) Reg (ja)";
|
|
|
|
static const WCHAR name_wws_ja_w[] = L"\x30d5\x30a9\x30f3\x30c8\x540d WWS (ja)";
|
2020-09-17 19:30:42 +02:00
|
|
|
|
|
|
|
struct enum_fullname_data efnd;
|
|
|
|
struct enum_fullname_data_w efnd_w;
|
|
|
|
char ttf_name[MAX_PATH], ttf_name2[MAX_PATH], ttf_name3[MAX_PATH];
|
|
|
|
LOGFONTA font = {0};
|
|
|
|
LOGFONTW font_w = {0};
|
|
|
|
int ret, i;
|
|
|
|
HDC dc;
|
|
|
|
const WCHAR *primary_family, *primary_fullname;
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_ENGLISH && PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_JAPANESE)
|
|
|
|
{
|
|
|
|
skip( "Primary language is neither English nor Japanese, skipping test\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_ttf_file( "wine_langnames.ttf", ttf_name ))
|
|
|
|
{
|
|
|
|
skip( "Failed to create ttf file for testing\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_ttf_file( "wine_langnames2.ttf", ttf_name2 ))
|
|
|
|
{
|
|
|
|
skip( "Failed to create ttf file for testing\n" );
|
|
|
|
DeleteFileA( ttf_name );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_ttf_file( "wine_langnames3.ttf", ttf_name3 ))
|
|
|
|
{
|
|
|
|
skip( "Failed to create ttf file for testing\n" );
|
|
|
|
DeleteFileA( ttf_name2 );
|
|
|
|
DeleteFileA( ttf_name );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = AddFontResourceExA( ttf_name, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "AddFontResourceEx() failed\n" );
|
|
|
|
|
|
|
|
dc = GetDC( NULL );
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
|
|
|
{
|
|
|
|
primary_family = L"Wine Lang Cond (en)";
|
|
|
|
primary_fullname = L"Wine Lang Cond Reg (en)";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
primary_family = name_cond_ja_w;
|
|
|
|
primary_fullname = name_cond_ja_reg_w;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
/* check that lookup by preferred or WWS family / full names or postscript FontName doesn't work */
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang (en)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Condensed Bold (ko)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
wcscpy( font_w.lfFaceName, name_wws_ja_w );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Reg WWS (zh-tw)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang (en) Reg WWS (en)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "WineLangNamesRegular" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
/* then, the primary ttf family name always works */
|
|
|
|
|
|
|
|
wcscpy( font_w.lfFaceName, primary_family );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == min( 2, i + 1 ), "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
|
|
|
{
|
|
|
|
wcscpy( font_w.lfFaceName, name_cond_ja_w );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if there is no primary ttf family name, the english ttf name, or postscript FamilyName are used instead */
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine_Lang_Names" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
if (i == 2)
|
|
|
|
ok( efnd.total == 1, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
else
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
/* same goes for ttf full names */
|
|
|
|
|
|
|
|
wcscpy( font_w.lfFaceName, primary_fullname );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == 1, "%d: EnumFontFamiliesExW unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
|
|
|
|
if (efnd_w.total >= 1)
|
|
|
|
{
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[0].elfLogFont.lfFaceName, primary_family ),
|
|
|
|
"%d: (%d) unexpected lfFaceName %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[0].elfLogFont.lfFaceName) );
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[0].elfFullName, primary_fullname ),
|
|
|
|
"%d: (%d) unexpected elfFullName %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[0].elfFullName) );
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[0].elfStyle, PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH ? L"Reg (en)" : L"Reg (ja)" ),
|
|
|
|
"%d: (%d) unexpected elfStyle %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[0].elfStyle) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
|
|
|
{
|
|
|
|
wcscpy( font_w.lfFaceName, name_cond_ja_reg_w );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
}
|
|
|
|
|
|
|
|
wcscpy( font_w.lfFaceName, L"Wine_Lang_Names_Regular" );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == i, "%d: EnumFontFamiliesExW unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
|
|
|
|
while (efnd_w.total--)
|
|
|
|
{
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[efnd_w.total].elfLogFont.lfFaceName, efnd_w.total == 1 ? L"Wine_Lang_Names" : primary_family ),
|
|
|
|
"%d: (%d) unexpected lfFaceName %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[efnd_w.total].elfLogFont.lfFaceName) );
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[efnd_w.total].elfFullName, L"Wine_Lang_Names_Regular" ),
|
|
|
|
"%d: (%d) unexpected elfFullName %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[efnd_w.total].elfFullName) );
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[efnd_w.total].elfStyle, efnd_w.total == 1 ? L"Regular" : L"Reg (en)" ),
|
|
|
|
"%d: (%d) unexpected elfStyle %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[efnd_w.total].elfStyle) );
|
|
|
|
else
|
|
|
|
ok( !wcscmp( (WCHAR *)efnd_w.elf[0].elfStyle, L"Reg (ja)" ),
|
|
|
|
"%d: (%d) unexpected elfStyle %s\n", i, efnd_w.total, debugstr_w((WCHAR *)efnd_w.elf[0].elfStyle) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
|
|
|
{
|
|
|
|
wcscpy( font_w.lfFaceName, name_cond_ja_reg_ja_w );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
|
|
|
ok( efnd_w.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* another language can also be used for lookup, if the primary langid isn't english, then
|
|
|
|
english seems to have priority, otherwise or if english is already the primary langid,
|
|
|
|
the family name with the smallest langid is used as secondary lookup language. */
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Cond (zh-tw)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
if (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
|
2020-09-17 19:30:43 +02:00
|
|
|
ok( efnd.total == min( 2, i + 1 ), "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
2020-09-17 19:30:42 +02:00
|
|
|
else /* (zh-tw) doesn't match here probably because there's an (en) name too */
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Cond (en)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
/* either because it's the primary language, or because it's a secondary */
|
|
|
|
ok( efnd.total == min( 2, i + 1 ), "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
2020-11-23 13:20:49 +01:00
|
|
|
wcscpy( font_w.lfFaceName, L"Wine Police d'\xe9" "criture (fr)" );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
2020-09-17 19:30:42 +02:00
|
|
|
/* as wine_langnames3.sfd does not specify (en) name, (fr) is preferred */
|
2020-11-23 13:20:49 +01:00
|
|
|
if (i == 2) ok( efnd_w.total == 1, "%d: EnumFontFamiliesExW unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
else ok( efnd_w.total == 0, "%d: EnumFontFamiliesExW unexpected count %u.\n", i, efnd_w.total );
|
|
|
|
|
|
|
|
/* case matching should not depend on the current locale */
|
|
|
|
if (i == 2)
|
|
|
|
{
|
|
|
|
wcscpy( font_w.lfFaceName, L"Wine POLICE D'\xc9" "CRITURE (fr)" );
|
|
|
|
memset( &efnd_w, 0, sizeof(efnd_w) );
|
|
|
|
EnumFontFamiliesExW( dc, &font_w, enum_fullname_data_proc_w, (LPARAM)&efnd_w, 0 );
|
2020-11-23 13:20:50 +01:00
|
|
|
ok( efnd_w.total == 1, "%d: EnumFontFamiliesExW unexpected count %u.\n", i, efnd_w.total );
|
2020-11-23 13:20:49 +01:00
|
|
|
}
|
2020-09-17 19:30:42 +02:00
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Cond (ko)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
/* that doesn't apply to full names */
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Cond Reg (zh-tw)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
strcpy( font.lfFaceName, "Wine Lang Cond Reg (fr)" );
|
|
|
|
memset( &efnd, 0, sizeof(efnd) );
|
|
|
|
EnumFontFamiliesExA( dc, &font, enum_fullname_data_proc, (LPARAM)&efnd, 0 );
|
|
|
|
ok( efnd.total == 0, "%d: EnumFontFamiliesExA unexpected count %u.\n", i, efnd.total );
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
ret = AddFontResourceExA( ttf_name2, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "AddFontResourceEx() failed\n" );
|
|
|
|
}
|
|
|
|
else if (i == 1)
|
|
|
|
{
|
|
|
|
ret = AddFontResourceExA( ttf_name3, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "AddFontResourceEx() failed\n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA( ttf_name3, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "RemoveFontResourceEx() failed\n" );
|
|
|
|
|
|
|
|
DeleteFileA( ttf_name3 );
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA( ttf_name2, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "RemoveFontResourceEx() failed\n" );
|
|
|
|
|
|
|
|
DeleteFileA( ttf_name2 );
|
|
|
|
|
|
|
|
ret = RemoveFontResourceExA( ttf_name, FR_PRIVATE, 0 );
|
|
|
|
ok( ret, "RemoveFontResourceEx() failed\n" );
|
|
|
|
|
|
|
|
DeleteFileA( ttf_name );
|
|
|
|
ReleaseDC( NULL, dc );
|
|
|
|
}
|
|
|
|
|
2019-04-09 11:33:00 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT majorVersion;
|
|
|
|
USHORT minorVersion;
|
|
|
|
SHORT ascender;
|
|
|
|
SHORT descender;
|
|
|
|
SHORT lineGap;
|
|
|
|
USHORT advanceWidthMax;
|
|
|
|
SHORT minLeftSideBearing;
|
|
|
|
SHORT minRightSideBearing;
|
|
|
|
SHORT xMaxExtent;
|
|
|
|
SHORT caretSlopeRise;
|
|
|
|
SHORT caretSlopeRun;
|
|
|
|
SHORT caretOffset;
|
|
|
|
SHORT reserved[4];
|
|
|
|
SHORT metricDataFormat;
|
|
|
|
SHORT numberOfHMetrics;
|
|
|
|
} TT_Hori_Header;
|
|
|
|
|
|
|
|
static void test_GetCharWidthInfo(void)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hfont, hfont_prev;
|
|
|
|
LOGFONTA lf;
|
|
|
|
BOOL r;
|
|
|
|
DWORD ret, i;
|
|
|
|
OUTLINETEXTMETRICA otm;
|
|
|
|
TT_Hori_Header hhea;
|
|
|
|
struct char_width_info
|
|
|
|
{
|
|
|
|
INT lsb, rsb, unk;
|
|
|
|
} info, info2;
|
|
|
|
SHORT minLeftSideBearing, minRightSideBearing;
|
|
|
|
POINT pt[2];
|
|
|
|
const char* face_list[] = { "Symbol", "Ume Gothic", "MS Gothic" };
|
|
|
|
|
|
|
|
if (!pGetCharWidthInfo)
|
|
|
|
{
|
|
|
|
win_skip("GetCharWidthInfo is unavailable\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
|
|
|
|
/* test default (System) font */
|
|
|
|
memset(&info, 0xaa, sizeof(info));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info);
|
|
|
|
if (r) /* win10 1803 succeeds */
|
|
|
|
{
|
|
|
|
ok(info.lsb == 0, "expected 0, got %d\n", info.lsb);
|
|
|
|
ok(info.rsb == 0, "expected 0, got %d\n", info.rsb);
|
|
|
|
ok(info.unk == 0, "expected 0, got %d\n", info.unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
ret = GetOutlineTextMetricsA(hdc, sizeof(otm), &otm);
|
|
|
|
ok(ret != 0, "GetOutlineTextMetricsA failed\n");
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
|
|
|
|
/* test Tahoma at the em square size */
|
|
|
|
lf.lfHeight = -(int)otm.otmEMSquare;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
ret = GetFontData(hdc, MS_MAKE_TAG('h','h','e','a'), 0, &hhea, sizeof(hhea));
|
|
|
|
ok(ret == sizeof(hhea), "got %u\n", ret);
|
|
|
|
minLeftSideBearing = GET_BE_WORD(hhea.minLeftSideBearing);
|
|
|
|
minRightSideBearing = GET_BE_WORD(hhea.minRightSideBearing);
|
|
|
|
|
|
|
|
memset(&info, 0xaa, sizeof(info));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info);
|
|
|
|
ok(r, "GetCharWidthInfo failed\n");
|
|
|
|
ok(info.lsb == minLeftSideBearing, "expected %d, got %d\n", minLeftSideBearing, info.lsb);
|
|
|
|
ok(info.rsb == minRightSideBearing, "expected %d, got %d\n", minRightSideBearing, info.rsb);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
|
|
|
|
/* these values are scaled, try with smaller size */
|
|
|
|
lf.lfHeight /= 3;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
memset(&info2, 0xaa, sizeof(info2));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info2);
|
|
|
|
ok(r, "pGetCharWidthInfo failed\n");
|
|
|
|
ok(info2.lsb == info.lsb/3, "expected %d, got %d\n", info.lsb/3, info2.lsb);
|
|
|
|
ok(info2.rsb == info.rsb/3, "expected %d, got %d\n", info.rsb/3, info2.rsb);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
/* test with another mapping mode */
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
SetMapMode(hdc, MM_ISOTROPIC);
|
|
|
|
SetWindowExtEx(hdc, 2, 2, NULL);
|
|
|
|
SetViewportExtEx(hdc, 1, 1, NULL);
|
|
|
|
|
|
|
|
memset(pt, 0, sizeof(pt));
|
|
|
|
pt[0].y = otm.otmEMSquare;
|
|
|
|
DPtoLP(hdc, pt, 1);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfCharSet = ANSI_CHARSET;
|
|
|
|
lf.lfHeight = -abs(pt[0].y);
|
|
|
|
strcpy(lf.lfFaceName, "Tahoma");
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
ok(hfont_prev != NULL, "SelectObject failed\n");
|
|
|
|
|
|
|
|
memset(&info2, 0xaa, sizeof(info2));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info2);
|
|
|
|
ok(r, "GetCharWidthInfo failed\n");
|
|
|
|
pt[0].x = info.lsb; pt[0].y = 0;
|
|
|
|
pt[1].x = info.rsb; pt[1].y = 0;
|
|
|
|
DPtoLP(hdc, pt, 2);
|
|
|
|
ok(pt[0].x == info2.lsb, "expected %d, got %d\n", pt[0].x, info2.lsb);
|
|
|
|
ok(pt[1].x == info2.rsb, "expected %d, got %d\n", pt[1].x, info2.rsb);
|
|
|
|
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
|
|
|
|
/* test with synthetic fonts */
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(face_list); i++)
|
|
|
|
{
|
|
|
|
const char* face = face_list[i];
|
|
|
|
if (!is_truetype_font_installed(face))
|
|
|
|
{
|
|
|
|
skip("%s is not installed\n", face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfHeight = -256;
|
|
|
|
strcpy(lf.lfFaceName, face);
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
hfont_prev = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
memset(&info, 0xaa, sizeof(info));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info);
|
|
|
|
ok(r, "%s: GetCharWidthInfo failed\n", face);
|
|
|
|
|
|
|
|
/* test with synthetic bold */
|
|
|
|
lf.lfWeight = FW_BOLD;
|
|
|
|
lf.lfItalic = FALSE;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&info2, 0xaa, sizeof(info2));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info2);
|
|
|
|
ok(r, "%s: GetCharWidthInfo failed\n", face);
|
|
|
|
ok(info.lsb == info2.lsb, "%s: expected %d, got %d\n", face, info.lsb, info2.lsb);
|
|
|
|
ok(info.rsb == info2.rsb, "%s: expected %d, got %d\n", face, info.rsb, info2.rsb);
|
|
|
|
|
|
|
|
/* test with synthetic italic */
|
|
|
|
lf.lfWeight = FW_NORMAL;
|
|
|
|
lf.lfItalic = TRUE;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont));
|
|
|
|
|
|
|
|
memset(&info2, 0xaa, sizeof(info2));
|
|
|
|
r = pGetCharWidthInfo(hdc, &info2);
|
|
|
|
ok(r, "%s: GetCharWidthInfo failed\n", face);
|
|
|
|
todo_wine ok(info.lsb > info2.lsb, "%s: expected less than %d, got %d\n", face, info.lsb, info2.lsb);
|
|
|
|
todo_wine ok(info.rsb > info2.rsb, "%s: expected less than %d, got %d\n", face, info.rsb, info2.rsb);
|
|
|
|
DeleteObject(SelectObject(hdc, hfont_prev));
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
}
|
|
|
|
|
2019-09-26 16:17:03 +02:00
|
|
|
static int CALLBACK get_char_width_proc(const LOGFONTA *lf,
|
|
|
|
const TEXTMETRICA *tm, DWORD type, LPARAM ctx)
|
|
|
|
{
|
|
|
|
HFONT font = CreateFontIndirectA(lf);
|
|
|
|
HDC dc = GetDC(NULL);
|
|
|
|
const char c = 'm';
|
|
|
|
ABCFLOAT abcf;
|
|
|
|
int i, i32;
|
|
|
|
BOOL ret;
|
|
|
|
float f;
|
|
|
|
ABC abc;
|
|
|
|
|
|
|
|
SelectObject(dc, font);
|
|
|
|
|
|
|
|
ret = GetCharWidthFloatA(dc, c, c, &f);
|
|
|
|
ok(ret, "%s: GetCharWidthFloat() failed\n", lf->lfFaceName);
|
|
|
|
ret = GetCharWidth32A(dc, c, c, &i32);
|
|
|
|
ok(ret, "%s: GetCharWidth32A() failed\n", lf->lfFaceName);
|
|
|
|
ret = GetCharWidthA(dc, c, c, &i);
|
|
|
|
ok(ret, "%s: GetCharWidthA() failed\n", lf->lfFaceName);
|
|
|
|
ok(i == i32, "%s: mismatched widths %d/%d\n", lf->lfFaceName, i, i32);
|
|
|
|
ok((float)i / 16.0f == f, "%s: mismatched widths %d/%.8e\n", lf->lfFaceName, i, f);
|
|
|
|
|
|
|
|
ret = GetCharABCWidthsFloatA(dc, c, c, &abcf);
|
|
|
|
ok(ret, "%s: GetCharABCWidths() failed\n", lf->lfFaceName);
|
|
|
|
if (GetCharABCWidthsA(dc, c, c, &abc))
|
|
|
|
ok((float)abc.abcB == abcf.abcfB, "%s: mismatched widths %d/%.8e\n",
|
|
|
|
lf->lfFaceName, abc.abcB, abcf.abcfB);
|
|
|
|
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
DeleteObject(font);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_char_width(void)
|
|
|
|
{
|
|
|
|
HDC dc = GetDC(NULL);
|
|
|
|
LOGFONTA lf = {0};
|
|
|
|
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
EnumFontFamiliesExA(dc, &lf, get_char_width_proc, 0, 0);
|
|
|
|
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:20:51 +02:00
|
|
|
static void test_GetCharacterPlacement_kerning(void)
|
|
|
|
{
|
|
|
|
LOGFONTA lf;
|
|
|
|
HFONT hfont, hfont_old;
|
|
|
|
KERNINGPAIR *kp;
|
|
|
|
HDC hdc;
|
|
|
|
DWORD count, ret, i, size, width, width_kern, idx;
|
|
|
|
WCHAR str[30];
|
|
|
|
GCP_RESULTSW result;
|
|
|
|
int kern[30], pos[30], pos_kern[30], dx[30], dx_kern[30], kern_amount;
|
|
|
|
|
|
|
|
if (!is_font_installed("Arial"))
|
|
|
|
{
|
|
|
|
skip("Arial is not installed, skipping the test\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
|
|
|
|
memset(&lf, 0, sizeof(lf));
|
|
|
|
strcpy(lf.lfFaceName, "Arial");
|
|
|
|
lf.lfHeight = 120;
|
|
|
|
hfont = CreateFontIndirectA(&lf);
|
|
|
|
ok(hfont != NULL, "CreateFontIndirect failed\n");
|
|
|
|
|
|
|
|
hfont_old = SelectObject(hdc, hfont);
|
|
|
|
|
|
|
|
count = GetKerningPairsW(hdc, 0, NULL);
|
|
|
|
kp = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*kp));
|
|
|
|
|
|
|
|
ret = GetKerningPairsW(hdc, count, kp);
|
|
|
|
ok(ret == count, "got %u, expected %u\n", ret, count);
|
|
|
|
|
|
|
|
size = kern_amount = idx = 0;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (kp[i].wFirst >= 'A' && kp[i].wFirst <= 'z' &&
|
|
|
|
kp[i].wSecond >= 'A' && kp[i].wSecond <= 'z')
|
|
|
|
{
|
|
|
|
str[size++] = kp[i].wFirst;
|
|
|
|
str[size++] = kp[i].wSecond;
|
|
|
|
str[size++] = 0;
|
|
|
|
kern[idx] = kp[i].iKernAmount;
|
|
|
|
idx++;
|
|
|
|
kern_amount += kp[i].iKernAmount;
|
|
|
|
if (size >= ARRAY_SIZE(str)) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, kp);
|
|
|
|
|
|
|
|
count = size;
|
|
|
|
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
result.lStructSize = sizeof(result);
|
|
|
|
result.lpCaretPos = pos;
|
|
|
|
result.lpDx = dx;
|
|
|
|
result.nGlyphs = count;
|
|
|
|
ret = GetCharacterPlacementW(hdc, str, count, 0, &result, 0);
|
|
|
|
ok(ret, "GetCharacterPlacement failed\n");
|
|
|
|
ok(result.nGlyphs == count, "got %u\n", result.nGlyphs);
|
|
|
|
width = LOWORD(ret);
|
|
|
|
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
result.lStructSize = sizeof(result);
|
|
|
|
result.lpCaretPos = pos_kern;
|
|
|
|
result.lpDx = dx_kern;
|
|
|
|
result.nGlyphs = count;
|
|
|
|
ret = GetCharacterPlacementW(hdc, str, count, 0, &result, GCP_USEKERNING);
|
|
|
|
ok(ret, "GetCharacterPlacement failed\n");
|
|
|
|
ok(result.nGlyphs == count, "got %u\n", result.nGlyphs);
|
|
|
|
width_kern = LOWORD(ret);
|
|
|
|
|
|
|
|
if (width == width_kern)
|
|
|
|
{
|
|
|
|
win_skip("GCP_USEKERNING is broken on this platform\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(width + kern_amount == width_kern, "%d + %d != %d\n", width, kern_amount, width_kern);
|
|
|
|
|
|
|
|
kern_amount = idx = 0;
|
|
|
|
for (i = 0; i < count; i += 3, idx++)
|
|
|
|
{
|
|
|
|
ok(pos[i] + kern_amount == pos_kern[i], "%d: %d + %d != %d\n", i, pos[i], kern_amount, pos_kern[i]);
|
|
|
|
kern_amount += kern[idx];
|
|
|
|
ok(pos[i+1] + kern_amount == pos_kern[i+1], "%d: %d + %d != %d\n", i, pos[i+1], kern_amount, pos_kern[i+1]);
|
|
|
|
ok(pos[i+2] + kern_amount == pos_kern[i+2], "%d: %d + %d != %d\n", i, pos[i+2], kern_amount, pos_kern[i+2]);
|
|
|
|
|
|
|
|
ok(dx[i] + kern[idx] == dx_kern[i], "%d: %d + %d != %d\n", i, dx[i], kern[idx], dx_kern[i]);
|
|
|
|
ok(dx[i+1] == dx_kern[i+1], "%d: %d != %d\n", i, dx[i+1], dx_kern[i+1]);
|
|
|
|
ok(dx[i+2] == dx_kern[i+2], "%d: %d != %d\n", i, dx[i+2], dx_kern[i+2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
SelectObject(hdc, hfont_old);
|
|
|
|
DeleteObject(hfont);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:59:27 +02:00
|
|
|
START_TEST(font)
|
|
|
|
{
|
2018-11-21 13:54:00 +01:00
|
|
|
static const char *test_names[] =
|
|
|
|
{
|
|
|
|
"AddFontMemResource",
|
|
|
|
};
|
|
|
|
char path_name[MAX_PATH];
|
|
|
|
STARTUPINFOA startup;
|
|
|
|
char **argv;
|
|
|
|
int argc, i;
|
|
|
|
|
2007-03-05 17:29:04 +01:00
|
|
|
init();
|
2010-05-18 13:53:18 +02:00
|
|
|
|
2018-11-21 13:54:00 +01:00
|
|
|
argc = winetest_get_mainargs(&argv);
|
|
|
|
if (argc >= 3)
|
|
|
|
{
|
|
|
|
if (!strcmp(argv[2], "AddFontMemResource"))
|
|
|
|
test_AddFontMemResource();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-04 05:05:25 +02:00
|
|
|
test_stock_fonts();
|
2006-04-03 14:59:27 +02:00
|
|
|
test_logfont();
|
|
|
|
test_bitmap_font();
|
2008-06-24 09:13:31 +02:00
|
|
|
test_outline_font();
|
2006-04-03 14:59:27 +02:00
|
|
|
test_bitmap_font_metrics();
|
|
|
|
test_GdiGetCharDimensions();
|
2007-12-08 22:55:01 +01:00
|
|
|
test_GetCharABCWidths();
|
2006-04-03 14:59:27 +02:00
|
|
|
test_text_extents();
|
2006-08-23 16:49:13 +02:00
|
|
|
test_GetGlyphIndices();
|
2006-09-21 09:10:53 +02:00
|
|
|
test_GetKerningPairs();
|
2007-02-02 11:18:15 +01:00
|
|
|
test_GetOutlineTextMetrics();
|
2007-02-08 16:12:08 +01:00
|
|
|
test_SetTextJustification();
|
2007-02-15 08:52:33 +01:00
|
|
|
test_font_charset();
|
2013-02-26 02:31:20 +01:00
|
|
|
test_GdiGetCodePage();
|
2007-03-01 20:30:12 +01:00
|
|
|
test_GetFontUnicodeRanges();
|
2007-07-31 18:57:34 +02:00
|
|
|
test_nonexistent_font();
|
2008-07-22 02:54:01 +02:00
|
|
|
test_orientation();
|
2010-05-18 13:53:18 +02:00
|
|
|
test_height_selection();
|
2011-02-14 10:55:03 +01:00
|
|
|
test_EnumFonts();
|
2015-07-17 11:23:14 +02:00
|
|
|
test_EnumFonts_subst();
|
2007-07-05 16:27:20 +02:00
|
|
|
|
2007-03-06 12:14:25 +01:00
|
|
|
/* On Windows Arial has a lot of default charset aliases such as Arial Cyr,
|
|
|
|
* I'd like to avoid them in this test.
|
|
|
|
*/
|
|
|
|
test_EnumFontFamilies("Arial Black", ANSI_CHARSET);
|
|
|
|
test_EnumFontFamilies("Symbol", SYMBOL_CHARSET);
|
|
|
|
if (is_truetype_font_installed("Arial Black") &&
|
|
|
|
(is_truetype_font_installed("Symbol") || is_truetype_font_installed("Wingdings")))
|
|
|
|
{
|
|
|
|
test_EnumFontFamilies("", ANSI_CHARSET);
|
|
|
|
test_EnumFontFamilies("", SYMBOL_CHARSET);
|
|
|
|
test_EnumFontFamilies("", DEFAULT_CHARSET);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
skip("Arial Black or Symbol/Wingdings is not installed\n");
|
2011-04-01 14:19:52 +02:00
|
|
|
test_EnumFontFamiliesEx_default_charset();
|
2007-03-15 07:12:09 +01:00
|
|
|
test_GetTextMetrics();
|
2015-08-13 16:39:19 +02:00
|
|
|
test_RealizationInfo();
|
2008-06-20 00:59:57 +02:00
|
|
|
test_GetTextFace();
|
2009-02-03 10:55:19 +01:00
|
|
|
test_GetGlyphOutline();
|
2009-10-07 10:50:32 +02:00
|
|
|
test_GetTextMetrics2("Tahoma", -11);
|
|
|
|
test_GetTextMetrics2("Tahoma", -55);
|
|
|
|
test_GetTextMetrics2("Tahoma", -110);
|
|
|
|
test_GetTextMetrics2("Arial", -11);
|
|
|
|
test_GetTextMetrics2("Arial", -55);
|
|
|
|
test_GetTextMetrics2("Arial", -110);
|
2018-07-16 09:30:57 +02:00
|
|
|
test_GetCharacterPlacement();
|
2020-07-09 16:20:51 +02:00
|
|
|
test_GetCharacterPlacement_kerning();
|
2019-04-09 11:33:00 +02:00
|
|
|
test_GetCharWidthInfo();
|
2009-11-13 23:05:20 +01:00
|
|
|
test_CreateFontIndirect();
|
2010-06-11 17:39:40 +02:00
|
|
|
test_CreateFontIndirectEx();
|
2009-12-30 11:44:21 +01:00
|
|
|
test_oemcharset();
|
2011-05-10 22:38:05 +02:00
|
|
|
test_fullname();
|
2012-09-07 12:39:51 +02:00
|
|
|
test_fullname2();
|
2012-02-08 17:32:58 +01:00
|
|
|
test_east_asian_font_selection();
|
2013-05-08 14:11:20 +02:00
|
|
|
test_max_height();
|
2013-06-18 14:42:00 +02:00
|
|
|
test_vertical_order();
|
2013-09-11 14:46:53 +02:00
|
|
|
test_GetCharWidth32();
|
2013-10-17 14:25:06 +02:00
|
|
|
test_fake_bold_font();
|
2013-12-11 13:11:17 +01:00
|
|
|
test_bitmap_font_glyph_index();
|
2017-04-12 23:47:39 +02:00
|
|
|
test_GetCharWidthI();
|
2017-11-26 14:33:17 +01:00
|
|
|
test_long_names();
|
2020-09-07 15:18:53 +02:00
|
|
|
test_ttf_names();
|
2020-09-17 19:30:42 +02:00
|
|
|
test_lang_names();
|
2019-09-26 16:17:03 +02:00
|
|
|
test_char_width();
|
2012-02-09 17:39:27 +01:00
|
|
|
|
|
|
|
/* These tests should be last test until RemoveFontResource
|
2011-08-30 04:59:42 +02:00
|
|
|
* is properly implemented.
|
|
|
|
*/
|
2012-02-09 17:39:27 +01:00
|
|
|
test_vertical_font();
|
2011-08-30 04:59:42 +02:00
|
|
|
test_CreateScalableFontResource();
|
2018-11-21 13:54:00 +01:00
|
|
|
|
|
|
|
winetest_get_mainargs( &argv );
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_names); ++i)
|
|
|
|
{
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
|
|
|
|
memset(&startup, 0, sizeof(startup));
|
|
|
|
startup.cb = sizeof(startup);
|
|
|
|
sprintf(path_name, "%s font %s", argv[0], test_names[i]);
|
|
|
|
ok(CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info),
|
|
|
|
"CreateProcess failed.\n");
|
2020-03-16 23:52:21 +01:00
|
|
|
wait_child_process(info.hProcess);
|
2018-11-21 13:54:00 +01:00
|
|
|
CloseHandle(info.hProcess);
|
|
|
|
CloseHandle(info.hThread);
|
|
|
|
}
|
2006-04-03 14:59:27 +02:00
|
|
|
}
|