summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-09-28 14:57:20 (GMT)
committerAlessandro Portale <alessandro.portale@nokia.com>2010-09-28 14:57:20 (GMT)
commitc4ef479906f073fa84999eb950f00e264ebd4e8e (patch)
treebac14192b21cb3c533961dda3abc42f6e5b94fc7 /tests
parent1341477e03dae2f9bc5ddb25beeb2ba3cd23358f (diff)
downloadQt-c4ef479906f073fa84999eb950f00e264ebd4e8e.zip
Qt-c4ef479906f073fa84999eb950f00e264ebd4e8e.tar.gz
Qt-c4ef479906f073fa84999eb950f00e264ebd4e8e.tar.bz2
Fix QFontMetrics::lineWidth() for fonts with defined point size
QFontMetrics::lineWidth() and ::underlinePos() return value 1 regardless of the font size if the size was defined in points (instead of pixels). (On Symbian) QFontMetrics::lineWidth() calls QFontEngine::lineThickness() which uses its fontDef.pixelSize in order to come up with a suitable line width. If the QFont size was defined in points, Qt needs to make sure that fontDef.pixelSize is set accordingly. This patch adds the code to make sure that QFontEngine::fontDef always has a valid pixel size. tst_QFontMetrics::lineWidth() was added, wich failed before and passes after this patch. Task-Number: QTBUG-13009 Autotest: Passes Reviewed-By: Eskil
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfontmetrics/tst_qfontmetrics.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
index a22d624..41121a5 100644
--- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp
@@ -74,6 +74,7 @@ private slots:
void bypassShaping();
void elidedMultiLength();
void elidedMultiLengthF();
+ void lineWidth();
};
tst_QFontMetrics::tst_QFontMetrics()
@@ -266,5 +267,22 @@ void tst_QFontMetrics::elidedMultiLengthF()
elidedMultiLength_helper<QFontMetricsF>();
}
+void tst_QFontMetrics::lineWidth()
+{
+ // QTBUG-13009, QTBUG-13011
+ QFont smallFont;
+ smallFont.setPointSize(8);
+ smallFont.setWeight(QFont::Light);
+ const QFontMetrics smallFontMetrics(smallFont);
+
+ QFont bigFont;
+ bigFont.setPointSize(40);
+ bigFont.setWeight(QFont::Black);
+ const QFontMetrics bigFontMetrics(bigFont);
+
+ QVERIFY(smallFontMetrics.lineWidth() >= 1);
+ QVERIFY(smallFontMetrics.lineWidth() < bigFontMetrics.lineWidth());
+}
+
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"