Commit 50b6b376 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

gdi32: EnumFontFamilies should enumerate substituted fonts only when directly asked for.

parent 5289c9fd
...@@ -5774,7 +5774,7 @@ static BOOL face_matches(const WCHAR *family_name, Face *face, const WCHAR *face ...@@ -5774,7 +5774,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, static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list,
FONTENUMPROCW proc, LPARAM lparam) FONTENUMPROCW proc, LPARAM lparam, const WCHAR *subst)
{ {
ENUMLOGFONTEXW elf; ENUMLOGFONTEXW elf;
NEWTEXTMETRICEXW ntm; NEWTEXTMETRICEXW ntm;
...@@ -5808,6 +5808,8 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha ...@@ -5808,6 +5808,8 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
else else
strcpyW(elf.elfFullName, family->FamilyName); strcpyW(elf.elfFullName, family->FamilyName);
} }
if (subst)
strcpyW(elf.elfLogFont.lfFaceName, subst);
TRACE("enuming face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n", 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.elfLogFont.lfFaceName),
debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle), debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
...@@ -5862,14 +5864,14 @@ static BOOL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc, ...@@ -5862,14 +5864,14 @@ static BOOL freetype_EnumFonts( PHYSDEV dev, LPLOGFONTW plf, FONTENUMPROCW proc,
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_matches(family->FamilyName, face, face_name)) continue; 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, proc, lparam, psub ? psub->from.name : NULL)) return FALSE;
} }
} }
} else { } else {
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);
face = LIST_ENTRY(list_head(face_list), Face, entry); 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, proc, lparam, NULL)) return FALSE;
} }
} }
LeaveCriticalSection( &freetype_cs ); LeaveCriticalSection( &freetype_cs );
......
...@@ -5051,12 +5051,9 @@ static void test_EnumFonts_subst(void) ...@@ -5051,12 +5051,9 @@ static void test_EnumFonts_subst(void)
memset(&efnd, 0, sizeof(efnd)); memset(&efnd, 0, sizeof(efnd));
strcpy(lf.lfFaceName, "MS Shell Dlg"); strcpy(lf.lfFaceName, "MS Shell Dlg");
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg_proc, (LPARAM)&efnd, 0); ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg_proc, (LPARAM)&efnd, 0);
todo_wine
ok(!ret, "MS Shell Dlg should be enumerated\n"); ok(!ret, "MS Shell Dlg should be enumerated\n");
todo_wine
ok(efnd.total > 0, "MS Shell Dlg should be enumerated\n"); ok(efnd.total > 0, "MS Shell Dlg should be enumerated\n");
ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg"); ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg");
todo_wine
ok(!ret, "expected MS Shell Dlg, got %s\n", efnd.elf[0].elfLogFont.lfFaceName); ok(!ret, "expected MS Shell Dlg, got %s\n", efnd.elf[0].elfLogFont.lfFaceName);
ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg"); ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg");
ok(ret, "did not expect MS Shell Dlg\n"); ok(ret, "did not expect MS Shell Dlg\n");
...@@ -5069,12 +5066,9 @@ todo_wine ...@@ -5069,12 +5066,9 @@ todo_wine
memset(&efnd, 0, sizeof(efnd)); memset(&efnd, 0, sizeof(efnd));
strcpy(lf.lfFaceName, "MS Shell Dlg 2"); strcpy(lf.lfFaceName, "MS Shell Dlg 2");
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg2_proc, (LPARAM)&efnd, 0); ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg2_proc, (LPARAM)&efnd, 0);
todo_wine
ok(!ret, "MS Shell Dlg 2 should be enumerated\n"); ok(!ret, "MS Shell Dlg 2 should be enumerated\n");
todo_wine
ok(efnd.total > 0, "MS Shell Dlg 2 should be enumerated\n"); ok(efnd.total > 0, "MS Shell Dlg 2 should be enumerated\n");
ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg 2"); ret = strcmp((const char *)efnd.elf[0].elfLogFont.lfFaceName, "MS Shell Dlg 2");
todo_wine
ok(!ret, "expected MS Shell Dlg 2, got %s\n", efnd.elf[0].elfLogFont.lfFaceName); ok(!ret, "expected MS Shell Dlg 2, got %s\n", efnd.elf[0].elfLogFont.lfFaceName);
ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg 2"); ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg 2");
ok(ret, "did not expect MS Shell Dlg 2\n"); ok(ret, "did not expect MS Shell Dlg 2\n");
......
...@@ -630,11 +630,15 @@ GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, ...@@ -630,11 +630,15 @@ GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi,
static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf, static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
const TEXTMETRICW *ntm, DWORD type, LPARAM lParam) const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
{ {
const ENUMLOGFONTW *elfW = (const ENUMLOGFONTW *)elf;
LOGFONTW *lf = (LOGFONTW *)lParam;
if (type & RASTER_FONTTYPE) if (type & RASTER_FONTTYPE)
return 1; return 1;
*(LOGFONTW *)lParam = *elf; *lf = *elf;
/* replace substituted font name by a real one */
lstrcpynW(lf->lfFaceName, elfW->elfFullName, LF_FACESIZE);
return 0; return 0;
} }
...@@ -656,8 +660,6 @@ static BOOL get_font_metrics(HDC hdc, struct font_metrics *fm) ...@@ -656,8 +660,6 @@ static BOOL get_font_metrics(HDC hdc, struct font_metrics *fm)
otm.otmSize = sizeof(otm); otm.otmSize = sizeof(otm);
if (!GetOutlineTextMetricsW(hdc, otm.otmSize, &otm)) return FALSE; if (!GetOutlineTextMetricsW(hdc, otm.otmSize, &otm)) return FALSE;
GetTextFaceW(hdc, LF_FACESIZE, fm->facename);
fm->em_height = otm.otmEMSquare; fm->em_height = otm.otmEMSquare;
fm->dpi = GetDeviceCaps(hdc, LOGPIXELSY); fm->dpi = GetDeviceCaps(hdc, LOGPIXELSY);
...@@ -706,6 +708,8 @@ static GpStatus find_installed_font(const WCHAR *name, struct font_metrics *fm) ...@@ -706,6 +708,8 @@ static GpStatus find_installed_font(const WCHAR *name, struct font_metrics *fm)
{ {
HFONT hfont, old_font; HFONT hfont, old_font;
strcpyW(fm->facename, lf.lfFaceName);
hfont = CreateFontIndirectW(&lf); hfont = CreateFontIndirectW(&lf);
old_font = SelectObject(hdc, hfont); old_font = SelectObject(hdc, hfont);
ret = get_font_metrics(hdc, fm) ? Ok : NotTrueTypeFont; ret = get_font_metrics(hdc, fm) ? Ok : NotTrueTypeFont;
......
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