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

Text trimming inconsistencies #17888

Open
adirh3 opened this issue Jan 4, 2025 · 2 comments · May be fixed by #17899
Open

Text trimming inconsistencies #17888

adirh3 opened this issue Jan 4, 2025 · 2 comments · May be fixed by #17899
Assignees
Labels

Comments

@adirh3
Copy link
Contributor

adirh3 commented Jan 4, 2025

Describe the bug

There are multiple issues -

  • Text trimming is inconsistent between RTL and LTR views
  • Text trimming for RTL text (e.g. Hebrew) is broken - no text is showing
  • Text trimming when RTL text is combined with LTR text, is showing but incorrectly (does not aligned properly to right)

To Reproduce

Add this to Control Catalog TextBlock page -

  <TextBlock Margin="0,0,10,0"
                     Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
                     TextTrimming="CharacterEllipsis" />
          <TextBlock Margin="0,0,10,0"
                     Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
                     TextTrimming="WordEllipsis" />
          <TextBlock Margin="0,0,10,0"
                     Text="טקסט בשפה עברית אמור להיות מוצג מימין לשמאל"
                     FontFamily="Arial"
                     TextTrimming="CharacterEllipsis" />
          <TextBlock Margin="0,0,10,0"
                     Text="טקסט בשפה עברית אמור להיות מוצג מימין לשמאל"
                     FontFamily="Arial"
                     TextTrimming="WordEllipsis" />
          <TextBlock Margin="0,0,10,0"
                     Text="אחד שתיים שלוש Four חמש Six שבע Eight"
                     FontFamily="Arial"
                     TextTrimming="CharacterEllipsis" />
          <TextBlock Margin="0,0,10,0"
                     Text="אחד שתיים שלוש Four חמש Six שבע Eight"
                     FontFamily="Arial"
                     TextTrimming="WordEllipsis" />

LTR -
image
Here only the English text is OK.

RTL -
image
Here all text is not displaying correctly, including English.

Expected behavior

Text to be displayed correctly when trimmed.
I will use GitHub to demonstrate as I assume you can't read Hebrew -

טקסט בשפה עברית אמור להיות מוצג מימין לשמאל
אחד שתיים שלוש Four חמש Six שבע Eight

Avalonia version

master

OS

No response

Additional context

I believe the issue is due to the TextBlock's FlowDirection is used when trimming and not the "resolved" flow direction.

@Gillibald
Copy link
Contributor

@adirh3 please have a look at my linked PR. It does similar things as your PR but also has different and less breaking changes in other parts. I hope you don't mind.

@adirh3
Copy link
Contributor Author

adirh3 commented Jan 6, 2025

@adirh3 please have a look at my linked PR. It does similar things as your PR but also has different and less breaking changes in other parts. I hope you don't mind.

Thanks for sharing! I don't mind at all, I just wanted to understand this code a bit.
I will try out your branch with some Hebrew strings and see how it works, thanks!

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