https://kotlinlang.org logo
#compose
Title
# compose
l

len

04/30/2020, 1:24 PM
Is it possible (or planned) to draw a
Text
with outline? This was done with
Paint.Style.STROKE
, but there's no painter on
Text
parameters. I want to draw a text in white with a black border (like a shadow, but without blur)
n

nicopasso

04/30/2020, 2:03 PM
I don’t think it’s possible (yet). I went already through all different possibilities offered by
TextStyle
or
SpanStyle
but it seems there’s no way right now to do that other than play around with shadows I guess
l

Leland Richardson [G]

04/30/2020, 2:19 PM
cc @Siyamed
s

Siyamed

04/30/2020, 6:58 PM
hmm.. I knew Paint would be an issue in the future but wasn’t expecting it to be fast.
Currently we do have internal Paint object(s) that we use. It is possible to expose it but I couldn’t know about the priority and side effects.
@len is it possible for you to create a ticket about this?
l

Leland Richardson [G]

04/30/2020, 7:03 PM
i think exposing paint seems like a strong step in the wrong direction. what about just adding stroke to textstyle or something?
s

Siyamed

04/30/2020, 7:04 PM
stroke?
l

Leland Richardson [G]

04/30/2020, 7:04 PM
but yeah, maybe a ticket is a better place to discuss 🙂
well it sounds like the stroke style is the desired support from len here, no?
s

Siyamed

04/30/2020, 7:04 PM
I was going to say even if Text exposes the Paint, it wouldnt possible to do the same for AnnatatedString so it might be a deep hole
I want to draw a text in white with a black border (like a shadow, but without blur)
if we add stroke etc, then it will end up in more Paint params. I need to check it but at the end of the day Paint has lots of configurations.
stroke, stroke type, dashed, stroke color you name it 🙂
l

len

04/30/2020, 7:26 PM
I was thinking of the stroke/outline like a subclass of
Shadow
, although it's not exactly that, but it allows to support them without changing the public
Text
API (or that's what I think)
But my solution doesn't sound right to me. I don't know what the proper solution would be, but I think it could be a nice addition for when you draw text over a background/image as it improves readability (shadow is also an option but IMO the outline is better, and also with any color, not just black)
❤️ 1
🙏 1
3 Views