Hello! Is there multiplatform way to draw text on ...
# compose
p
Hello! Is there multiplatform way to draw text on Canvas?
l
Not on Canvas, but we have
DrawScope.drawText
extension.
z
We recommend using TextMeasurer instead of using (multi)paragraph directly, since it does some more caching. Cc @Halil Ozercan
h
Yes, it could be quite expensive to create a Paragraph/MultiParagraph instance in DrawScope and draw without any kind of caching mechanism in place. TextMeasurer comes with an internal cache so you can call measure in whichever phase you need. Also,
DrawScope.drawText(textMeasurer, "Hello, World!")
is a handy way to merge measure and draw calls. All of this is ofc multiplatform.
424 Views