How would you draw a `AnnotationString` span on a ...
# compose
u
How would you draw a
AnnotationString
span on a angle? Rotation doesn't seem to be available on
SpanStyle
.. can I have custom rendering for a given span? (Or maybe some other technique?)
a
One option is to use `onTextLayout`'s result to find the bounding box for that text, then use
drawBehind
to draw the tilted box. Though this will introduce a one frame delay to the highlight drawing.
z
It shouldn’t have a delay - text measurement happens during the compose measure phase, before draw.
☝🏽 1
today i learned 3
☝️ 1
u
onTextLayout
that is the
Text
parameter, right? i.e. I should not go the `AnnotatedString`/span route? Or should I use Spans as indices markers and pick them up somehow in
onTextLAyout
?
j
Using
onTextLayout {}
should give you a
TextLayoutResult
that contains queryable information about the rendered text. Look into
TextLayoutResult.getBoundingBox(…)
to find the bounding box for your desired text run. Not sure if you will need
AnnotatedString
anymore if you are going to manually draw your angled highlight… depends if you have a need for additional “annotation” that you don’t want to manually draw on the canvas.