Akihiro Sagawa : win32u: Use a real family name as otmpFamilyName for substituted face.

Alexandre Julliard julliard at winehq.org
Mon Nov 8 15:45:05 CST 2021


Module: wine
Branch: master
Commit: 0d1b8adc9c12045816d56cdf09b7dd2378c3d4b2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0d1b8adc9c12045816d56cdf09b7dd2378c3d4b2

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Thu Nov  4 23:18:23 2021 +0900

win32u: Use a real family name as otmpFamilyName for substituted face.

GetTextFace remains to return the original face name, e.g. MS Shell Dlg.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/tests/font.c     |  2 +-
 dlls/win32u/font.c          | 26 +++++++++++++-------------
 dlls/win32u/ntgdi_private.h |  1 +
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index a8880c263ae..11150685bcd 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -7822,7 +7822,7 @@ static void test_GetOutlineTextMetrics_subst(void)
 
     /* family name */
     family_name = (const char*)otm + (UINT_PTR)otm->otmpFamilyName;
-    todo_wine ok(lstrcmpiA(lf.lfFaceName, family_name), "expected a real family name (e.g. Tahoma), got %s\n", family_name);
+    ok(lstrcmpiA(lf.lfFaceName, family_name), "expected a real family name (e.g. Tahoma), got %s\n", family_name);
 
     HeapFree(GetProcessHeap(), 0, otm);
     SelectObject(hdc, hfont_old);
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c
index e1603b3698a..1ac48e67d65 100644
--- a/dlls/win32u/font.c
+++ b/dlls/win32u/font.c
@@ -1866,7 +1866,7 @@ static struct gdi_font_face *find_any_face( const LOGFONTW *lf, FONTSIGNATURE fs
 }
 
 static struct gdi_font_face *find_matching_face( const LOGFONTW *lf, CHARSETINFO *csi, BOOL can_use_bitmap,
-                                                 const WCHAR **orig_name )
+                                                 BOOL *substituted )
 {
     BOOL want_vertical = (lf->lfFaceName[0] == '@');
     struct gdi_font_face *face;
@@ -1888,13 +1888,13 @@ static struct gdi_font_face *find_matching_face( const LOGFONTW *lf, CHARSETINFO
                    debugstr_w(subst), (subst_charset != -1) ? subst_charset : lf->lfCharSet );
 	    if (subst_charset != -1)
                 translate_charset_info( (DWORD *)(INT_PTR)subst_charset, csi, TCI_SRCCHARSET );
-            *orig_name = lf->lfFaceName;
+            *substituted = TRUE;
 	}
 
         if ((face = find_matching_face_by_name( lf->lfFaceName, subst, lf, csi->fs, can_use_bitmap )))
             return face;
     }
-    *orig_name = NULL; /* substitution is no longer relevant */
+    *substituted = FALSE; /* substitution is no longer relevant */
 
     /* If requested charset was DEFAULT_CHARSET then try using charset
        corresponding to the current ansi codepage */
@@ -2055,7 +2055,7 @@ static void free_gdi_font( struct gdi_font *font )
 
 static inline const WCHAR *get_gdi_font_name( struct gdi_font *font )
 {
-    return (WCHAR *)font->otm.otmpFamilyName;
+    return font->use_logfont_name ? font->lf.lfFaceName : (WCHAR *)font->otm.otmpFamilyName;
 }
 
 static struct gdi_font *create_gdi_font( const struct gdi_font_face *face, const WCHAR *family_name,
@@ -2481,10 +2481,7 @@ static void create_child_font_list( struct gdi_font *font )
 {
     struct gdi_font_link *font_link;
     struct gdi_font_link_entry *entry;
-    const WCHAR* font_name;
-
-    if (!(font_name = get_gdi_font_subst( get_gdi_font_name(font), -1, NULL )))
-        font_name = get_gdi_font_name( font );
+    const WCHAR* font_name = (WCHAR *)font->otm.otmpFaceName;
 
     if ((font_link = find_gdi_font_link( font_name )))
     {
@@ -3951,6 +3948,7 @@ static BOOL CDECL font_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices,
 static INT CDECL font_GetTextFace( PHYSDEV dev, INT count, WCHAR *str )
 {
     struct font_physdev *physdev = get_font_dev( dev );
+    const WCHAR *font_name;
     INT len;
 
     if (!physdev->font)
@@ -3958,10 +3956,11 @@ static INT CDECL font_GetTextFace( PHYSDEV dev, INT count, WCHAR *str )
         dev = GET_NEXT_PHYSDEV( dev, pGetTextFace );
         return dev->funcs->pGetTextFace( dev, count, str );
     }
-    len = lstrlenW( get_gdi_font_name(physdev->font) ) + 1;
+    font_name = get_gdi_font_name( physdev->font );
+    len = lstrlenW( font_name ) + 1;
     if (str)
     {
-        lstrcpynW( str, get_gdi_font_name(physdev->font), count );
+        lstrcpynW( str, font_name, count );
         len = min( count, len );
     }
     return len;
@@ -4079,7 +4078,7 @@ static struct gdi_font *select_font( LOGFONTW *lf, FMAT2 dcmat, BOOL can_use_bit
     struct gdi_font_face *face;
     INT height;
     CHARSETINFO csi;
-    const WCHAR *orig_name = NULL;
+    BOOL substituted = FALSE;
 
     static const WCHAR symbolW[] = {'S','y','m','b','o','l',0};
 
@@ -4095,14 +4094,15 @@ static struct gdi_font *select_font( LOGFONTW *lf, FMAT2 dcmat, BOOL can_use_bit
         TRACE( "returning cached gdiFont(%p)\n", font );
         return font;
     }
-    if (!(face = find_matching_face( lf, &csi, can_use_bitmap, &orig_name )))
+    if (!(face = find_matching_face( lf, &csi, can_use_bitmap, &substituted )))
     {
         FIXME( "can't find a single appropriate font - bailing\n" );
         return NULL;
     }
     height = lf->lfHeight;
 
-    font = create_gdi_font( face, orig_name, lf );
+    font = create_gdi_font( face, NULL, lf );
+    font->use_logfont_name = substituted;
     font->matrix = dcmat;
     font->can_use_bitmap = can_use_bitmap;
     if (!csi.fs.fsCsb[0]) get_nearest_charset( face->family->family_name, face, &csi );
diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h
index a8a855f5cc4..b678cd14539 100644
--- a/dlls/win32u/ntgdi_private.h
+++ b/dlls/win32u/ntgdi_private.h
@@ -275,6 +275,7 @@ struct gdi_font
     BOOL                   fake_italic : 1;
     BOOL                   fake_bold : 1;
     BOOL                   scalable : 1;
+    BOOL                   use_logfont_name : 1;
     struct gdi_font       *base_font;
     void                  *gsub_table;
     void                  *vert_feature;




More information about the wine-cvs mailing list