toptensoftware / RichTextKit

Rich text rendering for SkiaSharp
Other
366 stars 73 forks source link

Fix incorrect line breaks when MaxLines i set #68

Closed handerss-spotfire closed 1 year ago

handerss-spotfire commented 1 year ago

This PR fixes https://github.com/toptensoftware/RichTextKit/issues/65

When MaxLines set line breaks should only occur at a character boundary if there is no required (and valid) line break to use.

Additionally this PR opts for line breaking at a character boundary as opposed to a line break position. Since this only occurs on the final line this results in the most amount of characters being fitted before clipping/ellipsing. This allows for mimicking the behavior of System.Drawing.StringTrimming.EllipsisCharacter, but may not be the desired default behavior of this library. This behavior could instead be configured via a flag och TextBlock if desired.