From a53024537c03acb748935ba3621c7efa5c362d2c Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 28 Apr 2020 13:30:27 +0530 Subject: [PATCH 1/3] Update display.jl --- src/display.jl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/display.jl b/src/display.jl index a8b7660df..5cfbef7d3 100644 --- a/src/display.jl +++ b/src/display.jl @@ -74,9 +74,20 @@ for M in (MIME"text/plain", MIME) # set update to true, without triggering an event # this just indicates, that now we may update on e.g. resize update!(scene) + + # Here, we deal with the Juno plotsize. + # Since SVGs are in units of pt, which is 1/72 in, + # and pixels (which Juno reports its plotsize as) + # are 1/96 in, we need to rescale the scene, + # whose units are in pt, into the expected size in px. + # This means we have to scale by a factor of 72/96. res = get(io, :juno_plotsize, nothing) - res !== nothing && resize!(scene, res...) - ioc = IOContext(io, :full_fidelity => true, :pt_per_unit => get(io, :pt_per_unit, 0.75), :px_per_unit => get(io, :px_per_unit, 1.0)) + if !isnothing(res) && m isa MIME"image/svg+xml" + resize!(scene, round.(Int, res .* 0.75)) + end + + ioc = IOContext(io, :full_fidelity => true, :pt_per_unit => get(io, :pt_per_unit, 1.0), :px_per_unit => get(io, :px_per_unit, 1.0)) + screen = backend_show(current_backend[], ioc, m, scene) # E.g. text/plain doesn't have a display From 5ae45e6aa8857dee9be3ea2a38ef8b0a55cb4c4f Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 28 Apr 2020 13:34:20 +0530 Subject: [PATCH 2/3] Resize on png also --- src/display.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/display.jl b/src/display.jl index 5cfbef7d3..1785081f3 100644 --- a/src/display.jl +++ b/src/display.jl @@ -82,8 +82,11 @@ for M in (MIME"text/plain", MIME) # whose units are in pt, into the expected size in px. # This means we have to scale by a factor of 72/96. res = get(io, :juno_plotsize, nothing) - if !isnothing(res) && m isa MIME"image/svg+xml" - resize!(scene, round.(Int, res .* 0.75)) + if !isnothing(res) + if m isa MIME"image/svg+xml" + res = round.(Int, res .* 0.75) + end + resize!(scene, res) end ioc = IOContext(io, :full_fidelity => true, :pt_per_unit => get(io, :pt_per_unit, 1.0), :px_per_unit => get(io, :px_per_unit, 1.0)) From 00857343fb544b9c65906d411d689e6b5786c69c Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Tue, 28 Apr 2020 13:39:13 +0530 Subject: [PATCH 3/3] Splat res, since it can be an array --- src/display.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display.jl b/src/display.jl index 1785081f3..89650805c 100644 --- a/src/display.jl +++ b/src/display.jl @@ -86,7 +86,7 @@ for M in (MIME"text/plain", MIME) if m isa MIME"image/svg+xml" res = round.(Int, res .* 0.75) end - resize!(scene, res) + resize!(scene, res...) end ioc = IOContext(io, :full_fidelity => true, :pt_per_unit => get(io, :pt_per_unit, 1.0), :px_per_unit => get(io, :px_per_unit, 1.0))