From cb8445f0323b0eefbb04f1d8adad81a00b53abd8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 3 Feb 2012 14:28:16 +0100 Subject: Remove historical +1 from font height calculation Historically, we've calculated font height as ascent+descent+1. In Qt 4, a patch was added to work around this by subtracting 1 from the descent of the font engines. We now remove the +1 and the work arounds. Change-Id: I7e25d49b97ac892015d3328f32d70eb9a7c2d88f Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 4 ++-- tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 0b5486dd5a..4dbdf9a4f1 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -140,7 +140,7 @@ void tst_QFontMetrics::metrics() font = fdb.font(family, style, 12); QFontMetrics fontmetrics(font); - QCOMPARE(fontmetrics.ascent() + fontmetrics.descent() + 1, + QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(), fontmetrics.height()); QCOMPARE(fontmetrics.height() + fontmetrics.leading(), @@ -156,7 +156,7 @@ void tst_QFontMetrics::metrics() font = fdb.font(family, style, size); QFontMetrics fontmetrics(font); - QCOMPARE(fontmetrics.ascent() + fontmetrics.descent() + 1, + QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(), fontmetrics.height()); QCOMPARE(fontmetrics.height() + fontmetrics.leading(), fontmetrics.lineSpacing()); diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index e7435743e5..8920e63957 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -352,7 +352,7 @@ void tst_QTextLayout::threeLineBoundingRect() QCOMPARE(qRound(line.naturalTextWidth()), thirdLineWidth); y += qRound(line.ascent() + line.descent()); - QCOMPARE(layout.boundingRect(), QRectF(0, 0, longestLine, y + 1)); + QCOMPARE(layout.boundingRect(), QRectF(0, 0, longestLine, y)); } void tst_QTextLayout::boundingRectWithLongLineAndNoWrap() @@ -386,7 +386,7 @@ void tst_QTextLayout::forcedBreaks() QCOMPARE(line.textStart(), pos); QCOMPARE(line.textLength(),2); QCOMPARE(qRound(line.naturalTextWidth()),testFont.pixelSize()); - QCOMPARE((int) line.height(), testFont.pixelSize() + 1); // + 1 baseline + QCOMPARE((int) line.height(), testFont.pixelSize()); QCOMPARE(line.xToCursor(0), line.textStart()); pos += line.textLength(); @@ -395,7 +395,7 @@ void tst_QTextLayout::forcedBreaks() QCOMPARE(line.textStart(),pos); QCOMPARE(line.textLength(),1); QCOMPARE(qRound(line.naturalTextWidth()), 0); - QCOMPARE((int) line.height(), testFont.pixelSize() + 1); // + 1 baseline + QCOMPARE((int) line.height(), testFont.pixelSize()); QCOMPARE(line.xToCursor(0), line.textStart()); pos += line.textLength(); @@ -404,7 +404,7 @@ void tst_QTextLayout::forcedBreaks() QCOMPARE(line.textStart(),pos); QCOMPARE(line.textLength(),2); QCOMPARE(qRound(line.naturalTextWidth()),testFont.pixelSize()); - QCOMPARE(qRound(line.height()), testFont.pixelSize() + 1); // + 1 baseline + QCOMPARE(qRound(line.height()), testFont.pixelSize()); QCOMPARE(line.xToCursor(0), line.textStart()); pos += line.textLength(); @@ -413,7 +413,7 @@ void tst_QTextLayout::forcedBreaks() QCOMPARE(line.textStart(),pos); QCOMPARE(line.textLength(),1); QCOMPARE(qRound(line.naturalTextWidth()), testFont.pixelSize()); - QCOMPARE((int) line.height(), testFont.pixelSize() + 1); // + 1 baseline + QCOMPARE((int) line.height(), testFont.pixelSize()); QCOMPARE(line.xToCursor(0), line.textStart()); } -- cgit v1.2.3