[PATCH] gdi32: Report unsubstituted font face names.
Alex Henrie
alexhenrie24 at gmail.com
Fri May 2 22:43:35 CDT 2014
This unrelated bug was discovered while investigating bug 19289.
The 6 test failures are not caused by this patch:
https://testbot.winehq.org/JobDetails.pl?Key=6777
https://testbot.winehq.org/JobDetails.pl?Key=6779
I'm not sure whether I should have used
strcpyW(elf.elfLogFont.lfFaceName, unsubstitutedFaceName);
or
strncpyW(elf.elfLogFont.lfFaceName, unsubstitutedFaceName, LF_FACESIZE);
---
dlls/gdi32/freetype.c | 16 +++++++++++-----
dlls/gdi32/tests/font.c | 11 +++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index cece358..1c139f4 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 LOGFONTW *l
}
static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list,
- FONTENUMPROCW proc, LPARAM lparam)
+ WCHAR *unsubstitutedFaceName, FONTENUMPROCW proc, LPARAM lparam)
{
ENUMLOGFONTEXW elf;
NEWTEXTMETRICEXW ntm;
@@ -5765,6 +5765,11 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
else
strcpyW(elf.elfFullName, family->FamilyName);
}
+ /* Make sure that MS Shell Dlg says "MS Shell Dlg" and not "Tahoma" */
+ if (unsubstitutedFaceName)
+ {
+ strcpyW(elf.elfLogFont.lfFaceName, unsubstitutedFaceName);
+ }
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),
@@ -5805,12 +5810,13 @@ static BOOL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc,
GDI_CheckNotLock();
EnterCriticalSection( &freetype_cs );
if(plf->lfFaceName[0]) {
- FontSubst *psub;
- psub = get_font_subst(&font_subst_list, plf->lfFaceName, plf->lfCharSet);
+ FontSubst *psub = get_font_subst(&font_subst_list, plf->lfFaceName, plf->lfCharSet);
+ WCHAR *unsubstitutedFaceName = NULL;
if(psub) {
TRACE("substituting %s -> %s\n", debugstr_w(plf->lfFaceName),
debugstr_w(psub->to.name));
+ unsubstitutedFaceName = plf->lfFaceName;
lf = *plf;
strcpyW(lf.lfFaceName, psub->to.name);
plf = &lf;
@@ -5821,14 +5827,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, plf)) continue;
- if (!enum_face_charsets(family, face, &enum_charsets, proc, lparam)) return FALSE;
+ if (!enum_face_charsets(family, face, &enum_charsets, unsubstitutedFaceName, 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 fa3b420..9efa2b5 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -4738,6 +4738,17 @@ 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 */
+ ret = EnumFontFamiliesA(hdc, "MS Shell Dlg", enum_fonts_proc, (LPARAM)&lf);
+ ok(!ret, "font MS Shell Dlg is not enumerated\n");
+ ret = strcmp(lf.lfFaceName, "MS Shell Dlg");
+ ok(!ret, "expected MS Shell Dlg got %s\n", lf.lfFaceName);
+
+ ret = EnumFontFamiliesA(hdc, "MS Shell Dlg 2", enum_fonts_proc, (LPARAM)&lf);
+ ok(!ret, "font MS Shell Dlg 2 is not enumerated\n");
+ ret = strcmp(lf.lfFaceName, "MS Shell Dlg 2");
+ ok(!ret, "expected MS Shell Dlg 2 got %s\n", lf.lfFaceName);
+
DeleteDC(hdc);
}
--
1.8.3.2
More information about the wine-patches
mailing list