From d641792ff29cae3ef92bbc76f593e9262b4789ef Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 19 Feb 2014 18:00:24 +0100 Subject: Fix QFontMetrics width Commit f4dd534 introduced a regression, so that QFontMetrics reported a wrong size (to be more specific width) for FreeType fonts. The calculation of glyph advances has to to reflect (rounded) integral number of pixels. This was only done when the glyph was cached. So in some cases the first call to QFontMetrics::size gave a different result than the second. This patch reverts f4dd5344fbbce257a40e014acc4e87f4773f40. The tst_QFontMetrics::same auto test only happened to work on some platforms, on BlackBerry for instance it did not. Extended the test case to make sure it works for different font sizes. Change-Id: Ia5bb9abd3ff98193c9bba048b85207672ed8d9c3 Reviewed-by: Konstantin Ritt --- tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 7adaac9fac..d3f5ce4a7d 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -100,6 +100,12 @@ void tst_QFontMetrics::same() const QString text = QLatin1String("Some stupid STRING"); QCOMPARE(fm.size(0, text), fm.size(0, text)) ; + for (int i = 10; i <= 32; ++i) { + font.setPixelSize(i); + QFontMetrics fm1(font); + QCOMPARE(fm1.size(0, text), fm1.size(0, text)); + } + { QImage image; QFontMetrics fm2(font, &image); -- cgit v1.2.3