gr: fix text problems
This commit is contained in:
parent
c4b7757e22
commit
6df1f38492
@ -1,7 +1,7 @@
|
|||||||
name = "Plots"
|
name = "Plots"
|
||||||
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||||
author = ["Tom Breloff (@tbreloff)"]
|
author = ["Tom Breloff (@tbreloff)"]
|
||||||
version = "1.23.4"
|
version = "1.23.5"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||||
|
|||||||
@ -228,7 +228,7 @@ end
|
|||||||
gr_inqtext(x, y, s) = gr_inqtext(x, y, string(s))
|
gr_inqtext(x, y, s) = gr_inqtext(x, y, string(s))
|
||||||
|
|
||||||
function gr_inqtext(x, y, s::AbstractString)
|
function gr_inqtext(x, y, s::AbstractString)
|
||||||
if (occursin('\\', s) || occursin("10^{", s)) && match(r".*\$[^\$]+?\$.*", s) == nothing
|
if (occursin('\\', s) || occursin("10^{", s)) && match(r".*\$[^\$]+?\$.*", String(s)) == nothing
|
||||||
GR.inqtextext(x, y, s)
|
GR.inqtextext(x, y, s)
|
||||||
else
|
else
|
||||||
GR.inqtext(x, y, s)
|
GR.inqtext(x, y, s)
|
||||||
@ -238,7 +238,7 @@ end
|
|||||||
gr_text(x, y, s) = gr_text(x, y, string(s))
|
gr_text(x, y, s) = gr_text(x, y, string(s))
|
||||||
|
|
||||||
function gr_text(x, y, s::AbstractString)
|
function gr_text(x, y, s::AbstractString)
|
||||||
if (occursin('\\', s) || occursin("10^{", s)) && match(r".*\$[^\$]+?\$.*", s) == nothing
|
if (occursin('\\', s) || occursin("10^{", s)) && match(r".*\$[^\$]+?\$.*", String(s)) == nothing
|
||||||
GR.textext(x, y, s)
|
GR.textext(x, y, s)
|
||||||
else
|
else
|
||||||
GR.text(x, y, s)
|
GR.text(x, y, s)
|
||||||
@ -1243,21 +1243,26 @@ function gr_get_legend_geometry(viewport_plotarea, sp)
|
|||||||
if sp[:legend_position] != :none
|
if sp[:legend_position] != :none
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
|
GR.setcharup(0, 1)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
if sp[:legend_title] !== nothing
|
if sp[:legend_title] !== nothing
|
||||||
gr_set_font(legendtitlefont(sp), sp)
|
gr_set_font(legendtitlefont(sp), sp)
|
||||||
legendn += 1
|
legendn += 1
|
||||||
tbx, tby = gr_inqtext(0, 0, string(sp[:legend_title]))
|
tbx, tby = gr_inqtext(0, 0, string(sp[:legend_title]))
|
||||||
legendw = tbx[3] - tbx[1]
|
l, r = extrema(tbx)
|
||||||
dy = tby[3] - tby[1]
|
b, t = extrema(tby)
|
||||||
|
legendw = r - l
|
||||||
|
dy = t - b
|
||||||
end
|
end
|
||||||
gr_set_font(legendfont(sp), sp)
|
gr_set_font(legendfont(sp), sp)
|
||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
should_add_to_legend(series) || continue
|
should_add_to_legend(series) || continue
|
||||||
legendn += 1
|
legendn += 1
|
||||||
tbx, tby = gr_inqtext(0, 0, string(series[:label]))
|
tbx, tby = gr_inqtext(0, 0, string(series[:label]))
|
||||||
legendw = max(legendw, tbx[3] - tbx[1]) # Holds text width right now
|
l, r = extrema(tbx)
|
||||||
dy = max(dy, tby[3] - tby[1])
|
b, t = extrema(tby)
|
||||||
|
legendw = max(legendw, r - l) # Holds text width right now
|
||||||
|
dy = max(dy, t - b)
|
||||||
end
|
end
|
||||||
|
|
||||||
GR.setscale(1)
|
GR.setscale(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user