Ellipsis on multiple lines

22 views
Skip to first unread message

Alexandre Bléron

unread,
Sep 26, 2024, 4:25:55 PMSep 26
to skia-discuss
In this fiddle:


The text contains two lines (it has a line break) but only one line is printed with ellipsis when `setEllipsis()` is called (as if calling setEllipsis also calls setMaxLines(1)). Is this intended behavior? If so, is there a way to have the same behavior as this with `text-overflow: ellipsis`? I tried `setMaxLines(3);` but it doesn't ellipsize the first line.

jlav...@google.com

unread,
Sep 26, 2024, 4:56:46 PMSep 26
to skia-discuss
If you set the ellipsis it works in two cases:
1. When the wrapped text flows over the max line number (must be set by setMaxLines) or
2. When the max line number is not set (then we assume that we called setMaxLines(1) which is somewhat unclear, I agree).
So, the answer is yes, it's the intended behavior (required by Flutter).
There is no direct way to get what you want. The best work around I could think of is to break the paragraph into 2 paragraphs and draw them separately.
SkParagraph never only shows a single ellipsis at the end of the text.

Reply all
Reply to author
Forward
0 new messages