retitle 672554 konsole: vertically misaligned/cut off characters tags 672554 + patch thanks
Hello, This bug seems to be caused by a problem in the qt's painter::drawText method handling monospace fonts with different attributes (bold, inverted and such), that end up with slightly different positions. The konsole developers applied two patches to handle this problem, the first one increased the text linespacing so that the misalignment doesn't end up with cut off characters. (affecting src/TerminalDisplay.h setBidiEnabled function). The second patch adds a flag to the drawText to align the text (this shouldn't be needed in a monospace font), the result hides the problem in almost every case (affecting src/TerminalDisplay.cpp drawCharacters function). Both patches are applied only to the unidirectional text rendering, but after a few releases the bidirectional text rendering became the default, thus making this bug noticeable again. Although as the bidirectional renderer draws the whole line, the misplacement won't make the terminal useless as the unidirectional renderer used to cause; it's just annoying. The misplacement is not always the same, it depends on the font you are using, some fonts seem to be particularly prone to misplacement. Currently, I'm using the Anonymous Pro font; before, I used the Terminus font and it was displaced more heavily in presence of unicode chars, while the TrueType fonts seem to be displaced with the change of attributes. To test this bug, I use the manpage of fonts.conf, close to the end of the manpage, the line that starts with conf.d, the text is sligthly misplaced. Selecting a word causes the line to get redrawn in a slightly different position. This misplacement is very subtle, some texts produce a more serious misplacement, but this is the one I found when I was tracking the problem. I'm attaching two patches that modify the patches made by upstream, the first one adds the alignBottom flag to the bidirectional renderer. This patch hides part of the misplacement in the bidirectional renderer. The second patch reverts the added linespacing for the unidirectional renderer, making the lines in konsole of the same height than in any other program, while using the same font (this can be tested using a gnome-terminal or similar with transparency on top of konsole). As mentioned before, these patches only reduce the effect of the problem, but the error is somewhere in the execution produced by drawText. So far, I haven't found the culprit. -- "If you are in a hole, stop digging." -- The First Rule of Excavation Saludos /\/\ /\ >< `/
Index: konsole/src/TerminalDisplay.cpp =================================================================== --- konsole.orig/src/TerminalDisplay.cpp 2013-02-15 13:56:21.342032187 +0100 +++ konsole/src/TerminalDisplay.cpp 2013-02-15 14:37:06.932813212 +0100 @@ -701,6 +701,13 @@ if (isLineCharString(text)) { drawLineCharString(painter, rect.x(), rect.y(), text, style); } else { + // Avoid fonts vertical displacement. + + // See bug 280896 for more info + int flags = 0; +#if QT_VERSION >= 0x040800 + flags |= Qt::AlignBottom; +#endif // Force using LTR as the document layout for the terminal area, because // there is no use cases for RTL emulator and RTL terminal application. // @@ -715,14 +722,9 @@ // // This was discussed in: http://lists.kde.org/?t=120552223600002&r=1&w=2 if (_bidiEnabled) { - painter.drawText(rect, 0, text); + painter.drawText(rect, flags, text); } else { - // See bug 280896 for more info -#if QT_VERSION >= 0x040800 - painter.drawText(rect, Qt::AlignBottom, LTR_OVERRIDE_CHAR + text); -#else - painter.drawText(rect, 0, LTR_OVERRIDE_CHAR + text); -#endif + painter.drawText(rect, flags, LTR_OVERRIDE_CHAR + text); } } }
Index: konsole/src/TerminalDisplay.h =================================================================== --- konsole.orig/src/TerminalDisplay.h 2013-02-15 13:56:21.342032187 +0100 +++ konsole/src/TerminalDisplay.h 2013-02-15 15:19:43.391806071 +0100 @@ -384,7 +384,7 @@ if (_bidiEnabled) { setLineSpacing(0); } else { - setLineSpacing(2); + setLineSpacing(0); } #endif }
signature.asc
Description: Digital signature