Byeongsik Jeon : gdi32: Fix the linked child font bold, italic style correctly.

Alexandre Julliard julliard at winehq.org
Mon Nov 19 15:59:38 CST 2018


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

Author: Byeongsik Jeon <bsjeon at hanmail.net>
Date:   Tue Nov 13 18:38:03 2018 +0900

gdi32: Fix the linked child font bold, italic style correctly.

Signed-off-by: Byeongsik Jeon <bsjeon at hanmail.net>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/freetype.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 99b7d8c..3fc41c3 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -8116,8 +8116,30 @@ static UINT freetype_GetOutlineTextMetrics( PHYSDEV dev, UINT cbSize, OUTLINETEX
 
 static BOOL load_child_font(GdiFont *font, CHILD_FONT *child)
 {
+    const struct list *face_list;
+    Face *child_face = NULL, *best_face = NULL;
+    UINT penalty = 0, new_penalty = 0;
+    BOOL bold, italic, bd, it;
+
+    italic = font->font_desc.lf.lfItalic ? TRUE : FALSE;
+    bold = font->font_desc.lf.lfWeight > FW_MEDIUM ? TRUE : FALSE;
+
+    face_list = get_face_list_from_family( child->face->family );
+    LIST_FOR_EACH_ENTRY( child_face, face_list, Face, entry )
+    {
+        it = child_face->ntmFlags & NTM_ITALIC ? TRUE : FALSE;
+        bd = child_face->ntmFlags & NTM_BOLD ? TRUE : FALSE;
+        new_penalty = ( it ^ italic ) + ( bd ^ bold );
+        if (!best_face || new_penalty < penalty)
+        {
+            penalty = new_penalty;
+            best_face = child_face;
+        }
+    }
+    child_face = best_face ? best_face : child->face;
+
     child->font = alloc_font();
-    child->font->ft_face = OpenFontFace(child->font, child->face, 0, -font->ppem);
+    child->font->ft_face = OpenFontFace( child->font, child_face, 0, -font->ppem );
     if(!child->font->ft_face)
     {
         free_font(child->font);
@@ -8125,11 +8147,13 @@ static BOOL load_child_font(GdiFont *font, CHILD_FONT *child)
         return FALSE;
     }
 
+    child->font->fake_italic = italic && !( child_face->ntmFlags & NTM_ITALIC );
+    child->font->fake_bold = bold && !( child_face->ntmFlags & NTM_BOLD );
     child->font->font_desc = font->font_desc;
-    child->font->ntmFlags = child->face->ntmFlags;
+    child->font->ntmFlags = child_face->ntmFlags;
     child->font->orientation = font->orientation;
     child->font->scale_y = font->scale_y;
-    child->font->name = strdupW(child->face->family->FamilyName);
+    child->font->name = strdupW( child_face->family->FamilyName );
     child->font->base_font = font;
     TRACE("created child font %p for base %p\n", child->font, font);
     return TRUE;




More information about the wine-cvs mailing list