Dmitry Timoshkov : gdi32: EnumFontFamilies should also match against fully qualified face name.

Alexandre Julliard julliard at winehq.org
Thu Feb 24 11:43:26 CST 2011


Module: wine
Branch: master
Commit: 2aaf6c2c8cdde2e09ddfa745f1dab48cbf693769
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2aaf6c2c8cdde2e09ddfa745f1dab48cbf693769

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Mon Feb 14 17:54:25 2011 +0800

gdi32: EnumFontFamilies should also match against fully qualified face name.

---

 dlls/gdi32/freetype.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 506c994..512e08b 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -4064,6 +4064,54 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
     free_font(font);
 }
 
+static BOOL family_matches(Family *family, const LOGFONTW *lf)
+{
+    struct list *face_elem_ptr;
+
+    if (!strcmpiW(lf->lfFaceName, family->FamilyName)) return TRUE;
+
+    LIST_FOR_EACH(face_elem_ptr, &family->faces)
+    {
+        static const WCHAR spaceW[] = { ' ',0 };
+        WCHAR full_family_name[LF_FULLFACESIZE];
+        Face *face = LIST_ENTRY(face_elem_ptr, Face, entry);
+
+        if (strlenW(family->FamilyName) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE)
+        {
+            FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
+                  debugstr_w(family->FamilyName), debugstr_w(face->StyleName));
+            continue;
+        }
+
+        strcpyW(full_family_name, family->FamilyName);
+        strcatW(full_family_name, spaceW);
+        strcatW(full_family_name, face->StyleName);
+        if (!strcmpiW(lf->lfFaceName, full_family_name)) return TRUE;
+    }
+
+    return FALSE;
+}
+
+static BOOL face_matches(Face *face, const LOGFONTW *lf)
+{
+    static const WCHAR spaceW[] = { ' ',0 };
+    WCHAR full_family_name[LF_FULLFACESIZE];
+
+    if (!strcmpiW(lf->lfFaceName, face->family->FamilyName)) return TRUE;
+
+    if (strlenW(face->family->FamilyName) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE)
+    {
+        FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
+              debugstr_w(face->family->FamilyName), debugstr_w(face->StyleName));
+        return FALSE;
+    }
+
+    strcpyW(full_family_name, face->family->FamilyName);
+    strcatW(full_family_name, spaceW);
+    strcatW(full_family_name, face->StyleName);
+    return !strcmpiW(lf->lfFaceName, full_family_name);
+}
+
 /*************************************************************
  * WineEngEnumFonts
  *
@@ -4107,9 +4155,12 @@ DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
 
         LIST_FOR_EACH(family_elem_ptr, &font_list) {
             family = LIST_ENTRY(family_elem_ptr, Family, entry);
-            if(!strcmpiW(plf->lfFaceName, family->FamilyName)) {
+            if(family_matches(family, plf)) {
                 LIST_FOR_EACH(face_elem_ptr, &family->faces) {
                     face = LIST_ENTRY(face_elem_ptr, Face, entry);
+
+                    if (!face_matches(face, plf)) continue;
+
                     GetEnumStructs(face, &elf, &ntm, &type);
                     for(i = 0; i < 32; i++) {
                         if(!face->scalable && face->fs.fsCsb[0] == 0) { /* OEM bitmap */




More information about the wine-cvs mailing list