toptensoftware / RichTextKit

Rich text rendering for SkiaSharp
Other
361 stars 74 forks source link

Add option to control ellipsis #50 #51

Closed gresolio closed 2 years ago

toptensoftware commented 2 years ago

Thanks for this however it doesn't cover all cases.

The case you've handled is where a rich string is truncated exactly on a paragraph boundary. It also needs to handle the case where the truncation happens mid paragraph. Take a look atCheckHeightConstraints in TextBlock.cs for where it does this.

https://github.com/toptensoftware/RichTextKit/blob/master/Topten.RichTextKit/TextBlock.cs#L1978

To explain... a TextBlock is a single laid out paragraph. A RichString is a list of TextBlocks. When a height constraint is hit such that a previous paragraph fits, but the first line of the next paragraph doesn't, RichString goes back an appends the ellipsis to the prior paragraph. When a paragraph crosses a height constraint it creates the ellipsis itself.

gresolio commented 2 years ago

Thanks for the explanation. I have added EllipsisEnabled to TextBlock, now it should cover all the cases: af2e30f.

gresolio commented 2 years ago

Is this af2e30f good enough? Or do you have other suggestions for improvement?

toptensoftware commented 2 years ago

Thanks for that.. it looks good I think. I'll do some testing and merge it asap (but I have a couple of busy days ahead so bear with me).