Open isentropic opened 2 years ago
The bounding box of text objects can be obtained using the GR.inqtext
function. There are several examples in the GR examples directory (mixed_text.jl
, user_fonts.jl
, math_align.jl
, math_bbox.jl
, circumscribe_text.jl
), e.g.:
using GR
using LaTeXStrings
s = "Using inline math \$\\frac{2hc^2}{\\lambda^5} \\frac{1}{e^{\\frac{hc}{\\lambda k_B T}} - 1}\$ in GR text\nmixed with LaTeXStrings " * L"- \frac{{\hbar ^2}}{{2m}}\frac{{\partial ^2 \psi (x,t)}}{{\partial x^2 }} + U(x)\psi (x,t) = i\hbar \frac{{\partial \psi (x,t)}}{{\partial t}}" * "\n– with line breaks\nand UTF-8 characters (ħπ),\nand rendered using GR's text attributes"
selntran(0)
settextfontprec(232, 3)
settextalign(2, 3)
setcharheight(0.02)
for ϕ in LinRange(0, 2π, 360)
clearws()
setcharup(sin(ϕ), cos(ϕ))
text(0.5, 0.5, s)
tbx, tby = inqtext(0.5, 0.5, s)
fillarea(tbx, tby)
updatews()
end
From Plots.jl
, you can access this function with Plots.GR.inqtext()
. But as the text attributes might be changed within Plots
, it would probably be better to provide a dedicated Plots
function to provide this functionality.
It would be really great to be able to toggle bounding boxes in Plots
for developing / debugging.
Is there an easy way to obtain bboxes of text objects and latex rendered text objects? Asking to for Plots jl. If there would be some communication with gr backend it would be great. Now, creating layouts is a little difficult as it is hard to determining appropriate padding for text