From 9c2c548874f0d782cfe5522ea3aaa9b12ebe31e9 Mon Sep 17 00:00:00 2001 From: Florian Oswald Date: Wed, 17 May 2017 17:10:21 +0200 Subject: [PATCH] create dict _initial_fontsizes and copy from that. creates new method scalefontsizes() [no keyword] --- src/args.jl | 8 +++++--- src/components.jl | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/args.jl b/src/args.jl index be5c564c..f93aeae6 100644 --- a/src/args.jl +++ b/src/args.jl @@ -335,9 +335,11 @@ const _all_defaults = KW[ _axis_defaults_byletter ] -# to be able to reset things to initial values -const _all_initial_defaults = deepcopy(_all_defaults) -const _axis_initial_defaults = deepcopy(_axis_defaults) +# to be able to reset font sizes to initial values +const _initial_fontsizes = Dict(:titlefont => deepcopy(_subplot_defaults[:titlefont]), + :legendfont => deepcopy(_subplot_defaults[:legendfont]), + :tickfont => deepcopy(_axis_defaults[:tickfont]), + :guidefont => deepcopy(_axis_defaults[:guidefont])) const _all_args = sort(collect(union(map(keys, _all_defaults)...))) diff --git a/src/components.jl b/src/components.jl index e7eb74d6..1f53f2d1 100644 --- a/src/components.jl +++ b/src/components.jl @@ -303,21 +303,15 @@ function scalefontsizes(factor::Number) end end -function resetfontsize(k::Symbol) - i = initial(k) - f = default(k) - # some fonts don't have an initial value! - if i != false - f.pointsize = i.pointsize - default(k, i) - end -end - -"Reset all fonts to initial size" -function resetfontsizes() - for k in (:titlefont, :guidefont, :tickfont, :legendfont) - resetfontsize(k) - end +"Resets font sizes to initial default values" +function scalefontsizes() + for k in (:titlefont, :guidefont, :tickfont, :legendfont) + f = default(k) + if haskey(_initial_fontsizes,k) + factor = f.pointsize / _initial_fontsizes[k].pointsize + scalefontsize(k, 1.0/factor) + end + end end "Wrap a string with font info"