Nikolay Sivov : dwrite: Improve the way font weight is set with both OS/ 2 and 'head' values.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Aug 12 09:17:54 CDT 2015


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Aug 10 13:50:59 2015 +0300

dwrite: Improve the way font weight is set with both OS/2 and 'head' values.

---

 dlls/dwrite/opentype.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index 57660a3..c6d4ec3 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -1041,11 +1041,19 @@ void opentype_get_font_properties(IDWriteFontFileStream *stream, DWRITE_FONT_FAC
     if (tt_os2) {
         USHORT version = GET_BE_WORD(tt_os2->version);
         USHORT fsSelection = GET_BE_WORD(tt_os2->fsSelection);
+        USHORT usWeightClass = GET_BE_WORD(tt_os2->usWeightClass);
 
         if (GET_BE_WORD(tt_os2->usWidthClass) <= DWRITE_FONT_STRETCH_ULTRA_EXPANDED)
             props->stretch = GET_BE_WORD(tt_os2->usWidthClass);
 
-        props->weight = GET_BE_WORD(tt_os2->usWeightClass);
+        if (usWeightClass >= 1 && usWeightClass <= 9)
+            usWeightClass *= 100;
+
+        if (usWeightClass > DWRITE_FONT_WEIGHT_ULTRA_BLACK)
+            props->weight = DWRITE_FONT_WEIGHT_ULTRA_BLACK;
+        else
+            props->weight = usWeightClass;
+
         if (version >= 4 && (fsSelection & OS2_FSSELECTION_OBLIQUE))
             props->style = DWRITE_FONT_STYLE_OBLIQUE;
         else if (fsSelection & OS2_FSSELECTION_ITALIC)
@@ -1054,13 +1062,17 @@ void opentype_get_font_properties(IDWriteFontFileStream *stream, DWRITE_FONT_FAC
     }
     else if (tt_head) {
         USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
-        if (macStyle & TT_HEAD_MACSTYLE_ITALIC)
-            props->style = DWRITE_FONT_STYLE_ITALIC;
 
         if (macStyle & TT_HEAD_MACSTYLE_CONDENSED)
             props->stretch = DWRITE_FONT_STRETCH_CONDENSED;
         else if (macStyle & TT_HEAD_MACSTYLE_EXTENDED)
             props->stretch = DWRITE_FONT_STRETCH_EXPANDED;
+
+        if (macStyle & TT_HEAD_MACSTYLE_BOLD)
+            props->weight = DWRITE_FONT_WEIGHT_BOLD;
+
+        if (macStyle & TT_HEAD_MACSTYLE_ITALIC)
+            props->style = DWRITE_FONT_STYLE_ITALIC;
     }
 
     TRACE("stretch=%d, weight=%d, style %d\n", props->stretch, props->weight, props->style);




More information about the wine-cvs mailing list