From 1ee6fdc72c8f9903ef813341007156436f0758ea Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 8 Jan 2015 11:59:23 +0100 Subject: Fix QRawFont test when used with bundled FreeType The auto-hinter in the FreeType version bundled in Qt gives slightly different advances on some glyphs. As noted in the removed code, this was already observed on Windows and QNX, and recently also on Android. I'm sure it could also happen on platforms using the system library if the system library was the same version as the one bundled in Qt. Instead of expect-failing the test, we simply accept both the observed results as valid. Note that we need to accept 9 as a result for the default hinting preference on all platforms, not just Windows, since the default hinting preference in FreeType can be a system setting. Change-Id: I3cc0f33f0f66dd64419770b37c10dee457706b5e Reviewed-by: Konstantin Ritt Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'tests/auto/gui/text/qrawfont/tst_qrawfont.cpp') diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index bd4da12ea3..969c8f9ce7 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -307,24 +307,22 @@ void tst_QRawFont::advances() bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions(); QVector advances = font.advancesForGlyphIndexes(glyphIndices); - // On Windows and QNX, freetype engine returns advance of 9 for some of the glyphs - // when full hinting is used (default on Windows). - bool mayFail = false; -#if defined (Q_OS_WIN) - mayFail = font_d->fontEngine->type() == QFontEngine::Freetype - && (hintingPreference == QFont::PreferFullHinting - || hintingPreference == QFont::PreferDefaultHinting); -#elif defined(Q_OS_QNX) - mayFail = font_d->fontEngine->type() == QFontEngine::Freetype - && hintingPreference == QFont::PreferFullHinting; -#endif + bool mayDiffer = font_d->fontEngine->type() == QFontEngine::Freetype + && (hintingPreference == QFont::PreferFullHinting + || hintingPreference == QFont::PreferDefaultHinting); for (int i = 0; i < glyphIndices.size(); ++i) { - if (mayFail && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "FreeType engine reports unexpected advance " - "for some glyphs (9 instead of 8)", Continue); + if ((i == 0 || i == 5) && mayDiffer) { + QVERIFY2(qRound(advances.at(i).x()) == 8 + || qRound(advances.at(i).x()) == 9, + qPrintable(QStringLiteral("%1 != %2 && %1 != %3") + .arg(qRound(advances.at(i).x())) + .arg(8) + .arg(9))); + } else { + QCOMPARE(qRound(advances.at(i).x()), 8); } - QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); + if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); @@ -342,11 +340,17 @@ void tst_QRawFont::advances() QVERIFY(font.advancesForGlyphIndexes(glyphIndices.constData(), advances.data(), numGlyphs)); for (int i = 0; i < glyphIndices.size(); ++i) { - if (mayFail && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "FreeType engine reports unexpected advance " - "for some glyphs (9 instead of 8)", Continue); + if ((i == 0 || i == 5) && mayDiffer) { + QVERIFY2(qRound(advances.at(i).x()) == 8 + || qRound(advances.at(i).x()) == 9, + qPrintable(QStringLiteral("%1 != %2 && %1 != %3") + .arg(qRound(advances.at(i).x())) + .arg(8) + .arg(9))); + } else { + QCOMPARE(qRound(advances.at(i).x()), 8); } - QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); + if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); -- cgit v1.2.3