Underline for trailing spaces

38 views
Skip to first unread message

Lakshmi Priya

unread,
Apr 23, 2025, 11:13:51 AM4/23/25
to skia-discuss
Hi ,
     I want to draw underline for a text which has trailing spaces. For eg : "Skia   ". When I applied underline for the above text , underline is not drawn for the trailing spaces. But when i checked the maxIntrinsicWidth of the text , it includes the trailing spaces too. Also i tried adding spaces in-front of the text ("  Skia") and applied underline. This time it worked for me. Could someone please confirm if this is how it works?? I am using SkParagraph for my text rendering

jlav...@google.com

unread,
Apr 23, 2025, 3:49:14 PM4/23/25
to skia-discuss
Underline decoration is an attribute of a text. Trailing spaces are not the text exactly. We do not draw them and we do not decorate them (leading spaces and spaces in the middle of the text are treated as normal text, though).
If you are talking about a single-line text you can use non-breaking space instead: 0x00A0. 
const char16_t* text = u"Hello\u00A0\u00A0\u00A0"; 
Then you will have your trailing spaces underlined.
It will not work for multilined text though, since non-breaking space is non breaking and does not break the line.

I can only confirm that maxIntrinsicWidth works as it's defined for Flutter whether it seems logical or not.


Reply all
Reply to author
Forward
0 new messages