Skip to content

Draw right-to-left views with GDI, as DirectWrite can't mirror them - #18503

Open
Pyre909 wants to merge 1 commit into
notepad-plus-plus:masterfrom
Pyre909:rtl-views-gdi_20261006
Open

Pyre909 wants to merge 1 commit into
notepad-plus-plus:masterfrom
Pyre909:rtl-views-gdi_20261006

Conversation

@Pyre909

@Pyre909 Pyre909 commented Oct 16, 2026 •

Copy link
Copy Markdown

Notepad++ shows an RTL document by mirroring the editor window (WS_EX_LAYOUTRTL), but only GDI drawing actually follows that mirroring. With DirectWrite the text still comes out left-to-right while Windows mirrors the scrollbar and the mouse, so clicks end up on the wrong side. Scintilla won't help here either, its maintainer said mirroring only ever worked with GDI: https://sourceforge.net/p/scintilla/feature-requests/1435/

What that looks like right now:

  • With DirectWrite on, View > Text Direction RTL pops up "RTL is not compatible with DirectWrite mode" once, then just does nothing after that ([BUG] <title>Text Direction RTL Shortcut Ctrl+Alt+R not work #17865).
  • With an RTL UI language (Hebrew, Arabic, Farsi, Kurdish, Urdu, Uyghur), documents start RTL and every view is mirrored from the start. DirectWrite is the default rendering mode, so out of the box the editor is drawn left-to-right inside a mirrored window, no warning at all. Screenshot below: 8.9.8.1 on the left, this PR on the right. 9bc790b used to turn DirectWrite off for that case, but the per-document RTL change (2724e0d) took that check out.

So this PR just draws a mirrored view with GDI, whatever the rendering mode is, and gives it back whatever it was using once it's LTR again (that includes switching between RTL and LTR tabs, and a technology a plugin set on the view). A view that starts mirrored never gets DirectWrite in the first place. The refusal and its message are gone.

While I was in there: at startup the first document gets activated while it's already the current one, so the views never got their direction set, and with editZoneRTL="no" they stayed mirrored anyway (#17518). Two lines in Notepad_plus::init fix that.

5 files, nothing in Scintilla.

Hebrew UI with DirectWrite: 8.9.8.1 on the left, this PR on the right

Tested on Windows 11 ARM64 with Release builds of this branch, fresh config so DirectWrite is on (all 13 CI jobs pass on my fork too: MSVC x64, Win32 and ARM64 Release and Debug, CMake, MinGW, Clang): RTL/LTR back and forth, RTL and LTR tabs, an RTL doc cloned to the other view, the Document Map following along, a long wrapped doc keeping its scroll position through all of it, and the Hebrew UI from startup to exit, also with editZoneRTL="no" and no session, in both GDI (the case in #17518) and DirectWrite. No messages anywhere, and LTR documents stay on DirectWrite.

Two things I know about and left alone: with an RTL UI, a Scintilla a plugin creates is mirrored from the start like the others, so it starts on GDI too, and a plugin's SCI_SETBIDIRECTIONAL gets cleared when its view switches to GDI (that's Scintilla's doing).

AI disclosure: I wrote this with help from an AI assistant (Claude), then reviewed and tested it myself.

  • I have read contributing guidelines

fix #17865, fix #17518

Fix notepad-plus-plus#17865, fix notepad-plus-plus#17518

Notepad++ shows a right-to-left document by mirroring its Scintilla
window (WS_EX_LAYOUTRTL), and only GDI follows that mirroring:
DirectWrite draws such a view left-to-right while Windows mirrors its
scrollbar and mouse coordinates. RTL was refused while DirectWrite was
on (a message shown once, then nothing: notepad-plus-plus#17865), and with an RTL UI
language the views mirrored from the start were drawn with DirectWrite
anyway, the default rendering mode.

A right-to-left view is now drawn with GDI whatever the rendering mode,
and gets its own technology back once left-to-right (the one it had,
so a rendering mode changed in Preferences still waits for a restart,
and a technology set by a plugin is kept); a view mirrored at creation
gets the rendering mode once left-to-right. The refusal and its message
are gone.

At startup the views also get the direction of their first document:
with editZoneRTL="no" they stayed mirrored (notepad-plus-plus#17518).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pyre909 added a commit to Pyre909/notepad-plus-plus that referenced this pull request Oct 16, 2026
…sted), the live switch's texts name it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chcg chcg added the enhancement Proposed enhancements of existing features label Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Proposed enhancements of existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] <title>Text Direction RTL Shortcut Ctrl+Alt+R not work Bug: editZoneRTL="no" is ignored in GDI mode, forcing RTL code editing

2 participants