Commit 6245f072 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

gdi32/tests: Test GetGlyphIndices with '\0' default and a glyph.

parent 4e9f855b
...@@ -24,6 +24,7 @@ FONT_SRCS = \ ...@@ -24,6 +24,7 @@ FONT_SRCS = \
wine_langnames2.sfd \ wine_langnames2.sfd \
wine_langnames3.sfd \ wine_langnames3.sfd \
wine_longname.sfd \ wine_longname.sfd \
wine_nul.sfd \
wine_test.sfd \ wine_test.sfd \
wine_ttfnames.sfd \ wine_ttfnames.sfd \
wine_ttfnames_bold.sfd \ wine_ttfnames_bold.sfd \
......
...@@ -1587,6 +1587,45 @@ static void test_text_extents(void) ...@@ -1587,6 +1587,45 @@ static void test_text_extents(void)
ReleaseDC(NULL, hdc); ReleaseDC(NULL, hdc);
} }
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;
}
static void test_GetGlyphIndices(void) static void test_GetGlyphIndices(void)
{ {
HDC hdc; HDC hdc;
...@@ -1598,6 +1637,10 @@ static void test_GetGlyphIndices(void) ...@@ -1598,6 +1637,10 @@ static void test_GetGlyphIndices(void)
WORD glyphs[(sizeof(testtext)/2)-1]; WORD glyphs[(sizeof(testtext)/2)-1];
TEXTMETRICA textm; TEXTMETRICA textm;
HFONT hOldFont; HFONT hOldFont;
HANDLE rsrc;
DWORD ret, font_size, num_fonts;
void *font;
char ttf_name[MAX_PATH];
if (!pGetGlyphIndicesW) { if (!pGetGlyphIndicesW) {
win_skip("GetGlyphIndicesW not available on platform\n"); win_skip("GetGlyphIndicesW not available on platform\n");
...@@ -1653,6 +1696,36 @@ static void test_GetGlyphIndices(void) ...@@ -1653,6 +1696,36 @@ static void test_GetGlyphIndices(void)
ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]); 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]); ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont)); DeleteObject(SelectObject(hdc, hOldFont));
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);
todo_wine ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
todo_wine ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont));
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());
} }
static void test_GetKerningPairs(void) static void test_GetKerningPairs(void)
...@@ -5000,45 +5073,6 @@ static void test_CreateFontIndirectEx(void) ...@@ -5000,45 +5073,6 @@ static void test_CreateFontIndirectEx(void)
DeleteObject(hfont); DeleteObject(hfont);
} }
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;
}
static void test_realization_info(const char *name, DWORD size, BOOL is_memory_resource) static void test_realization_info(const char *name, DWORD size, BOOL is_memory_resource)
{ {
struct font_realization_info info; struct font_realization_info info;
......
...@@ -46,3 +46,6 @@ wine_langnames2.ttf RCDATA wine_langnames2.ttf ...@@ -46,3 +46,6 @@ wine_langnames2.ttf RCDATA wine_langnames2.ttf
/* @makedep: wine_langnames3.ttf */ /* @makedep: wine_langnames3.ttf */
wine_langnames3.ttf RCDATA wine_langnames3.ttf wine_langnames3.ttf RCDATA wine_langnames3.ttf
/* @makedep: wine_nul.ttf */
wine_nul.ttf RCDATA wine_nul.ttf
SplineFontDB: 3.2
FontName: wine_nul
FullName: wine_nul
FamilyName: wine_nul
Weight: Medium
Copyright: Copyright (c) 2020 Remi Bernon for CodeWeavers
Version: 001.000
ItalicAngle: 0
UnderlinePosition: -205
UnderlineWidth: 102
Ascent: 1638
Descent: 410
InvalidEm: 0
sfntRevision: 0x00010000
LayerCount: 2
Layer: 0 1 "Back" 1
Layer: 1 1 "Fore" 0
XUID: [1021 905 592216984 1247726]
FSType: 32767
OS2Version: 2
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1607427474
ModificationTime: 1607428497
PfmFamily: 17
TTFWeight: 500
TTFWidth: 5
LineGap: 184
VLineGap: 0
Panose: 2 0 6 3 0 0 0 0 0 0
OS2TypoAscent: 0
OS2TypoAOffset: 1
OS2TypoDescent: 0
OS2TypoDOffset: 1
OS2TypoLinegap: 184
OS2WinAscent: 1638
OS2WinAOffset: 0
OS2WinDescent: 410
OS2WinDOffset: 0
HheadAscent: 0
HheadAOffset: 1
HheadDescent: 0
HheadDOffset: 1
OS2SubXSize: 1331
OS2SubYSize: 1433
OS2SubXOff: 0
OS2SubYOff: 286
OS2SupXSize: 1331
OS2SupYSize: 1433
OS2SupXOff: 0
OS2SupYOff: 983
OS2StrikeYSize: 102
OS2StrikeYPos: 530
OS2Vendor: 'Wine'
OS2CodePages: 00000001.00000000
OS2UnicodeRanges: 00000001.00000000.00000000.00000000
MarkAttachClasses: 1
DEI: 91125
ShortTable: cvt 2
68
1297
EndShort
ShortTable: maxp 16
1
0
4
8
2
0
0
2
0
1
1
0
64
46
0
0
EndShort
LangName: 1033 "" "" "" "Wine : wine_nul : 4-11-2010"
GaspTable: 1 65535 2 0
Encoding: ISO8859-1
UnicodeInterp: none
NameList: Adobe Glyph List
DisplaySize: -24
AntiAlias: 1
FitToEm: 1
WinInfo: 0 76 22
BeginPrivate: 0
EndPrivate
BeginChars: 256 1
StartChar: uni0000
Encoding: 0 0 0
Width: 2048
LayerCount: 2
Fore
SplineSet
667 1485 m 5,0,-1
1327 1485 l 1,1,-1
1327 0 l 1,2,-1
667 0 l 1,3,-1
667 1485 l 5,0,-1
601 1575 m 1,0,-1
1405 1575 l 1,1,-1
1405 -63 l 1,2,-1
601 -63 l 1,3,-1
601 1575 l 1,0,-1
EndSplineSet
EndChar
EndChars
EndSplineFont
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment