[PATCH 4/5] dwrite: Improve the way font weight is set with both OS/2 and 'head' values
Nikolay Sivov
nsivov at codeweavers.com
Mon Aug 10 05:50:59 CDT 2015
---
-------------- next part --------------
>From fd0e4c6fe8bd6587168d99711e0d8b46afab454d Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri, 7 Aug 2015 17:50:44 +0300
Subject: [PATCH 4/5] 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);
--
2.1.4
More information about the wine-patches
mailing list