From 6fb5b6fa58df4b622d47a8d71ba0f5f2b938cd63 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 9 Jul 2012 14:14:36 +0200 Subject: 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 --- .../platforms/windows/qwindowsfontenginedirectwrite.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index e90c6b6048..3d10d5aa82 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -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__); } -- cgit v1.2.3