xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Combination of FormattedString and TailTruncation problems #5669

Open EislerDavid opened 5 years ago

EislerDavid commented 5 years ago

Description

When I use Label with LineBreakMode="TailTruncation" and set FormattedText with some spans then tail truncation is not working on iOS and freezes on Android.

Steps to Reproduce

  1. Create Label with LineBreakMode="TailTruncation"
  2. Set FormattedText with some spans
    • tail truncation not working on iOS and freezes on Android API22 and lower
  3. Add into FormattedText some new line characters
    • freezes on Android API23 and higher

Expected Behavior

iOS: Tail truncation on both Labels with FormattedText Android: Tail truncation on both Labels with FormattedText

Actual Behavior

iOS: No truncation Android API23 and higher: Application freezes when page appeared with new lines in text Android API22 and lower: Application freezes when page appeared

Basic Information

Reproduction Link

https://github.com/EislerDavid/FormattedTextSamplaProject

adrianknight89 commented 5 years ago

Seeing this issue as well. On iOS, tail truncation does not work with spans.

I've also run into incorrect Label height calculations when spans are added (especially if a span is added towards the end of the line). The height of the label will be greater than what it should be (i.e. there is an extra empty line added even though the span text does not end with whitespace).

KaelSuncaster commented 5 years ago

Hi,

This is a major issue for us, functionally broken by simply updating to the latest Xamarin, something clients do not understand.

Is there any ETA for this?

edebali commented 5 years ago

Hi, this issue is important for us, is there any plan for the fix? thanks

melimion commented 5 years ago

Any update?

MathewLC commented 4 years ago

This is related with two different errors #8831 and #7534.

ghost commented 3 years ago

When using FormattedText property on Label it generates NSAttributedString and sets to the UILabel.AttributedText property. The issue with truncation is caused by the fact that built NSAttributedString has ParagraphStyle set which overrides LineBreakMode to the default word wrap.

I was able to fix that in renderer by regenerating NSAttributedString and setting LineBreakMode for the paragraph style in each range.

Dids commented 3 years ago

This is still an active issue.