gdi32/tests: Test extended TTF font names and collisions.

This shows that although Windows is only matching family names up to
LF_FACESIZE chars, and that it doesn't match against the preferred /
typographic family names and styles, it still keeps the faces separate
when the full names don't match. Wine incorrectly discard one of them.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-09-07 15:18:53 +02:00 committed by Alexandre Julliard
parent 595f2846b2
commit afc857436a
7 changed files with 249 additions and 0 deletions

View File

@ -22,6 +22,8 @@ FONT_SRCS = \
vertical.sfd \
wine_longname.sfd \
wine_test.sfd \
wine_ttfnames.sfd \
wine_ttfnames_bold.sfd \
wine_vdmx.sfd
RC_SRCS = resource.rc

View File

@ -6940,6 +6940,76 @@ static void test_long_names(void)
ReleaseDC(NULL, dc);
}
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);
todo_wine
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);
todo_wine
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);
todo_wine
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);
}
typedef struct
{
USHORT majorVersion;
@ -7351,6 +7421,7 @@ START_TEST(font)
test_bitmap_font_glyph_index();
test_GetCharWidthI();
test_long_names();
test_ttf_names();
test_char_width();
/* These tests should be last test until RemoveFontResource

View File

@ -31,3 +31,9 @@ vertical.ttf RCDATA vertical.ttf
/* @makedep: wine_longname.ttf */
wine_longname.ttf RCDATA wine_longname.ttf
/* @makedep: wine_ttfnames.ttf */
wine_ttfnames.ttf RCDATA wine_ttfnames.ttf
/* @makedep: wine_ttfnames_bold.ttf */
wine_ttfnames_bold.ttf RCDATA wine_ttfnames_bold.ttf

View File

@ -0,0 +1,85 @@
SplineFontDB: 3.2
FontName: Wine_TTF_Names_Long_Family1_Cond_Regular
FamilyName: Wine_TTF_Names_Long_Family1_Cond
Weight: Regular
Copyright: Copyright (c) 2020, Remi Bernon for CodeWeavers
UComments: "2017-11-17: Created with FontForge (http://fontforge.org)"
Version: 001.000
ItalicAngle: 0
UnderlinePosition: -102
UnderlineWidth: 51
Ascent: 819
Descent: 205
InvalidEm: 0
LayerCount: 2
Layer: 0 0 "Back" 1
Layer: 1 0 "Fore" 0
XUID: [1021 48 28337276 3092883]
OS2Version: 0
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1510948643
ModificationTime: 1598865292
OS2TypoAscent: 0
OS2TypoAOffset: 1
OS2TypoDescent: 0
OS2TypoDOffset: 1
OS2TypoLinegap: 0
OS2WinAscent: 0
OS2WinAOffset: 1
OS2WinDescent: 0
OS2WinDOffset: 1
HheadAscent: 0
HheadAOffset: 1
HheadDescent: 0
HheadDOffset: 1
OS2Vendor: 'PfEd'
MarkAttachClasses: 1
DEI: 91125
LangName: 1033 \
"" \
"Wine TTF Names Long Family1 Cond" \
"Regular" \
"" \
"Wine TTF Names Long Family1 Extremely Long Full Name Condensed" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"Wine TTF Names Long Family1" \
"Condensed Regular" \
Encoding: ISO8859-1
UnicodeInterp: none
NameList: AGL For New Fonts
DisplaySize: -48
AntiAlias: 1
FitToEm: 0
WinInfo: 64 16 4
BeginPrivate: 0
EndPrivate
BeginChars: 256 1
StartChar: at
Encoding: 64 64 0
Width: 1024
VWidth: 0
Flags: HW
LayerCount: 2
Fore
SplineSet
259 332 m 29
468 664 l 29
514 332 l 29
259 332 l 29
EndSplineSet
EndChar
EndChars
EndSplineFont

Binary file not shown.

View File

@ -0,0 +1,85 @@
SplineFontDB: 3.2
FontName: Wine_TTF_Names_Long_Family1_Cond_Regular
FamilyName: Wine_TTF_Names_Long_Family1_Cond
Weight: Regular
Copyright: Copyright (c) 2020, Remi Bernon for CodeWeavers
UComments: "2017-11-17: Created with FontForge (http://fontforge.org)"
Version: 001.000
ItalicAngle: 0
UnderlinePosition: -102
UnderlineWidth: 51
Ascent: 819
Descent: 205
InvalidEm: 0
LayerCount: 2
Layer: 0 0 "Back" 1
Layer: 1 0 "Fore" 0
XUID: [1021 48 28337276 3092883]
OS2Version: 0
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1510948643
ModificationTime: 1598865292
OS2TypoAscent: 0
OS2TypoAOffset: 1
OS2TypoDescent: 0
OS2TypoDOffset: 1
OS2TypoLinegap: 0
OS2WinAscent: 0
OS2WinAOffset: 1
OS2WinDescent: 0
OS2WinDOffset: 1
HheadAscent: 0
HheadAOffset: 1
HheadDescent: 0
HheadDOffset: 1
OS2Vendor: 'PfEd'
MarkAttachClasses: 1
DEI: 91125
LangName: 1033 \
"" \
"Wine TTF Names Long Family1 CondBold" \
"Regular" \
"" \
"Wine TTF Names Long Family1 Extremely Long Full Name Condensed Bold" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"" \
"Wine TTF Names Long Family1" \
"Condensed Bold Regular" \
Encoding: ISO8859-1
UnicodeInterp: none
NameList: AGL For New Fonts
DisplaySize: -48
AntiAlias: 1
FitToEm: 0
WinInfo: 64 16 4
BeginPrivate: 0
EndPrivate
BeginChars: 256 1
StartChar: at
Encoding: 64 64 0
Width: 1024
VWidth: 0
Flags: HW
LayerCount: 2
Fore
SplineSet
259 332 m 29
468 664 l 29
514 332 l 29
259 332 l 29
EndSplineSet
EndChar
EndChars
EndSplineFont

Binary file not shown.