Skip to content

Add initial rendering-only BiDi support to AtlasEngine#20377

Draft
i7xre wants to merge 3 commits into
microsoft:mainfrom
i7xre:rtl-upstreamable-bidi-ordering
Draft

Add initial rendering-only BiDi support to AtlasEngine#20377
i7xre wants to merge 3 commits into
microsoft:mainfrom
i7xre:rtl-upstreamable-bidi-ordering

Conversation

@i7xre

@i7xre i7xre commented Jun 30, 2026

Copy link
Copy Markdown

Summary

This PR adds initial rendering-only bidirectional text support to AtlasEngine.

The change improves visual ordering and shaping for RTL scripts such as Arabic, Persian, and Hebrew by using DirectWrite BiDi analysis in the Atlas text shaping path, ordering visual spans by resolved embedding levels, and emitting RTL shaped clusters in visual order.

This intentionally does not implement full terminal BiDi support. The scope of this PR is limited to rendered text ordering inside AtlasEngine.


Implementation

  • Capture DirectWrite BiDi levels during text analysis.
  • Run line-level IDWriteTextAnalyzer::AnalyzeBidi.
  • Store resolved BiDi runs for the current rendered line.
  • Build visual spans by intersecting renderer spans with resolved BiDi runs.
  • Split same-level spans at whitespace boundaries to improve RTL phrase ordering.
  • Apply UAX Default to msbuild.exe on PATH if found #9 L2-style level ordering before rendering.
  • Emit RTL shaped clusters in visual order while preserving glyph order inside each cluster.

Validation

Built locally:

  • src/renderer/atlas/atlas.vcxproj

Validated manually using a local Windows Terminal Dev package with:

  • Arabic words
  • Arabic multi-word phrases
  • Persian phrases
  • Hebrew phrases
  • RTL text after an LTR PowerShell prompt
  • Mixed LTR/RTL text
  • Existing LTR rendering

Known Limitations

This is intentionally a rendering-only implementation.

The following are out of scope for this PR:

  • BiDi-aware cursor/caret movement
  • Editable input navigation
  • Selection and hit testing
  • Copy/paste logical ↔ visual mapping
  • Wrapping and reflow
  • Bracket mirroring
  • Paragraph/base direction handling

Current known issues:

  • Neutral punctuation around RTL editable input (quotes, brackets, colons, etc.) can still produce incorrect caret behavior.
  • Cursor/editing remains logical-cell based.
  • Combining marks and diacritics are not yet fully correct in all cases.

Follow-up Work

Future work should address:

  • Caret movement
  • Selection and hit testing
  • Copy/paste mapping
  • Wrapping/reflow
  • Neutral punctuation
  • Paragraph direction
  • Combining mark placement

This PR is intended as an initial rendering improvement and as a foundation for future BiDi work, rather than a complete RTL terminal implementation.

@i7xre

i7xre commented Jun 30, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@DHowett

DHowett commented Jun 30, 2026

Copy link
Copy Markdown
Member

Coordinate your efforts with #20159. Make sure that you aren't making the same mistakes as we have discussed with them. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants