microsoft / microsoft/microsoft-ui-xaml

Proposal: Explicit LTR/RTL TextReadingOrder

Open
#10,949 0 comments 0 reactions 0 assignees View on GitHub
area-Layouts area-TextBlocks feature proposal
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Title

Add `LeftToRight` and `RightToLeft` values to `TextReadingOrder` enum which explicitly set the reading order without using the content or the `FlowDirection`.

### Summary

Developers should be able to explicitly set the `TextReadingOrder` to either `LeftToRight` or `RightToLeft` rather than ensuring `TextReadingOrder="UseFlowDireciton"` and assigning the `FlowDirection`.

### Rationale

This allows developers to more easily control the text reading order of text through direct control rather than tangentially by adjusting multiple properties.

### Scope

| Capability | Priority |
| :---------- | :------- |
| This proposal will allow developers to explicitly set the `TextReadingOrder` | Must |
| This proposal will allow end users to read text in their language more easily | Must |

### Important Notes

Notice the period by the arrow is on the other side of the message than all the others.
Image

That is because the string begins with a formatted token, and the `TextReadingOrder` is `DetectFromContent`. The text flow direction is detected as left to right because the first directional character in the string is `'s'`. That's perfectly expected but, in this instance, incorrect. I believe the developer should be able to explicitly set the `TextReadingOrder` to either `LeftToRight` or `RightToLeft` without setting the `FlowDirection`, since that would invert all the other properties (such as alignment).

The image below shows what happens if you set **ONLY** the `FlowDirection` to `RightToLeft` and `TextReadingOrder` to `UseFlowDirection`.
Image

The text reading order is fixed! But notice how the `TextAlignment` is inverted as well. In order to restore left hand alignment, you must also set the `TextAlignment` to `Right`. However, you must **not** invert the `TextAlignment` if the app `FlowDirection` is the same as the text flow direction. I would consider this a work-around. Not a fix.

As is, RTL localization is often overlooked, and this a small convenience that can greatly simplify displaying RTL text in an LTR environment or vice-versa.

### Open Questions

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the TextReadingOrder enum and the code handling DetectFromContent and UseFlowDirection. Review how reading order and FlowDirection currently affect alignment; the work is done when LeftToRight and RightToLeft explicitly control text reading order without requiring or changing FlowDirection.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.