summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-08 11:59:23 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-01-16 09:27:29 +0100
commit1ee6fdc72c8f9903ef813341007156436f0758ea (patch)
treea628d3bfcbb4e9ab060ad022cb1526a6f63e6cc5 /tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
parentb4031387f91d9e96c19521486b82accdc45c178e (diff)
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 <ritt.ks@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/gui/text/qrawfont/tst_qrawfont.cpp')
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp42
1 files changed, 23 insertions, 19 deletions
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<QPointF> 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);