mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 18:43:37 +00:00
gdi32: In AddFaceToList allow fonts with long names and add tests.
Signed-off-by: Fabian Maurer <dark.shadow4@web.de> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
67926ec8c3
commit
6f790606c0
|
@ -1027,7 +1027,7 @@ static Face *find_face_from_filename(const WCHAR *file_name, const WCHAR *face_n
|
||||||
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
||||||
{
|
{
|
||||||
const struct list *face_list;
|
const struct list *face_list;
|
||||||
if(face_name && strcmpiW(face_name, family->FamilyName))
|
if(face_name && strncmpiW(face_name, family->FamilyName, LF_FACESIZE - 1))
|
||||||
continue;
|
continue;
|
||||||
face_list = get_face_list_from_family(family);
|
face_list = get_face_list_from_family(family);
|
||||||
LIST_FOR_EACH_ENTRY(face, face_list, Face, entry)
|
LIST_FOR_EACH_ENTRY(face, face_list, Face, entry)
|
||||||
|
@ -1053,7 +1053,7 @@ static Family *find_family_from_name(const WCHAR *name)
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
||||||
{
|
{
|
||||||
if(!strcmpiW(family->FamilyName, name))
|
if(!strncmpiW(family->FamilyName, name, LF_FACESIZE -1))
|
||||||
return family;
|
return family;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,9 +1066,9 @@ static Family *find_family_from_any_name(const WCHAR *name)
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
||||||
{
|
{
|
||||||
if(!strcmpiW(family->FamilyName, name))
|
if(!strncmpiW(family->FamilyName, name, LF_FACESIZE - 1))
|
||||||
return family;
|
return family;
|
||||||
if(family->EnglishName && !strcmpiW(family->EnglishName, name))
|
if(family->EnglishName && !strncmpiW(family->EnglishName, name, LF_FACESIZE - 1))
|
||||||
return family;
|
return family;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2141,13 +2141,6 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
|
||||||
|
|
||||||
face = create_face( ft_face, face_index, file, font_data_ptr, font_data_size, flags );
|
face = create_face( ft_face, face_index, file, font_data_ptr, font_data_size, flags );
|
||||||
family = get_family( ft_face, flags & ADDFONT_VERTICAL_FONT );
|
family = get_family( ft_face, flags & ADDFONT_VERTICAL_FONT );
|
||||||
if (strlenW(family->FamilyName) >= LF_FACESIZE)
|
|
||||||
{
|
|
||||||
WARN("Ignoring %s because name is too long\n", debugstr_w(family->FamilyName));
|
|
||||||
release_face( face );
|
|
||||||
release_family( family );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (insert_face_in_family_list( face, family ))
|
if (insert_face_in_family_list( face, family ))
|
||||||
{
|
{
|
||||||
|
@ -2471,7 +2464,7 @@ static SYSTEM_LINKS *find_font_link(const WCHAR *name)
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
||||||
{
|
{
|
||||||
if(!strcmpiW(font_link->font_name, name))
|
if(!strncmpiW(font_link->font_name, name, LF_FACESIZE - 1))
|
||||||
return font_link;
|
return font_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4320,7 +4313,7 @@ static BOOL move_to_front(const WCHAR *name)
|
||||||
Family *family, *cursor2;
|
Family *family, *cursor2;
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(family, cursor2, &font_list, Family, entry)
|
LIST_FOR_EACH_ENTRY_SAFE(family, cursor2, &font_list, Family, entry)
|
||||||
{
|
{
|
||||||
if(!strcmpiW(family->FamilyName, name))
|
if(!strncmpiW(family->FamilyName, name, LF_FACESIZE - 1))
|
||||||
{
|
{
|
||||||
list_remove(&family->entry);
|
list_remove(&family->entry);
|
||||||
list_add_head(&font_list, &family->entry);
|
list_add_head(&font_list, &family->entry);
|
||||||
|
@ -5476,8 +5469,8 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
|
||||||
or if that's unavailable the first charset that the font supports.
|
or if that's unavailable the first charset that the font supports.
|
||||||
*/
|
*/
|
||||||
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
||||||
if (!strcmpiW(family->FamilyName, FaceName) ||
|
if (!strncmpiW(family->FamilyName, FaceName, LF_FACESIZE - 1) ||
|
||||||
(psub && !strcmpiW(family->FamilyName, psub->to.name)))
|
(psub && !strncmpiW(family->FamilyName, psub->to.name, LF_FACESIZE - 1)))
|
||||||
{
|
{
|
||||||
font_link = find_font_link(family->FamilyName);
|
font_link = find_font_link(family->FamilyName);
|
||||||
face_list = get_face_list_from_family(family);
|
face_list = get_face_list_from_family(family);
|
||||||
|
@ -5499,7 +5492,7 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
|
||||||
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
||||||
face_list = get_face_list_from_family(family);
|
face_list = get_face_list_from_family(family);
|
||||||
LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
|
LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
|
||||||
if(face->FullName && !strcmpiW(face->FullName, FaceName) &&
|
if(face->FullName && !strncmpiW(face->FullName, FaceName, LF_FACESIZE - 1) &&
|
||||||
(face->scalable || can_use_bitmap))
|
(face->scalable || can_use_bitmap))
|
||||||
{
|
{
|
||||||
if (csi.fs.fsCsb[0] & face->fs.fsCsb[0] || !csi.fs.fsCsb[0])
|
if (csi.fs.fsCsb[0] & face->fs.fsCsb[0] || !csi.fs.fsCsb[0])
|
||||||
|
@ -5518,8 +5511,8 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
|
||||||
*/
|
*/
|
||||||
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
||||||
{
|
{
|
||||||
if(!strcmpiW(font_link->font_name, FaceName) ||
|
if(!strncmpiW(font_link->font_name, FaceName, LF_FACESIZE - 1) ||
|
||||||
(psub && !strcmpiW(font_link->font_name,psub->to.name)))
|
(psub && !strncmpiW(font_link->font_name,psub->to.name, LF_FACESIZE - 1)))
|
||||||
{
|
{
|
||||||
TRACE("found entry in system list\n");
|
TRACE("found entry in system list\n");
|
||||||
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
||||||
|
@ -5569,7 +5562,7 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
|
||||||
else
|
else
|
||||||
strcpyW(lf.lfFaceName, defSans);
|
strcpyW(lf.lfFaceName, defSans);
|
||||||
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
|
||||||
if(!strcmpiW(family->FamilyName, lf.lfFaceName)) {
|
if(!strncmpiW(family->FamilyName, lf.lfFaceName, LF_FACESIZE - 1)) {
|
||||||
font_link = find_font_link(family->FamilyName);
|
font_link = find_font_link(family->FamilyName);
|
||||||
face_list = get_face_list_from_family(family);
|
face_list = get_face_list_from_family(family);
|
||||||
LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
|
LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
|
||||||
|
@ -6037,20 +6030,20 @@ static BOOL family_matches(Family *family, const WCHAR *face_name)
|
||||||
Face *face;
|
Face *face;
|
||||||
const struct list *face_list;
|
const struct list *face_list;
|
||||||
|
|
||||||
if (!strcmpiW(face_name, family->FamilyName)) return TRUE;
|
if (!strncmpiW(face_name, family->FamilyName, LF_FACESIZE - 1)) return TRUE;
|
||||||
|
|
||||||
face_list = get_face_list_from_family(family);
|
face_list = get_face_list_from_family(family);
|
||||||
LIST_FOR_EACH_ENTRY(face, face_list, Face, entry)
|
LIST_FOR_EACH_ENTRY(face, face_list, Face, entry)
|
||||||
if (face->FullName && !strcmpiW(face_name, face->FullName)) return TRUE;
|
if (face->FullName && !strncmpiW(face_name, face->FullName, LF_FACESIZE - 1)) return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL face_matches(const WCHAR *family_name, Face *face, const WCHAR *face_name)
|
static BOOL face_matches(const WCHAR *family_name, Face *face, const WCHAR *face_name)
|
||||||
{
|
{
|
||||||
if (!strcmpiW(face_name, family_name)) return TRUE;
|
if (!strncmpiW(face_name, family_name, LF_FACESIZE - 1)) return TRUE;
|
||||||
|
|
||||||
return (face->FullName && !strcmpiW(face_name, face->FullName));
|
return (face->FullName && !strncmpiW(face_name, face->FullName, LF_FACESIZE - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list,
|
static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list,
|
||||||
|
@ -6082,11 +6075,11 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
|
||||||
/* Font Replacement */
|
/* Font Replacement */
|
||||||
if (family != face->family)
|
if (family != face->family)
|
||||||
{
|
{
|
||||||
strcpyW(elf.elfLogFont.lfFaceName, family->FamilyName);
|
lstrcpynW(elf.elfLogFont.lfFaceName, family->FamilyName, LF_FACESIZE);
|
||||||
if (face->FullName)
|
if (face->FullName)
|
||||||
strcpyW(elf.elfFullName, face->FullName);
|
lstrcpynW(elf.elfFullName, face->FullName, LF_FULLFACESIZE);
|
||||||
else
|
else
|
||||||
strcpyW(elf.elfFullName, family->FamilyName);
|
lstrcpynW(elf.elfFullName, family->FamilyName, LF_FULLFACESIZE);
|
||||||
}
|
}
|
||||||
if (subst)
|
if (subst)
|
||||||
strcpyW(elf.elfLogFont.lfFaceName, subst);
|
strcpyW(elf.elfLogFont.lfFaceName, subst);
|
||||||
|
|
|
@ -19,6 +19,7 @@ C_SRCS = \
|
||||||
|
|
||||||
FONT_SRCS = \
|
FONT_SRCS = \
|
||||||
vertical.sfd \
|
vertical.sfd \
|
||||||
|
wine_longname.sfd \
|
||||||
wine_test.sfd \
|
wine_test.sfd \
|
||||||
wine_vdmx.sfd
|
wine_vdmx.sfd
|
||||||
|
|
||||||
|
|
|
@ -6679,6 +6679,59 @@ static void test_GetCharWidthI(void)
|
||||||
ReleaseDC(0, hdc);
|
ReleaseDC(0, hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(font)
|
START_TEST(font)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -6742,6 +6795,7 @@ START_TEST(font)
|
||||||
test_fake_bold_font();
|
test_fake_bold_font();
|
||||||
test_bitmap_font_glyph_index();
|
test_bitmap_font_glyph_index();
|
||||||
test_GetCharWidthI();
|
test_GetCharWidthI();
|
||||||
|
test_long_names();
|
||||||
|
|
||||||
/* These tests should be last test until RemoveFontResource
|
/* These tests should be last test until RemoveFontResource
|
||||||
* is properly implemented.
|
* is properly implemented.
|
||||||
|
|
|
@ -28,3 +28,6 @@ wine_vdmx.ttf RCDATA wine_vdmx.ttf
|
||||||
|
|
||||||
/* @makedep: vertical.ttf */
|
/* @makedep: vertical.ttf */
|
||||||
vertical.ttf RCDATA vertical.ttf
|
vertical.ttf RCDATA vertical.ttf
|
||||||
|
|
||||||
|
/* @makedep: wine_longname.ttf */
|
||||||
|
wine_longname.ttf RCDATA wine_longname.ttf
|
||||||
|
|
66
dlls/gdi32/tests/wine_longname.sfd
Normal file
66
dlls/gdi32/tests/wine_longname.sfd
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
SplineFontDB: 3.0
|
||||||
|
FontName: wine_1_this_is_a_very_long_name_that_might_be_too_long_for_gdi32
|
||||||
|
FullName: wine_2_this_is_a_very_long_name_that_might_be_too_long_for_gdi32
|
||||||
|
FamilyName: wine_3_this_is_a_very_long_name_that_might_be_too_long_for_gdi32
|
||||||
|
Weight: Regular
|
||||||
|
Copyright: Copyright (c) 2017, Fabian Maurer
|
||||||
|
UComments: "2017-11-17: Created with FontForge (http://fontforge.org)"
|
||||||
|
Version: 001.000
|
||||||
|
ItalicAngle: 0
|
||||||
|
UnderlinePosition: -102.4
|
||||||
|
UnderlineWidth: 51.2
|
||||||
|
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: 1510949092
|
||||||
|
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
|
||||||
|
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
|
BIN
dlls/gdi32/tests/wine_longname.ttf
Normal file
BIN
dlls/gdi32/tests/wine_longname.ttf
Normal file
Binary file not shown.
Loading…
Reference in a new issue