You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RichTextBlock: TextReadingOrder and content-driven bidi are inert #24339
TextReadingOrder is [NotImplemented] and TextAlignment.DetectFromContent always resolves to Left. RTL content is laid out left-to-right.
An explicit FlowDirection on the control or on a Runis honoured — what is missing is content-driven detection and full Unicode bidi reordering.
Why is this needed? 🤔
RTL languages render incorrectly rather than merely losing a feature, which makes this the most user-visible correctness gap left on the control.
Renderer 🎨
Skia
Native
For which platforms 📱💻🖥️
All platforms 🌍
Anything else we need to know? 💬
This is a pre-existing limitation of the Uno text engine rather than a regression of the port: TextBlock behaves the same way. Fixing it once would serve both.
Follow-up from the RichTextBlock deep-core port; recorded in specs/richtextblock-winui-port/port-validation-winui-2.4.0.md.
Still to come: a fix for text containing U+001C–U+001E making the layout throw, the engine swap itself, TextReadingOrder, and the removal of ParsedText.
Why RichTextBlock has no bidi.TextBlock, TextBox and RichEditBox lay out text with UnicodeText, which runs ICU's implementation of the Unicode Bidi Algorithm. RichTextBlock misses out because SkiaTextFormatter/SkiaTextLine bridge the ported BlockLayoutEngine onto the legacy ParsedText. That path guesses direction per segment through HarfBuzz and hard-codes IsBaseDirectionRightToLeft => false. So the fix is to move RichTextBlock's paragraphs onto UnicodeText; no new bidi implementation is needed.
UnicodeText had bidi problems of its own, though, which the swap would have carried over. They are what #26726 fixes for every control that uses it.
A new formatter on UnicodeText replaces SkiaTextFormatter/SkiaTextLine. The existing RichTextBlock tests are compared against a baseline from master at each step, and the TextBlock, TextBox and RichEditBox suites stay green, since they share the engine.
RichTextBlock behaves as TextReadingOrder.DetectFromContent. That is WinUI's default, measured for RichTextBlock and TextBlock; the generated stub's 0 (UseFlowDirection) was the Windows 8.1 default. TextAlignment.DetectFromContent works with it, and the public TextReadingOrder property follows in its own PR.
Afterwards, ParsedText and the legacy Run/Segment/RenderLine shaping code are deleted, about 3,000 lines.
#24748 gets fixed by the swap instead of a separate patch: a right-to-left link will react where it is drawn. A fix in ParsedText alone would break the ported ParagraphNode paths (selection, GetPositionFromPoint, automation bounds), which currently rely on that mismatch. One correction to that issue, from clicking on native WinUI: a click on the empty space beside a line that holds only a Hyperlink does raise Click there, on either side, so "clicking empty space doesn't raise Click" isn't WinUI's behavior.
RTL coordinates. The ported ParagraphNode/RichTextBlockView math follows WinUI's convention: a right-to-left element stays mirrored, the layout math is flow-relative, and the text drawing context mirrors back. UIElement.GetFlowDirectionTransform cancels the mirror for text surfaces instead, which only works for RichTextBlock today because the detected direction is always left-to-right. The swap follows WinUI: RichTextBlock and RichTextBlockOverflow stay mirrored, and one small helper mirrors back around the text paint and the engine's hit-tests. Measured on native WinUI:
an overflow lays out and mirrors by its master's FlowDirection, whatever its own is;
WinUI's RichTextBlock reports GetCharacterRect and GetPositionFromPoint on the wrong side of the line when the content's direction differs from FlowDirection and the alignment isn't the start. WinUI's TextBlock reports the same cases on the drawn text. I'm matching the drawn text.
Longer term, which is where I'd like your input: I think the end state is the WinUI model for every text control.
One engine,UnicodeText, which this work completes.
One coordinate convention. WinUI's mirroring for every text control, with the mirror-back in one place at the engine boundary (draw, hit-test and rectangle queries) instead of the isMirroredTextSurface exception. The helper the swap adds is written so TextBlock and TextBox can use it unchanged.
One layout stack for TextBlock and RichTextBlock, as in WinUI.
TextBlockView is already ported but not used yet.
TextBlock has its own selection and hit-testing beside the ported TextSelectionManager.
Moving TextBlock onto PageNode/TextBlockView/TextSelectionManager would remove that duplication, and give TextBlockTextPointer and text-view automation parity.
It would keep a fast path for plain text, as WinUI does with DWriteLayout, so labels don't pay for the node tree.
This issue only covers RichTextBlock. The rest would be separate PRs, and none of the PRs above depends on the answers. Before I plan them:
Is moving TextBlock onto the shared stack (the port notes call it "Stage 9") planned or in progress on your side?
That move would rewrite the measure, arrange and paint paths the open TextBlock performance PRs optimize. Should it wait until they are merged, and is there a benchmark it has to hold?
Any objection to WinUI's mirror convention as the target for all the text controls?
Activity
mikernet commentedon Nov 25, 2026
I'm taking this one. Status, what scoping and measuring on native WinUI found, and a question about the longer-term direction.
Status. The work is a stack of PRs. In review order:
RichTextBlockgeometry against native WinUI, so the engine change has a regression net.UnicodeText. Only a run whose direction differs from its control's is embedded, bidi control characters in text are honored, and the buffers ICU keeps pointers to stay alive. Closes Latin text in aFlowDirection=RightToLeftTextBlock is laid out as RTL on Skia: punctuation moves and brackets flip (WinUI keeps LTR order) #25291, Bidi control characters (RLO, RLE, PDF, isolates) in text are ignored on Skia #26722 and Skia text: ICU's bidi object reads a pooled array after it was returned to the pool #26723.TextHighlighterthat sets none. Closes TextBlock TextHighlighter with no Background paints no highlight; WinUI falls back to the yellow TextControlHighlighterBackground #24747.RichTextBlockneeds fromUnicodeText: resuming a paragraph on an overflow, trimming at another width,InlineUIContainerplaceholders, and reading and drawing by line.TextReadingOrder, and the removal ofParsedText.Why
RichTextBlockhas no bidi.TextBlock,TextBoxandRichEditBoxlay out text withUnicodeText, which runs ICU's implementation of the Unicode Bidi Algorithm.RichTextBlockmisses out becauseSkiaTextFormatter/SkiaTextLinebridge the portedBlockLayoutEngineonto the legacyParsedText. That path guesses direction per segment through HarfBuzz and hard-codesIsBaseDirectionRightToLeft => false. So the fix is to moveRichTextBlock's paragraphs ontoUnicodeText; no new bidi implementation is needed.UnicodeTexthad bidi problems of its own, though, which the swap would have carried over. They are what #26726 fixes for every control that uses it.The swap, in the PR after #26727:
UnicodeTextreplacesSkiaTextFormatter/SkiaTextLine. The existingRichTextBlocktests are compared against a baseline from master at each step, and theTextBlock,TextBoxandRichEditBoxsuites stay green, since they share the engine.RichTextBlockbehaves asTextReadingOrder.DetectFromContent. That is WinUI's default, measured forRichTextBlockandTextBlock; the generated stub's0(UseFlowDirection) was the Windows 8.1 default.TextAlignment.DetectFromContentworks with it, and the publicTextReadingOrderproperty follows in its own PR.ParsedTextand the legacyRun/Segment/RenderLineshaping code are deleted, about 3,000 lines.#24748 gets fixed by the swap instead of a separate patch: a right-to-left link will react where it is drawn. A fix in
ParsedTextalone would break the portedParagraphNodepaths (selection,GetPositionFromPoint, automation bounds), which currently rely on that mismatch. One correction to that issue, from clicking on native WinUI: a click on the empty space beside a line that holds only aHyperlinkdoes raiseClickthere, on either side, so "clicking empty space doesn't raiseClick" isn't WinUI's behavior.RTL coordinates. The ported
ParagraphNode/RichTextBlockViewmath follows WinUI's convention: a right-to-left element stays mirrored, the layout math is flow-relative, and the text drawing context mirrors back.UIElement.GetFlowDirectionTransformcancels the mirror for text surfaces instead, which only works forRichTextBlocktoday because the detected direction is always left-to-right. The swap follows WinUI:RichTextBlockandRichTextBlockOverflowstay mirrored, and one small helper mirrors back around the text paint and the engine's hit-tests. Measured on native WinUI:FlowDirection, whatever its own is;RichTextBlockreportsGetCharacterRectandGetPositionFromPointon the wrong side of the line when the content's direction differs fromFlowDirectionand the alignment isn't the start. WinUI'sTextBlockreports the same cases on the drawn text. I'm matching the drawn text.Longer term, which is where I'd like your input: I think the end state is the WinUI model for every text control.
UnicodeText, which this work completes.isMirroredTextSurfaceexception. The helper the swap adds is written soTextBlockandTextBoxcan use it unchanged.TextBlockandRichTextBlock, as in WinUI.TextBlockViewis already ported but not used yet.TextBlockhas its own selection and hit-testing beside the portedTextSelectionManager.TextBlockontoPageNode/TextBlockView/TextSelectionManagerwould remove that duplication, and giveTextBlockTextPointerand text-view automation parity.DWriteLayout, so labels don't pay for the node tree.This issue only covers
RichTextBlock. The rest would be separate PRs, and none of the PRs above depends on the answers. Before I plan them:TextBlockonto the shared stack (the port notes call it "Stage 9") planned or in progress on your side?TextBlockperformance PRs optimize. Should it wait until they are merged, and is there a benchmark it has to hold?