From 782d14471a15f3eda1f5a06c32c45a128528ab78 Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Thu, 12 Feb 2026 19:10:40 +0100 Subject: [PATCH] Fix double-width line (DECDWL / ESC #6) fragment positioning The old code inverse-mapped the entire top-left point (margins + column offset), so the painter's scale(2,1) simply recovered the original single-width coordinates. On lines with multiple text fragments (e.g. box-drawing chars + text + box-drawing chars), each fragment was placed at its single-width position but rendered at double width, causing overlaps and gaps. Fix by inverse-mapping only the margin/origin offset and leaving the column position unmapped, so the painter scale correctly doubles it. Co-Authored-By: Claude Opus 4.6 --- lib/TerminalDisplay.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index d6c1edfa..479afd92 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -2007,12 +2007,13 @@ void TerminalDisplay::drawContents(QPainter &paint, const QRect &rect) QRect textArea = calculateTextArea(tLx, tLy, x, y, len); //move the calculated area to take account of scaling applied to the painter. - //the position of the area from the origin (0,0) is scaled - //by the opposite of whatever - //transformation has been applied to the painter. this ensures that - //painting does actually start from textArea.topLeft() - //(instead of textArea.topLeft() * painter-scale) - textArea.moveTopLeft( textScale.inverted().map(textArea.topLeft()) ); + //Only the origin offset (margins) is inverse-mapped so the painter + //scale does not shift it. The column/row position is left unmapped + //so the painter scale correctly doubles it for double-width/height lines. + QPoint origin = textScale.inverted().map(QPoint(_leftMargin + tLx, _topMargin + tLy)); + int colLeft = _fixedFont ? _fontWidth * x : textWidth(0, x, y); + int colTop = _fontHeight * y; + textArea.moveTopLeft(QPoint(origin.x() + colLeft, origin.y() + colTop)); //paint text fragment drawTextFragment(paint,