[3/4] gdi32: EnumFontFamilies should enumerate substituted fonts only when directly asked for.

Dmitry Timoshkov dmitry at baikal.ru
Fri Jul 17 04:23:19 CDT 2015


I.e. EnumFontFamilies(NULL) won't enumerate substituted fonts, but
EnumFontFamilies("MS Shell Dlg") will do.

As a part of this patch GetTextFace() no longer returns real font names
for substituted fonts (there is a test that confirms that this is correct
behaviour), but this breaks gdiplus assumptions about GetTextFace() and
therefore gdiplus should be fixed as well.

Part1 of the fix for bug 19289.
---
 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 73824ea..1dd889f 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -5761,7 +5761,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;
@@ -5795,6 +5795,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),
@@ -5849,14 +5851,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;
-- 
2.4.5




More information about the wine-patches mailing list