From: Alex Henrie Subject: gdi32: Report unsubstituted font face names. (try 5) Message-Id: <20140508164824.36eefd17380308abc7161a79@gmail.com> Date: Thu, 8 May 2014 16:48:24 -0600 I kept the full name tests, but now they make sure that the full name is a SUBSTITUTED font name. --- dlls/gdi32/freetype.c | 15 ++++++++++++--- dlls/gdi32/tests/font.c | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index fae9ffe..ac6aa8f 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -5731,7 +5731,7 @@ static BOOL face_matches(const WCHAR *family_name, Face *face, const WCHAR *face } static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list, - FONTENUMPROCW proc, LPARAM lparam) + WCHAR *unsubstituted_face_name, FONTENUMPROCW proc, LPARAM lparam) { ENUMLOGFONTEXW elf; NEWTEXTMETRICEXW ntm; @@ -5765,6 +5765,13 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha else strcpyW(elf.elfFullName, family->FamilyName); } + /* MS Shell Dlg's face name is "MS Shell Dlg", not "Tahoma" or similar */ + /* MS Shell Dlg's full name is still "Tahoma" or similar */ + /* The same rule applies to other substituted fonts like Tms Rmn */ + if (unsubstituted_face_name) + { + lstrcpynW(elf.elfLogFont.lfFaceName, unsubstituted_face_name, LF_FACESIZE); + } TRACE("enuming face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n", debugstr_w(elf.elfLogFont.lfFaceName), debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle), @@ -5806,12 +5813,14 @@ static BOOL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, EnterCriticalSection( &freetype_cs ); if(plf->lfFaceName[0]) { WCHAR *face_name = plf->lfFaceName; + WCHAR *unsubstituted_face_name = NULL; FontSubst *psub = get_font_subst(&font_subst_list, plf->lfFaceName, plf->lfCharSet); if(psub) { TRACE("substituting %s -> %s\n", debugstr_w(plf->lfFaceName), debugstr_w(psub->to.name)); face_name = psub->to.name; + unsubstituted_face_name = plf->lfFaceName; } LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) { @@ -5819,14 +5828,14 @@ static BOOL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, face_list = get_face_list_from_family(family); LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) { if (!face_matches(family->FamilyName, face, face_name)) continue; - if (!enum_face_charsets(family, face, &enum_charsets, proc, lparam)) return FALSE; + if (!enum_face_charsets(family, face, &enum_charsets, unsubstituted_face_name, proc, lparam)) return FALSE; } } } else { LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) { face_list = get_face_list_from_family(family); face = LIST_ENTRY(list_head(face_list), Face, entry); - if (!enum_face_charsets(family, face, &enum_charsets, proc, lparam)) return FALSE; + if (!enum_face_charsets(family, face, &enum_charsets, NULL, proc, lparam)) return FALSE; } } LeaveCriticalSection( &freetype_cs ); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 255771a..0a4a399 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4681,6 +4681,7 @@ static void test_EnumFonts(void) int ret; LOGFONTA lf; HDC hdc; + struct enum_fullname_data efnd; if (!is_truetype_font_installed("Arial")) { @@ -4741,6 +4742,28 @@ static void test_EnumFonts(void) ret = EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)&lf); ok(ret, "font Arial Italic Bold should not be enumerated\n"); + /* MS Shell Dlg and MS Shell Dlg 2 must exist */ + memset(&lf, 0, sizeof(lf)); + lf.lfCharSet = DEFAULT_CHARSET; + + memset(&efnd, 0, sizeof(efnd)); + strcpy(lf.lfFaceName, "MS Shell Dlg"); + ret = EnumFontFamiliesExA(hdc, &lf, enum_fullname_data_proc, (LPARAM)&efnd, 0); + ok(ret, "font MS Shell Dlg is not enumerated\n"); + ret = strcmp((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((char*)efnd.elf[0].elfFullName, "MS Shell Dlg"); + ok(ret, "did not expect MS Shell Dlg\n"); + + memset(&efnd, 0, sizeof(efnd)); + strcpy(lf.lfFaceName, "MS Shell Dlg 2"); + ret = EnumFontFamiliesExA(hdc, &lf, enum_fullname_data_proc, (LPARAM)&efnd, 0); + ok(ret, "font MS Shell Dlg 2 is not enumerated\n"); + ret = strcmp((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((char*)efnd.elf[0].elfFullName, "MS Shell Dlg 2"); + ok(ret, "did not expect MS Shell Dlg 2\n"); + DeleteDC(hdc); } -- 1.9.1