dwrite: Improve the way font weight is set with both OS/2 and 'head' values.
This commit is contained in:
parent
123c7cde07
commit
785c592ada
@ -1041,11 +1041,19 @@ void opentype_get_font_properties(IDWriteFontFileStream *stream, DWRITE_FONT_FAC
|
|||||||
if (tt_os2) {
|
if (tt_os2) {
|
||||||
USHORT version = GET_BE_WORD(tt_os2->version);
|
USHORT version = GET_BE_WORD(tt_os2->version);
|
||||||
USHORT fsSelection = GET_BE_WORD(tt_os2->fsSelection);
|
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)
|
if (GET_BE_WORD(tt_os2->usWidthClass) <= DWRITE_FONT_STRETCH_ULTRA_EXPANDED)
|
||||||
props->stretch = GET_BE_WORD(tt_os2->usWidthClass);
|
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))
|
if (version >= 4 && (fsSelection & OS2_FSSELECTION_OBLIQUE))
|
||||||
props->style = DWRITE_FONT_STYLE_OBLIQUE;
|
props->style = DWRITE_FONT_STYLE_OBLIQUE;
|
||||||
else if (fsSelection & OS2_FSSELECTION_ITALIC)
|
else if (fsSelection & OS2_FSSELECTION_ITALIC)
|
||||||
@ -1054,13 +1062,17 @@ void opentype_get_font_properties(IDWriteFontFileStream *stream, DWRITE_FONT_FAC
|
|||||||
}
|
}
|
||||||
else if (tt_head) {
|
else if (tt_head) {
|
||||||
USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
|
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)
|
if (macStyle & TT_HEAD_MACSTYLE_CONDENSED)
|
||||||
props->stretch = DWRITE_FONT_STRETCH_CONDENSED;
|
props->stretch = DWRITE_FONT_STRETCH_CONDENSED;
|
||||||
else if (macStyle & TT_HEAD_MACSTYLE_EXTENDED)
|
else if (macStyle & TT_HEAD_MACSTYLE_EXTENDED)
|
||||||
props->stretch = DWRITE_FONT_STRETCH_EXPANDED;
|
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);
|
TRACE("stretch=%d, weight=%d, style %d\n", props->stretch, props->weight, props->style);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user