Fixes for TextLeadingPrefixCharacterEllipsis - #19387
Conversation
…e TextRun per line.
|
You can test this PR using the following package version. |
|
|
@cla-avalonia agree |
|
We should probably inherit the bidi level from the split run, so nothing changes. Could you clarify when TextFormatterImpl.SplitTextRuns produces wrong results? |
|
You can test this PR using the following package version. |
|
I think the text trimming implementation needs to be rewritten so it uses the hit testing APIs to find the actual split positions. We need to find the run that is at the split position and remove glyphs from it until the line fits into the requested width. This is a single position for trailing or leading ellipses and two positions for trimming with a defined prefix/suffix. In the end, the algorithm should not change the bidi order, etc. |
|
This PR works perfectly fine but only when text is entirely Left To Right. I don't have the know-how or time to fix the RTL and mixed BIDI level issues. |
|
This fixes a bug I reported in #20535, but it reveals another issue with |
|
Should be fixed in master |

What does the pull request do?
TextLeadingPrefixCharacterEllipsiscan now correctly handle multiple TextRuns.This is a followup for #17998
And fix for #19339
What is the current behavior?
Current implementation of
TextLeadingPrefixCharacterEllipsisonly works whenTextLinehas a singleShapedTextRun.When there's more (there are emojis or special characters) it breaks by crashing (in debug mode) or incorrectly accumulates
availableWidthwhich ends up excessively trimming the text (in some cases only leaving the ellipsis).This affects
TextTrimming="LeadingCharacterEllipsis"andTextTrimming="PrefixCharacterEllipsis":What is the updated/expected behavior with this PR?
TextLeadingPrefixCharacterEllipsisshould now correctly measure the text and prepare the prefix:How was the solution implemented (if it's not obvious)?
Update
TextLeadingPrefixCharacterEllipsis.Collapselogic.Checklist
Known issue:
PrefixCharacterEllipsishas inconsistent results with RTL text (ie. hebrew characters)TextFormatterImpl.SplitTextRunsreturn value might not be correct…) is lower than rest of text which can cause unexpected reordering of prefixFixed issues
Fixes #19339