Fix bounding box of DirectWrite font engine

Vertical bearings of the font were ignored, giving the wrong height.
Also, the left bearing is right bound in DirectWrite, so the sign
should be flipped.

Task-number: QTBUG-22649
Change-Id: I82934f5b08e68e46d1b2221b35008bf9d75c5748
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2012-07-09 14:14:36 +02:00 committed by Qt by Nokia
parent bcf6333c6f
commit 6fb5b6fa58

View File

@ -434,6 +434,8 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g)
QFixed rightSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.rightSideBearing);
QFixed advanceHeight = DESIGN_TO_LOGICAL(glyphMetrics.advanceHeight);
QFixed verticalOriginY = DESIGN_TO_LOGICAL(glyphMetrics.verticalOriginY);
QFixed topSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.topSideBearing);
QFixed bottomSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.bottomSideBearing);
if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
advanceWidth = advanceWidth.round();
@ -441,10 +443,13 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox(glyph_t g)
}
QFixed width = advanceWidth - leftSideBearing - rightSideBearing;
return glyph_metrics_t(-leftSideBearing, -verticalOriginY,
width, m_ascent + m_descent,
advanceWidth, advanceHeight);
QFixed height = advanceHeight - topSideBearing - bottomSideBearing;
return glyph_metrics_t(leftSideBearing,
-verticalOriginY + topSideBearing,
width,
height,
advanceWidth,
advanceHeight);
} else {
qErrnoWarning("%s: GetDesignGlyphMetrics failed", __FUNCTION__);
}