Fill a bounding box of a text in Makie

This works:

using GLMakie
using GLMakie: Quaternionf0

positions = rand(Point2f0, 5)
fig, ax, textplot = text([(string(Tuple(round.(x, digits=2))), x) for x in positions], align=(:center, :center))

layouts = textplot._glyphlayout[]
strings = textplot[1][]
bbs = map(strings, layouts) do str, l 
    GLMakie.AbstractPlotting.data_text_boundingbox(str[1], l, Quaternionf0(0,0,0,1), Point3f0(0))
end
scatter!(ax, positions, markersize=widths.(bbs), marker=Rect)
reverse!(ax.scene.plots)
display(fig)

1 Like