From e7ac6667f27369c25719ebedefd2d5344fd93bfd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 6 Aug 2024 07:45:46 +0200 Subject: [PATCH] Fix tst_QTextLayout::softHyphens failure with some fonts The test did not account for the fact that kerning can alter the distance between subsequent characters, so sum of horizontal advances does not accurately measure the width of the string when kerning is enabled. This caused the test to fail with e.g. with the font Ubuntu Sans. This amends 0ffdbb21261eee3a9ec1cd541478ee883a12065c . Pick-to: 6.2 6.5 6.7 6.8 Fixes: QTBUG-127512 Change-Id: Id3ae7a6c79c84edd603db2fc0fed07777fa67741 Reviewed-by: Liang Qi --- tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 4c886584103..a8c737634a3 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -2563,6 +2563,7 @@ void tst_QTextLayout::softHyphens() QFont font; font.setPixelSize(fontSize); font.setHintingPreference(QFont::PreferNoHinting); + font.setKerning(false); const float xAdvance = QFontMetricsF(font).horizontalAdvance(QChar::fromLatin1('x')); float shyWidth = 0.0f; QTextLayout layout(text, font);