From: Nikolay Sivov Subject: [PATCH 1/2] dwrite: Respect typographic metrics when font instructs us to Message-Id: <54784ACB.6010509@codeweavers.com> Date: Fri, 28 Nov 2014 13:13:31 +0300 --- From 2f631c09d6371b91760e482df9400609ee868c26 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 27 Nov 2014 14:59:00 +0300 Subject: [PATCH 1/2] dwrite: Respect typographic metrics when font instructs us to --- dlls/dwrite/opentype.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 8a22699..28923c5 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -185,6 +185,19 @@ typedef struct } TT_OS2_V2; #include "poppack.h" +enum OS2_FSSELECTION { + OS2_FSSELECTION_ITALIC = 1 << 0, + OS2_FSSELECTION_UNDERSCORE = 1 << 1, + OS2_FSSELECTION_NEGATIVE = 1 << 2, + OS2_FSSELECTION_OUTLINED = 1 << 3, + OS2_FSSELECTION_STRIKEOUT = 1 << 4, + OS2_FSSELECTION_BOLD = 1 << 5, + OS2_FSSELECTION_REGULAR = 1 << 6, + OS2_FSSELECTION_USE_TYPO_METRICS = 1 << 7, + OS2_FSSELECTION_WWS = 1 << 8, + OS2_FSSELECTION_OBLIQUE = 1 << 9 +}; + typedef struct { WORD platformID; WORD encodingID; @@ -875,8 +888,12 @@ void opentype_get_font_metrics(const void *os2, const void *head, const void *po } if (tt_os2) { + USHORT version = GET_BE_WORD(tt_os2->version); + metrics->ascent = GET_BE_WORD(tt_os2->usWinAscent); metrics->descent = GET_BE_WORD(tt_os2->usWinDescent); + /* FIXME: sTypoLineGap should only be used when USE_TYPO_METRICS is set, + if not set this value is probably derived from other metrics */ metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap); metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition); metrics->strikethroughThickness = GET_BE_WORD(tt_os2->yStrikeoutSize); @@ -891,10 +908,21 @@ void opentype_get_font_metrics(const void *os2, const void *head, const void *po metrics->superscriptSizeY = GET_BE_WORD(tt_os2->ySuperscriptYSize); /* version 2 fields */ - if (tt_os2->version >= 2) { + if (version >= 2) { metrics->capHeight = GET_BE_WORD(tt_os2->sCapHeight); metrics->xHeight = GET_BE_WORD(tt_os2->sxHeight); } + + /* version 4 fields */ + if (version >= 4) { + if (GET_BE_WORD(tt_os2->fsSelection) & OS2_FSSELECTION_USE_TYPO_METRICS) { + SHORT descent = GET_BE_WORD(tt_os2->sTypoDescender); + metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender); + metrics->descent = descent < 0 ? -descent : 0; + metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap); + metrics->hasTypographicMetrics = TRUE; + } + } } if (tt_post) { -- 2.1.3