How do I draw `Text` with a specific size in pixel...
# compose
m
How do I draw
Text
with a specific size in pixels? It seems you can only specify the size in
sp
and
em
.
f
You can convert pixels to
Sp
with `Density`:
Copy code
val density = LocalDensity.current
val spFromPx = with(density) { 12.toSp() }
But be aware that the
SP
unit exists for a reason and the
Text
composable does not take pixels intentionally.
m
I know it's usually a bad idea, but I have a specific use-case here which requires it. Thanks for the conversion idea, that works!
👌 1