Seems like a layering problem. Drawing would then have to involve knowledge of the entire text stack. Ultimately text and a font bottom out in drawing commands.
It's like asking why there is no drawJpeg or drawSvg. You want something at a higher level of abstraction to handle the high-level semantics of the thing, and then issue low-level drawing calls to the canvas.
m
Mark
12/28/2023, 4:40 AM
Hmm, I guess so. I noticed there’s a
drawText
extension function on
DrawScope
so was just wondering why there wouldn’t also be a
Canvas.drawText
extension function.
j
jw
12/28/2023, 4:54 AM
DrawScope is at a much higher level of abstraction since you're above the layout system now which would be required for a text engine to do things like wrapping
m
Mark
12/28/2023, 3:07 PM
I’ve got some custom drawing logic (mostly `Path`s but also some shapes and text). Should I be building that on top of
Canvas
or
DrawScope
? It’s certainly a lot easier to do the latter, since I no longer need to deal with
Paint
(and especially not Android-only
TextPaint
) and no longer need to dip into
Canvas.nativeCanvas
. OTOH, for the caller,
DrawScope
, I guess, is more tricky to set up being a higher level of abstraction. BTW, I don’t need to do things like text wrapping. The only text is always one or two digits placed in a circle.