summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorBernd Weimer <bweimer@blackberry.com>2014-02-19 18:00:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-20 20:13:27 +0100
commitd641792ff29cae3ef92bbc76f593e9262b4789ef (patch)
tree9bfe649d393135bada63352d88a247a8e8b539aa /tests/auto/gui
parent2d22e737757c959fff103a4a99fbd896ef09597b (diff)
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 <ritt.ks@gmail.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp6
1 files changed, 6 insertions, 0 deletions
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);