Here using: Qt: 4.6.1 (kde-qt master commit 5ccbae0c2d9254efe67599137afec763d4fec0f6 Date: Tue Jan 19 20:42:24 2010 +0100) KDE Development Platform: 4.4.61 (KDE 4.4.61 (KDE 4.5 >= 20100127)) kdelibs svn rev. 1082077 / kdebase svn rev. 1082077 on ArchLinux i686 - Kernel 2.6.32.3 Testcase HTML: <a href="#">ToToToToToToToToToToToToToToToToToToToToToToToToToToToToToToToToTo</a> Bug: The underline of that link is longer than the text itself. The problem gets bigger if the "To" sequence is bigger. It could be related to the line width not calculating the font kerning: the "o" are below the "T".
Created attachment 40420 [details] Testcase
Created attachment 40421 [details] Screenshot of the bug
Not only the underline, but the "hit box" is affected, too.
See also bug 307824.
khtml/rendering/font.cpp:317 (Font::width function) It seems "fast algorithm" does not always return correct string length (that's the case of the reported testcase). That's is the sum of the single char with (QFontMetrics::width(QChar)) of the string does't always match the length of the string (QFontMetrics::width(QString,..)).
... and the reason why "fast algorithm" was introduced is stated in comment at the beginning of Font::width function (major speed regression in qt4 compared to qt3)
Dear user, KHTML (and KJS) was a long time more or less unmaintained and got removed in KF6. Please migrate to use a QWebEngine based HTML component. We will do no further fixes or improvements to the KF5 branches of these components beside important security fixes. For security issues, please see: https://kde.org/info/security/ Sorry that we did not fix this issue during the life-time of KHTML. Greetings Christoph Cullmann