From 5e66fb7d2e3cccf7e83fb4424e67f73ce48b0bfe Mon Sep 17 00:00:00 2001 From: ali kettab Date: Tue, 12 May 2026 01:40:54 +0100 Subject: [PATCH] wxMSW: Fix drawing vertical lines with pen width > 1 in RTL layout Shift them to account for an offset when using RTL. Closes #26448. --- src/msw/dc.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 19f2c6487b..486ba71a71 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -718,7 +718,18 @@ void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) } else { - wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2)); + int dx = 0; + + // In RTL layout, we need this adjustment because vertical lines drawn + // with pen width > 1 are incorrectly shifted to the left by one pixel. + if ( x1 == x2 && y1 != y2 && + m_pen.GetWidth() > 1 && + GetLayoutDirection() == wxLayout_RightToLeft ) + { + dx = -1; + } + + wxDrawLine(GetHdc(), XLOG2DEV(x1) + dx, YLOG2DEV(y1), XLOG2DEV(x2) + dx, YLOG2DEV(y2)); } if ( AreAutomaticBoundingBoxUpdatesEnabled() )