Dmitry Timoshkov : gdi32: EnumFontFamilies should enumerate substituted fonts only when directly asked for.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jul 17 08:03:41 CDT 2015
Module: wine
Branch: master
Commit: 50b6b376cbd521486c7765a11d88d17533f2057d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=50b6b376cbd521486c7765a11d88d17533f2057d
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Fri Jul 17 17:23:19 2015 +0800
gdi32: EnumFontFamilies should enumerate substituted fonts only when directly asked for.
---
dlls/gdi32/freetype.c | 8 +++++---
dlls/gdi32/tests/font.c | 6 ------
dlls/gdiplus/font.c | 12 ++++++++----
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index e57d1a9..9a7a3d7 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -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,
- FONTENUMPROCW proc, LPARAM lparam)
+ FONTENUMPROCW proc, LPARAM lparam, const WCHAR *subst)
{
ENUMLOGFONTEXW elf;
NEWTEXTMETRICEXW ntm;
@@ -5808,6 +5808,8 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
else
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",
debugstr_w(elf.elfLogFont.lfFaceName),
debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
@@ -5862,14 +5864,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, proc, lparam, psub ? psub->from.name : NULL)) 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, proc, lparam, NULL)) return FALSE;
}
}
LeaveCriticalSection( &freetype_cs );
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 1a663d7..cce4a1f 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -5051,12 +5051,9 @@ static void test_EnumFonts_subst(void)
memset(&efnd, 0, sizeof(efnd));
strcpy(lf.lfFaceName, "MS Shell Dlg");
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg_proc, (LPARAM)&efnd, 0);
-todo_wine
ok(!ret, "MS Shell Dlg should be enumerated\n");
-todo_wine
ok(efnd.total > 0, "MS Shell Dlg should be enumerated\n");
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);
ret = strcmp((const char *)efnd.elf[0].elfFullName, "MS Shell Dlg");
ok(ret, "did not expect MS Shell Dlg\n");
@@ -5069,12 +5066,9 @@ todo_wine
memset(&efnd, 0, sizeof(efnd));
strcpy(lf.lfFaceName, "MS Shell Dlg 2");
ret = EnumFontFamiliesExA(hdc, &lf, enum_ms_shell_dlg2_proc, (LPARAM)&efnd, 0);
-todo_wine
ok(!ret, "MS Shell Dlg 2 should be enumerated\n");
-todo_wine
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");
-todo_wine
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");
ok(ret, "did not expect MS Shell Dlg 2\n");
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 850f44a..3d8501e 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -630,11 +630,15 @@ GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi,
static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf,
const TEXTMETRICW *ntm, DWORD type, LPARAM lParam)
{
+ const ENUMLOGFONTW *elfW = (const ENUMLOGFONTW *)elf;
+ LOGFONTW *lf = (LOGFONTW *)lParam;
+
if (type & RASTER_FONTTYPE)
return 1;
- *(LOGFONTW *)lParam = *elf;
-
+ *lf = *elf;
+ /* replace substituted font name by a real one */
+ lstrcpynW(lf->lfFaceName, elfW->elfFullName, LF_FACESIZE);
return 0;
}
@@ -656,8 +660,6 @@ static BOOL get_font_metrics(HDC hdc, struct font_metrics *fm)
otm.otmSize = sizeof(otm);
if (!GetOutlineTextMetricsW(hdc, otm.otmSize, &otm)) return FALSE;
- GetTextFaceW(hdc, LF_FACESIZE, fm->facename);
-
fm->em_height = otm.otmEMSquare;
fm->dpi = GetDeviceCaps(hdc, LOGPIXELSY);
@@ -706,6 +708,8 @@ static GpStatus find_installed_font(const WCHAR *name, struct font_metrics *fm)
{
HFONT hfont, old_font;
+ strcpyW(fm->facename, lf.lfFaceName);
+
hfont = CreateFontIndirectW(&lf);
old_font = SelectObject(hdc, hfont);
ret = get_font_metrics(hdc, fm) ? Ok : NotTrueTypeFont;
More information about the wine-cvs
mailing list