Scintilla only (experimentally) supports bidirectional text with the SCI_SETBIDIRECTIONAL API.
I suspect what you are seeing is Notepad++ setting a text direction with WS_EX_LAYOUTRTL or WS_EX_RTLREADING or similar on a Scintilla window. Scintilla has never actively supported this and any past success with these modes was accidental. May have worked with GDI drawing but not DirectWrite.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems adding a 90 degrees transform (in ScintillaWin::EnsureRenderTarget()) will make Technology::DirectWriteDC rendered into same thing as GDI.
// test code, need to load D2D1MakeRotateMatrix() and check window layout#pragma comment(lib, "D2d1.lib")pRenderTarget->SetTransform(D2D1::Matrix3x2F::Rotation(90.0f,D2D1::Point2F(0.0f,0.0f)));
Edit: this does work, nothing is rendered.
Last edit: Zufu Liu 2022-04-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
SetReadingDirection inside SurfaceD2D::DrawTextCommon can only affect one lexeme.
Here is a mixed language and mixed direction comment which is a single lexeme with DWRITE_READING_DIRECTION_LEFT_TO_RIGHT (top) and DWRITE_READING_DIRECTION_RIGHT_TO_LEFT (bottom):
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using https://github.com/notepad-plus-plus/notepad-plus-plus/commit/b4a58429c3c8f7fe3250aa4a0e57743c2bceaf3a
See also: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11476
Last edit: Yaron 2022-04-07
Scintilla only (experimentally) supports bidirectional text with the SCI_SETBIDIRECTIONAL API.
I suspect what you are seeing is Notepad++ setting a text direction with WS_EX_LAYOUTRTL or
WS_EX_RTLREADINGor similar on a Scintilla window. Scintilla has never actively supported this and any past success with these modes was accidental. May have worked with GDI drawing but not DirectWrite.Browsing commit 7fa6fb083b0 confirms that is the case:
That does not work as expected, see https://github.com/zufuliu/notepad2/issues/392
Neil,
Thank you for the detailed and useful reply.
I'd like to thank you also for the Scintilla project. I appreciate your work.
Please consider this thread as another request for a better RTL support. :)
Robert & Zufu,
Thank you for the additional info.
I don't think this is describing a feature that can be implemented.
May be fixed with [fa80f5].
Related
Commit: [fa80f5]
It seems adding a 90 degrees transform (in
ScintillaWin::EnsureRenderTarget()) will makeTechnology::DirectWriteDCrendered into same thing as GDI.Edit: this does work, nothing is rendered.
Last edit: Zufu Liu 2022-04-10
A 180 degree rotation is more likely wanted than 90 but that inverts the y axis.
This code inverts x for
Technology::DirectWriteDCbut then the text is no longer on the right:For
WS_EX_LAYOUTRTLtheIDWriteTextFormat::SetReadingDirectionAPI is likely the key.https://docs.microsoft.com/en-us/windows/win32/directwrite/how-to-ensure-text-is-displayed-with-the-correct-reading-direction
Code from Raghda's bidi work:
SetReadingDirection()has no effect.however
SetLayout(hdc, LAYOUT_BITMAPORIENTATIONPRESERVED);can be added intoScintillaWin::PaintDC()to make all DirectWrite technologies behaviors same (no RTL), which is documented at https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nn-d2d1-id2d1dcrendertarget#id2d1dcrendertargets--gdi-transforms--and-right-to-left-language-builds-of-windowsSetReadingDirectioninsideSurfaceD2D::DrawTextCommoncan only affect one lexeme.Here is a mixed language and mixed direction comment which is a single lexeme with

DWRITE_READING_DIRECTION_LEFT_TO_RIGHT(top) andDWRITE_READING_DIRECTION_RIGHT_TO_LEFT(bottom):move rotation local into
SurfaceD2D::DrawTextCommon()has some effects forSC_TECHNOLOGY_DIRECTWRITEDC.@nyamatongwe,
Thanks again for the fix. I appreciate it.
@zufuliu,
Thank you for the interesting info.