Skip to content

Bidi control characters (RLO, RLE, PDF, isolates) in text are ignored on Skia #26722

Backlog

Description

@mikernet

Current behavior 🐛

On Skia, the Unicode bidi control characters in the text of a TextBlock, TextBox, PasswordBox (when it shows its password) or RichEditBox have no effect: U+202A–U+202E (LRE, RLE, PDF, LRO, RLO) and U+2066–U+2069 (LRI, RLI, FSI, PDI) are laid out as if they weren't there. For example, with FlowDirection="LeftToRight":

Text Uno Skia WinUI 3
1 + RLO + abcd + PDF 1abcd 1dcba
x + RLE + ab!! + PDF + y x ab!! y x !!ab y

The same happens whether or not a Run in the text has its own FlowDirection.

The cause: UnicodeText passes ICU an explicit embedding level for every character (ubidi_setPara with an embeddingLevels array), and ICU ignores the explicit formatting characters when it gets such an array.

Expected behavior 🎯

As on WinUI, the bidi control characters are applied by the Unicode Bidirectional Algorithm: 1dcba and x !!ab y above.

How to reproduce it (as minimally and precisely as possible) 🔬

<StackPanel Padding="20" Spacing="8">
    <!-- U+202E (RLO) ... U+202C (PDF) -->
    <TextBlock FontSize="32" Text="1&#x202E;abcd&#x202C;" />
    <!-- U+202B (RLE) ... U+202C (PDF) -->
    <TextBlock FontSize="32" Text="x &#x202B;ab!!&#x202C; y" />
</StackPanel>
  1. Run on Skia Desktop: the first line reads 1abcd, the second x ab!! y.
  2. Run the same XAML on WinUI 3: 1dcba and x !!ab y.

Workaround 🛠️

None in XAML. Split the text into Runs and give the right-to-left part its own FlowDirection; that covers embeddings and overrides of a whole run only.

Affected platforms 📱💻🖥️

All platforms 🌍 (every Skia target; Windows App SDK is not affected)

Uno.Sdk version (and other relevant versions) 📦

master (7.x).

IDE version 🧑‍💻

Not relevant.

Anything else we need to know? 💬

Related: #25291 (the same UnicodeText bidi setup embeds Latin text in a right-to-left TextBlock).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions