Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][Text]Fix multiple issues with bidi text trimming #17899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Jan 6, 2025

What does the pull request do?

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes: #14068
Fixes: #17888
Fixes: #17569

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054128-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@adirh3
Copy link
Contributor

adirh3 commented Jan 6, 2025

Thanks for the quick fix!
I have tested it, and it fixes almost all the issues in #17888 except when mixing RTL and LTR text.

image

It should look like this -

אחד שתיים שלוש Four חמש Six שבע Eight

But in Avalonia it aligned to left, like this -
אחד שתיים שלוש Four חמש Six שבע Eight

I think the issue is the resolved direction is LTR instead of RTL (which should be based on the first word (or in this case ShapedTextRun)

@Gillibald
Copy link
Contributor Author

Thanks for the quick fix! I have tested it, and it fixes almost all the issues in #17888 except when mixing RTL and LTR text.

image

It should look like this -

אחד שתיים שלוש Four חמש Six שבע Eight

But in Avalonia it aligned to left, like this - אחד שתיים שלוש Four חמש Six שבע Eight

I think the issue is the resolved direction is LTR instead of RTL (which should be based on the first word (or in this case ShapedTextRun)

Your example is embedding RTL into LTR so the resolved direction is LTR. Set the FlowDirection to RTL and it should be ordered like your example.

@adirh3
Copy link
Contributor

adirh3 commented Jan 6, 2025

Thanks for the quick fix! I have tested it, and it fixes almost all the issues in #17888 except when mixing RTL and LTR text.
image
It should look like this -
אחד שתיים שלוש Four חמש Six שבע Eight
But in Avalonia it aligned to left, like this - אחד שתיים שלוש Four חמש Six שבע Eight
I think the issue is the resolved direction is LTR instead of RTL (which should be based on the first word (or in this case ShapedTextRun)

Your example is embedding RTL into LTR so the resolved direction is LTR. Set the FlowDirection to RTL and it should be ordered like your example.

I checked with RTL layout; it's not working unfortunately.
image

Also, I believe it should be resolving based on first token (e.g. word/character), that's the behavior I am seeing in almost all apps and I am typing a lot in RTL mixed with LTR text.

Edit: FYI this is happening with full RTL text, if it has inlines -

  <TextBlock TextTrimming="CharacterEllipsis">
          <Run Text="אחד"/>
          <Run Text="שתיים"/>
          <Run Text="שלוש"/>
          <Run Text="ארבע"/>
          <Run Text="חמש"/>
          <Run Text="שש"/>
          <Run Text="שבע"/>
          <Run Text="שמונה"/>
          <Run Text="תשע"/>
        </TextBlock> 

image

@Gillibald
Copy link
Contributor Author

Gillibald commented Jan 7, 2025

Screenshot 2025-01-07 075814
Chromium does the same thing

@adirh3
Copy link
Contributor

adirh3 commented Jan 7, 2025

Screenshot 2025-01-07 075814 Chromium does the same thing

Ok it's up to you flow direction detection, developers can easily implement it in their apps either way.
But still in Avalonia (with this PR), the text is still incorrectly displayed regardless of the flow direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants